diff options
| -rw-r--r-- | SoftwareProperties/SoftwareProperties.py | 39 | ||||
| -rw-r--r-- | data/SoftwareProperties.glade | 1 |
2 files changed, 31 insertions, 9 deletions
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 +="<big><b>%s </b></big> (%s) <small>\n%s</small>" % (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 @@ <property name="hover_selection">False</property> <property name="hover_expand">False</property> <signal name="row_activated" handler="on_channel_activated" last_modification_time="Fri, 24 Mar 2006 12:56:00 GMT"/> + <signal name="cursor_changed" handler="on_treeview_sources_cursor_changed" last_modification_time="Fri, 24 Mar 2006 13:00:27 GMT"/> </widget> </child> </widget> |
