diff src/browser/sat_browser/main_panel.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 ebb602d8b3f2
children a90cc8fc9605
line wrap: on
line diff
--- a/src/browser/sat_browser/main_panel.py	Tue Mar 17 20:28:41 2015 +0100
+++ b/src/browser/sat_browser/main_panel.py	Tue Mar 17 20:42:02 2015 +0100
@@ -36,10 +36,10 @@
 from pyjamas.ui import HasVerticalAlignment
 
 
-import base_menu
 import menu
 import dialog
 import base_widget
+import base_menu
 import libervia_widget
 import editor_widget
 import contact_list
@@ -168,10 +168,11 @@
     def __init__(self, parent):
         styles = {'menu_bar': 'presence-button'}
         base_widget.WidgetMenuBar.__init__(self, parent, parent.host, styles=styles)
-        self.button = self.addCategory(u"◉", u"◉", '')
+        self.button = self.addCategory(u"◉")
+        presence_menu = self.button.getSubMenu()
         for presence, presence_i18n in C.PRESENCE.items():
             html = u'<span class="%s">◉</span> %s' % (contact_list.buildPresenceStyle(presence), presence_i18n)
-            self.addMenuItem([u"◉", presence], [u"◉", html], '', base_menu.MenuCmd(self, 'changePresenceCb', presence), asHTML=True)
+            presence_menu.addItem(html, True, base_menu.SimpleCmd(lambda presence=presence: self.changePresenceCb(presence)))
         self.parent_panel = parent
 
     def changePresenceCb(self, presence=''):
@@ -189,15 +190,16 @@
 
     def __init__(self, host, presence="", status=""):
         self.host = host
+        self.plugin_menu_context = []
         HorizontalPanel.__init__(self, Width='100%')
-        self.menu = PresenceStatusMenuBar(self)
+        self.presence_bar = PresenceStatusMenuBar(self)
         self.status_panel = StatusPanel(host, status=status)
         self.setPresence(presence)
 
         panel = HorizontalPanel()
-        panel.add(self.menu)
+        panel.add(self.presence_bar)
         panel.add(self.status_panel)
-        panel.setCellVerticalAlignment(self.menu, 'baseline')
+        panel.setCellVerticalAlignment(self.presence_bar, 'baseline')
         panel.setCellVerticalAlignment(self.status_panel, 'baseline')
         panel.setStyleName("presenceStatusPanel")
         self.add(panel)
@@ -217,7 +219,7 @@
 
     def setPresence(self, presence):
         self._presence = presence
-        contact_list.setPresenceStyle(self.menu.button, self._presence)
+        contact_list.setPresenceStyle(self.presence_bar.button, self._presence)
 
     def setStatus(self, status):
         self.status_panel.setContent({'text': status})
@@ -242,7 +244,7 @@
         self.header = VerticalPanel(StyleName="header")
         self.menu = menu.MainMenuBar(host)
         self.header.add(self.menu)
- 
+
         # contacts
         self.contacts_switch = Button(u'«', self._contactsSwitch)
         self.contacts_switch.addStyleName('contactsSwitch')
@@ -250,7 +252,7 @@
         # tab panel
         self.tab_panel = libervia_widget.MainTabPanel(host)
         self.tab_panel.addWidgetsTab(_(u"Discussions"), select=True, locked=True)
- 
+
         # XXX: widget's addition order is important!
         self.add(self.header, DockPanel.NORTH)
         self.add(self.tab_panel, DockPanel.CENTER)