Add configurable GrampsBar gramplets to the Configure View dialog
svn: r16554
This commit is contained in:
parent
bdde8f08fe
commit
d094f2e218
@ -430,6 +430,30 @@ class GrampsBar(gtk.Notebook):
|
|||||||
# TODO: We will probably want a context menu here.
|
# TODO: We will probably want a context menu here.
|
||||||
self.__add_clicked()
|
self.__add_clicked()
|
||||||
|
|
||||||
|
def get_config_funcs(self):
|
||||||
|
"""
|
||||||
|
Return a list of configuration functions.
|
||||||
|
"""
|
||||||
|
funcs = []
|
||||||
|
if self.empty:
|
||||||
|
gramplets = []
|
||||||
|
else:
|
||||||
|
gramplets = self.get_children()
|
||||||
|
for gramplet in gramplets + self.detached_gramplets:
|
||||||
|
gui_options = gramplet.make_gui_options()
|
||||||
|
if gui_options:
|
||||||
|
funcs.append(self.__build_panel(gramplet, gui_options))
|
||||||
|
return funcs
|
||||||
|
|
||||||
|
def __build_panel(self, title, gui_options):
|
||||||
|
"""
|
||||||
|
Return a configuration function that returns the title of a page in
|
||||||
|
the Configure View dialog and a gtk container defining the page.
|
||||||
|
"""
|
||||||
|
def gramplet_panel(configdialog):
|
||||||
|
return title, gui_options
|
||||||
|
return gramplet_panel
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# TabGramplet class
|
# TabGramplet class
|
||||||
|
@ -591,9 +591,19 @@ class PageView(DbGUIElement):
|
|||||||
title = _("Configure %(cat)s - %(view)s") % \
|
title = _("Configure %(cat)s - %(view)s") % \
|
||||||
{'cat': self.get_translated_category(),
|
{'cat': self.get_translated_category(),
|
||||||
'view': self.get_title()}
|
'view': self.get_title()}
|
||||||
|
|
||||||
|
if self.can_configure():
|
||||||
|
config_funcs = self._get_configure_page_funcs()
|
||||||
|
else:
|
||||||
|
config_funcs = []
|
||||||
|
if self.sidebar:
|
||||||
|
config_funcs += self.sidebar.get_config_funcs()
|
||||||
|
if self.bottombar:
|
||||||
|
config_funcs += self.bottombar.get_config_funcs()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ViewConfigureDialog(self.uistate, self.dbstate,
|
ViewConfigureDialog(self.uistate, self.dbstate,
|
||||||
self._get_configure_page_funcs(),
|
config_funcs,
|
||||||
self, self._config, dialogtitle=title,
|
self, self._config, dialogtitle=title,
|
||||||
ident=_("%(cat)s - %(view)s") %
|
ident=_("%(cat)s - %(view)s") %
|
||||||
{'cat': self.get_translated_category(),
|
{'cat': self.get_translated_category(),
|
||||||
@ -603,7 +613,7 @@ class PageView(DbGUIElement):
|
|||||||
|
|
||||||
class ViewConfigureDialog(ConfigureDialog):
|
class ViewConfigureDialog(ConfigureDialog):
|
||||||
"""
|
"""
|
||||||
All workspaces can have their own configuration dialog
|
All views can have their own configuration dialog
|
||||||
"""
|
"""
|
||||||
def __init__(self, uistate, dbstate, configure_page_funcs, configobj,
|
def __init__(self, uistate, dbstate, configure_page_funcs, configobj,
|
||||||
configmanager,
|
configmanager,
|
||||||
|
@ -529,22 +529,30 @@ class GuiGramplet(object):
|
|||||||
|
|
||||||
def make_gui_options(self):
|
def make_gui_options(self):
|
||||||
if not self.pui: return
|
if not self.pui: return
|
||||||
|
# BEGIN WORKAROUND:
|
||||||
|
# This is necessary because gtk doesn't redisplay these widgets
|
||||||
|
# correctly so we replace them with new ones
|
||||||
|
self.pui.save_options()
|
||||||
|
self.pui.update_options = {}
|
||||||
|
self.pui.option_order = []
|
||||||
|
self.pui.build_options()
|
||||||
|
# END WORKAROUND
|
||||||
if len(self.pui.option_order) == 0: return
|
if len(self.pui.option_order) == 0: return
|
||||||
frame = gtk.Frame()
|
frame = gtk.Frame()
|
||||||
topbox = gtk.VBox()
|
topbox = gtk.VBox(False)
|
||||||
hbox = gtk.HBox()
|
hbox = gtk.HBox(False, 5)
|
||||||
labels = gtk.VBox()
|
labels = gtk.VBox(True)
|
||||||
options = gtk.VBox()
|
options = gtk.VBox(True)
|
||||||
hbox.pack_start(labels, False)
|
hbox.pack_start(labels, False)
|
||||||
hbox.pack_start(options, True)
|
hbox.pack_start(options, True)
|
||||||
topbox.add(hbox)
|
topbox.pack_start(hbox, False, False)
|
||||||
for item in self.pui.option_order:
|
for item in self.pui.option_order:
|
||||||
label = gtk.Label(item + ":")
|
label = gtk.Label(item + ":")
|
||||||
label.set_alignment(1.0, 0.5)
|
label.set_alignment(1.0, 0.5)
|
||||||
labels.add(label)
|
labels.pack_start(label)
|
||||||
options.add(self.pui.option_dict[item][0]) # widget
|
options.pack_start(self.pui.option_dict[item][0]) # widget
|
||||||
save_button = gtk.Button(stock=gtk.STOCK_SAVE)
|
save_button = gtk.Button(stock=gtk.STOCK_SAVE)
|
||||||
topbox.add(save_button)
|
topbox.pack_end(save_button, False, False)
|
||||||
save_button.connect('clicked', self.pui.save_update_options)
|
save_button.connect('clicked', self.pui.save_update_options)
|
||||||
frame.add(topbox)
|
frame.add(topbox)
|
||||||
frame.show_all()
|
frame.show_all()
|
||||||
@ -1436,15 +1444,6 @@ class GrampletPane(gtk.ScrolledWindow):
|
|||||||
return _('Gramplet Layout'), table
|
return _('Gramplet Layout'), table
|
||||||
|
|
||||||
def build_panel(self, gramplet):
|
def build_panel(self, gramplet):
|
||||||
# BEGIN WORKAROUND:
|
|
||||||
# This is necessary because gtk doesn't redisplay these widgets
|
|
||||||
# correctly so we replace them with new ones
|
|
||||||
if gramplet.pui:
|
|
||||||
gramplet.pui.save_options()
|
|
||||||
gramplet.pui.update_options = {}
|
|
||||||
gramplet.pui.option_order = []
|
|
||||||
gramplet.pui.build_options()
|
|
||||||
# END WORKAROUND
|
|
||||||
self._config.register("%s.title" % gramplet.title,
|
self._config.register("%s.title" % gramplet.title,
|
||||||
str, gramplet.get_title, gramplet.set_title)
|
str, gramplet.get_title, gramplet.set_title)
|
||||||
self._config.register("%s.height" % gramplet.title,
|
self._config.register("%s.height" % gramplet.title,
|
||||||
|
Loading…
Reference in New Issue
Block a user