From fcfe78901e56fda24dcefe699566386b6ff8fa7f Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 27 Jun 2009 16:14:00 +0100 Subject: [PATCH] Improved UI for versions menu There is now a single popup menu, with both the stability ratings and the function for opening the cached copy, and it can be opened by clicking anywhere on a row. --- zeroinstall/0launch-gui/impl_list.py | 69 +++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/zeroinstall/0launch-gui/impl_list.py b/zeroinstall/0launch-gui/impl_list.py index 3f9ae17..dabb431 100644 --- a/zeroinstall/0launch-gui/impl_list.py +++ b/zeroinstall/0launch-gui/impl_list.py @@ -7,17 +7,38 @@ from zeroinstall import support from zeroinstall.gtkui.treetips import TreeTips import utils -def popup_menu(bev, values, fn): +def _build_stability_menu(policy, impl): menu = gtk.Menu() - for value in values: - if value is None: - item = gtk.SeparatorMenuItem() + + upstream = impl.upstream_stability or model.testing + choices = model.stability_levels.values() + choices.sort() + choices.reverse() + + def set(new): + if isinstance(new, model.Stability): + impl.user_stability = new else: - item = gtk.MenuItem(str(value).capitalize()) - item.connect('activate', lambda item, v=value: fn(v)) + impl.user_stability = None + writer.save_feed(impl.feed) + policy.recalculate() + + item = gtk.MenuItem('Unset (%s)' % upstream) + item.connect('activate', lambda item: set(None)) + item.show() + menu.append(item) + + item = gtk.SeparatorMenuItem() + item.show() + menu.append(item) + + for value in choices: + item = gtk.MenuItem(str(value).capitalize()) + item.connect('activate', lambda item, v = value: set(v)) item.show() menu.append(item) - menu.popup(None, None, None, bev.button, bev.time) + + return menu rox_filer = 'http://rox.sourceforge.net/2005/interfaces/ROX-Filer' @@ -107,26 +128,26 @@ class ImplementationList: return False path, col, x, y = pos impl = self.model[path][ITEM] - if col == stability: - upstream = impl.upstream_stability or model.testing - choices = model.stability_levels.values() - choices.sort() - choices.reverse() - def set(new): - if isinstance(new, model.Stability): - impl.user_stability = new - else: - impl.user_stability = None - writer.save_feed(impl.feed) - self.policy.recalculate() - popup_menu(bev, ['Unset (%s)' % upstream, None] + choices, - set) - elif bev.button == 3 and self.policy.get_cached(impl): - def open(item): + + menu = gtk.Menu() + + stability_menu = gtk.MenuItem('Rating') + stability_menu.set_submenu(_build_stability_menu(self.policy, impl)) + stability_menu.show() + menu.append(stability_menu) + + if self.policy.get_cached(impl): + def open(): os.spawnlp(os.P_WAIT, '0launch', '0launch', rox_filer, '-d', self.policy.get_implementation_path(impl)) - popup_menu(bev, ['Open cached copy'], open) + item = gtk.MenuItem('Open cached copy') + item.connect('activate', lambda item: open()) + item.show() + menu.append(item) + + menu.popup(None, None, None, bev.button, bev.time) + self.tree_view.connect('button-press-event', button_press) def get_selection(self): -- 2.11.4.GIT