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".
This commit is contained in:
parent
d792723caa
commit
cac3cd810f
5 changed files with 53 additions and 24 deletions
|
|
@ -74,21 +74,37 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def setFocus(self, name, select=False):
|
def setFocus(self, text, select=False):
|
||||||
"""give focus to the first group or contact wich contain the given name
|
"""give focus to the first element that matches the given text. You can also
|
||||||
@param name: name to check
|
pass in text a sat.tools.jid.JID (it's a subclass of unicode).
|
||||||
@param select: if True, the contact/group is also clicked"""
|
@param text: contact group name, contact or muc userhost, muc private dialog jid
|
||||||
|
@param select: if True, the element is also clicked
|
||||||
|
"""
|
||||||
idx = 0
|
idx = 0
|
||||||
for widget in self.frame.body.body:
|
for widget in self.frame.body.body:
|
||||||
try:
|
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)
|
self.frame.body.set_focus(idx)
|
||||||
if select:
|
if select:
|
||||||
self.__contactClicked(widget, True)
|
self.__contactClicked(widget, True)
|
||||||
return
|
return
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
idx+=1
|
idx += 1
|
||||||
|
|
||||||
def putAlert(self, jid):
|
def putAlert(self, jid):
|
||||||
"""Put an alert on the jid to get attention from user (e.g. for new message)"""
|
"""Put an alert on the jid to get attention from user (e.g. for new message)"""
|
||||||
|
|
@ -202,7 +218,6 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
||||||
if widget.__class__ == sat_widgets.SelectableText:
|
if widget.__class__ == sat_widgets.SelectableText:
|
||||||
widget.setState(False, invisible=True)
|
widget.setState(False, invisible=True)
|
||||||
|
|
||||||
|
|
||||||
def getContact(self):
|
def getContact(self):
|
||||||
"""Return contact currently selected"""
|
"""Return contact currently selected"""
|
||||||
return self.selected
|
return self.selected
|
||||||
|
|
@ -232,14 +247,6 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
||||||
self.groups[group][1].add(jid.short)
|
self.groups[group][1].add(jid.short)
|
||||||
self.update()
|
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):
|
def remove(self, jid):
|
||||||
"""remove a contact from the list"""
|
"""remove a contact from the list"""
|
||||||
QuickContactList.remove(self, jid)
|
QuickContactList.remove(self, jid)
|
||||||
|
|
@ -258,19 +265,24 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
||||||
"""add a contact to the list"""
|
"""add a contact to the list"""
|
||||||
self.replace(jid,param_groups)
|
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
|
"""Set entity as a special
|
||||||
@param jid: jid of the entity
|
@param jid: jid of the entity
|
||||||
@param _type: special type (e.g.: "MUC")
|
@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:
|
if None in self.groups:
|
||||||
folded,group_jids = self.groups[None]
|
folded, group_jids = self.groups[None]
|
||||||
for group_jid in group_jids:
|
for group_jid in group_jids:
|
||||||
if JID(group_jid).short == special_jid.short:
|
if JID(group_jid).short == special_jid.short:
|
||||||
group_jids.remove(group_jid)
|
group_jids.remove(group_jid)
|
||||||
break
|
break
|
||||||
self.update()
|
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):
|
def updatePresence(self, jid, show, priority, statuses):
|
||||||
#XXX: for the moment, we ignore presence updates for special entities
|
#XXX: for the moment, we ignore presence updates for special entities
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ class QuickApp(object):
|
||||||
self.chat_wins[room_jid].setType("group")
|
self.chat_wins[room_jid].setType("group")
|
||||||
self.chat_wins[room_jid].id = room_jid
|
self.chat_wins[room_jid].id = room_jid
|
||||||
self.chat_wins[room_jid].setPresents(list(set([user_nick]+room_nicks)))
|
self.chat_wins[room_jid].setPresents(list(set([user_nick]+room_nicks)))
|
||||||
self.contact_list.setSpecial(JID(room_jid), "MUC")
|
self.contact_list.setSpecial(JID(room_jid), "MUC", show=True)
|
||||||
|
|
||||||
def roomLeft(self, room_jid_s, profile):
|
def roomLeft(self, room_jid_s, profile):
|
||||||
"""Called when a MUC room is left"""
|
"""Called when a MUC room is left"""
|
||||||
|
|
@ -573,3 +573,4 @@ class QuickApp(object):
|
||||||
self.bridge.disconnect(self.profile)
|
self.bridge.disconnect(self.profile)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,6 @@ class QuickChat(object):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
def startGame(self, game_type, referee, players):
|
def startGame(self, game_type, referee, players):
|
||||||
"""Configure the chat window to start a game"""
|
"""Configure the chat window to start a game"""
|
||||||
#No need to raise an error as game are not mandatory
|
#No need to raise an error as game are not mandatory
|
||||||
|
|
@ -151,3 +150,4 @@ class QuickChat(object):
|
||||||
"""Return class managing the game type"""
|
"""Return class managing the game type"""
|
||||||
#No need to raise an error as game are not mandatory
|
#No need to raise an error as game are not mandatory
|
||||||
warning(_('getGame is not implemented in this frontend'))
|
warning(_('getGame is not implemented in this frontend'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,11 @@ class QuickContactList(object):
|
||||||
"""Return special type of jid, or None if it's not special"""
|
"""Return special type of jid, or None if it's not special"""
|
||||||
return self.specials.get(jid.short)
|
return self.specials.get(jid.short)
|
||||||
|
|
||||||
def setSpecial(self, jid, _type):
|
def setSpecial(self, jid, _type, show=False):
|
||||||
"""Set entity as a special
|
"""Set entity as a special
|
||||||
@param jid: jid of the entity
|
@param jid: jid of the entity
|
||||||
@param _type: special type (e.g.: "MUC")
|
@param _type: special type (e.g.: "MUC")
|
||||||
|
@param show: True to display the dialog to chat with this entity
|
||||||
"""
|
"""
|
||||||
self.specials[jid.short] = _type
|
self.specials[jid.short] = _type
|
||||||
|
|
||||||
|
|
@ -89,4 +90,3 @@ class QuickContactList(object):
|
||||||
self.setCache(jid, 'prority', priority)
|
self.setCache(jid, 'prority', priority)
|
||||||
self.setCache(jid, 'statuses', statuses)
|
self.setCache(jid, 'statuses', statuses)
|
||||||
self.update_jid(jid)
|
self.update_jid(jid)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,8 +166,24 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
|
||||||
if _present:
|
if _present:
|
||||||
self.Insert(_present, gp_idx+1, contact)
|
self.Insert(_present, gp_idx+1, contact)
|
||||||
|
|
||||||
def setSpecial(self, special_jid, special_type):
|
def setSpecial(self, special_jid, special_type, show=False):
|
||||||
QuickContactList.setSpecial(self, special_jid, special_type)
|
"""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, show)
|
||||||
|
if show:
|
||||||
|
self._showDialog(special_jid)
|
||||||
|
|
||||||
|
def _showDialog(self, jid):
|
||||||
|
"""Show the dialog associated to the given jid."""
|
||||||
|
indexes = self.__find_idx(jid)
|
||||||
|
if not indexes:
|
||||||
|
return
|
||||||
|
self.DeselectAll()
|
||||||
|
self.SetSelection(indexes[0])
|
||||||
|
self.onActivated(wx.MouseEvent())
|
||||||
|
|
||||||
def remove(self, contact):
|
def remove(self, contact):
|
||||||
"""remove a contact from the list"""
|
"""remove a contact from the list"""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue