def __on_remove_button_clicked (self, button):
        debuglog.uprint ("PessulusSimpleEditableTreeview: remove button clicked")

        model, iter = self.treeview.get_selection ().get_selected ()

        # if nothing selected...
        if not iter:
            print >> sys.stderr, "Warning: ask for removal in treeview while nothing selected"
            return

        selected_value = model[iter][self.COLUMN_EDITABLE]

        # if selection should not be here...
        if selected_value not in self.content_set:
            print >> sys.stderr, "Warning: %s should not be in the treeview" % selected_value
            del (model[iter])
            return
        
        # try to find the future selection (after this item has been removed)
        # note that we can not save a path since the paths might change
        new_selected_iter = model.iter_next (iter)
        if not new_selected_iter:
            # there's no next item. This item was the last one. Select the
            # item that's before.
            children = model.iter_n_children (None)
            if children > 1:
                new_selected_iter = model.iter_nth_child (None, children - 2)
        if new_selected_iter:
            path = model.get_path (new_selected_iter)
            self.selected_content = model[path][self.COLUMN_EDITABLE]

        self.content_set.remove (selected_value)
        self.__update_model ()
        self.emit ("changed", self.content_set)
    def __on_add_button_clicked (self, button):
        debuglog.uprint ("PessulusSimpleEditableTreeview: add button clicked")

        # add a row and start editing it
        iter = self.liststore.append ()
        path = self.liststore.get_path (iter)
        self.treeview.set_cursor_on_cell (path, self.column, self.cell, True)
        self.new_edited_path = path
    def __on_edit_button_clicked (self, button):
        debuglog.uprint ("PessulusSimpleEditableTreeview: edit button clicked")

        model, iter = self.treeview.get_selection ().get_selected ()

        # if nothing selected...
        if not iter:
            print >> sys.stderr, "Warning: ask for edition in treeview while nothing selected"
            return

        path = model.get_path (iter)
        self.treeview.set_cursor_on_cell (path, self.column, self.cell, True)
    def __on_toggled (self, toggle, path):
        def toggle_value (model, iter, column):
            model[iter][column] = not model[iter][column]
            return model[iter][column]

        iter = self.liststore.get_iter (path)
        active = toggle_value (self.liststore, iter, self.COLUMN_DISABLED)

        iid = self.liststore[iter][self.COLUMN_IID]
        if active:
            if iid not in self.disabled_applets:
                debuglog.uprint ('adding "%s" to list of disabled applets', iid)
                self.disabled_applets.add (iid)
                globalvar.applier.set_list (self.key, gconf.VALUE_STRING,
                                            list (self.disabled_applets),
                                            self.lockdownbutton.get ())
        elif iid in self.disabled_applets:
            debuglog.uprint ('removing "%s" from list of disabled applets', iid)
            self.disabled_applets.remove (iid)
            globalvar.applier.set_list (self.key, gconf.VALUE_STRING,
                                        list (self.disabled_applets),
                                        self.lockdownbutton.get ())
    def __on_cell_edited (self, cell, path, new_text):
        debuglog.uprint ('PessulusSimpleEditableTreeview: edited cell; new contents: "%s"', new_text)

        self.editing = False
        self.__update_sensitivity ()

        new = False
        if self.new_edited_path:
            if self.new_edited_path != path:
                new = True
            else:
                print >> sys.stderr, "Warning: path should have been a new edited one in the treeview"
            self.new_edited_path = None

        if self.strip_text:
            text = new_text.strip ()
        else:
            text = new_text

        # don't accept new items that are ""
        if text == "" and new:
            del (self.liststore[path])
            return

        if new or self.liststore[path][self.COLUMN_EDITABLE] != text:
            # save the selected content so that it will be selected again
            # later
            self.selected_content = text

            if not new:
                self.content_set.remove (self.liststore[path][self.COLUMN_EDITABLE])
            if text != "":
                self.content_set.add (text)

            self.__update_model ()
            self.emit ("changed", self.content_set)
Ejemplo n.º 6
0
 def __on_unsafeprotocols_toggled (self, checkbutton, hbox):
     sensitive = checkbutton.get_active ()
     debuglog.uprint ("PessulusMainDialog: setting unsafe protocols toggle to %s", sensitive)
     hbox.set_sensitive (sensitive)
     self.safeprotocols.set_sensitive (sensitive)
 def __on_check_toggled (self, checkbutton):
     debuglog.uprint ('option checkbutton for "%s" set to %s', self.key, checkbutton.get_active ())
     self.__do_change ()
 def __on_lockdownbutton_toggled (self, lockdownbutton, mandatory):
     debuglog.uprint ('lockdown button for "%s" set to %s', self.key, lockdownbutton.get ())
     self.__do_change ()