diff options
| author | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-03-24 14:28:38 +0100 |
|---|---|---|
| committer | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-03-24 14:28:38 +0100 |
| commit | b151c61e5838fe08af8cc25c36c045a44ad0c98b (patch) | |
| tree | 7cabce637c95fa5986246dc11e217fb33e64c938 /SoftwareProperties | |
| parent | efa4ee5ee367927e75c6135387b999153d849f0f (diff) | |
| download | python-apt-b151c61e5838fe08af8cc25c36c045a44ad0c98b.tar.gz | |
* do not allow to edit cdrom sources
Diffstat (limited to 'SoftwareProperties')
| -rw-r--r-- | SoftwareProperties/SoftwareProperties.py | 39 |
1 files changed, 30 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() |
