def _rename_cb(self, widget):
     """Properties dialog rename callback"""
     # XXX Because of the way this works, groups can only be renamed from
     # XXX    the widget's properties dialog at present. Maybe that's OK.
     self._dialog.hide()
     old_group = self._group
     new_group = dialogs.ask_for_name(
         self,
         C_("brush group rename dialog: title", "Rename Group"),
         old_group,
     )
     if not new_group:
         return
     if old_group not in self._app.brushmanager.groups:
         return
     if new_group not in self._app.brushmanager.groups:
         self._app.brushmanager.rename_group(old_group, new_group)
         self._group = new_group
         workspace = self._app.workspace
         gtype_name = self.__gtype_name__
         workspace.update_tool_widget_params(gtype_name,
                                             (old_group,), (new_group,))
         self._update_brush_list()
     else:
         dialogs.error(self, C_(
             'brush group rename',
             'A group with this name already exists!',
         ))
 def _new_brush_group_cb(self, widget):
     # XXX should be moved somewhere more sensible than this
     toplevel = self.app.drawWindow
     name = dialogs.ask_for_name(toplevel, C_("new brush group dialog: title", "Create Group"), "")
     if name:
         bm = self.app.brushmanager
         bm.create_group(name)
Beispiel #3
0
 def _rename_cb(self, widget):
     """Properties dialog rename callback"""
     # XXX Because of the way this works, groups can only be renamed from
     # XXX    the widget's properties dialog at present. Maybe that's OK.
     self._dialog.hide()
     old_group = self._group
     new_group = dialogs.ask_for_name(
         self,
         C_("brush group rename dialog: title", "Rename Group"),
         old_group,
     )
     if not new_group:
         return
     if old_group not in self._app.brushmanager.groups:
         return
     if new_group not in self._app.brushmanager.groups:
         self._app.brushmanager.rename_group(old_group, new_group)
         self._group = new_group
         workspace = self._app.workspace
         gtype_name = self.__gtype_name__
         workspace.update_tool_widget_params(gtype_name, (old_group, ),
                                             (new_group, ))
         self._update_brush_list()
     else:
         dialogs.error(
             self,
             C_(
                 'brush group rename',
                 'A group with this name already exists!',
             ))
Beispiel #4
0
 def treeview_button_press_cb(self, treeview, event):
     x, y = int(event.x), int(event.y)
     bw_x, bw_y = treeview.convert_widget_to_bin_window_coords(x, y)
     path_info = treeview.get_path_at_pos(bw_x, bw_y)
     if path_info is None:
         return False
     clicked_path, clicked_col, cell_x, cell_y = path_info
     layer, = self.liststore[clicked_path[0]]
     doc = self.app.doc.model
     if clicked_col is self.visible_col:
         doc.set_layer_visibility(not layer.visible, layer)
         self.treeview.queue_draw()
         return True
     elif clicked_col is self.locked_col:
         doc.set_layer_locked(not layer.locked, layer)
         self.treeview.queue_draw()
         return True
     elif clicked_col is self.name_col:
         if event.type == gdk._2BUTTON_PRESS:
             new_name = dialogs.ask_for_name(self, _("Name"), layer.name)
             if new_name:
                 layer.name = new_name
                 self.treeview.queue_draw()
             return True
     return False
Beispiel #5
0
 def _new_brush_group_cb(self, widget):
     # XXX should be moved somewhere more sensible than this
     toplevel = self.app.drawWindow
     name = dialogs.ask_for_name(toplevel, _('Create Group'), '')
     if name:
         bm = self.app.brushmanager
         bm.create_group(name)
Beispiel #6
0
    def rename_button_clicked_cb(self, button):
        """Rename the current brush; user is prompted for a new name"""
        bm = self.app.brushmanager
        src_brush = bm.selected_brush
        if not src_brush.name:
            dialogs.error(self, C_(
                'brush settings editor: rename brush: error message',
                'No brush selected!',
            ))
            return

        src_name_pp = src_brush.name.replace('_', ' ')
        dst_name = dialogs.ask_for_name(
            self,
            C_(
                "brush settings editor: rename brush: dialog title",
                "Rename Brush",
            ),
            src_name_pp,
        )
        if not dst_name:
            return
        dst_name = dst_name.replace(' ', '_')
        # ensure we don't overwrite an existing brush by accident
        dst_deleted = None
        for group, brushes in bm.groups.iteritems():
            for b2 in brushes:
                if b2.name == dst_name:
                    if group == brushmanager.DELETED_BRUSH_GROUP:
                        dst_deleted = b2
                    else:
                        msg = C_(
                            'brush settings editor: '
                            'rename brush: error message',
                            'A brush with this name already exists!',
                        )
                        dialogs.error(self, msg)
                        return

        logger.info("Renaming brush %r -> %r", src_brush.name, dst_name)
        if dst_deleted:
            deleted_group = brushmanager.DELETED_BRUSH_GROUP
            deleted_brushes = bm.get_group_brushes(deleted_group)
            deleted_brushes.remove(dst_deleted)
            bm.brushes_changed(deleted_brushes)

        # save src as dst
        src_name = src_brush.name
        src_brush.name = dst_name
        src_brush.save()
        src_brush.name = src_name
        # load dst
        dst_brush = brushmanager.ManagedBrush(bm, dst_name, persistent=True)
        dst_brush.load()

        # Replace src with dst, but keep src in the deleted list if it
        # is a stock brush
        self._delete_brush(src_brush, replacement=dst_brush)

        bm.select_brush(dst_brush)
