summaryrefslogtreecommitdiff
path: root/SoftwareProperties
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-04-19 14:57:57 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-04-19 14:57:57 +0200
commit3cb73fd8b75b2ef4de7a9bd25fb5d41950078550 (patch)
treee2025b906fd88b9e1c5f284e82962f5258f61da1 /SoftwareProperties
parent43b6ac8b952098943868404e8e28868bdf6265a5 (diff)
parentf8724e0b2329dbd497419123e38bb36d7bbeed71 (diff)
downloadpython-apt-3cb73fd8b75b2ef4de7a9bd25fb5d41950078550.tar.gz
* merged with sebastian (thanks!)
* updated the changelog * added dh_iconcache to debian/rules
Diffstat (limited to 'SoftwareProperties')
-rw-r--r--SoftwareProperties/SoftwareProperties.py1
-rw-r--r--SoftwareProperties/aptsources.py2
-rw-r--r--SoftwareProperties/dialog_add.py14
-rw-r--r--SoftwareProperties/dialog_edit.py73
4 files changed, 66 insertions, 24 deletions
diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py
index aa3114f0..237ffbdd 100644
--- a/SoftwareProperties/SoftwareProperties.py
+++ b/SoftwareProperties/SoftwareProperties.py
@@ -57,6 +57,7 @@ CONF_MAP = {
class SoftwareProperties(SimpleGladeApp):
def __init__(self, datadir=None, options=None, parent=None):
+ gtk.window_set_default_icon_name("software-properties")
# FIXME: some saner way is needed here
if datadir == None:
diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py
index 417563d4..133e9b3d 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_add.py b/SoftwareProperties/dialog_add.py
index fbf741c5..b5fbe07f 100644
--- a/SoftwareProperties/dialog_add.py
+++ b/SoftwareProperties/dialog_add.py
@@ -172,13 +172,19 @@ class dialog_add:
self.selected_comps = []
vbox = self.gladexml.get_widget("vbox_comps")
vbox.foreach(self.get_enabled_comps)
+
# check if we are in 'add' or 'edit' mode
if self.source_entry:
# 'edit' - ode
- if not self.custom:
- entry = self._make_source_entry()
- if entry:
- self.sourceslist.list[self.source_entry_index] = entry
+ # check if there are no selected components
+ if len(self.selected_comps) < 1:
+ # remove the source
+ self.sourceslist.remove(self.source_entry)
+ else:
+ if not self.custom:
+ entry = self._make_source_entry()
+ if entry:
+ self.sourceslist.list[self.source_entry_index] = entry
else:
# 'add' mode
self.sourceslist.add(self.selected.type,
diff --git a/SoftwareProperties/dialog_edit.py b/SoftwareProperties/dialog_edit.py
index 05cbddba..59788915 100644
--- a/SoftwareProperties/dialog_edit.py
+++ b/SoftwareProperties/dialog_edit.py
@@ -41,6 +41,7 @@ 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")
# type
combo_type = self.gladexml.get_widget("combobox_type")
@@ -70,29 +71,61 @@ 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):
+ 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")
+ 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")
+ 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:
- # 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()
-
- 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_comment")
- if entry.get_text() != "":
- line = line + " #" + entry.get_text() + "\n"
- else:
- line = line + "\n"
+ line = self.get_line()
# change repository
index = self.sourceslist.list.index(self.source_entry)