diff options
| author | Sebastian Heinlein <renate@hph4> | 2006-04-17 16:20:07 +0200 |
|---|---|---|
| committer | Sebastian Heinlein <renate@hph4> | 2006-04-17 16:20:07 +0200 |
| commit | 4b4323bc297cde4d65280a0844b7977ce52a34b7 (patch) | |
| tree | 4ba61a0faf408265258d0138e98507c3cd04aeae | |
| parent | b06e74048b8b959e4216e79af759d0d4ad365573 (diff) | |
| download | python-apt-4b4323bc297cde4d65280a0844b7977ce52a34b7.tar.gz | |
* do not allow to create an invalid channel in the edit dialog
| -rw-r--r-- | SoftwareProperties/dialog_edit.py | 57 | ||||
| -rw-r--r-- | data/SoftwarePropertiesDialogs.glade | 48 |
2 files changed, 63 insertions, 42 deletions
diff --git a/SoftwareProperties/dialog_edit.py b/SoftwareProperties/dialog_edit.py index 05cbddba..eb2cdc97 100644 --- a/SoftwareProperties/dialog_edit.py +++ b/SoftwareProperties/dialog_edit.py @@ -41,6 +41,9 @@ class dialog_edit: self.gladexml = gtk.glade.XML("%s/glade/SoftwarePropertiesDialogs.glade" % datadir) self.main = self.gladexml.get_widget("dialog_edit") self.main.set_transient_for(parent) + self.button_edit_ok = self.gladexml.get_widget("button_edit_ok") + self.gladexml.signal_connect("on_entry_source_line_changed", + self.check_line) # type combo_type = self.gladexml.get_widget("combobox_type") @@ -70,29 +73,43 @@ class dialog_edit: entry = self.gladexml.get_widget("entry_comment") entry.set_text(source_entry.comment) - def run(self): - res = self.main.run() - if res == gtk.RESPONSE_OK: - # get values - combo_type = self.gladexml.get_widget("combobox_type") - if combo_type.get_active() == 0: - line = "deb" - else: - line = "deb-src" - entry = self.gladexml.get_widget("entry_uri") - line = line + " " + entry.get_text() + def check_line(self, *args): + """Check for a valid apt line and set the sensitiveness of the + button 'add' accordingly""" + line = self.get_line() + source_entry = aptsources.SourceEntry(line) + if source_entry.invalid == True or source_entry.disabled == True: + self.button_edit_ok.set_sensitive(False) + else: + self.button_edit_ok.set_sensitive(True) + + def get_line(self): + """Collect all values from the entries and create an apt line""" + combo_type = self.gladexml.get_widget("combobox_type") + if combo_type.get_active() == 0: + line = "deb" + else: + line = "deb-src" + entry = self.gladexml.get_widget("entry_uri") + line = line + " " + entry.get_text() - entry = self.gladexml.get_widget("entry_dist") - line = line + " " + entry.get_text() + entry = self.gladexml.get_widget("entry_dist") + line = line + " " + entry.get_text() - entry = self.gladexml.get_widget("entry_comps") - line = line + " " + entry.get_text() + entry = self.gladexml.get_widget("entry_comps") + line = line + " " + entry.get_text() - entry = self.gladexml.get_widget("entry_comment") - if entry.get_text() != "": - line = line + " #" + entry.get_text() + "\n" - else: - line = line + "\n" + entry = self.gladexml.get_widget("entry_comment") + if entry.get_text() != "": + line = line + " #" + entry.get_text() + "\n" + else: + line = line + "\n" + return line + + def run(self): + res = self.main.run() + if res == gtk.RESPONSE_OK: + line = self.get_line() # change repository index = self.sourceslist.list.index(self.source_entry) diff --git a/data/SoftwarePropertiesDialogs.glade b/data/SoftwarePropertiesDialogs.glade index afbb39b5..549a9c7c 100644 --- a/data/SoftwarePropertiesDialogs.glade +++ b/data/SoftwarePropertiesDialogs.glade @@ -590,7 +590,7 @@ The APT line contains the type, location and sections of a channel, for example </child> <child> - <widget class="GtkButton" id="button8"> + <widget class="GtkButton" id="button_edit_ok"> <property name="visible">True</property> <property name="can_default">True</property> <property name="has_default">True</property> @@ -745,6 +745,7 @@ The APT line contains the type, location and sections of a channel, for example <property name="has_frame">True</property> <property name="invisible_char">*</property> <property name="activates_default">True</property> + <signal name="changed" handler="on_entry_source_line_changed" last_modification_time="Mon, 17 Apr 2006 14:14:17 GMT"/> </widget> <packing> <property name="left_attach">1</property> @@ -756,27 +757,6 @@ The APT line contains the type, location and sections of a channel, for example </child> <child> - <widget class="GtkEntry" id="entry_dist"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">*</property> - <property name="activates_default">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="y_options"></property> - </packing> - </child> - - <child> <widget class="GtkEntry" id="entry_comps"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -787,6 +767,7 @@ The APT line contains the type, location and sections of a channel, for example <property name="has_frame">True</property> <property name="invisible_char">*</property> <property name="activates_default">True</property> + <signal name="changed" handler="on_entry_source_line_changed" last_modification_time="Mon, 17 Apr 2006 14:15:14 GMT"/> </widget> <packing> <property name="left_attach">1</property> @@ -854,6 +835,7 @@ Source</property> <property name="has_frame">True</property> <property name="invisible_char">*</property> <property name="activates_default">True</property> + <signal name="changed" handler="on_entry_source_line_changed" last_modification_time="Mon, 17 Apr 2006 14:15:19 GMT"/> </widget> <packing> <property name="left_attach">1</property> @@ -863,6 +845,28 @@ Source</property> <property name="y_options"></property> </packing> </child> + + <child> + <widget class="GtkEntry" id="entry_dist"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">True</property> + <signal name="changed" handler="on_entry_source_line_changed" last_modification_time="Mon, 17 Apr 2006 14:14:17 GMT"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="y_options"></property> + </packing> + </child> </widget> <packing> <property name="padding">0</property> |
