summaryrefslogtreecommitdiff
path: root/SoftwareProperties
diff options
context:
space:
mode:
authorSebastian Heinlein <sebastian.heinlein@web.de>2006-02-24 02:18:49 +0100
committerSebastian Heinlein <sebastian.heinlein@web.de>2006-02-24 02:18:49 +0100
commit629ab77bfdd4979cb6da87a0e20c5b131906c977 (patch)
tree1b6ec87cdbeddaed29bcb6aa3eb3585fb61b8da0 /SoftwareProperties
parent4c058967a18024dc127179c98fb02bbc4eda2e7b (diff)
downloadpython-apt-629ab77bfdd4979cb6da87a0e20c5b131906c977.tar.gz
* Rendering of channel sources:
- add a small white space around each line - move the rendering to its own method and aptsources so that it can be reused in the dialog_sources_list - Tag debian sources - Do not show the components of updates, security-updates and backports * Channel handling - Bring not yet used methods for removing and disabling components in position - Add support for automatically updated updates and backports * General - comment out debug outputs - fix the plural gettext in the dialog_sources_list - fix d'n'd and mime type opening - was a bug in the renderer - add more TODO
Diffstat (limited to 'SoftwareProperties')
-rw-r--r--SoftwareProperties/SoftwareProperties.py15
-rw-r--r--SoftwareProperties/aptsources.py156
-rw-r--r--SoftwareProperties/dialog_sources_list.py19
3 files changed, 140 insertions, 50 deletions
diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py
index 0209825d..f6977275 100644
--- a/SoftwareProperties/SoftwareProperties.py
+++ b/SoftwareProperties/SoftwareProperties.py
@@ -225,13 +225,15 @@ class SoftwareProperties(SimpleGladeApp):
self.treeview_sources.set_model(self.source_store)
cell_desc = gtk.CellRendererText()
- #cell_desc.set_property("xpad", 10)
- #cell_desc.set_property("ypad", 10)
+ cell_desc.set_property("xpad", 2)
+ cell_desc.set_property("ypad", 2)
col_desc = gtk.TreeViewColumn(_("Software Channel"), cell_desc,
markup=COLUMN_DESC)
- col_desc.set_max_width(500)
+ col_desc.set_max_width(1000)
cell_toggle = gtk.CellRendererToggle()
+ cell_toggle.set_property("xpad", 2)
+ cell_toggle.set_property("ypad", 2)
cell_toggle.connect('toggled', self.on_channel_toggled)
col_active = gtk.TreeViewColumn(_("Active"), cell_toggle,
active=COLUMN_ACTIVE)
@@ -265,12 +267,7 @@ class SoftwareProperties(SimpleGladeApp):
for source in self.sourceslist.list:
if source.invalid:
continue
- (nice_type, nice_dist, nice_comps, special) = self.matcher.match(source)
- print "match: %s %s" % (source.dist, special)
-
- contents = "<b>%s</b>%s" % (nice_dist, nice_comps)
- if source.type == "deb-src":
- contents = "<b>%s</b> - %s %s" % (nice_dist, nice_type, nice_comps)
+ contents = self.sourceslist.render_source(source)
self.source_store.append([not source.disabled, contents, source])
def reload_keyslist(self):
diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py
index 5f9c6d24..604af097 100644
--- a/SoftwareProperties/aptsources.py
+++ b/SoftwareProperties/aptsources.py
@@ -236,6 +236,81 @@ class SourcesList:
line = line + "\n"
self.list.insert(pos, SourceEntry(line))
+ def disable_components(self, comps, source_entry):
+ """Disable components of a source"""
+ comps_remove = set(comps) & set(source_entry.comps)
+ if len(comps_remove) >= len(source_entry.comps):
+ # disable the whole source
+ source_entry.disabled = True
+ elif len(comps_remove) > 0:
+ # Remove the sections from the original source
+ comps_new = set(source_entry.comps) - comps_remove
+ comps_write=""
+ for comp in comps_new:
+ comps_write += " %s" % comp
+ line = "%s %s %s %s" % (source.type, source.uri, source.dist,
+ comps_write)
+ if source.comment:
+ line += "# %s" % source.comment
+ line += "\n"
+ index = self.list.index(source_entry)
+ file = self.list[index].file
+ self.list[index] = SourceEntry(line, file)
+
+ # Add a disabled line with the disabled comps after the
+ # original line
+ comps_write=""
+ for comp in comps_remove:
+ comps_write = " %s" % comp
+ line_disabled = "#%s %s %s %s" % (source.type, source.uri, source.dist,
+ comps_remove)
+ if source.comment:
+ line_disabled += "# %s" % source.comment
+ line_disabled += "\n"
+ self.list.insert[index+1](SourceEntry(line_disabled, file))
+
+ def remove_components(self, comps, source_entry):
+ """ Remove components of a source"""
+ # The components that need to be removed from the source
+ comps_remove = set(comps) & set(source_entry.comps)
+ if len(comps_remove) >= len(source_entry.comps):
+ # Delete the whole source if there are no comps left
+ self.list.remove(source_entry)
+ elif len(comps_remove) > 0:
+ # Remove the sections from the original source
+ comps_new = set(source_entry.comps) - comps_remove
+ comps_write = ""
+ for comp in comps_new:
+ comps_write += " %s" % comp
+ line = "%s %s %s %s" % (source.type, source.uri, source.dist,
+ comps_write)
+ if source.comment:
+ line += "# %s" % source.comment
+ line += "\n"
+ index = self.list.index(source_entry)
+ file = self.list[index].file
+ self.list[index] = SourceEntry(line, file)
+
+ def render_source(self, source):
+ """Render a nice output to show the source in a treeview"""
+ (nice_type, nice_dist, nice_comps, special) = self.matcher.match(source)
+
+ if special in (SOURCE_UPDATES, SOURCE_BACKPORTS, SOURCE_SECURITY):
+ contents = "<b>%s</b>" % nice_dist
+ elif special == SOURCE_SYSTEM:
+ contents = "<b>%s</b>" % nice_dist
+ if source.type in ("deb-src", "rpm-src"):
+ contents += " (%s)" % nice_type
+ for comp in nice_comps:
+ contents += "\n%s" % comp
+ else:
+ contents = "<b>%s</b>" % nice_dist
+ if source.type in ("deb-src", "rpm-src"):
+ contents += " (%s)" % nice_type
+ for comp in nice_comps:
+ contents += "%s" % comp
+ return contents
+
def remove(self, source_entry):
self.list.remove(source_entry)
@@ -298,7 +373,7 @@ class SourcesList:
if source.invalid:
continue
(nice_type, nice_dist, nice_comps, special) = self.matcher.match(source)
- print "match: %s %s" % (source.dist, special)
+ #print "match: %s %s" % (source.dist, special)
# Collect the components of an activated system dist
if special == SOURCE_SYSTEM and source.disabled != True:
@@ -316,19 +391,18 @@ class SourcesList:
elif special == SOURCE_BACKPORTS:
self.sources_backports.append(source)
-
- print "\nSystem Compos: %s " % self.system_comps
+ #print "\nSystem Compos: %s " % self.system_comps
# Check if each security source contains all components of
# the same dist
- self.add_updates(self.sources_security)
- self.add_updates(self.sources_updates)
- self.add_updates(self.sources_backports)
+ self.check_updates(self.sources_security)
+ self.check_updates(self.sources_updates)
+ self.check_updates(self.sources_backports)
- def add_updates(self, updates):
+ def check_updates(self, updates):
modified = False
for source in updates:
- print "SecSource: %s" % source.dist
+ #print "SecSource: %s" % source.dist
# Skip the "-security" and "-updates" from the dist
i = source.dist.find("-")
dist = source.dist[:i]
@@ -338,17 +412,28 @@ class SourcesList:
comps_sec = set(source.comps)
# Are there components without updates?
comps_endangered = comps_sys - comps_sec
- print "In Danger: %s " % comps_endangered
+ #print "In Danger: %s " % comps_endangered
if len(comps_endangered) > 0:
# convert the set into a list
- comps_new=[]
- for comp in comps_endangered:
- comps_new.append(comp)
- # add a security source with the additional components
- print "Adding updates for %s - %s" % (source.dist, comps_new)
- self.add(source.type, source.uri, source.dist, comps_new,
- source.comment)
+ comps_write=""
+ for comp in comps_sys:
+ comps_write += " %s" % comp
+ # add all system components to the securtiy line
+ line = "%s %s %s %s" % (source.type, source.uri, source.dist,
+ comps_write)
+ if source.comment:
+ line += "# %s" % source.comment
+ line += "\n"
+ index = self.list.index(source)
+ file = self.list[index].file
+ self.list[index] = SourceEntry(line, file)
modified = True
+ else:
+ # FIXME: What to do if there are no system sources?
+ # To disable the security updates would be the best
+ # option, but what about people with a local mirror
+ # that fetch sec updates from the ubuntu servers
+ pass
return modified
# templates for the add dialog
@@ -562,43 +647,52 @@ class SourceEntryMatcher:
self.dist_list.append(self.MatchDist(".*debian.org/debian",
"^sarge$",
_("Debian 3.1 'Sarge'"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SYSTEM))
self.dist_list.append(self.MatchDist(".*debian.org/debian",
"^woody$",
_("Debian 3.0 'Woody'"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SYSTEM))
# securtiy
self.dist_list.append(self.MatchDist(".*security.debian.org",
"^stable.*$",
_("Debian Stable Security Updates"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SECURITY))
# dists by status
self.dist_list.append(self.MatchDist(".*debian.org/debian",
"^stable$",
_("Debian Stable"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SYSTEM))
self.dist_list.append(self.MatchDist(".*debian.org/debian",
"^testing$",
_("Debian Testing"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SYSTEM))
self.dist_list.append(self.MatchDist(".*debian.org/debian",
"^unstable$",
_("Debian Unstable 'Sid'"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SYSTEM))
# non-us
self.dist_list.append(self.MatchDist(".*debian.org/debian-non-US",
"^stable.*$",
_("Debian Non-US (Stable)"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SYSTEM))
self.dist_list.append(self.MatchDist(".*debian.org/debian-non-US",
"^testing.*$",
_("Debian Non-US (Testing)"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SYSTEM))
self.dist_list.append(self.MatchDist(".*debian.org/debian-non-US",
"^unstable.*$",
_("Debian Non-US (Unstable)"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SYSTEM))
def match(self,source):
_ = gettext.gettext
@@ -619,24 +713,24 @@ class SourceEntryMatcher:
type_description = _(t.description)
break
+ comp_descriptions = []
for d in self.dist_list:
#print "'%s'" %source.uri
if re.match(d.uri, source.uri) and re.match(d.dist, source.dist):
dist_description = d.description
- comp_description = ""
+ comp_descriptions = []
special = d.special
for c in source.comps:
found = False
for i in range(len(d.comps)):
if re.match(d.comps[i], c):
- comp_description = comp_description+"\n"+d.comps_descriptions[i]
+ comp_descriptions.append(d.comps_descriptions[i])
found = True
if found == False:
- comp_description = comp_description+" "+c
+ comp_descriptions.append(c)
break
-
-
- return (type_description, dist_description, comp_description, special)
+
+ return (type_description, dist_description, comp_descriptions, special)
# some simple tests
diff --git a/SoftwareProperties/dialog_sources_list.py b/SoftwareProperties/dialog_sources_list.py
index 9159d01f..a09542c8 100644
--- a/SoftwareProperties/dialog_sources_list.py
+++ b/SoftwareProperties/dialog_sources_list.py
@@ -39,6 +39,8 @@ class AddSourcesList:
self.store = gtk.ListStore(gobject.TYPE_STRING)
self.treeview.set_model(self.store)
cell = gtk.CellRendererText()
+ cell.set_property("xpad", 2)
+ cell.set_property("ypad", 2)
column = gtk.TreeViewColumn("Software Channel", cell, markup=0)
column.set_max_width(500)
self.treeview.append_column(column)
@@ -49,35 +51,31 @@ class AddSourcesList:
except:
self.error()
return
- self.matcher = SourceEntryMatcher()
# show the found channels or an error message
if len(self.sources.list) > 0:
self.button_close.hide()
- found = False
+ counter = 0
for source in self.sources.list:
if source.invalid or source.disabled:
continue
- found = True
- (a_type, dist, comps) = self.matcher.match(source)
-
- line = "<b>%s</b> (%s)%s" %\
- (dist, a_type, comps)
+ counter = counter +1
+ line = self.sources.render_source(source)
self.store.append([line])
- if found == False:
+ if counter == 0:
self.error()
return
header = gettext.ngettext("Add the following software channel?",
"Add the following software channels?",
- len(self.sources.list))
+ counter)
body = _("You can install software from a channel. Use "\
"trusted channels, only.")
self.label.set_markup("<big><b>%s</b></big>\n\n%s" % (header, body))
self.button_add.set_use_underline(True)
self.button_add.set_label(gettext.ngettext("_Add Channel",
"_Add Channels",
- len(self.sources.list)))
+ counter))
else:
self.error()
return
@@ -118,5 +116,6 @@ class AddSourcesList:
class SingleSourcesList(SourcesList):
def __init__(self, file):
+ self.matcher = SourceEntryMatcher()
self.list = []
self.load(file)