diff --git a/src/gui/widgets/grampletpane.py b/src/gui/widgets/grampletpane.py index 5eee19b24..4595d9de8 100644 --- a/src/gui/widgets/grampletpane.py +++ b/src/gui/widgets/grampletpane.py @@ -175,6 +175,23 @@ def logical_true(value): """ return value in ["True", True, 1, "1"] +class ConfigInterface(object): + def __init__(self, pane): + self.pane = pane + + def get(self, item): + print "get:", item + if item == "Gramplet View Options.column_count": + return self.pane.column_count + + def set(self, widget, key): + if key == "Gramplet View Options.column_count": + try: + value = int(widget.get_text()) + self.pane.set_columns(value) + except: + pass + class LinkTag(gtk.TextTag): """ Class for keeping track of link data. @@ -734,6 +751,7 @@ class GuiGramplet(object): class GrampletPane(gtk.ScrolledWindow): def __init__(self, configfile, pageview, dbstate, uistate, **kwargs): gtk.ScrolledWindow.__init__(self) + self._config = ConfigInterface(self) self.configfile = os.path.join(const.VERSION_DIR, "%s.ini" % configfile) # default for new user; may be overridden in config: self.column_count = kwargs.get("column_count", 2) @@ -1174,3 +1192,35 @@ class GrampletPane(gtk.ScrolledWindow): gramplet.pui.on_save() self.save() + def can_configure(self): + """ + See :class:`~gui.views.pageview.PageView + :return: bool + """ + return True + + def _get_configure_page_funcs(self): + """ + Return a list of functions that create gtk elements to use in the + notebook pages of the Configure dialog + + :return: list of functions + """ + return [self.config_panel] + + def config_panel(self, configdialog): + """ + Function that builds the widget in the configuration dialog + """ + table = gtk.Table(3, 2) + table.set_border_width(12) + table.set_col_spacings(6) + table.set_row_spacings(6) + + configdialog.add_pos_int_entry(table, + _('Number of Columns'), + 0, + 'Gramplet View Options.column_count', + self._config.set) + return _('Layout'), table + diff --git a/src/plugins/view/grampletview.py b/src/plugins/view/grampletview.py index dda23b321..beb676325 100644 --- a/src/plugins/view/grampletview.py +++ b/src/plugins/view/grampletview.py @@ -68,15 +68,6 @@ class GrampletView(PageView): self.action = gtk.ActionGroup(self.title + "/Gramplets") self.action.add_actions([('AddGramplet',gtk.STOCK_ADD,_("_Add a gramplet")), ('RestoreGramplet',None,_("_Undelete gramplet")), - ('Columns1',None,_("Set Columns to _1"), - None,None, - lambda obj:self.widget.set_columns(1)), - ('Columns2',None,_("Set Columns to _2"), - None,None, - lambda obj:self.widget.set_columns(2)), - ('Columns3',None,_("Set Columns to _3"), - None,None, - lambda obj:self.widget.set_columns(3)), ]) self._add_action_group(self.action) @@ -103,23 +94,29 @@ class GrampletView(PageView): def ui_definition(self): return """ - - - - - - - - - - - """ def on_delete(self): self.widget.on_delete() + + def can_configure(self): + """ + See :class:`~gui.views.pageview.PageView + :return: bool + """ + self._config = self.widget._config + return self.widget.can_configure() + + def _get_configure_page_funcs(self): + """ + Return a list of functions that create gtk elements to use in the + notebook pages of the Configure dialog + + :return: list of functions + """ + return self.widget._get_configure_page_funcs()