Added a basic configure for GrampletView; removed config of columns by right-clicking
svn: r14305
This commit is contained in:
parent
5c3f83816d
commit
458c42b0d4
@ -175,6 +175,23 @@ def logical_true(value):
|
|||||||
"""
|
"""
|
||||||
return value in ["True", True, 1, "1"]
|
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 LinkTag(gtk.TextTag):
|
||||||
"""
|
"""
|
||||||
Class for keeping track of link data.
|
Class for keeping track of link data.
|
||||||
@ -734,6 +751,7 @@ class GuiGramplet(object):
|
|||||||
class GrampletPane(gtk.ScrolledWindow):
|
class GrampletPane(gtk.ScrolledWindow):
|
||||||
def __init__(self, configfile, pageview, dbstate, uistate, **kwargs):
|
def __init__(self, configfile, pageview, dbstate, uistate, **kwargs):
|
||||||
gtk.ScrolledWindow.__init__(self)
|
gtk.ScrolledWindow.__init__(self)
|
||||||
|
self._config = ConfigInterface(self)
|
||||||
self.configfile = os.path.join(const.VERSION_DIR, "%s.ini" % configfile)
|
self.configfile = os.path.join(const.VERSION_DIR, "%s.ini" % configfile)
|
||||||
# default for new user; may be overridden in config:
|
# default for new user; may be overridden in config:
|
||||||
self.column_count = kwargs.get("column_count", 2)
|
self.column_count = kwargs.get("column_count", 2)
|
||||||
@ -1174,3 +1192,35 @@ class GrampletPane(gtk.ScrolledWindow):
|
|||||||
gramplet.pui.on_save()
|
gramplet.pui.on_save()
|
||||||
self.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
|
||||||
|
|
||||||
|
@ -68,15 +68,6 @@ class GrampletView(PageView):
|
|||||||
self.action = gtk.ActionGroup(self.title + "/Gramplets")
|
self.action = gtk.ActionGroup(self.title + "/Gramplets")
|
||||||
self.action.add_actions([('AddGramplet',gtk.STOCK_ADD,_("_Add a gramplet")),
|
self.action.add_actions([('AddGramplet',gtk.STOCK_ADD,_("_Add a gramplet")),
|
||||||
('RestoreGramplet',None,_("_Undelete 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)
|
self._add_action_group(self.action)
|
||||||
|
|
||||||
@ -103,23 +94,29 @@ class GrampletView(PageView):
|
|||||||
def ui_definition(self):
|
def ui_definition(self):
|
||||||
return """
|
return """
|
||||||
<ui>
|
<ui>
|
||||||
<menubar name="MenuBar">
|
|
||||||
<menu action="ViewMenu">
|
|
||||||
<menuitem action="Columns1"/>
|
|
||||||
<menuitem action="Columns2"/>
|
|
||||||
<menuitem action="Columns3"/>
|
|
||||||
</menu>
|
|
||||||
</menubar>
|
|
||||||
<popup name="Popup">
|
<popup name="Popup">
|
||||||
<menuitem action="AddGramplet"/>
|
<menuitem action="AddGramplet"/>
|
||||||
<menuitem action="RestoreGramplet"/>
|
<menuitem action="RestoreGramplet"/>
|
||||||
<separator/>
|
|
||||||
<menuitem action="Columns1"/>
|
|
||||||
<menuitem action="Columns2"/>
|
|
||||||
<menuitem action="Columns3"/>
|
|
||||||
</popup>
|
</popup>
|
||||||
</ui>
|
</ui>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def on_delete(self):
|
def on_delete(self):
|
||||||
self.widget.on_delete()
|
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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user