From 245cb13ab98063040794e361f5d5bf1bb7ddf6a6 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 7 Jun 2008 20:51:36 +0100 Subject: [PATCH] Replaced the Cached column with a Fetch one The list of versions used to have a "Cached" checkbox column indicating whether that version needed to be fetched or not. Now it shows the download size, or (cached), (local) or (package), like the Fetch column in the main window does. --- zeroinstall/0launch-gui/iface_browser.py | 23 +++-------------------- zeroinstall/0launch-gui/impl_list.py | 19 +++++++++---------- zeroinstall/0launch-gui/properties.py | 12 ++++++++---- zeroinstall/0launch-gui/utils.py | 22 ++++++++++++++++++++++ zeroinstall/support/__init__.py | 2 +- 5 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 zeroinstall/0launch-gui/utils.py diff --git a/zeroinstall/0launch-gui/iface_browser.py b/zeroinstall/0launch-gui/iface_browser.py index 71386a0..58b5e31 100644 --- a/zeroinstall/0launch-gui/iface_browser.py +++ b/zeroinstall/0launch-gui/iface_browser.py @@ -10,6 +10,7 @@ import properties from treetips import TreeTips from zeroinstall import support from logging import warn +import utils def _stability(impl): assert impl @@ -321,7 +322,7 @@ class InterfaceBrowser: version_str += " (was " + old_impl.get_version() + ")" self.model[iter][InterfaceBrowser.VERSION] = version_str - self.model[iter][InterfaceBrowser.DOWNLOAD_SIZE] = self._get_fetch_info(impl) + self.model[iter][InterfaceBrowser.DOWNLOAD_SIZE] = utils.get_fetch_info(self.policy, impl) if hasattr(impl, 'requires'): children = impl.requires else: @@ -341,24 +342,6 @@ class InterfaceBrowser: add_node(None, self.root) self.tree_view.expand_all() - def _get_fetch_info(self, impl): - """Get the text for the Fetch column.""" - if impl is None: - return "" - elif self.policy.get_cached(impl): - if impl.id.startswith('/'): - return '(local)' - elif impl.id.startswith('package:'): - return '(package)' - else: - return '(cached)' - else: - src = self.policy.fetcher.get_best_source(impl) - if src: - return support.pretty_size(src.size) - else: - return '(unavailable)' - def show_popup_menu(self, iface, bev): import bugs @@ -433,5 +416,5 @@ class InterfaceBrowser: fraction += " in %d downloads" % len(downloads) row[InterfaceBrowser.SUMMARY] = "(downloading %s/%s)" % (pretty_size(so_far), fraction) else: - row[InterfaceBrowser.DOWNLOAD_SIZE] = self._get_fetch_info(impl) + row[InterfaceBrowser.DOWNLOAD_SIZE] = utils.get_fetch_info(self.policy, impl) row[InterfaceBrowser.SUMMARY] = iface.summary diff --git a/zeroinstall/0launch-gui/impl_list.py b/zeroinstall/0launch-gui/impl_list.py index e30b0f9..522b121 100644 --- a/zeroinstall/0launch-gui/impl_list.py +++ b/zeroinstall/0launch-gui/impl_list.py @@ -5,6 +5,7 @@ import gtk, gobject, os from zeroinstall.injector import model, writer from zeroinstall import support from treetips import TreeTips +import utils def popup_menu(bev, values, fn): menu = gtk.Menu() @@ -25,7 +26,7 @@ ITEM = 0 ARCH = 1 STABILITY = 2 VERSION = 3 -CACHED = 4 +FETCH = 4 UNUSABLE = 5 RELEASED = 6 NOTES = 7 @@ -60,24 +61,22 @@ class ImplementationList: self.interface = interface self.policy = policy - self.model = gtk.ListStore(object, str, str, str, - gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN, - str, str) + self.model = gtk.ListStore(object, str, str, str, # Item, arch, stability, version, + str, gobject.TYPE_BOOLEAN, str, str) # fetch, unusable, released, notes self.tree_view = widgets.get_widget('versions_list') self.tree_view.set_model(self.model) text = gtk.CellRendererText() text_strike = gtk.CellRendererText() - toggle = gtk.CellRendererToggle() stability = gtk.TreeViewColumn('Stability', text, text = STABILITY) - for column in (gtk.TreeViewColumn('Version', text, text = VERSION, strikethrough = UNUSABLE), - gtk.TreeViewColumn('Released', text, text = RELEASED, strikethrough = UNUSABLE), + for column in (gtk.TreeViewColumn('Version', text_strike, text = VERSION, strikethrough = UNUSABLE), + gtk.TreeViewColumn('Released', text, text = RELEASED), stability, - gtk.TreeViewColumn('C', toggle, active = CACHED), - gtk.TreeViewColumn('Arch', text, text = ARCH), + gtk.TreeViewColumn('Fetch', text, text = FETCH), + gtk.TreeViewColumn('Arch', text_strike, text = ARCH, strikethrough = UNUSABLE), gtk.TreeViewColumn('Notes', text, text = NOTES)): self.tree_view.append_column(column) @@ -139,7 +138,7 @@ class ImplementationList: self.model[new][ITEM] = item self.model[new][VERSION] = item.get_version() self.model[new][RELEASED] = item.released or "-" - self.model[new][CACHED] = self.policy.get_cached(item) + self.model[new][FETCH] = utils.get_fetch_info(self.policy, item) if item.user_stability: self.model[new][STABILITY] = str(item.user_stability).upper() else: diff --git a/zeroinstall/0launch-gui/properties.py b/zeroinstall/0launch-gui/properties.py index ad4ffee..2ba353b 100644 --- a/zeroinstall/0launch-gui/properties.py +++ b/zeroinstall/0launch-gui/properties.py @@ -479,10 +479,14 @@ Released gives the date this entry was added to the feed. Stability is 'stable' if the implementation is believed to be stable, 'buggy' if \ it is known to contain serious bugs, and 'testing' if its stability is not yet \ known. This information is normally supplied and updated by the author of the \ -software, but you can override their rating (overridden values are shown in upper-case). \ -You can also use the special level 'preferred'. - -C(ached) indicates whether the implementation is already stored on your computer. \ +software, but you can override their rating by right-clicking here (overridden \ +values are shown in upper-case). You can also use the special level 'preferred'. + +Fetch indicates how much data needs to be downloaded to get this version if you don't \ +have it. If the implementation has already been downloaded to your computer, \ +it will say (cached). (local) means that you installed this version manually and \ +told Zero Install about it by adding a feed. (package) means that this version \ +is provided by your distribution's package manager, not by Zero Install. \ In off-line mode, only cached implementations are considered for use. Arch indicates what kind of computer system the implementation is for, or 'any' \ diff --git a/zeroinstall/0launch-gui/utils.py b/zeroinstall/0launch-gui/utils.py new file mode 100644 index 0000000..52e8a15 --- /dev/null +++ b/zeroinstall/0launch-gui/utils.py @@ -0,0 +1,22 @@ +# Copyright (C) 2008, Thomas Leonard +# See the README file for details, or visit http://0install.net. + +from zeroinstall import support + +def get_fetch_info(policy, impl): + """Get the text for a Fetch column.""" + if impl is None: + return "" + elif policy.get_cached(impl): + if impl.id.startswith('/'): + return '(local)' + elif impl.id.startswith('package:'): + return '(package)' + else: + return '(cached)' + else: + src = policy.fetcher.get_best_source(impl) + if src: + return support.pretty_size(src.size) + else: + return '(unavailable)' diff --git a/zeroinstall/support/__init__.py b/zeroinstall/support/__init__.py index 059b1c2..b1e1e39 100644 --- a/zeroinstall/support/__init__.py +++ b/zeroinstall/support/__init__.py @@ -59,7 +59,7 @@ def pretty_size(size): if size < 2048: return '%d bytes' % size size = float(size) - for unit in ('Kb', 'Mb', 'Gb', 'Tb'): + for unit in ('KB', 'MB', 'GB', 'TB'): size /= 1024 if size < 2048: break -- 2.11.4.GIT