Add configurable GrampsBar gramplets to the Configure View dialog
svn: r16554
This commit is contained in:
		@@ -430,6 +430,30 @@ class GrampsBar(gtk.Notebook):
 | 
			
		||||
            # TODO: We will probably want a context menu here.
 | 
			
		||||
            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
 | 
			
		||||
 
 | 
			
		||||
@@ -591,9 +591,19 @@ class PageView(DbGUIElement):
 | 
			
		||||
        title = _("Configure %(cat)s - %(view)s") % \
 | 
			
		||||
                        {'cat': self.get_translated_category(), 
 | 
			
		||||
                         '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:
 | 
			
		||||
            ViewConfigureDialog(self.uistate, self.dbstate, 
 | 
			
		||||
                            self._get_configure_page_funcs(),
 | 
			
		||||
                            config_funcs,
 | 
			
		||||
                            self, self._config, dialogtitle=title,
 | 
			
		||||
                            ident=_("%(cat)s - %(view)s") % 
 | 
			
		||||
                                    {'cat': self.get_translated_category(),
 | 
			
		||||
@@ -603,7 +613,7 @@ class PageView(DbGUIElement):
 | 
			
		||||
 | 
			
		||||
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,
 | 
			
		||||
                 configmanager,
 | 
			
		||||
 
 | 
			
		||||
@@ -529,22 +529,30 @@ class GuiGramplet(object):
 | 
			
		||||
 | 
			
		||||
    def make_gui_options(self):
 | 
			
		||||
        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
 | 
			
		||||
        frame = gtk.Frame()
 | 
			
		||||
        topbox = gtk.VBox()
 | 
			
		||||
        hbox = gtk.HBox()
 | 
			
		||||
        labels = gtk.VBox()
 | 
			
		||||
        options = gtk.VBox()
 | 
			
		||||
        topbox = gtk.VBox(False)
 | 
			
		||||
        hbox = gtk.HBox(False, 5)
 | 
			
		||||
        labels = gtk.VBox(True)
 | 
			
		||||
        options = gtk.VBox(True)
 | 
			
		||||
        hbox.pack_start(labels, False)
 | 
			
		||||
        hbox.pack_start(options, True)
 | 
			
		||||
        topbox.add(hbox)
 | 
			
		||||
        topbox.pack_start(hbox, False, False)
 | 
			
		||||
        for item in self.pui.option_order:
 | 
			
		||||
            label = gtk.Label(item + ":")
 | 
			
		||||
            label.set_alignment(1.0, 0.5)
 | 
			
		||||
            labels.add(label)
 | 
			
		||||
            options.add(self.pui.option_dict[item][0]) # widget
 | 
			
		||||
            labels.pack_start(label)
 | 
			
		||||
            options.pack_start(self.pui.option_dict[item][0]) # widget
 | 
			
		||||
        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)
 | 
			
		||||
        frame.add(topbox)
 | 
			
		||||
        frame.show_all()
 | 
			
		||||
@@ -1436,15 +1444,6 @@ class GrampletPane(gtk.ScrolledWindow):
 | 
			
		||||
        return _('Gramplet Layout'), table
 | 
			
		||||
 
 | 
			
		||||
    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, 
 | 
			
		||||
                              str, gramplet.get_title, gramplet.set_title)
 | 
			
		||||
        self._config.register("%s.height" % gramplet.title, 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user