comparison 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
comparison
equal deleted inserted replaced
670:a80c13249f5d 671:2201ff543a05
80 """ContactList graphic representation 80 """ContactList graphic representation
81 81
82 Special features like popup menu panel or changing the contact states must be done in a sub-class. 82 Special features like popup menu panel or changing the contact states must be done in a sub-class.
83 """ 83 """
84 84
85 def __init__(self, parent, on_click=None, handle_menu=True, contacts_style=None, contacts_display=C.CONTACT_DEFAULT_DISPLAY): 85 def __init__(self, host, contacts_click=None, contacts_style=None, contacts_menus=True, contacts_display=C.CONTACT_DEFAULT_DISPLAY):
86 """ 86 """
87 @param on_click (callable): click callback (used if ContactBox is created) 87
88 @param handle_menu (bool): if True, bind a popup menu to the avatar (used if ContactBox is created) 88 @param host (SatWebFrontend): host instance
89 """ # FIXME 89 @param contacts_click (callable): click callback for the contact boxes
90 @param contacts_style (unicode): CSS style name for the contact boxes
91 @param contacts_menus (tuple): define the menu types that fit this
92 contact panel, with values from the menus type constants.
93 @param contacts_display (tuple): prioritize the display methods of the
94 contact's label with values in ("jid", "nick", "bare", "resource")
95 """
90 VerticalPanel.__init__(self) 96 VerticalPanel.__init__(self)
91 self._parent = parent 97 self.host = host
92 self.host = parent.host 98 self._contacts = {} # entity jid to ContactBox map
93 self._contacts = {} # entity jid to ContactBox map
94 self.click_listener = None 99 self.click_listener = None
95 self.handle_menu = handle_menu 100
96 101 if contacts_click is not None:
97 if on_click is not None: 102 self.onClick = contacts_click
98 self.onClick = on_click 103
99 104 self.contacts_style = contacts_style
100 self.contacts_style=contacts_style 105 self.contacts_menus = contacts_menus
101 self.contacts_display = contacts_display 106 self.contacts_display = contacts_display
102 107
103 def setList(self, jids): 108 def setList(self, jids):
104 """set all contacts in the list in one shot. 109 """set all contacts in the list in one shot.
105 110
132 @return: ContactBox instance 137 @return: ContactBox instance
133 """ 138 """
134 try: 139 try:
135 return self._contacts[contact_jid.bare] 140 return self._contacts[contact_jid.bare]
136 except KeyError: 141 except KeyError:
137 box = contact_widget.ContactBox(self, contact_jid, style_name=self.contacts_style, display=self.contacts_display) 142 box = contact_widget.ContactBox(self.host, contact_jid,
143 style_name=self.contacts_style,
144 menu_types=self.contacts_menus,
145 display=self.contacts_display)
138 self._contacts[contact_jid.bare] = box 146 self._contacts[contact_jid.bare] = box
139 return box 147 return box
140 148
141 def updateAvatar(self, jid_, url): 149 def updateAvatar(self, jid_, url):
142 """Update the avatar of the given contact 150 """Update the avatar of the given contact