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, parent, notebook, chosen_plugin=None): Dialog.__init__(self, parent, _('Properties'), help='Help:Properties') # T: Dialog title self.notebook = notebook stack = Gtk.Stack() sidebar = Gtk.StackSidebar() sidebar.set_stack(stack) hbox = Gtk.Box() hbox.add(sidebar) hbox.add(stack) self.vbox.add(hbox) def add_widget(form, name, title): if chosen_plugin and chosen_plugin != name: return if self.notebook.readonly: for widget in list(form.widgets.values()): widget.set_sensitive(False) box = Gtk.VBox() box.pack_start(form, False, False, 0) stack.add_titled(box, name, title) self.form = InputForm( inputs=notebook_properties, values=notebook.config['Notebook'] ) self.form.widgets['icon'].set_use_relative_paths(self.notebook) self.form.widgets['document_root'].set_use_relative_paths(self.notebook) add_widget(self.form, 'notebook', _('Notebook')) self.plugin_forms = {} plugins = PluginManager() for name in plugins: plugin = plugins[name] if plugin.plugin_notebook_properties: key = plugin.config_key form = InputForm( inputs=plugin.form_fields(plugin.plugin_notebook_properties), values=notebook.config[key] ) self.plugin_forms[key] = form add_widget(form, name, plugin.plugin_info['name'])
def __init__(self, parent, config, notebook): Dialog.__init__(self, parent, _('Properties'), help='Help:Properties') # T: Dialog title self.notebook = notebook self.config = config stack = Gtk.Stack() sidebar = Gtk.StackSidebar() sidebar.set_stack(stack) hbox = Gtk.Box() hbox.add(sidebar) hbox.add(stack) self.vbox.add(hbox) self.form = InputForm(inputs=notebook_properties, values=notebook.config['Notebook']) self.form.widgets['icon'].set_use_relative_paths(self.notebook) if self.notebook.readonly: for widget in list(self.form.widgets.values()): widget.set_sensitive(False) stack.add_titled(self.form, 'notebook', _('Notebook')) self.plugin_forms = {} plugins = get_window(parent).__pluginmanager__ # XXX for name in plugins: plugin = plugins[name] if plugin.plugin_notebook_properties: key = plugin.config_key form = InputForm(inputs=plugin.form_fields( plugin.plugin_notebook_properties), values=notebook.config[key]) self.plugin_forms[key] = form if self.notebook.readonly: for widget in list(form.widgets.values()): widget.set_sensitive(False) box = Gtk.VBox() box.pack_start(form, False, False, 0) stack.add_titled(box, name, plugin.plugin_info['name'])
def __init__(self, window, notebook=None, page=None, namespace=None, basename=None, append=None, text=None, template_options=None, attachments=None): assert page is None, 'TODO' manager = ConfigManager() # FIXME should be passed in self.config = manager.get_config_dict('quicknote.conf') self.uistate = self.config['QuickNoteDialog'] Dialog.__init__(self, window, _('Quick Note')) self._updating_title = False self._title_set_manually = not basename is None self.attachments = attachments if notebook and not isinstance(notebook, str): notebook = notebook.uri self.uistate.setdefault('lastnotebook', None, str) if self.uistate['lastnotebook']: notebook = notebook or self.uistate['lastnotebook'] self.config['Namespaces'].setdefault(notebook, None, str) namespace = namespace or self.config['Namespaces'][notebook] self.form = InputForm() self.vbox.pack_start(self.form, False, True, 0) # TODO dropdown could use an option "Other..." label = Gtk.Label(label=_('Notebook') + ': ') label.set_alignment(0.0, 0.5) self.form.attach(label, 0, 1, 0, 1, xoptions=Gtk.AttachOptions.FILL) # T: Field to select Notebook from drop down list self.notebookcombobox = NotebookComboBox(current=notebook) self.notebookcombobox.connect('changed', self.on_notebook_changed) self.form.attach(self.notebookcombobox, 1, 2, 0, 1) self._init_inputs(namespace, basename, append, text, template_options) self.uistate['lastnotebook'] = notebook self._set_autocomplete(notebook)
def __init__(self, window, notebook, ui, page=None, namespace=None, basename=None, append=None, text=None, template_options=None, attachments=None): Dialog.__init__(self, window, _('Quick Note')) self._ui = ui self._updating_title = False self._title_set_manually = not basename is None self.attachments = attachments self.uistate.setdefault('namespace', None, basestring) namespace = namespace or self.uistate['namespace'] self.form = InputForm(notebook=notebook) self.vbox.pack_start(self.form, False) self._init_inputs(namespace, basename, append, text, template_options)
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')))