Exemplo n.º 1
0
    def update(self, settings):
        if 'stylesheet' in settings and settings['stylesheet'] is not None:
            self.stylesheet_chooser.set_filename(settings['stylesheet'])
        else:
            self.stylesheet_chooser.set_filename(None)

        if 'renderer' not in settings:
            utils.combo_set_active_text(self.widgets.renderer_combo,
                                        default_renderer)
        else:
            utils.combo_set_active_text(self.widgets.renderer_combo,
                                        settings['renderer'])

        if 'source_type' not in settings:
            utils.combo_set_active_text(self.widgets.source_type_combo,
                                        default_source_type)
        else:
            utils.combo_set_active_text(self.widgets.source_type_combo,
                                        settings['source_type'])

        if 'authors' in settings:
            self.widgets.author_check.set_active(settings['authors'])
        else:
            self.widgets.author_check.set_active(False)

        if 'private' in settings:
            self.widgets.private_check.set_active(settings['private'])
        else:
            self.widgets.private_check.set_active(False)
    def set_formatter_combo(self, val):
        """
        Set the formatter combo to val and emit the 'changed' signal.

        :param val: either an integer index or a string value in the
          combo combo = self.view.widgets.formatter_combo
        """
        combo = self.view.widgets.formatter_combo
        if val is None:
            combo.set_active(-1)
        elif isinstance(val, int):
            combo.set_active(val)
        else:
            utils.combo_set_active_text(combo, val)
Exemplo n.º 3
0
    def set_formatter_combo(self, val):
        """
        Set the formatter combo to val and emit the 'changed' signal.

        :param val: either an integer index or a string value in the
          combo combo = self.view.widgets.formatter_combo
        """
        combo = self.view.widgets.formatter_combo
        if val is None:
            combo.set_active(-1)
        elif isinstance(val, int):
            combo.set_active(val)
        else:
            utils.combo_set_active_text(combo, val)
Exemplo n.º 4
0
    def update(self, settings):
        if 'stylesheet' in settings and settings['stylesheet'] is not None:
            self.stylesheet_chooser.set_filename(settings['stylesheet'])
        else:
            self.stylesheet_chooser.set_filename(None)

        if 'renderer' not in settings:
            utils.combo_set_active_text(self.widgets.renderer_combo,
                                        default_renderer)
        else:
            utils.combo_set_active_text(self.widgets.renderer_combo,
                                        settings['renderer'])

        if 'source_type' not in settings:
            utils.combo_set_active_text(self.widgets.source_type_combo,
                                        default_source_type)
        else:
            utils.combo_set_active_text(self.widgets.source_type_combo,
                                        settings['source_type'])

        if 'authors' in settings:
            self.widgets.author_check.set_active(settings['authors'])
        else:
            self.widgets.author_check.set_active(False)

        if 'private' in settings:
            self.widgets.private_check.set_active(settings['private'])
        else:
            self.widgets.private_check.set_active(False)
    def set_names_combo(self, val):
        """
        Set the names combo to val and emit the 'changed' signal,
        :param val: either an integer index or a string value in the combo

        If the model on the combo is None then this method will return
        and not emit the changed signal
        """
        combo = self.view.widgets.names_combo
        if combo.get_model() is None:
            self.view.widgets.details_box.set_sensitive(False)
            return
        if val is None:
            combo.set_active(-1)
        elif isinstance(val, int):
            combo.set_active(val)
        else:
            utils.combo_set_active_text(combo, val)
Exemplo n.º 6
0
    def set_names_combo(self, val):
        """
        Set the names combo to val and emit the 'changed' signal,
        :param val: either an integer index or a string value in the combo

        If the model on the combo is None then this method will return
        and not emit the changed signal
        """
        combo = self.view.widgets.names_combo
        if combo.get_model() is None:
            self.view.set_sensitive('details_box', False)
            return
        if val is None:
            combo.set_active(-1)
        elif isinstance(val, int):
            combo.set_active(val)
        else:
            utils.combo_set_active_text(combo, val)
Exemplo n.º 7
0
 def on_new_button_clicked(self, *args):
     # TODO: don't set the OK button as sensitive in the name dialog
     # if the name already exists
     # TOD0: make "Enter" in the entry fire the default response
     d = gtk.Dialog(_("Formatter Name"),
                    self.view.dialog,
                    gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                             gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     d.vbox.set_spacing(10)
     d.set_default_response(gtk.RESPONSE_ACCEPT)
     text = '<b>%s</b>' % _('Enter a name for the new formatter')
     label = gtk.Label()
     label.set_markup(text)
     label.set_padding(10, 10)
     d.vbox.pack_start(label)
     entry = gtk.Entry()
     entry.set_activates_default(True)
     d.vbox.pack_start(entry)
     d.show_all()
     names_model = self.view.widgets.names_combo.get_model()
     while True:
         if d.run() == gtk.RESPONSE_ACCEPT:
             name = entry.get_text()
             if name == '':
                 continue
             elif names_model is not None \
                     and utils.tree_model_has(names_model, name):
                 utils.message_dialog(_('%s already exists') % name)
                 continue
             else:
                 self.set_prefs_for(entry.get_text(), None, {})
                 self.populate_names_combo()
                 utils.combo_set_active_text(self.view.widgets.names_combo,
                                             name)
                 break
         else:
             break
     d.destroy()
 def on_new_button_clicked(self, *args):
     # TODO: don't set the OK button as sensitive in the name dialog
     # if the name already exists
     # TOD0: make "Enter" in the entry fire the default response
     d = gtk.Dialog(_("Formatter Name"), self.view.dialog,
                    gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                             gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     d.vbox.set_spacing(10)
     d.set_default_response(gtk.RESPONSE_ACCEPT)
     text = '<b>%s</b>' % _('Enter a name for the new formatter')
     label = gtk.Label()
     label.set_markup(text)
     label.set_padding(10, 10)
     d.vbox.pack_start(label)
     entry = gtk.Entry()
     entry.set_activates_default(True)
     d.vbox.pack_start(entry)
     d.show_all()
     names_model = self.view.widgets.names_combo.get_model()
     while True:
         if d.run() == gtk.RESPONSE_ACCEPT:
             name = entry.get_text()
             if name == '':
                 continue
             elif names_model is not None \
                      and utils.tree_model_has(names_model, name):
                 utils.message_dialog(_('%s already exists') % name)
                 continue
             else:
                 self.set_prefs_for(entry.get_text(), None, {})
                 self.populate_names_combo()
                 utils.combo_set_active_text(self.view.widgets.names_combo,
                                             name)
                 break
         else:
             break
     d.destroy()