# HG changeset patch # User Goffi # Date 1424713388 -3600 # Node ID c2abadf31afb5cda8560cd4011ef7044b4ca6222 # Parent e287a4b431c1609d2f64f675cf9e665ee425deda browser side (menu): minor improvments: - use of new style class for MenuCmd and PluginMenuCmd (useless for pyjamas, but can be useful in the future) - use of try/except instead of hasattr - do not use "None" for WidgetMenuBar's __init__ diff -r e287a4b431c1 -r c2abadf31afb src/browser/sat_browser/base_menu.py --- a/src/browser/sat_browser/base_menu.py Mon Feb 23 18:20:04 2015 +0100 +++ b/src/browser/sat_browser/base_menu.py Mon Feb 23 18:43:08 2015 +0100 @@ -37,7 +37,7 @@ import re -class MenuCmd: +class MenuCmd(object): """Return an object with an "execute" method that can be set to a menu item callback""" def __init__(self, object_, handler=None, data=None): @@ -58,7 +58,7 @@ self.callback(self.data) if self.data else self.callback() -class PluginMenuCmd: +class PluginMenuCmd(object): """Like MenuCmd, but instead of executing a method, it will command the bridge to launch an action""" def __init__(self, host, action_id, menu_data=None): diff -r e287a4b431c1 -r c2abadf31afb src/browser/sat_browser/base_widget.py --- a/src/browser/sat_browser/base_widget.py Mon Feb 23 18:20:04 2015 +0100 +++ b/src/browser/sat_browser/base_widget.py Mon Feb 23 18:43:08 2015 +0100 @@ -223,10 +223,13 @@ menu_styles.update(styles) base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, styles=menu_styles) - if hasattr(parent, 'addMenus'): - # regroup all the dynamic menu categories in a sub-menu - sub_menu = WidgetSubMenuBar(host, vertical=True) + # regroup all the dynamic menu categories in a sub-menu + sub_menu = WidgetSubMenuBar(host, vertical=True) + try: parent.addMenus(sub_menu) + except (AttributeError, TypeError): # FIXME: pyjamas can throw a TypeError depending on compilation options + pass + else: if len(sub_menu.getCategories()) > 0: self.addCategory('', '', 'plugins', sub_menu) diff -r e287a4b431c1 -r c2abadf31afb src/browser/sat_browser/panels.py --- a/src/browser/sat_browser/panels.py Mon Feb 23 18:20:04 2015 +0100 +++ b/src/browser/sat_browser/panels.py Mon Feb 23 18:43:08 2015 +0100 @@ -388,7 +388,7 @@ class PresenceStatusMenuBar(base_widget.WidgetMenuBar): def __init__(self, parent): styles = {'menu_bar': 'presence-button'} - base_widget.WidgetMenuBar.__init__(self, None, parent.host, styles=styles) + base_widget.WidgetMenuBar.__init__(self, parent, parent.host, styles=styles) self.button = self.addCategory(u"◉", u"◉", '') for presence, presence_i18n in C.PRESENCE.items(): html = u' %s' % (contact_list.buildPresenceStyle(presence), presence_i18n)