diff src/browser/sat_browser/contact_panel.py @ 671:2201ff543a05 frontends_multi_profiles

browser_side: replace ContactsPanel and ContactBox init "parent" attribute with "host" + menus bound to the avatar can be parameterized
author souliane <souliane@mailoo.org>
date Mon, 09 Mar 2015 16:30:06 +0100
parents 267761bf7f08
children e489218886d7
line wrap: on
line diff
--- a/src/browser/sat_browser/contact_panel.py	Mon Mar 09 16:27:20 2015 +0100
+++ b/src/browser/sat_browser/contact_panel.py	Mon Mar 09 16:30:06 2015 +0100
@@ -82,22 +82,27 @@
     Special features like popup menu panel or changing the contact states must be done in a sub-class.
     """
 
-    def __init__(self, parent, on_click=None, handle_menu=True, contacts_style=None, contacts_display=C.CONTACT_DEFAULT_DISPLAY):
+    def __init__(self, host, contacts_click=None, contacts_style=None, contacts_menus=True, contacts_display=C.CONTACT_DEFAULT_DISPLAY):
         """
-        @param on_click (callable): click callback (used if ContactBox is created)
-        @param handle_menu (bool): if True, bind a popup menu to the avatar (used if ContactBox is created)
-        """ # FIXME
+
+        @param host (SatWebFrontend): host instance
+        @param contacts_click (callable): click callback for the contact boxes
+        @param contacts_style (unicode): CSS style name for the contact boxes
+        @param contacts_menus (tuple): define the menu types that fit this
+            contact panel, with values from the menus type constants.
+        @param contacts_display (tuple): prioritize the display methods of the
+            contact's label with values in ("jid", "nick", "bare", "resource")
+        """
         VerticalPanel.__init__(self)
-        self._parent = parent
-        self.host = parent.host
-        self._contacts = {} # entity jid to ContactBox map
+        self.host = host
+        self._contacts = {}  # entity jid to ContactBox map
         self.click_listener = None
-        self.handle_menu = handle_menu
 
-        if on_click is not None:
-            self.onClick = on_click
+        if contacts_click is not None:
+            self.onClick = contacts_click
 
-        self.contacts_style=contacts_style
+        self.contacts_style = contacts_style
+        self.contacts_menus = contacts_menus
         self.contacts_display = contacts_display
 
     def setList(self, jids):
@@ -134,7 +139,10 @@
         try:
             return self._contacts[contact_jid.bare]
         except KeyError:
-            box = contact_widget.ContactBox(self, contact_jid, style_name=self.contacts_style, display=self.contacts_display)
+            box = contact_widget.ContactBox(self.host, contact_jid,
+                                            style_name=self.contacts_style,
+                                            menu_types=self.contacts_menus,
+                                            display=self.contacts_display)
             self._contacts[contact_jid.bare] = box
             return box