diff src/browser/sat_browser/chat.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 e489218886d7
children a90cc8fc9605
line wrap: on
line diff
--- a/src/browser/sat_browser/chat.py	Tue Mar 17 20:28:41 2015 +0100
+++ b/src/browser/sat_browser/chat.py	Tue Mar 17 20:42:02 2015 +0100
@@ -20,10 +20,10 @@
 from sat.core.log import getLogger
 log = getLogger(__name__)
 
-from sat_frontends.tools.games import SYMBOLS
+# from sat_frontends.tools.games import SYMBOLS
 from sat_frontends.tools import strings
 from sat_frontends.tools import jid
-from sat_frontends.quick_frontend import quick_widgets, quick_games
+from sat_frontends.quick_frontend import quick_widgets, quick_games, quick_menus
 from sat_frontends.quick_frontend.quick_chat import QuickChat
 from sat.core.i18n import _
 
@@ -134,6 +134,10 @@
         assert len(self.profiles) == 1 and not self.PROFILES_MULTIPLE and not self.PROFILES_ALLOW_NONE
         return list(self.profiles)[0]
 
+    @property
+    def plugin_menu_context(self):
+        return (C.MENU_ROOM,) if self.type == C.CHAT_GROUP else (C.MENU_SINGLE,)
+
     # @classmethod
     # def createPanel(cls, host, item, type_=C.CHAT_ONE2ONE):
     #     assert(item)
@@ -167,16 +171,6 @@
         else:
             self.host.showWarning(*self.getWarningData())
 
-    def addMenus(self, menu_bar):
-        """Add cached menus to the header.
-
-        @param menu_bar (GenericMenuBar): menu bar of the widget's header
-        """
-        if self.type == C.CHAT_GROUP:
-            menu_bar.addCachedMenus(C.MENU_ROOM, {'room_jid': self.target.bare})
-        elif self.type == C.CHAT_ONE2ONE:
-            menu_bar.addCachedMenus(C.MENU_SINGLE, {'jid': self.target})
-
     def getWarningData(self):
         if self.type not in [C.CHAT_ONE2ONE, C.CHAT_GROUP]:
             raise Exception("Unmanaged type !")
@@ -349,3 +343,5 @@
 quick_widgets.register(quick_games.Tarot, game_tarot.TarotPanel)
 quick_widgets.register(quick_games.Radiocol, game_radiocol.RadioColPanel)
 libervia_widget.LiberviaWidget.addDropKey("CONTACT", lambda host, item: host.displayWidget(Chat, jid.JID(item), dropped=True))
+quick_menus.QuickMenusManager.addDataCollector(C.MENU_ROOM, {'room_jid': 'target'})
+quick_menus.QuickMenusManager.addDataCollector(C.MENU_SINGLE, {'jid': 'target'})