def __init__(self, app): Gtk.VBox.__init__(self) self.app = app self.bm = app.brushmanager active_group_name = app.preferences.get(self.PREFS_KEY, None) model = self._make_groups_sb_model() self.groups_sb = spinbox.ItemSpinBox(model, self._groups_sb_changed_cb, active_group_name) active_group_name = self.groups_sb.get_value() self.brushlist = BrushList(app, active_group_name) self.brushlist.dragging_allowed = False self.bm.groups_changed += self._update_groups_sb scrolledwin = Gtk.ScrolledWindow() scrolledwin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS) scrolledwin.add_with_viewport(self.brushlist) w = int(self.ICON_SIZE * 4.5) h = int(self.ICON_SIZE * 5.0) scrolledwin.set_min_content_width(w) scrolledwin.set_min_content_height(h) scrolledwin.get_child().set_size_request(w, h) self.pack_start(self.groups_sb, False, False) self.pack_start(scrolledwin, True, True) self.set_spacing(widgets.SPACING_TIGHT)
def __init__(self, app, prefs_id=_DEFAULT_PREFS_ID, single_click=False): Gtk.VBox.__init__(self) self._app = app self._spinbox_model = [] self._adjs = {} self._pages = [] mgr = app.brush_color_manager if single_click: adjuster_classes = self._SINGLE_CLICK_ADJUSTER_CLASSES else: adjuster_classes = self._ALL_ADJUSTER_CLASSES for page_class in adjuster_classes: name = page_class.__name__ page = page_class() self._pages.append(page) self._spinbox_model.append((name, page.tool_widget_title)) self._adjs[name] = page page.set_color_manager(mgr) if page_class in self._SINGLE_CLICK_ADJUSTER_CLASSES: page.connect_after( "button-release-event", self._ccwidget_btn_release_cb, ) self._prefs_key = self._PREFS_KEY_TEMPLATE % (prefs_id, ) active_page = app.preferences.get(self._prefs_key, None) sb = spinbox.ItemSpinBox(self._spinbox_model, self._spinbox_changed_cb, active_page) active_page = sb.get_value() self._spinbox = sb self._active_adj = self._adjs[active_page] self.pack_start(sb, False, False, 0) self.pack_start(self._active_adj, True, True, 0) self.set_spacing(widgets.SPACING_TIGHT)
def __init__(self, app, prefs_id=_DEFAULT_PREFS_ID): """Initialize""" Gtk.VBox.__init__(self) self.app = app self.bm = app.brushmanager self._prefs_key = self._PREFS_KEY_TEMPLATE % (prefs_id,) active_group_name = app.preferences.get(self._prefs_key, None) model = self._make_groups_sb_model() self.groups_sb = spinbox.ItemSpinBox(model, self._groups_sb_changed_cb, active_group_name) active_group_name = self.groups_sb.get_value() brushes = self.bm.groups[active_group_name][:] self.brushlist = PixbufList(brushes, self.ICON_SIZE, self.ICON_SIZE, namefunc=lambda x: x.name, pixbuffunc=lambda x: x.preview) self.brushlist.dragging_allowed = False self.bm.groups_changed += self._update_groups_sb self.brushlist.item_selected += self._item_selected_cb scrolledwin = Gtk.ScrolledWindow() scrolledwin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS) scrolledwin.add_with_viewport(self.brushlist) w = int(self.ICON_SIZE * 4.5) h = int(self.ICON_SIZE * 5.0) scrolledwin.set_min_content_width(w) scrolledwin.set_min_content_height(h) scrolledwin.get_child().set_size_request(w, h) self.pack_start(self.groups_sb, False, False, 0) self.pack_start(scrolledwin, True, True, 0) self.set_spacing(widgets.SPACING_TIGHT)