diff src/browser/sat_browser/panels.py @ 495:587fe75d1b16

browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
author souliane <souliane@mailoo.org>
date Tue, 15 Jul 2014 18:45:33 +0200
parents 437eefa53a01
children 0924710b666a
line wrap: on
line diff
--- a/src/browser/sat_browser/panels.py	Tue Jul 15 18:43:55 2014 +0200
+++ b/src/browser/sat_browser/panels.py	Tue Jul 15 18:45:33 2014 +0200
@@ -1093,15 +1093,15 @@
         @param host: SatWebFrontend instance
         @param target: entity (jid.JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room)
         @param type: one2one for simple conversation, group for MUC"""
-        base_widget.LiberviaWidget.__init__(self, host, title=target.bare, selectable=True)
         self.vpanel = VerticalPanel()
         self.vpanel.setSize('100%', '100%')
-        self.type = type_
         self.nick = None
         if not target:
             log.error("Empty target !")
             return
         self.target = target
+        self.type = type_
+        base_widget.LiberviaWidget.__init__(self, host, title=target.bare, selectable=True)
         self.__body = AbsolutePanel()
         self.__body.setStyleName('chatPanel_body')
         chat_area = HorizontalPanel()
@@ -1168,6 +1168,16 @@
             e.include_traceback()
             return False
 
+    def addCachedMenus(self, menu_bar):
+        """Add cached menus to the header.
+
+        @param menu_bar (GenericMenuBar): menu bar of the widget's header
+        """
+        if self.type == 'group':
+            menu_bar.addCachedMenus(C.MENU_ROOM, {'room_jid': self.target.bare})
+        elif self.type == 'one2one':
+            menu_bar.addCachedMenus(C.MENU_SINGLE, {'jid': self.target})
+
     def getWarningData(self):
         if self.type not in ["one2one", "group"]:
             raise Exception("Unmanaged type !")
@@ -1350,7 +1360,7 @@
         AbsolutePanel.__init__(self)
 
         # menu
-        self.menu = menu.Menu(host)
+        self.menu = menu.MainMenuPanel(host)
 
         # unibox
         self.unibox_panel = UniBoxPanel(host)