Mercurial > libervia-web
comparison browser_side/contact.py @ 279:2d6bd975a72d
browser_side: set your own presence status and display those of others
author | souliane <souliane@mailoo.org> |
---|---|
date | Sat, 23 Nov 2013 14:46:03 +0100 |
parents | 0cb9869b42b6 |
children | 3216c8d5432b |
comparison
equal
deleted
inserted
replaced
278:4517978a2e7e | 279:2d6bd975a72d |
---|---|
29 from jid import JID | 29 from jid import JID |
30 from pyjamas import Window | 30 from pyjamas import Window |
31 from pyjamas import DOM | 31 from pyjamas import DOM |
32 | 32 |
33 from browser_side.panels import ChatPanel, MicroblogPanel, PopupMenuPanel, WebPanel | 33 from browser_side.panels import ChatPanel, MicroblogPanel, PopupMenuPanel, WebPanel |
34 from browser_side.tools import DragLabel, html_sanitize | 34 from browser_side.tools import DragLabel, html_sanitize, setPresenceStyle |
35 from __pyjamas__ import doc | 35 from __pyjamas__ import doc |
36 | 36 |
37 | 37 |
38 class GroupLabel(DragLabel, Label, ClickHandler): | 38 class GroupLabel(DragLabel, Label, ClickHandler): |
39 def __init__(self, host, group): | 39 def __init__(self, host, group): |
159 GenericContactList.__init__(self, host, handleClick=True) | 159 GenericContactList.__init__(self, host, handleClick=True) |
160 self.menu_entries = {"blog": {"title": "Public blog..."}} | 160 self.menu_entries = {"blog": {"title": "Public blog..."}} |
161 self.context_menu = PopupMenuPanel(entries=self.menu_entries, | 161 self.context_menu = PopupMenuPanel(entries=self.menu_entries, |
162 hide=self.contextMenuHide, | 162 hide=self.contextMenuHide, |
163 callback=self.contextMenuCallback, | 163 callback=self.contextMenuCallback, |
164 vertical=False, menu_style="menu") | 164 vertical=False, style={"selected": "menu-selected"}) |
165 | 165 |
166 def contextMenuHide(self, sender, key): | 166 def contextMenuHide(self, sender, key): |
167 """Return True if the item for that sender should be hidden.""" | 167 """Return True if the item for that sender should be hidden.""" |
168 # TODO: enable the blogs of users that are on another server | 168 # TODO: enable the blogs of users that are on another server |
169 return JID(sender.jid).domain != self.host._defaultDomain | 169 return JID(sender.jid).domain != self.host._defaultDomain |
192 - for availability type: | 192 - for availability type: |
193 'unavailable' if not connected, else presence like RFC6121 #4.7.2.1""" | 193 'unavailable' if not connected, else presence like RFC6121 #4.7.2.1""" |
194 _item = self.getContactLabel(jid) | 194 _item = self.getContactLabel(jid) |
195 if _item: | 195 if _item: |
196 if type_ == 'availability': | 196 if type_ == 'availability': |
197 if state == 'unavailable': | 197 setPresenceStyle(_item, state) |
198 _item.removeStyleName('contactConnected') | |
199 else: | |
200 _item.addStyleName('contactConnected') | |
201 elif type_ == 'messageWaiting': | 198 elif type_ == 'messageWaiting': |
202 _item.setMessageWaiting(state) | 199 _item.setMessageWaiting(state) |
203 | 200 |
204 | 201 |
205 class ContactTitleLabel(DragLabel, Label, ClickHandler): | 202 class ContactTitleLabel(DragLabel, Label, ClickHandler): |
375 def onMouseLeave(self, sender): | 372 def onMouseLeave(self, sender): |
376 if isinstance(sender, GroupLabel): | 373 if isinstance(sender, GroupLabel): |
377 for contact in self._contact_list: | 374 for contact in self._contact_list: |
378 if contact.jid in self.groups[sender.group]: | 375 if contact.jid in self.groups[sender.group]: |
379 contact.removeStyleName("selected") | 376 contact.removeStyleName("selected") |
377 |