Mercurial > libervia-backend
diff 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 |
line wrap: on
line diff
--- a/frontends/src/primitivus/contact_list.py Thu Oct 24 08:47:45 2013 +0200 +++ b/frontends/src/primitivus/contact_list.py Mon Oct 28 18:29:34 2013 +0100 @@ -74,21 +74,37 @@ return True return False - def setFocus(self, name, select=False): - """give focus to the first group or contact wich contain the given name - @param name: name to check - @param select: if True, the contact/group is also clicked""" + def setFocus(self, text, select=False): + """give focus to the first element that matches the given text. You can also + pass in text a sat.tools.jid.JID (it's a subclass of unicode). + @param text: contact group name, contact or muc userhost, muc private dialog jid + @param select: if True, the element is also clicked + """ idx = 0 for widget in self.frame.body.body: try: - if name in widget.getValue(): + if isinstance(widget, sat_widgets.ClickableText): + # contact group + value = widget.getValue() + elif isinstance(widget, sat_widgets.SelectableText): + if widget.data.startswith(const_PRIVATE_PREFIX): + # muc private dialog + value = widget.getValue() + else: + # contact or muc + value = widget.data + else: + # Divider instance + continue + # there's sometimes a leading space + if text.strip() == value.strip(): self.frame.body.set_focus(idx) if select: self.__contactClicked(widget, True) return except AttributeError: pass - idx+=1 + idx += 1 def putAlert(self, jid): """Put an alert on the jid to get attention from user (e.g. for new message)""" @@ -202,7 +218,6 @@ if widget.__class__ == sat_widgets.SelectableText: widget.setState(False, invisible=True) - def getContact(self): """Return contact currently selected""" return self.selected @@ -232,14 +247,6 @@ self.groups[group][1].add(jid.short) self.update() - - """contacts = self.list_wid.getAllValues() - if jid.short not in contacts: - contacts.append(jid.short) - contacts.sort() - self.list_wid.changeValues(contacts) - self._emit('change')""" - def remove(self, jid): """remove a contact from the list""" QuickContactList.remove(self, jid) @@ -258,19 +265,24 @@ """add a contact to the list""" self.replace(jid,param_groups) - def setSpecial(self, special_jid, special_type): + def setSpecial(self, special_jid, special_type, show=False): """Set entity as a special @param jid: jid of the entity @param _type: special type (e.g.: "MUC") + @param show: True to display the dialog to chat with this entity """ - QuickContactList.setSpecial(self, special_jid, special_type) + QuickContactList.setSpecial(self, special_jid, special_type, show) if None in self.groups: - folded,group_jids = self.groups[None] + folded, group_jids = self.groups[None] for group_jid in group_jids: if JID(group_jid).short == special_jid.short: group_jids.remove(group_jid) break self.update() + if show: + # also display the dialog for this room + self.setFocus(special_jid, True) + self.host.redraw() def updatePresence(self, jid, show, priority, statuses): #XXX: for the moment, we ignore presence updates for special entities