diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-08-02 12:41:24 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-08-02 12:41:24 +0200 |
| commit | 6de4c375de972ad34a15dbe56305d62e8faa23a0 (patch) | |
| tree | ac5b87ea589b63428ddc4c4b7ae157d220243e8b /UpdateManager | |
| parent | eb74fddcc11cf40ef207157a36308aa29801e907 (diff) | |
| download | python-apt-6de4c375de972ad34a15dbe56305d62e8faa23a0.tar.gz | |
* UpdateManager/UpdateManager.py:
- implemented support to show what origin the update comes from
Diffstat (limited to 'UpdateManager')
| -rw-r--r-- | UpdateManager/UpdateManager.py | 104 |
1 files changed, 72 insertions, 32 deletions
diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index d1a680fb..ce46d737 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -69,8 +69,7 @@ from MetaRelease import Dist, MetaRelease # - kill "all_changes" and move the changes into the "Update" class # list constants -(LIST_INSTALL, LIST_CONTENTS, LIST_NAME, LIST_SHORTDESC, - LIST_VERSION, LIST_LONG_DESCR, LIST_PKG) = range(7) +(LIST_INSTALL, LIST_CONTENTS, LIST_NAME, LIST_PKG) = range(4) # actions for "invoke_manager" (INSTALL, UPDATE) = range(2) @@ -201,23 +200,43 @@ class MyCache(apt.Cache): lock.release() class UpdateList: + ORIGIN_MAPPING = { ("edgy-security","Ubuntu"): _("Ubuntu security updates"), + ("edgy-updates","Ubuntu"): _("Ubuntu important updates updates"), + ("edgy","Ubuntu"): _("Ubuntu updates") + } + def __init__(self, parent_window): - self.pkgs = [] + # a map of packages under their origin + self.pkgs = {} self.num_updates = 0 self.parent_window = parent_window def update(self, cache): held_back = [] broken = [] + + # do the upgrade cache.saveDistUpgrade() + + # sort by origin for pkg in cache: if pkg.markedUpgrade or pkg.markedInstall: - self.pkgs.append(pkg) + originstr = _("Unknown") + for aorigin in pkg.candidateOrigin: + archive = aorigin.archive + origin = aorigin.origin + if self.ORIGIN_MAPPING.has_key((archive,origin)) and aorigin.trusted: + originstr = self.ORIGIN_MAPPING[(archive,origin)] + if not self.pkgs.has_key(originstr): + self.pkgs[originstr] = [] + self.pkgs[originstr].append(pkg) self.num_updates = self.num_updates + 1 elif pkg.isUpgradable: - #print "MarkedKeep: %s " % pkg.name held_back.append(pkg.name) - self.pkgs.sort(lambda x,y: cmp(x.name,y.name)) + for l in self.pkgs.keys(): + self.pkgs[l].sort(lambda x,y: cmp(x.name,y.name)) + + # check if we have held-back something if cache._depcache.KeepCount > 0: #print "WARNING, keeping packages" msg = ("<big><b>%s</b></big>\n\n%s" % \ @@ -295,32 +314,34 @@ class UpdateManager(SimpleGladeApp): self.button_close.connect("clicked", lambda w: self.exit()) # the treeview (move into it's own code!) - self.store = gtk.ListStore(gobject.TYPE_BOOLEAN, str, str, str, str, str, - gobject.TYPE_PYOBJECT) + self.store = gtk.ListStore(gobject.TYPE_BOOLEAN, str, str, gobject.TYPE_PYOBJECT) self.treeview_update.set_model(self.store) self.treeview_update.set_headers_clickable(True); tr = gtk.CellRendererText() tr.set_property("xpad", 10) tr.set_property("ypad", 10) - cr = gtk.CellRendererToggle() + self.cr = cr = gtk.CellRendererToggle() cr.set_property("activatable", True) cr.set_property("xpad", 10) cr.connect("toggled", self.toggled) - self.cb = gtk.TreeViewColumn("Install", cr, active=LIST_INSTALL) - c0 = gtk.TreeViewColumn("Name", tr, markup=LIST_CONTENTS) - c0.set_resizable(True) + + column_install = gtk.TreeViewColumn("Install", cr) + column_install.set_cell_data_func (cr, self.install_column_view_func) + column = gtk.TreeViewColumn("Name", tr, markup=LIST_CONTENTS) + column.set_cell_data_func (tr, self.package_column_view_func) + column.set_resizable(True) major,minor,patch = gtk.pygtk_version if (major >= 2) and (minor >= 5): - self.cb.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) - self.cb.set_fixed_width(30) - c0.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) - c0.set_fixed_width(100) + column_install.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) + column_install.set_fixed_width(30) + column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) + column.set_fixed_width(100) #self.treeview_update.set_fixed_height_mode(True) - self.treeview_update.append_column(self.cb) - self.cb.set_visible(True) - self.treeview_update.append_column(c0) + self.treeview_update.append_column(column_install) + column_install.set_visible(True) + self.treeview_update.append_column(column) self.treeview_update.set_search_column(LIST_NAME) @@ -356,6 +377,23 @@ class UpdateManager(SimpleGladeApp): self.restore_state() self.window_main.show() + def header_column_func(self, cell_layot, renderer, model, iter): + pkg = model.get_value(iter, LIST_PKG) + if pkg == None: + renderer.set_property("cell-background","green") + else: + renderer.set_property("cell-background", None) + + def install_column_view_func(self, cell_layout, renderer, model, iter): + self.header_column_func(cell_layout, renderer, model, iter) + pkg = model.get_value(iter, LIST_PKG) + if self.cr == renderer: + renderer.set_property("visible", pkg != None) + + + def package_column_view_func(self, cell_layout, renderer, model, iter): + self.header_column_func(cell_layout, renderer, model, iter) + def setupDbus(self): """ this sets up a dbus listener if none is installed alread """ # check if there is another g-a-i already and if not setup one @@ -429,7 +467,10 @@ class UpdateManager(SimpleGladeApp): iter = model.get_iter(path) # set descr - long_desc = model.get_value(iter, LIST_LONG_DESCR) + pkg = model.get_value(iter, LIST_PKG) + if pkg == None: + return + long_desc = pkg.description if long_desc == None: return # Skip the first line - it's a duplicate of the summary @@ -526,7 +567,7 @@ class UpdateManager(SimpleGladeApp): self.notebook_details.set_sensitive(True) self.treeview_update.set_sensitive(True) self.button_install.grab_default() - self.treeview_update.set_cursor(0) + self.treeview_update.set_cursor(1) self.label_header.set_markup(text_header) self.label_downsize.set_markup(text_download) @@ -657,17 +698,16 @@ class UpdateManager(SimpleGladeApp): self.list.update(self.cache) if self.list.num_updates > 0: i=0 - for pkg in self.list.pkgs: - - name = xml.sax.saxutils.escape(pkg.name) - summary = xml.sax.saxutils.escape(pkg.summary) - contents = "<big><b>%s</b></big>\n<small>%s\n\n" % (name, summary) - contents = contents + _("New version: %s (Size: %s)") % (pkg.candidateVersion,apt.SizeToStr(pkg.packageSize)) + "</small>" - - iter = self.store.append([True, contents, pkg.name, pkg.summary, - pkg.candidateVersion, pkg.description, pkg]) - self.add_update(pkg) - i = i + 1 + for origin in self.list.pkgs.keys(): + self.store.append([False, '<span weight="bold" size="large">%s</span>' % origin, origin, None]) + for pkg in self.list.pkgs[origin]: + name = xml.sax.saxutils.escape(pkg.name) + summary = xml.sax.saxutils.escape(pkg.summary) + contents = "<big><b>%s</b></big>\n<small>%s\n\n" % (name, summary) + contents = contents + _("New version: %s (Size: %s)") % (pkg.candidateVersion,apt.SizeToStr(pkg.packageSize)) + "</small>" + iter = self.store.append([True, contents, pkg.name, pkg]) + self.add_update(pkg) + i = i + 1 self.update_count() # use the normal cursor |
