comparison src/browser/sat_browser/contact_widget.py @ 684:e876f493dccc

browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation: - some MUC handlers are no more needed, the presence handler is enough - move the chat states logic to quick_frontend - display MUC games symbols - remove classes contact_list.ContactsPanel, contact_panel.Occupant and contact_panel.OccupantsList - move buildPresenceStyle and setPresenceStyle to html_tools - fixes games menu callback
author souliane <souliane@mailoo.org>
date Wed, 18 Mar 2015 10:17:04 +0100
parents 849ffb24d5bf
children 9877607c719a
comparison
equal deleted inserted replaced
683:801eb94aa869 684:e876f493dccc
72 else: 72 else:
73 raise exceptions.InternalError(u"Unknown display argument [{}]".format(disp)) 73 raise exceptions.InternalError(u"Unknown display argument [{}]".format(disp))
74 if contact_raw: 74 if contact_raw:
75 break 75 break
76 if not contact_raw: 76 if not contact_raw:
77 log.error(u"Counld not find a contact display for jid {jid} (display: {display})".format(jid=self.jid, display=self.display)) 77 log.error(u"Could not find a contact display for jid {jid} (display: {display})".format(jid=self.jid, display=self.display))
78 contact_raw = "UNNAMED" 78 contact_raw = "UNNAMED"
79 contact_html = html_tools.html_sanitize(contact_raw) 79 contact_html = html_tools.html_sanitize(contact_raw)
80 html = "%(alert)s%(contact)s" % {'alert': alert_html, 80 html = "%(alert)s%(contact)s" % {'alert': alert_html,
81 'contact': contact_html} 81 'contact': contact_html}
82 self.setHTML(html) 82 self.setHTML(html)
130 ClickHandler.__init__(self) 130 ClickHandler.__init__(self)
131 libervia_widget.DragLabel.__init__(self, jid_, "CONTACT", host) 131 libervia_widget.DragLabel.__init__(self, jid_, "CONTACT", host)
132 self.jid = jid_ 132 self.jid = jid_
133 self.label = ContactLabel(host, self.jid, display=display) 133 self.label = ContactLabel(host, self.jid, display=display)
134 self.avatar = ContactMenuBar(self, host) if plugin_menu_context else Image() 134 self.avatar = ContactMenuBar(self, host) if plugin_menu_context else Image()
135 self.states = HTML("")
135 try: # FIXME: dirty hack to force using an Image when the menu is actually empty 136 try: # FIXME: dirty hack to force using an Image when the menu is actually empty
136 self.avatar.items[0] 137 self.avatar.items[0]
137 except IndexError: 138 except IndexError:
138 self.avatar = Image() 139 self.avatar = Image()
139 self.updateAvatar(host.getAvatarURL(self.jid.bare)) 140 self.updateAvatar(host.getAvatarURL(self.jid.bare))
140 self.add(self.avatar) 141 self.add(self.avatar)
141 self.add(self.label) 142 self.add(self.label)
143 self.add(self.states)
142 self.addClickListener(self) 144 self.addClickListener(self)
143 145
144 def setAlert(self, alert): 146 def setAlert(self, alert):
145 """Show a visual indicator 147 """Show a visual indicator.
146 148
147 @param alert: True if alert indicator show be shown""" 149 @param alert (bool): True if alert indicator show be shown
150 """
148 self.label.setAlert(alert) 151 self.label.setAlert(alert)
149 152
150 def updateAvatar(self, url): 153 def updateAvatar(self, url):
151 """Update the avatar. 154 """Update the avatar.
152 155
157 def updateNick(self, new_nick): 160 def updateNick(self, new_nick):
158 """Update the nickname. 161 """Update the nickname.
159 162
160 @param new_nick (unicode): new nickname to use 163 @param new_nick (unicode): new nickname to use
161 """ 164 """
162 self.label.updateNick(new_nick) 165 self.label.updateNick(html_tools.html_sanitize(new_nick))
166
167 def updateStates(self, states):
168 """Update the states.
169
170 @param states (dict{unicode: unicode}): new states
171 """
172 self.states.setHTML(u''.join(states.values()))
163 173
164 def onClick(self, sender): 174 def onClick(self, sender):
165 try: 175 try:
166 self.parent.onClick(self.jid.bare) 176 self.parent.onClick(self.jid.bare)
167 except (AttributeError, TypeError): 177 except (AttributeError, TypeError):