def __init__(self, ui, default_tab=None, select_plugin=None): Dialog.__init__(self, ui, _('Preferences')) # T: Dialog title gtknotebook = gtk.Notebook() self.vbox.add(gtknotebook) # saves a list of loaded plugins to be used later self.p_save_loaded = [p.__class__ for p in self.ui.plugins] # Dynamic tabs self.forms = {} for category, preferences in ui.preferences_register.items(): vbox = gtk.VBox() index = gtknotebook.append_page(vbox, gtk.Label(_(category))) # From GTK Doc: Note that due to historical reasons, GtkNotebook refuses # to switch to a page unless the child widget is visible. vbox.show() if category == default_tab: gtknotebook.set_current_page(index) fields = [] values = {} sections = {} for p in preferences: if len(p) == 4: section, key, type, label = p fields.append((key, type, label)) else: section, key, type, label, check = p fields.append((key, type, label, check)) values[key] = ui.preferences[section][key] sections[key] = section form = InputForm(fields, values) form.preferences_sections = sections vbox.pack_start(form, False) self.forms[category] = form if category == 'Interface': self._add_font_selection(form) # Styles tab #~ gtknotebook.append_page(StylesTab(self), gtk.Label(_('Styles'))) # Keybindings tab #~ gtknotebook.append_page(KeyBindingsTab(self), gtk.Label(_('Key bindings'))) # Plugins tab plugins_tab = PluginsTab(self, self.ui.plugins) plugins_tab_index = gtknotebook.append_page(plugins_tab, gtk.Label(_('Plugins'))) # T: Heading in preferences dialog plugins_tab.show() #~ print default_tab, index if default_tab == "Plugins": gtknotebook.set_current_page(plugins_tab_index) if not select_plugin is None: plugins_tab.select_plugin(select_plugin) # Applications tab gtknotebook.append_page(ApplicationsTab(self), gtk.Label(_('Applications')))
def __init__(self, ui): Dialog.__init__(self, ui, _('Preferences')) # T: Dialog title gtknotebook = gtk.Notebook() self.vbox.add(gtknotebook) # saves a list of loaded plugins to be used later self.p_save_loaded = [p.__class__ for p in self.ui.plugins] # Dynamic tabs self.forms = {} for category, preferences in ui.preferences_register.items(): vbox = gtk.VBox() gtknotebook.append_page(vbox, gtk.Label(_(category))) fields = [] values = {} sections = {} for p in preferences: if len(p) == 4: section, key, type, label = p fields.append((key, type, label)) else: section, key, type, label, check = p fields.append((key, type, label, check)) values[key] = ui.preferences[section][key] sections[key] = section form = InputForm(fields, values) form.preferences_sections = sections vbox.pack_start(form, False) self.forms[category] = form if category == 'Interface': self._add_font_selection(form) # Styles tab #~ gtknotebook.append_page(StylesTab(self), gtk.Label('Styles')) # Keybindings tab #~ gtknotebook.append_page(KeyBindingsTab(self), gtk.Label('Key bindings')) # Plugins tab gtknotebook.append_page(PluginsTab(self), gtk.Label(_('Plugins')))
def __init__(self, widget, config, default_tab=None, select_plugin=None): Dialog.__init__(self, widget, _('Preferences')) # T: Dialog title self.config = config self.preferences = self.config.get_config_dict( '<profile>/preferences.conf') # saves a list of loaded plugins to be used later self.plugins = get_window(widget).__pluginmanager__ # XXX self.p_save_loaded = list(self.plugins) # Dynamic tabs gtknotebook = Gtk.Notebook() self.vbox.pack_start(gtknotebook, True, True, 0) self.forms = {} ############################### needs rewrite to make defintion more robust for category in ('Interface', 'Editing'): vbox = Gtk.VBox() index = gtknotebook.append_page(vbox, Gtk.Label(label=_(category))) # From GTK Doc: Note that due to historical reasons, GtkNotebook refuses # to switch to a page unless the child widget is visible. vbox.show() if category == default_tab: gtknotebook.set_current_page(index) fields = [] values = {} sections = {} for section, preferences in (('GtkInterface', interface_preferences), ('PageView', pageview_preferences)): for p in [p for p in preferences if p[2] == category]: # key, type, category, label, default, (check) if len(p) == 5: key, type, cat, label, default = p self.preferences[section].setdefault(key, default) fields.append((key, type, label)) else: key, type, cat, label, default, check = p self.preferences[section].setdefault( key, default, check) fields.append((key, type, label, check)) values[key] = self.preferences[section][key] sections[key] = section form = InputForm(fields, values) form.preferences_sections = sections vbox.pack_start(form, False, True, 0) self.forms[category] = form if category == 'Interface': self._add_font_selection(form) # Styles tab #~ gtknotebook.append_page(StylesTab(self), Gtk.Label(label=_('Styles'))) # Keybindings tab #~ gtknotebook.append_page(KeyBindingsTab(self), Gtk.Label(label=_('Key bindings'))) # Plugins tab self.plugins_tab = PluginsTab(self, self.plugins) plugins_tab_index = gtknotebook.append_page( self.plugins_tab, Gtk.Label(label=_('Plugins'))) # T: Heading in preferences dialog self.plugins_tab.show() #~ print default_tab, index if default_tab == "Plugins": gtknotebook.set_current_page(plugins_tab_index) if not select_plugin is None: self.plugins_tab.select_plugin(select_plugin) # Applications tab gtknotebook.append_page(ApplicationsTab(self), Gtk.Label(label=_('Applications')))