annotate frontends/wix/contact_list.py @ 213:5c420b1f1df4

removed connect on statService, this was causing issue on first launch
author Goffi <goffi@goffi.org>
date Mon, 27 Dec 2010 15:14:28 +0100
parents 58f96e66ec17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
1 import wx
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 from quick_frontend.quick_contact_list import QuickContactList
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3 from logging import debug, info, error
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from cgi import escape
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from tools.jid import JID
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
7
199
58f96e66ec17 wix: unicode fixes in contact list
Goffi <goffi@goffi.org>
parents: 183
diff changeset
8 class Group(unicode):
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
9 """Class used to recognize groups"""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
10
199
58f96e66ec17 wix: unicode fixes in contact list
Goffi <goffi@goffi.org>
parents: 183
diff changeset
11 class Contact(unicode):
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
12 """Class used to recognize groups"""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
13
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
14 class ContactList(wx.SimpleHtmlListBox, QuickContactList):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
15 """Customized control to manage contacts."""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
17 def __init__(self, parent, host, type="JID"):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
18 """init the contact list
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19 @param parent: WxWidgets parent of the widget
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
20 @param host: wix main app class
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
21 @param type: type of contact list: "JID" for the usual big jid contact list
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
22 "CUSTOM" for a customized contact list (self.__presentItem must then be overrided)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
23 """
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
24 wx.SimpleHtmlListBox.__init__(self, parent, -1)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 QuickContactList.__init__(self, host.CM)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 self.host = host
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
27 self.type = type
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
28 self.__typeSwitch()
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
29 self.groups = {} #list contacts in each groups, key = group
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30 self.Bind(wx.EVT_LISTBOX, self.onSelected)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
31 self.Bind(wx.EVT_LISTBOX_DCLICK, self.onActivated)
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 75
diff changeset
32
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 75
diff changeset
33 def __contains__(self, jid):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 75
diff changeset
34 return bool(self.__find_idx(jid))
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
35
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
36 def __typeSwitch(self):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
37 if self.type == "JID":
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
38 self.__presentItem = self.__presentItemJID
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
39 elif type != "CUSTOM":
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
40 self.__presentItem = self.__presentItemDefault
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
41
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
42 def __find_idx(self, entity):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
43 """Find indexes of given contact (or groups) in contact list, manage jid
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
44 @return: list of indexes"""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
45 result=[]
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
46 for i in range(self.GetCount()):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
47 if (type(entity) == JID and type(self.GetClientData(i)) == JID and self.GetClientData(i).short == entity.short) or\
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.GetClientData(i) == entity:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
49 result.append(i)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
50 return result
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
51
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
52 def replace(self, contact, groups=None):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
53 debug(_("update %s") % contact)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
54 if not self.__find_idx(contact):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
55 self.add(contact, groups)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
56 else:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
57 for i in self.__find_idx(contact):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
58 self.SetString(i, self.__presentItem(contact))
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
59
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
60 def disconnect(self, contact):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
61 self.remove(contact) #for now, we only show online contacts
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
62
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
63 def __eraseGroup(self, group):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
64 """Erase all contacts in group
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
65 @param group: group to erase
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
66 @return: True if something as been erased"""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
67 erased = False
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
68 indexes = self.__find_idx(group)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
69 for idx in indexes:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
70 while idx<self.GetCount()-1 and type(self.GetClientData(idx+1)) != Group:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
71 erased = True
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
72 self.Delete(idx+1)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
73 return erased
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
74
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
75
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
76 def __presentGroup(self, group):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
77 """Make a nice presentation for the contact groups"""
199
58f96e66ec17 wix: unicode fixes in contact list
Goffi <goffi@goffi.org>
parents: 183
diff changeset
78 html = u"""-- [%s] --""" % group
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
79
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
80 return html
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
81
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
82 def __presentItemDefault(self, contact):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
83 """Make a basic presentation of string contacts in the list."""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
84 return contact
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
85
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
86 def __presentItemJID(self, jid):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
87 """Make a nice presentation of the contact in the list for JID contacts."""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
88 name = self.CM.getAttr(jid,'name')
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
89 nick = self.CM.getAttr(jid,'nick')
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
90 show = filter(lambda x:x[0]==self.CM.getAttr(jid,'show'), const_STATUS)[0]
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
91 #show[0]==shortcut
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
92 #show[1]==human readable
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
93 #show[2]==color (or None)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
94 show_html = "<font color='%s'>[%s]</font>" % (show[2], show[1]) if show[2] else ""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
95 status = self.CM.getAttr(jid,'status') or ''
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
96 avatar = self.CM.getAttr(jid,'avatar') or IMAGE_DIR+'/empty_avatar.png'
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
97
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
98 html = """
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
99 <table border='0'>
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
100 <td>
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
101 <img height='64' width='64' src='%s' />
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
102 </td>
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
103 <td>
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
104 <b>%s</b> %s<br />
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
105 <i>%s</i>
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
106 </td>
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
107 </table>
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
108 """ % (avatar,
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
109 escape(nick or name or jid.node or jid.short),
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
110 show_html,
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
111 escape(status))
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
112
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
113 return html
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
114
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
115 def clear_contacts(self):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
116 """Clear all the contact list"""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
117 self.Clear()
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
118
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
119 def add(self, contact, groups = None):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
120 """add a contact to the list"""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
121 debug (_("adding %s"),contact)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
122 if not groups:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
123 idx = self.Insert(self.__presentItem(contact), 0, contact)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
124 else:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
125 for group in groups:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
126 indexes = self.__find_idx(group)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
127 gp_idx = 0
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
128 if not indexes: #this is a new group, we have to create it
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
129 gp_idx = self.Append(self.__presentGroup(group), Group(group))
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
130 else:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
131 gp_idx = indexes[0]
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
132
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
133 self.Insert(self.__presentItem(contact), gp_idx+1, contact)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
134
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
135
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
136
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
137 def remove(self, contact):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
138 """remove a contact from the list"""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
139 debug (_("removing %s"), contact)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
140 list_idx = self.__find_idx(contact)
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
141 list_idx.reverse() #as we make some deletions, we have to reverse the order
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
142 for i in list_idx:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
143 self.Delete(i)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
144
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
145 def onSelected(self, event):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
146 """Called when a contact is selected."""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
147 data = self.getSelection()
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
148 if data == None: #we have a group
138
2f8c86488b05 wix: scrolling is not reseted anymore when clicking on a group on contact list
Goffi <goffi@goffi.org>
parents: 125
diff changeset
149 first_visible = self.GetVisibleBegin()
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
150 group = self.GetClientData(self.GetSelection())
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
151 erased = self.__eraseGroup(group)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
152 if not erased: #the group was already erased, we can add again the contacts
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
153 contacts = self.CM.getContFromGroup(group)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
154 contacts.sort()
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
155 id_insert = self.GetSelection()+1
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
156 for contact in contacts:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
157 self.Insert(self.__presentItem(contact), id_insert, contact)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
158 self.SetSelection(wx.NOT_FOUND)
138
2f8c86488b05 wix: scrolling is not reseted anymore when clicking on a group on contact list
Goffi <goffi@goffi.org>
parents: 125
diff changeset
159 self.ScrollToLine(first_visible)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
160 event.Skip(False)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
161 else:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
162 event.Skip()
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
163
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
164 def onActivated(self, event):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
165 """Called when a contact is clicked or activated with keyboard."""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
166 data = self.getSelection()
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
167 self.onActivatedCB(data)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
168 event.Skip()
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
169
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
170 def getSelection(self):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
171 """Return the selected contact, or an empty string if there is not"""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
172 if self.GetSelection() == wx.NOT_FOUND:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
173 return None
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
174 data = self.GetClientData(self.GetSelection())
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
175 if type(data) == Group:
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
176 return None
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
177 return data
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
178
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
179 def registerActivatedCB(self, cb):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
180 """Register a callback with manage contact activation."""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
181 self.onActivatedCB=cb
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
182