diff options
| -rw-r--r-- | SoftwareProperties/aptsources.py | 2 | ||||
| -rw-r--r-- | SoftwareProperties/dialog_edit.py | 26 |
2 files changed, 23 insertions, 5 deletions
diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py index a2d0a67d..247879a3 100644 --- a/SoftwareProperties/aptsources.py +++ b/SoftwareProperties/aptsources.py @@ -155,6 +155,8 @@ class SourceEntry: return # URI self.uri = string.strip(pieces[1]) + if len(self.uri) < 1: + self.invalid = True # distro and components (optional) # Directory or distro self.dist = string.strip(pieces[2]) diff --git a/SoftwareProperties/dialog_edit.py b/SoftwareProperties/dialog_edit.py index eb2cdc97..59788915 100644 --- a/SoftwareProperties/dialog_edit.py +++ b/SoftwareProperties/dialog_edit.py @@ -42,8 +42,6 @@ class dialog_edit: 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") @@ -73,12 +71,20 @@ class dialog_edit: entry = self.gladexml.get_widget("entry_comment") entry.set_text(source_entry.comment) + # finally set the signal so that the check function is not tiggered + # during initialisation + self.gladexml.signal_connect("on_entry_source_line_changed", + self.check_line) + def check_line(self, *args): """Check for a valid apt line and set the sensitiveness of the button 'add' accordingly""" line = self.get_line() + if line == False: + self.button_edit_ok.set_sensitive(False) + return source_entry = aptsources.SourceEntry(line) - if source_entry.invalid == True or source_entry.disabled == True: + 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) @@ -90,13 +96,23 @@ class dialog_edit: line = "deb" else: line = "deb-src" - entry = self.gladexml.get_widget("entry_uri") - line = line + " " + entry.get_text() + + entry = self.gladexml.get_widget("entry_uri") + text = entry.get_text() + if len(text) < 1 or text.find(" ") != -1 or text.find("#") != -1: + return False + line = line + " " + entry.get_text() entry = self.gladexml.get_widget("entry_dist") + text = entry.get_text() + if len(text) < 1 or text.find(" ") != -1 or text.find("#") != -1: + return False line = line + " " + entry.get_text() entry = self.gladexml.get_widget("entry_comps") + text = entry.get_text() + if len(text) < 1 or text.find("#") != -1: + return False line = line + " " + entry.get_text() entry = self.gladexml.get_widget("entry_comment") |