Beispiel #7
0
 def rename_layer_cb(self, action):
     """Prompts for a new name for the current layer (action callback)"""
     layer = self.model.get_current_layer()
     new_name = dialogs.ask_for_name(self.app.drawWindow, _("Layer Name"),
                                     layer.name)
     if new_name:
         self.model.rename_layer(layer, new_name)
Beispiel #8
0
    def rename_button_clicked_cb(self, button):
        """Rename the current brush; user is prompted for a new name"""
        bm = self.app.brushmanager
        src_brush = bm.selected_brush
        if not src_brush.name:
            dialogs.error(self, C_(
                'brush settings editor: rename brush: error message',
                'No brush selected!',
            ))
            return

        src_name_pp = src_brush.name.replace('_', ' ')
        dst_name = dialogs.ask_for_name(
            self,
            C_(
                "brush settings editor: rename brush: dialog title",
                "Rename Brush",
            ),
            src_name_pp,
        )
        if not dst_name:
            return
        dst_name = dst_name.replace(' ', '_')
        # ensure we don't overwrite an existing brush by accident
        dst_deleted = None
        for group, brushes in bm.groups.iteritems():
            for b2 in brushes:
                if b2.name == dst_name:
                    if group == brushmanager.DELETED_BRUSH_GROUP:
                        dst_deleted = b2
                    else:
                        msg = C_(
                            'brush settings editor: rename brush: error message',
                            'A brush with this name already exists!',
                        )
                        dialogs.error(self, msg)
                        return

        logger.info("Renaming brush %r -> %r", src_brush.name, dst_name)
        if dst_deleted:
            deleted_group = brushmanager.DELETED_BRUSH_GROUP
            deleted_brushes = bm.get_group_brushes(deleted_group)
            deleted_brushes.remove(dst_deleted)
            bm.brushes_changed(deleted_brushes)

        # save src as dst
        src_name = src_brush.name
        src_brush.name = dst_name
        src_brush.save()
        src_brush.name = src_name
        # load dst
        dst_brush = brushmanager.ManagedBrush(bm, dst_name, persistent=True)
        dst_brush.load()

        # Replace src with dst, but keep src in the deleted list if it
        # is a stock brush
        self._delete_brush(src_brush, replacement=dst_brush)

        bm.select_brush(dst_brush)
Beispiel #9
0
 def rename_group_cb(self, w, old_group):
     new_group = dialogs.ask_for_name(self, _('Rename Group'), old_group)
     if not new_group:
         return
     if new_group not in self.bm.groups:
         self.bm.rename_group(old_group, new_group)
     else:
         dialogs.error(self, _('A group with this name already exists!'))
Beispiel #10
0
 def _new_brush_group_cb(self, widget):
     # XXX should be moved somewhere more sensible than this
     toplevel = self.app.drawWindow
     name = dialogs.ask_for_name(
         toplevel,
         C_("new brush group dialog: title", 'Create Group'),
         '',
     )
     if name is None:
         return
     name = name.strip()
     if name:
         bm = self.app.brushmanager
         bm.create_group(name)
    def rename_brush_cb(self, window):
        src_brush = self.bm.selected_brush
        if not src_brush.name:
            dialogs.error(self, _('No brush selected!'))
            return

        dst_name = dialogs.ask_for_name(self, _("Rename Brush"), src_brush.name.replace('_', ' '))
        if not dst_name:
            return
        dst_name = dst_name.replace(' ', '_')
        # ensure we don't overwrite an existing brush by accident
        dst_deleted = None
        for group, brushes in self.bm.groups.iteritems():
            for b2 in brushes:
                if b2.name == dst_name:
                    if group == brushmanager.DELETED_BRUSH_GROUP:
                        dst_deleted = b2
                    else:
                        dialogs.error(self, _('A brush with this name already exists!'))
                        return

        print 'renaming brush', repr(src_brush.name), '-->', repr(dst_name)
        if dst_deleted:
            deleted_brushes = self.bm.get_group_brushes(brushmanager.DELETED_BRUSH_GROUP)
            deleted_brushes.remove(dst_deleted)
            for f in self.bm.brushes_observers: f(deleted_brushes)

        # save src as dst
        src_name = src_brush.name
        src_brush.name = dst_name
        src_brush.save()
        src_brush.name = src_name
        # load dst
        dst_brush = brushmanager.ManagedBrush(self.bm, dst_name, persistent=True)
        dst_brush.load()
        dst_brush.in_brushlist = True

        # replace src with dst (but keep src in the deleted list if it is a stock brush)
        self.delete_brush_internal(src_brush, replacement=dst_brush)

        self.bm.select_brush(dst_brush)
Beispiel #12
0
 def create_group_cb(self, w, group):
     new_group = dialogs.ask_for_name(self, _('Create Group'), '')
     if new_group:
         self.bm.create_group(new_group)
Beispiel #13
0
 def rename_layer_cb(self, action):
     """Prompts for a new name for the current layer (action callback)"""
     layer = self.model.get_current_layer()
     new_name = dialogs.ask_for_name(self.app.drawWindow, _("Layer Name"), layer.name)
     if new_name:
         self.model.rename_layer(layer, new_name)