From 27e71eda76fa9b8ad8a40e20e89a3f492fd0dde4 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 17 May 2008 12:35:15 +0100 Subject: [PATCH] Replaced "Interface Properties" button with a menu button on each row of the table. This should make the other options (e.g. Compile and Report Bug) easier to find. The Refresh and Show Cache buttons move down into the new space, making the window shorter overall. Also, elide the end of the summary when the window is too narrow, rather than showing a scrollbar. --- zeroinstall/0launch-gui/iface_browser.py | 75 +++++++----- zeroinstall/0launch-gui/mainwindow.py | 10 +- zeroinstall/0launch-gui/zero-install.glade | 187 ++++++----------------------- 3 files changed, 87 insertions(+), 185 deletions(-) diff --git a/zeroinstall/0launch-gui/iface_browser.py b/zeroinstall/0launch-gui/iface_browser.py index c7473b9..06ceeab 100644 --- a/zeroinstall/0launch-gui/iface_browser.py +++ b/zeroinstall/0launch-gui/iface_browser.py @@ -1,4 +1,4 @@ -import gtk, gobject +import gtk, gobject, pango from zeroinstall.support import basedir, tasks, pretty_size from zeroinstall.injector.iface_cache import iface_cache @@ -33,6 +33,8 @@ class InterfaceTips(TreeTips): return None first_para = interface.description.split('\n\n', 1)[0] return first_para.replace('\n', ' ') + elif model_column is None: + return _("Click here for more options...") impl = self.mainwindow.policy.implementation.get(interface, None) if not impl: @@ -59,6 +61,29 @@ class InterfaceTips(TreeTips): return _("Need to download %s (%s bytes)") % \ (support.pretty_size(src.size), src.size) +class MenuIconRenderer(gtk.GenericCellRenderer): + def __init__(self): + gtk.GenericCellRenderer.__init__(self) + self.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE) + + def do_set_property(self, prop, value): + setattr(self, prop.name, value) + + def on_get_size(self, widget, cell_area, layout = None): + return (0, 0, 20, 20) + + def on_render(self, window, widget, background_area, cell_area, expose_area, flags): + if flags & gtk.CELL_RENDERER_PRELIT: + state = gtk.STATE_PRELIGHT + else: + state = gtk.STATE_NORMAL + + widget.style.paint_box(window, state, gtk.SHADOW_OUT, expose_area, widget, None, + cell_area.x, cell_area.y, cell_area.width, cell_area.height) + widget.style.paint_arrow(window, state, gtk.SHADOW_NONE, expose_area, widget, None, + gtk.ARROW_RIGHT, True, + cell_area.x + 5, cell_area.y + 5, cell_area.width - 10, cell_area.height - 10) + class IconAndTextRenderer(gtk.GenericCellRenderer): __gproperties__ = { "image": (gobject.TYPE_OBJECT, "Image", "Image", gobject.PARAM_READWRITE), @@ -109,11 +134,11 @@ if gtk.pygtk_version < (2, 8, 0): # Note sure exactly which versions need this. # 2.8.0 gives a warning if you include it, though. gobject.type_register(IconAndTextRenderer) + gobject.type_register(MenuIconRenderer) class InterfaceBrowser: model = None root = None - edit_properties = None cached_icon = None policy = None original_implementation = None @@ -128,7 +153,8 @@ class InterfaceBrowser: columns = [(_('Interface'), INTERFACE_NAME), (_('Version'), VERSION), (_('Fetch'), DOWNLOAD_SIZE), - (_('Description'), SUMMARY)] + (_('Description'), SUMMARY), + ('', None)] def __init__(self, policy, widgets): tips = InterfaceTips(self) @@ -140,9 +166,6 @@ class InterfaceBrowser: self.default_icon = tree_view.style.lookup_icon_set(gtk.STOCK_EXECUTE).render_icon(tree_view.style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_SMALL_TOOLBAR, tree_view, None) - self.edit_properties = widgets.get_widget('properties') - self.edit_properties.set_property('sensitive', False) - self.model = gtk.TreeStore(object, str, str, str, str, gtk.gdk.Pixbuf) self.tree_view = tree_view tree_view.set_model(self.model) @@ -156,8 +179,19 @@ class InterfaceBrowser: column = gtk.TreeViewColumn(name, IconAndTextRenderer(), text = model_column, image = InterfaceBrowser.ICON) + elif model_column == None: + menu_column = column = gtk.TreeViewColumn('', MenuIconRenderer()) else: - column = gtk.TreeViewColumn(name, text, text = model_column) + if model_column == InterfaceBrowser.SUMMARY: + text_ellip = gtk.CellRendererText() + try: + text_ellip.set_property('ellipsize', pango.ELLIPSIZE_END) + except: + pass + column = gtk.TreeViewColumn(name, text_ellip, text = model_column) + column.set_expand(True) + else: + column = gtk.TreeViewColumn(name, text, text = model_column) tree_view.append_column(column) column_objects.append(column) @@ -187,36 +221,23 @@ class InterfaceBrowser: tree_view.connect('motion-notify-event', motion) tree_view.connect('leave-notify-event', lambda tv, ev: tips.hide()) - def sel_changed(sel): - store, iter = sel.get_selected() - self.edit_properties.set_property('sensitive', iter != None) - selection.connect('changed', sel_changed) - def button_press(tree_view, bev): - if bev.button == 3 and bev.type == gtk.gdk.BUTTON_PRESS: - pos = tree_view.get_path_at_pos(int(bev.x), int(bev.y)) - if not pos: - return False - path, col, x, y = pos + pos = tree_view.get_path_at_pos(int(bev.x), int(bev.y)) + if not pos: + return False + path, col, x, y = pos + + if (bev.button == 3 or (bev.button < 4 and col is menu_column)) \ + and bev.type == gtk.gdk.BUTTON_PRESS: selection.select_path(path) iface = self.model[path][InterfaceBrowser.INTERFACE] self.show_popup_menu(iface, bev) return True if bev.button != 1 or bev.type != gtk.gdk._2BUTTON_PRESS: return False - pos = tree_view.get_path_at_pos(int(bev.x), int(bev.y)) - if not pos: - return False - path, col, x, y = pos properties.edit(policy, self.model[path][InterfaceBrowser.INTERFACE]) tree_view.connect('button-press-event', button_press) - def edit_selected(action): - store, iter = selection.get_selected() - assert iter - properties.edit(policy, self.model[iter][InterfaceBrowser.INTERFACE]) - self.edit_properties.connect('clicked', edit_selected) - tree_view.connect('destroy', lambda s: policy.watchers.remove(self.build_tree)) policy.watchers.append(self.build_tree) diff --git a/zeroinstall/0launch-gui/mainwindow.py b/zeroinstall/0launch-gui/mainwindow.py index 4d0f617..75ed660 100644 --- a/zeroinstall/0launch-gui/mainwindow.py +++ b/zeroinstall/0launch-gui/mainwindow.py @@ -164,7 +164,7 @@ class MainWindow: gui_help = help_box.HelpBox("Injector Help", ('Overview', """ A program is made up of many different components, typically written by different \ -groups of people. Each component is available in multiple versions. The injector is \ +groups of people. Each component is available in multiple versions. Zero Install is \ used when starting a program. Its job is to decide which implementation of each required \ component to use. @@ -172,7 +172,7 @@ An interface describes what a component does. The injector starts with \ the interface for the program you want to run (like 'The Gimp') and chooses an \ implementation (like 'The Gimp 2.2.0'). However, this implementation \ will in turn depend on other interfaces, such as 'GTK' (which draws the menus \ -and buttons). Thus, the injector must choose implementations of \ +and buttons). Thus, it must choose implementations of \ each dependency (each of which may require further interfaces, and so on)."""), ('List of interfaces', """ @@ -189,11 +189,9 @@ To control which implementations (versions) are chosen you can click on Preferen and adjust the network policy and the overall stability policy. These settings affect \ all programs run using Zero Install. -Alternatively, you can edit the policy of an individual interface by selecting it \ -and clicking on the 'Interface Properties' button. \ +Alternatively, you can edit the policy of an individual interface by clicking on the \ +button at the end of its line in the table and choosing "Show Versions" from the menu. \ See that dialog's help text for more information. - -Right-click on an interface in the list for a menu. """), ('Reporting bugs', """ diff --git a/zeroinstall/0launch-gui/zero-install.glade b/zeroinstall/0launch-gui/zero-install.glade index 81cda31..7d1a68d 100644 --- a/zeroinstall/0launch-gui/zero-install.glade +++ b/zeroinstall/0launch-gui/zero-install.glade @@ -85,114 +85,40 @@ 0 - + True - False - 4 - - - - True - Choose the versions to use: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - True - True - - + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - + True - Check all the components below for updates. True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-refresh - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Re_fresh all now - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - + True + False + False + True + False + False + False - - 0 - False - False - + + + 4 + True + True + + + + + + True + False + 4 @@ -272,60 +198,17 @@ False - - - 0 - False - True - - - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_ALWAYS - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - False - False - False - - - - - 4 - True - True - - - - - - True - False - 0 - + True - See and edit the details of the selected interface. + Check all the components for updates. True GTK_RELIEF_NORMAL True - + True 0.5 0.5 @@ -337,15 +220,15 @@ 0 - + True False 2 - + True - gtk-properties + gtk-refresh 4 0.5 0.5 @@ -360,9 +243,9 @@ - + True - Interface properties... + Re_fresh all now True False GTK_JUSTIFY_LEFT -- 2.11.4.GIT