Mercurial > libervia-backend
comparison frontends/src/primitivus/contact_list.py @ 685:0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
- a patch will follow to add a parameter for the user to choose between "always open", "never open" and "ask each time".
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 28 Oct 2013 18:29:34 +0100 |
parents | f7804c52c754 |
children | f7878ad3c846 |
comparison
equal
deleted
inserted
replaced
684:969562c4761b | 685:0b9bd47dffcd |
---|---|
72 for group in self.groups: | 72 for group in self.groups: |
73 if jid.short in self.groups[group][1]: | 73 if jid.short in self.groups[group][1]: |
74 return True | 74 return True |
75 return False | 75 return False |
76 | 76 |
77 def setFocus(self, name, select=False): | 77 def setFocus(self, text, select=False): |
78 """give focus to the first group or contact wich contain the given name | 78 """give focus to the first element that matches the given text. You can also |
79 @param name: name to check | 79 pass in text a sat.tools.jid.JID (it's a subclass of unicode). |
80 @param select: if True, the contact/group is also clicked""" | 80 @param text: contact group name, contact or muc userhost, muc private dialog jid |
81 @param select: if True, the element is also clicked | |
82 """ | |
81 idx = 0 | 83 idx = 0 |
82 for widget in self.frame.body.body: | 84 for widget in self.frame.body.body: |
83 try: | 85 try: |
84 if name in widget.getValue(): | 86 if isinstance(widget, sat_widgets.ClickableText): |
87 # contact group | |
88 value = widget.getValue() | |
89 elif isinstance(widget, sat_widgets.SelectableText): | |
90 if widget.data.startswith(const_PRIVATE_PREFIX): | |
91 # muc private dialog | |
92 value = widget.getValue() | |
93 else: | |
94 # contact or muc | |
95 value = widget.data | |
96 else: | |
97 # Divider instance | |
98 continue | |
99 # there's sometimes a leading space | |
100 if text.strip() == value.strip(): | |
85 self.frame.body.set_focus(idx) | 101 self.frame.body.set_focus(idx) |
86 if select: | 102 if select: |
87 self.__contactClicked(widget, True) | 103 self.__contactClicked(widget, True) |
88 return | 104 return |
89 except AttributeError: | 105 except AttributeError: |
90 pass | 106 pass |
91 idx+=1 | 107 idx += 1 |
92 | 108 |
93 def putAlert(self, jid): | 109 def putAlert(self, jid): |
94 """Put an alert on the jid to get attention from user (e.g. for new message)""" | 110 """Put an alert on the jid to get attention from user (e.g. for new message)""" |
95 self.alert_jid.add(jid.short) | 111 self.alert_jid.add(jid.short) |
96 self.update() | 112 self.update() |
200 self.selected = None | 216 self.selected = None |
201 for widget in self.frame.body.body: | 217 for widget in self.frame.body.body: |
202 if widget.__class__ == sat_widgets.SelectableText: | 218 if widget.__class__ == sat_widgets.SelectableText: |
203 widget.setState(False, invisible=True) | 219 widget.setState(False, invisible=True) |
204 | 220 |
205 | |
206 def getContact(self): | 221 def getContact(self): |
207 """Return contact currently selected""" | 222 """Return contact currently selected""" |
208 return self.selected | 223 return self.selected |
209 | 224 |
210 def clearContacts(self): | 225 def clearContacts(self): |
230 if not self.groups.has_key(group): | 245 if not self.groups.has_key(group): |
231 self.groups[group] = [True,set()] #[unfold,list_of_contacts] | 246 self.groups[group] = [True,set()] #[unfold,list_of_contacts] |
232 self.groups[group][1].add(jid.short) | 247 self.groups[group][1].add(jid.short) |
233 self.update() | 248 self.update() |
234 | 249 |
235 | |
236 """contacts = self.list_wid.getAllValues() | |
237 if jid.short not in contacts: | |
238 contacts.append(jid.short) | |
239 contacts.sort() | |
240 self.list_wid.changeValues(contacts) | |
241 self._emit('change')""" | |
242 | |
243 def remove(self, jid): | 250 def remove(self, jid): |
244 """remove a contact from the list""" | 251 """remove a contact from the list""" |
245 QuickContactList.remove(self, jid) | 252 QuickContactList.remove(self, jid) |
246 groups_to_remove = [] | 253 groups_to_remove = [] |
247 for group in self.groups: | 254 for group in self.groups: |
256 | 263 |
257 def add(self, jid, param_groups=[None]): | 264 def add(self, jid, param_groups=[None]): |
258 """add a contact to the list""" | 265 """add a contact to the list""" |
259 self.replace(jid,param_groups) | 266 self.replace(jid,param_groups) |
260 | 267 |
261 def setSpecial(self, special_jid, special_type): | 268 def setSpecial(self, special_jid, special_type, show=False): |
262 """Set entity as a special | 269 """Set entity as a special |
263 @param jid: jid of the entity | 270 @param jid: jid of the entity |
264 @param _type: special type (e.g.: "MUC") | 271 @param _type: special type (e.g.: "MUC") |
272 @param show: True to display the dialog to chat with this entity | |
265 """ | 273 """ |
266 QuickContactList.setSpecial(self, special_jid, special_type) | 274 QuickContactList.setSpecial(self, special_jid, special_type, show) |
267 if None in self.groups: | 275 if None in self.groups: |
268 folded,group_jids = self.groups[None] | 276 folded, group_jids = self.groups[None] |
269 for group_jid in group_jids: | 277 for group_jid in group_jids: |
270 if JID(group_jid).short == special_jid.short: | 278 if JID(group_jid).short == special_jid.short: |
271 group_jids.remove(group_jid) | 279 group_jids.remove(group_jid) |
272 break | 280 break |
273 self.update() | 281 self.update() |
282 if show: | |
283 # also display the dialog for this room | |
284 self.setFocus(special_jid, True) | |
285 self.host.redraw() | |
274 | 286 |
275 def updatePresence(self, jid, show, priority, statuses): | 287 def updatePresence(self, jid, show, priority, statuses): |
276 #XXX: for the moment, we ignore presence updates for special entities | 288 #XXX: for the moment, we ignore presence updates for special entities |
277 if jid.short not in self.specials: | 289 if jid.short not in self.specials: |
278 QuickContactList.updatePresence(self, jid, show, priority, statuses) | 290 QuickContactList.updatePresence(self, jid, show, priority, statuses) |