diff src/browser/sat_browser/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 6d3142b782c3
children a90cc8fc9605
line wrap: on
line diff
--- a/src/browser/sat_browser/widget.py	Tue Mar 17 20:28:41 2015 +0100
+++ b/src/browser/sat_browser/widget.py	Tue Mar 17 20:42:02 2015 +0100
@@ -21,6 +21,8 @@
 from sat.core.log import getLogger
 log = getLogger(__name__)
 
+from sat.core.i18n import D_
+
 from pyjamas.ui.VerticalPanel import VerticalPanel
 from pyjamas.ui.HorizontalPanel import HorizontalPanel
 from pyjamas.ui.Button import Button
@@ -32,6 +34,7 @@
 import libervia_widget
 from constants import Const as C
 from sat_frontends.quick_frontend import quick_widgets
+from sat_frontends.tools import host_listener
 
 
 # class UniBoxPanel(HorizontalPanel):
@@ -242,3 +245,17 @@
         if scheme not in C.WEB_PANEL_SCHEMES:
             url = "http://" + url
         self._frame.setUrl(url)
+
+
+##  Menu
+
+def hostReady(host):
+    def onWebWidget():
+        web_widget = host.displayWidget(WebWidget, C.WEB_PANEL_DEFAULT_URL)
+        host.setSelected(web_widget)
+
+    def gotMenus():
+        host.menus.addMenu(C.MENU_GLOBAL, (D_(u"General"), D_(u"Web widget")), callback=onWebWidget)
+    host.addListener('gotMenus', gotMenus)
+
+host_listener.addListener(hostReady)