From efa4ee5ee367927e75c6135387b999153d849f0f Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Fri, 24 Mar 2006 13:57:06 +0100 Subject: * open the edit dialog if the channel was double clicked --- SoftwareProperties/SoftwareProperties.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'SoftwareProperties/SoftwareProperties.py') diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py index 099576d0..8d75a6c1 100644 --- a/SoftwareProperties/SoftwareProperties.py +++ b/SoftwareProperties/SoftwareProperties.py @@ -367,7 +367,11 @@ class SoftwareProperties(SimpleGladeApp): if dialog.run() == gtk.RESPONSE_OK: self.reload_sourceslist() self.modified = True - + + def on_channel_activated(self, treeview, path, column): + """Open the edit dialog if a channel was double clicked""" + self.on_edit_clicked(treeview) + def on_remove_clicked(self, widget): sel = self.treeview_sources.get_selection() (model, iter) = sel.get_selected() -- cgit v1.2.3 From b151c61e5838fe08af8cc25c36c045a44ad0c98b Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Fri, 24 Mar 2006 14:28:38 +0100 Subject: * do not allow to edit cdrom sources --- SoftwareProperties/SoftwareProperties.py | 39 ++++++++++++++++++++++++-------- data/SoftwareProperties.glade | 1 + 2 files changed, 31 insertions(+), 9 deletions(-) (limited to 'SoftwareProperties/SoftwareProperties.py') diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py index 8d75a6c1..943af28d 100644 --- a/SoftwareProperties/SoftwareProperties.py +++ b/SoftwareProperties/SoftwareProperties.py @@ -223,15 +223,15 @@ class SoftwareProperties(SimpleGladeApp): contents +="%s (%s) \n%s" % (dist,a_type, comps) self.source_store.append([contents, not source.disabled, source]) - if len(self.source_store) < 1: - self.button_remove.set_sensitive(False) - self.button_edit.set_sensitive(False) - else: - if path_x == None or self.treeview_sources.set_cursor(path_x): + # try to reselect the latest selected channel or if it fails the first + # one + if len(self.source_store) > 0 and \ + (path_x == None or self.treeview_sources.set_cursor(path_x)): self.treeview_sources.set_cursor(0) - self.button_remove.set_sensitive(True) - self.button_edit.set_sensitive(True) - + else: + # call the cursor_changed signal if no channel is selected + self.treeview_sources.emit("cursor_changed") + def reload_keyslist(self): self.keys_store.clear() for key in self.apt_key.list(): @@ -370,7 +370,28 @@ class SoftwareProperties(SimpleGladeApp): def on_channel_activated(self, treeview, path, column): """Open the edit dialog if a channel was double clicked""" - self.on_edit_clicked(treeview) + # check if the channel can be edited + if self.button_edit.get_property("sensitive") == True: + self.on_edit_clicked(treeview) + + def on_treeview_sources_cursor_changed(self, treeview): + """set the sensitiveness of the edit and remove button + corresponding to the selected channel""" + sel = self.treeview_sources.get_selection() + (model, iter) = sel.get_selected() + if not iter: + # No channel is selected, so disable edit and remove + self.button_edit.set_sensitive(False) + self.button_remove.set_sensitive(False) + return + # allow to remove the selected channel + self.button_remove.set_sensitive(True) + # disable editing of cdrom sources + source_entry = model.get_value(iter, LIST_ENTRY_OBJ) + if source_entry.uri.startswith("cdrom:"): + self.button_edit.set_sensitive(False) + else: + self.button_edit.set_sensitive(True) def on_remove_clicked(self, widget): sel = self.treeview_sources.get_selection() diff --git a/data/SoftwareProperties.glade b/data/SoftwareProperties.glade index c1cdc87f..da164c23 100644 --- a/data/SoftwareProperties.glade +++ b/data/SoftwareProperties.glade @@ -94,6 +94,7 @@ False False + -- cgit v1.2.3