Mercurial > libervia-web
comparison browser_side/contact.py @ 47:7cabe3c1a5f2
browser side: connected contacts now appear differently
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 May 2011 17:17:48 +0200 |
parents | e70521e6d803 |
children | 9f19e16187ff |
comparison
equal
deleted
inserted
replaced
46:c3ee630914ba | 47:7cabe3c1a5f2 |
---|---|
103 def add(self, jid, name=None): | 103 def add(self, jid, name=None): |
104 _item = ContactLabel(jid, name) | 104 _item = ContactLabel(jid, name) |
105 DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer") | 105 DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer") |
106 VerticalPanel.add(self, _item) | 106 VerticalPanel.add(self, _item) |
107 self.contacts.append(_item) | 107 self.contacts.append(_item) |
108 | |
109 def setState(self, jid, state): | |
110 """Change the appearance of the contact, according to the state | |
111 @param jid: jid which need to change state | |
112 @param state: 'unavailable' if not connected, else presence like RFC6121 #4.7.2.1""" | |
113 _item = None | |
114 for contact in self.contacts: | |
115 if contact.jid == jid: | |
116 _item = contact | |
117 break | |
118 if _item: | |
119 if state == 'unavailable': | |
120 _item.removeStyleName('contactConnected') | |
121 else: | |
122 _item.addStyleName('contactConnected') | |
108 | 123 |
109 class ContactTitleLabel(DragLabel, Label): | 124 class ContactTitleLabel(DragLabel, Label): |
110 def __init__(self, text): | 125 def __init__(self, text): |
111 Label.__init__(self, text) #, Element=DOM.createElement('div') | 126 Label.__init__(self, text) #, Element=DOM.createElement('div') |
112 self.setStyleName('contactTitle') | 127 self.setStyleName('contactTitle') |
159 del self.connected[jid] | 174 del self.connected[jid] |
160 else: | 175 else: |
161 if not self.connected.has_key(jid): | 176 if not self.connected.has_key(jid): |
162 self.connected[jid] = {} | 177 self.connected[jid] = {} |
163 self.connected[jid][resource] = (availability, priority, statuses) | 178 self.connected[jid][resource] = (availability, priority, statuses) |
179 self._contactList.setState(jid, availability) | |
164 | 180 |
165 def getConnected(self): | 181 def getConnected(self): |
166 """return a list of all jid (bare jid) connected""" | 182 """return a list of all jid (bare jid) connected""" |
167 return self.connected.keys() | 183 return self.connected.keys() |
168 | 184 |