From 28d131b543b638589c243abb6b1c247c8c653321 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Thu, 23 Feb 2006 13:24:40 +0100 Subject: * Move the mime type handling of sources.lists to gnome-software-properties * Renamed mime type to text/x-apt-sources-list * Remove all depricated add-software-channel code * Add a schemas file for update-manager * Use dh_gconf * Software Properties: - Move the channel buttons to the bottom of the notebook to get more vertical space for the channels - Set a global window icon for SoftwareProperties and its children - Add drag and drop support for sources.list on the treeview_sources - Allow to enable and disable channels - Do not use so much space for rendering the sources lista - Use the comment instead of the URI in the channel list if we don't find a nice name - Show the type only on source channels - "binary" is too technial - Add some small sanity checks to aptsources - Use single quotes in the predefind distru names * Dialog add: - merge the custom and the default add dialog - sanity checks for the custom apt line, that do not allow to add a wrong one * Update Manager: - add an option to hide the reload reminder --- SoftwareProperties/dialog_add.py | 89 ++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 27 deletions(-) (limited to 'SoftwareProperties/dialog_add.py') diff --git a/SoftwareProperties/dialog_add.py b/SoftwareProperties/dialog_add.py index 9b384623..effd9f24 100644 --- a/SoftwareProperties/dialog_add.py +++ b/SoftwareProperties/dialog_add.py @@ -45,16 +45,58 @@ class dialog_add: self.main = widget = self.gladexml.get_widget("dialog_add") self.main.set_transient_for(self.parent) - combo = self.gladexml.get_widget("combobox_what") + # Setup the official channel widgets + self.combo = self.gladexml.get_widget("combobox_what") self.gladexml.signal_connect("on_combobox_what_changed", self.on_combobox_what_changed, None) - # combox box needs cell = gtk.CellRendererText() - combo.pack_start(cell, True) - combo.add_attribute(cell, 'text', 0) - self.fill_combo(combo) - self.gladexml.signal_connect("on_button_custom_clicked", - self.on_button_custom_clicked, None) + self.combo.pack_start(cell, True) + self.combo.add_attribute(cell, 'text', 0) + self.fill_combo(self.combo) + # Setup the custom channel widgets + self.entry = self.gladexml.get_widget("entry_source_line") + self.gladexml.signal_connect("on_entry_source_line_changed", + self.check_line) + + # Setup the toggle action + self.radio_official = self.gladexml.get_widget("radiobutton_official") + self.radio_custom = self.gladexml.get_widget("radiobutton_custom") + self.button_add = self.gladexml.get_widget("button_add_channel") + self.gladexml.signal_connect("on_radiobutton_custom_toggled", + self.on_radio_custom_toggled) + self.gladexml.signal_connect("on_radiobutton_official_toggled", + self.on_radio_official_toggled) + + # We start with the official channels: + self.official = True + self.radio_custom.toggled() + + def check_line(self, *args): + """Check for a valid apt line""" + if self.official == True: + self.button_add.set_sensitive(True) + return + + line = self.entry.get_text() + "\n" + source_entry = aptsources.SourceEntry(line) + if source_entry.invalid == True or source_entry.disabled == True: + self.button_add.set_sensitive(False) + else: + self.button_add.set_sensitive(True) + + + def on_radio_custom_toggled(self, radio): + state = radio.get_active() + self.entry.set_sensitive(state) + self.check_line() + + def on_radio_official_toggled(self, radio): + state = radio.get_active() + self.combo.set_sensitive(state) + for check in self.comps: + check.set_sensitive(state) + self.official = state + self.button_add.set_sensitive(state) def fill_combo(self,combo): liststore = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_PYOBJECT) @@ -72,25 +114,14 @@ class dialog_add: (name, template) = liststore.get(a_iter, 0,1) self.selected = template comps = template.comps + self.comps=[] for c in comps: checkbox = gtk.CheckButton(c.description) checkbox.set_active(c.on_by_default) checkbox.set_data("name",c.name) vbox.pack_start(checkbox) checkbox.show() - - def on_button_custom_clicked(self, widget, data): - #print "on_button_custom_clicked()" - # this hide here is ugly :/ - self.main.hide() - dialog = self.gladexml.get_widget("dialog_add_custom") - dialog.set_transient_for(self.parent) - res = dialog.run() - dialog.hide() - entry = self.gladexml.get_widget("entry_source_line") - line = entry.get_text() + "\n" - self.sourceslist.list.append(aptsources.SourceEntry(line)) - self.main.response(res) + self.comps.append(checkbox) def get_enabled_comps(self, checkbutton): if checkbutton.get_active(): @@ -100,12 +131,16 @@ class dialog_add: res = self.main.run() if res == gtk.RESPONSE_OK: # add repository - self.selected_comps = [] - vbox = self.gladexml.get_widget("vbox_comps") - vbox.foreach(self.get_enabled_comps) - self.sourceslist.add(self.selected.type, - self.selected.uri, - self.selected.dist, - self.selected_comps) + if self.official == True: + self.selected_comps = [] + vbox = self.gladexml.get_widget("vbox_comps") + vbox.foreach(self.get_enabled_comps) + self.sourceslist.add(self.selected.type, + self.selected.uri, + self.selected.dist, + self.selected_comps) + else: + line = self.entry.get_text() + "\n" + self.sourceslist.list.append(aptsources.SourceEntry(line)) self.main.hide() return res -- cgit v1.2.3