From 41b33ac46f0226b756c8547513404d62449715bf Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Sun, 26 Feb 2006 13:26:11 +0100 Subject: * Add a button revert and make the channel list instant apply * Reorder the buttons on the key view to correspond with the channel view --- SoftwareProperties/SoftwareProperties.py | 65 ++++++-- data/SoftwareProperties.glade | 274 +++++++++++++++++-------------- 2 files changed, 201 insertions(+), 138 deletions(-) diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py index 250e2c1d..f7f7f6f2 100644 --- a/SoftwareProperties/SoftwareProperties.py +++ b/SoftwareProperties/SoftwareProperties.py @@ -91,6 +91,7 @@ class SoftwareProperties(SimpleGladeApp): self.init_sourceslist() self.reload_sourceslist() + self.button_revert.set_sensitive(False) # internet update setings @@ -179,6 +180,10 @@ class SoftwareProperties(SimpleGladeApp): else: self.checkbutton_unattended.set_active(False) + # Backup the source list + self.sourceslist.clearBackup(".save") + self.sourceslist.backup(".save") + # apt-key stuff self.apt_key = apt_key() self.init_keyslist() @@ -204,8 +209,7 @@ class SoftwareProperties(SimpleGladeApp): file) res = dialog.run() if res == gtk.RESPONSE_OK: - self.reload_sourceslist() - self.modified = True + self.modified_sourceslist() def on_sources_drag_data_received(self, widget, context, x, y, selection, target_type, timestamp): @@ -244,13 +248,27 @@ class SoftwareProperties(SimpleGladeApp): self.sourceslist = aptsources.SourcesList() self.matcher = aptsources.SourceEntryMatcher() + def on_channel_activate(self, treeview, path, column): + """Open the edit dialog if a channel was double clicked""" + self.on_edit_clicked(treeview) + + def on_treeview_sources_cursor_changed(self, treeview): + """Enable the buttons remove and edit if a channel is selected""" + sel = self.treeview_sources.get_selection() + (model, iter) = sel.get_selected() + if iter: + self.button_edit.set_sensitive(True) + self.button_remove.set_sensitive(True) + else: + self.button_edit.set_sensitive(False) + self.button_remove.set_sensitive(False) + def on_channel_toggled(self, cell_toggle, path): """Enable or disable the selected channel""" iter = self.source_store.get_iter((int(path),)) source_entry = self.source_store.get_value(iter, LIST_ENTRY_OBJ) source_entry.disabled = not source_entry.disabled - self.reload_sourceslist() - self.modified = True + self.modified_sourceslist() def init_keyslist(self): self.keys_store = gtk.ListStore(str) @@ -261,6 +279,21 @@ class SoftwareProperties(SimpleGladeApp): keys_col = gtk.TreeViewColumn("Key", tr, text=0) self.treeview2.append_column(keys_col) + def on_button_revert_clicked(self, button): + """Restore the source list from the startup of the dialog""" + self.sourceslist.restoreBackup(".save") + self.sourceslist.clearBackup(".save") + self.sourceslist.backup(".save") + self.sourceslist.refresh() + self.reload_sourceslist() + self.button_revert.set_sensitive(False) + + def modified_sourceslist(self): + """The sources list was changed and now needs to be saved and reloaded""" + self.button_revert.set_sensitive(True) + self.save_sourceslist() + self.reload_sourceslist() + def reload_sourceslist(self): self.source_store.clear() self.sourceslist.check_for_endangered_dists() @@ -377,18 +410,17 @@ class SoftwareProperties(SimpleGladeApp): def save_sourceslist(self): #location = "/etc/apt/sources.list" #shutil.copy(location, location + ".save") - self.sourceslist.clearBackup(".save") - self.sourceslist.backup(".save") self.sourceslist.save() - + def on_add_clicked(self, widget): + """Open a dialog to add new channels""" dialog = dialog_add.dialog_add(self.window_main, self.sourceslist, self.datadir) if dialog.run() == gtk.RESPONSE_OK: - self.reload_sourceslist() - self.modified = True - + self.modified_sourceslist() + def on_edit_clicked(self, widget): + """Open a dialog to edit the currently selected dialog""" sel = self.treeview_sources.get_selection() (model, iter) = sel.get_selected() if not iter: @@ -397,17 +429,17 @@ class SoftwareProperties(SimpleGladeApp): dialog = dialog_edit.dialog_edit(self.window_main, self.sourceslist, source_entry, self.datadir) if dialog.run() == gtk.RESPONSE_OK: - self.reload_sourceslist() - self.modified = True - + self.modified_sourceslist() + def on_remove_clicked(self, widget): sel = self.treeview_sources.get_selection() (model, iter) = sel.get_selected() if iter: source = model.get_value(iter, LIST_ENTRY_OBJ) self.sourceslist.remove(source) - self.reload_sourceslist() - self.modified = True + self.modified_sourceslist() + self.button_edit.set_sensitive(False) + self.button_remove.set_sensitive(False) def add_key_clicked(self, widget): chooser = gtk.FileChooserDialog(title=_("Import key"), @@ -492,8 +524,7 @@ class SoftwareProperties(SimpleGladeApp): if line != "": full_path = "%s%s" % (apt_pkg.Config.FindDir("Dir::Etc"),saved_entry) self.sourceslist.list.append(aptsources.SourceEntry(line,full_path)) - self.reload_sourceslist() - self.modified = True + self.modified_sourceslist() # FIXME: move this into a different file diff --git a/data/SoftwareProperties.glade b/data/SoftwareProperties.glade index 27f53404..9a5edbeb 100644 --- a/data/SoftwareProperties.glade +++ b/data/SoftwareProperties.glade @@ -5,7 +5,6 @@ 6 - 580 400 True Software Preferences @@ -93,6 +92,8 @@ False False False + + @@ -107,135 +108,167 @@ True False - 6 + 12 - + True - True - True - gtk-add - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - - - - - True - True - True - gtk-remove - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - - - - - True - True - True - gtk-edit - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - + False + 6 - - - True - True - True - GTK_RELIEF_NORMAL - True - + + + True + True + True + gtk-add + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + + - + True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 + True + True + GTK_RELIEF_NORMAL + True + - + True - False - 2 + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 - + True - gtk-cdrom - 4 - 0.5 - 0.5 - 0 - 0 + False + 2 + + + + True + gtk-cdrom + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Add _Cdrom + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + - - 0 - False - False - - - - - - True - Add _Cdrom - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - + + 0 + False + False + + + + + + True + False + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + + + + + + True + False + True + True + gtk-edit + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + + + 0 + True + True + + + + + + True + True + gtk-revert-to-saved + True + GTK_RELIEF_NORMAL + True + + 0 False @@ -608,43 +641,42 @@ 0 False False + GTK_PACK_END - + True + Import the public key from a trusted software provider True - gtk-remove - True + _Import Key File + True GTK_RELIEF_NORMAL True - + 0 False False - GTK_PACK_END - + True - Import the public key from a trusted software provider True - _Import Key File - True + gtk-remove + True GTK_RELIEF_NORMAL True - + 0 False False - GTK_PACK_END -- cgit v1.2.3