diff src/browser/sat_browser/libervia_widget.py @ 676:849ffb24d5bf frontends_multi_profiles

browser side: menus refactorisation: - use of the new quick_frontends.quick_menus module, resulting in a big code simplification in Libervia - menu are added in there respective modules: main menus are done directely in libervia_main, while tarot and radiocol menus are done in game_tarot and game_radiocol - launchAction has the same signature as in QuickApp - base_menu: there are now 2 classes to launch an action: MenuCmd which manage quick_menus classes, and SimpleCmd to launch a generic callback - base_menu: MenuNode has been removed as logic is now in quick_menus - base_menu: GenericMenuBar.update method can be called to fully (re)build the menus - base_widget: removed WidgetSubMenuBar which is no more useful (GenericMenuBar do the same thing) - plugin_menu_context is used in LiberviaWidget and other classes with menus to indicate which menu types must be used - otr menus hooks are temporarily removed, will be fixed soon
author Goffi <goffi@goffi.org>
date Tue, 17 Mar 2015 20:42:02 +0100
parents 423182fea41c
children 9877607c719a
line wrap: on
line diff
--- a/src/browser/sat_browser/libervia_widget.py	Tue Mar 17 20:28:41 2015 +0100
+++ b/src/browser/sat_browser/libervia_widget.py	Tue Mar 17 20:42:02 2015 +0100
@@ -346,8 +346,8 @@
             button_group_wrapper = SimplePanel()
         button_group_wrapper.setStyleName('widgetHeader_buttonsWrapper')
         button_group = base_widget.WidgetMenuBar(parent, host)
-        button_group.addItem('<img src="media/icons/misc/settings.png"/>', True, base_menu.MenuCmd(parent, 'onSetting'))
-        button_group.addItem('<img src="media/icons/misc/close.png"/>', True, base_menu.MenuCmd(parent, 'onClose'))
+        button_group.addItem('<img src="media/icons/misc/settings.png"/>', True, base_menu.SimpleCmd(parent.onSetting))
+        button_group.addItem('<img src="media/icons/misc/close.png"/>', True, base_menu.SimpleCmd(parent.onClose))
         button_group_wrapper.add(button_group)
         self.add(button_group_wrapper)
         self.addStyleName('widgetHeader')
@@ -357,18 +357,20 @@
 class LiberviaWidget(DropCell, VerticalPanel, ClickHandler):
     """Libervia's widget which can replace itself with a dropped widget on DnD"""
 
-    def __init__(self, host, title='', info=None, selectable=False):
+    def __init__(self, host, title='', info=None, selectable=False, plugin_menu_context=None):
         """Init the widget
 
         @param host (SatWebFrontend): SatWebFrontend instance
         @param title (unicode): title shown in the header of the widget
         @param info (unicode): info shown in the header of the widget
         @param selectable (bool): True is widget can be selected by user
+        @param plugin_menu_context (iterable): contexts of menus to have (list of C.MENU_* constant)
         """
         VerticalPanel.__init__(self)
         DropCell.__init__(self, host)
         ClickHandler.__init__(self)
         self._selectable = selectable
+        self._plugin_menu_context = [] if plugin_menu_context is None else plugin_menu_context
         self._title_id = HTMLPanel.createUniqueId()
         self._setting_button_id = HTMLPanel.createUniqueId()
         self._close_button_id = HTMLPanel.createUniqueId()
@@ -395,6 +397,10 @@
             # self.addCloseListener(onClose)
         # self.host.registerWidget(self) # FIXME
 
+    @property
+    def plugin_menu_context(self):
+        return self._plugin_menu_context
+
     def getDebugName(self):
         return "%s (%s)" % (self, self._title.getText())
 
@@ -572,14 +578,6 @@
         # the event will not propagate to children
         VerticalPanel.doAttachChildren(self)
 
-    def addMenus(self, menu_bar):
-        """Add menus to the header.
-
-        This method can be overwritten by child classes.
-        @param menu_bar (GenericMenuBar): menu bar of the widget's header
-        """
-        pass
-
 
 # XXX: WidgetsPanel and MainTabPanel are both here to avoir cyclic import