Mercurial > libervia-backend
annotate frontends/src/wix/contact_list.py @ 1269:91e5becc6623
test: add tests for plugin_misc_groupblog
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 15 Dec 2014 14:05:28 +0100 |
parents | 75025461141f |
children |
rev | line source |
---|---|
227 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
4 # wix: a SAT frontend |
811 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) |
227 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
10 # (at your option) any later version. |
227 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
15 # GNU Affero General Public License for more details. |
227 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
227 | 19 |
771 | 20 from sat.core.i18n import _ |
72 | 21 import wx |
227 | 22 from sat_frontends.quick_frontend.quick_contact_list import QuickContactList |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
23 from sat_frontends.wix.constants import Const |
1011 | 24 from sat.core.log import getLogger |
25 log = getLogger(__name__) | |
72 | 26 from cgi import escape |
1139
75025461141f
move sat.tools.jid to sat_frontends.tools.jid
souliane <souliane@mailoo.org>
parents:
1058
diff
changeset
|
27 from sat_frontends.tools.jid import JID |
366
0806a65a5fa9
wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents:
316
diff
changeset
|
28 from os.path import join |
72 | 29 |
30 | |
199 | 31 class Group(unicode): |
72 | 32 """Class used to recognize groups""" |
33 | |
199 | 34 class Contact(unicode): |
72 | 35 """Class used to recognize groups""" |
36 | |
37 class ContactList(wx.SimpleHtmlListBox, QuickContactList): | |
38 """Customized control to manage contacts.""" | |
39 | |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
40 def __init__(self, parent, host, type_="JID"): |
72 | 41 """init the contact list |
42 @param parent: WxWidgets parent of the widget | |
43 @param host: wix main app class | |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
44 @param type_: type of contact list: "JID" for the usual big jid contact list |
1011 | 45 "CUSTOM" for a customized contact list (self._presentItem must then be overrided) |
72 | 46 """ |
47 wx.SimpleHtmlListBox.__init__(self, parent, -1) | |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
48 QuickContactList.__init__(self) |
72 | 49 self.host = host |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
50 self.type = type_ |
72 | 51 self.__typeSwitch() |
52 self.groups = {} #list contacts in each groups, key = group | |
366
0806a65a5fa9
wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents:
316
diff
changeset
|
53 self.empty_avatar = join(host.media_dir, 'misc/empty_avatar') |
72 | 54 self.Bind(wx.EVT_LISTBOX, self.onSelected) |
55 self.Bind(wx.EVT_LISTBOX_DCLICK, self.onActivated) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
56 |
124 | 57 def __contains__(self, jid): |
58 return bool(self.__find_idx(jid)) | |
72 | 59 |
60 def __typeSwitch(self): | |
61 if self.type == "JID": | |
1011 | 62 self._presentItem = self._presentItemJID |
63 elif self.type != "CUSTOM": | |
64 self._presentItem = self._presentItemDefault | |
72 | 65 |
66 def __find_idx(self, entity): | |
67 """Find indexes of given contact (or groups) in contact list, manage jid | |
68 @return: list of indexes""" | |
69 result=[] | |
70 for i in range(self.GetCount()): | |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
71 if (type(entity) == JID and type(self.GetClientData(i)) == JID and self.GetClientData(i).bare == entity.bare) or\ |
72 | 72 self.GetClientData(i) == entity: |
73 result.append(i) | |
74 return result | |
75 | |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
76 def update_jid(self, jid): |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
77 self.replace(jid) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
78 |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
79 def replace(self, contact, groups=None, attributes=None): |
1000
6f1e03068b5f
primitivus: fixes contact group update
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
80 """Add a contact to the list if doesn't exist, else update it. |
6f1e03068b5f
primitivus: fixes contact group update
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
81 |
1058
0a9986452bba
frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
82 This method can be called with groups=None for the purpose of updating |
0a9986452bba
frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
83 the contact's attributes (e.g. nickname). In that case, the groups |
0a9986452bba
frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
84 attribute must not be set to the default group but ignored. If not, |
0a9986452bba
frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
85 you may move your contact from its actual group(s) to the default one. |
0a9986452bba
frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
86 |
0a9986452bba
frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
87 None value for 'groups' has a different meaning than [None] which is for the default group. |
0a9986452bba
frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
88 |
1000
6f1e03068b5f
primitivus: fixes contact group update
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
89 @param jid (JID) |
6f1e03068b5f
primitivus: fixes contact group update
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
90 @param groups (list): list of groups or None to ignore the groups membership. |
6f1e03068b5f
primitivus: fixes contact group update
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
91 @param attributes (dict) |
6f1e03068b5f
primitivus: fixes contact group update
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
92 """ |
1011 | 93 log.debug(_("update %s") % contact) |
72 | 94 if not self.__find_idx(contact): |
95 self.add(contact, groups) | |
96 else: | |
97 for i in self.__find_idx(contact): | |
1011 | 98 _present = self._presentItem(contact) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
99 if _present != None: |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
100 self.SetString(i, _present) |
72 | 101 |
102 def __eraseGroup(self, group): | |
103 """Erase all contacts in group | |
104 @param group: group to erase | |
105 @return: True if something as been erased""" | |
106 erased = False | |
107 indexes = self.__find_idx(group) | |
108 for idx in indexes: | |
109 while idx<self.GetCount()-1 and type(self.GetClientData(idx+1)) != Group: | |
110 erased = True | |
111 self.Delete(idx+1) | |
112 return erased | |
113 | |
114 | |
1011 | 115 def _presentGroup(self, group): |
72 | 116 """Make a nice presentation for the contact groups""" |
199 | 117 html = u"""-- [%s] --""" % group |
72 | 118 |
119 return html | |
120 | |
1011 | 121 def _presentItemDefault(self, contact): |
72 | 122 """Make a basic presentation of string contacts in the list.""" |
123 return contact | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
124 |
1011 | 125 def _presentItemJID(self, jid): |
72 | 126 """Make a nice presentation of the contact in the list for JID contacts.""" |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
127 name = self.getCache(jid,'name') |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
128 nick = self.getCache(jid,'nick') |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
129 _show = self.getCache(jid,'show') |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
130 if _show == None or _show == 'unavailable': |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
131 return None |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
132 show = [x for x in Const.PRESENCE if x[0] == _show][0] |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
133 |
72 | 134 #show[0]==shortcut |
135 #show[1]==human readable | |
136 #show[2]==color (or None) | |
137 show_html = "<font color='%s'>[%s]</font>" % (show[2], show[1]) if show[2] else "" | |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
138 status = self.getCache(jid,'status') or '' |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
139 avatar = self.getCache(jid,'avatar') or self.empty_avatar #XXX: there is a weird bug here: if the image has an extension (i.e. empty_avatar.png), |
316
3a21d586dae4
wix: workaround a weird bug which crash wix while using empty_avatar, see comments for more information
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
140 #WxPython segfault, and it doesn't without nothing. I couldn't reproduce the case with a basic test script, so it need further investigation before reporting it |
3a21d586dae4
wix: workaround a weird bug which crash wix while using empty_avatar, see comments for more information
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
141 #to WxPython dev. Anyway, the program crash with a segfault, not a python exception, so there is definitely something wrong with WxPython. |
3a21d586dae4
wix: workaround a weird bug which crash wix while using empty_avatar, see comments for more information
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
142 #The case seems to happen when SimpleHtmlListBox parse the HTML with the <img> tag |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
143 |
72 | 144 html = """ |
145 <table border='0'> | |
146 <td> | |
147 <img height='64' width='64' src='%s' /> | |
148 </td> | |
149 <td> | |
150 <b>%s</b> %s<br /> | |
151 <i>%s</i> | |
152 </td> | |
153 </table> | |
154 """ % (avatar, | |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
155 escape(nick or name or jid.node or jid.bare), |
72 | 156 show_html, |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
157 escape(status)) |
72 | 158 |
159 return html | |
160 | |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
161 def clearContacts(self): |
72 | 162 """Clear all the contact list""" |
163 self.Clear() | |
164 | |
165 def add(self, contact, groups = None): | |
166 """add a contact to the list""" | |
1011 | 167 log.debug (_("adding %s"),contact) |
72 | 168 if not groups: |
1011 | 169 _present = self._presentItem(contact) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
170 if _present: |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
171 idx = self.Insert(_present, 0, contact) |
72 | 172 else: |
173 for group in groups: | |
174 indexes = self.__find_idx(group) | |
175 gp_idx = 0 | |
176 if not indexes: #this is a new group, we have to create it | |
1011 | 177 gp_idx = self.Append(self._presentGroup(group), Group(group)) |
72 | 178 else: |
179 gp_idx = indexes[0] | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
180 |
1011 | 181 _present = self._presentItem(contact) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
182 if _present: |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
183 self.Insert(_present, gp_idx+1, contact) |
72 | 184 |
685
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
185 def setSpecial(self, special_jid, special_type, show=False): |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
186 """Set entity as a special |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
187 @param jid: jid of the entity |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
188 @param _type: special type (e.g.: "MUC") |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
189 @param show: True to display the dialog to chat with this entity |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
190 """ |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
191 QuickContactList.setSpecial(self, special_jid, special_type, show) |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
192 if show: |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
193 self._showDialog(special_jid) |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
194 |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
195 def _showDialog(self, jid): |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
196 """Show the dialog associated to the given jid.""" |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
197 indexes = self.__find_idx(jid) |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
198 if not indexes: |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
199 return |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
200 self.DeselectAll() |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
201 self.SetSelection(indexes[0]) |
0b9bd47dffcd
primitivus, wix: auto-display MUC dialog after it has been joined:
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
202 self.onActivated(wx.MouseEvent()) |
72 | 203 |
204 def remove(self, contact): | |
205 """remove a contact from the list""" | |
1011 | 206 log.debug (_("removing %s"), contact) |
72 | 207 list_idx = self.__find_idx(contact) |
75 | 208 list_idx.reverse() #as we make some deletions, we have to reverse the order |
72 | 209 for i in list_idx: |
210 self.Delete(i) | |
211 | |
212 def onSelected(self, event): | |
213 """Called when a contact is selected.""" | |
214 data = self.getSelection() | |
215 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
|
216 first_visible = self.GetVisibleBegin() |
72 | 217 group = self.GetClientData(self.GetSelection()) |
218 erased = self.__eraseGroup(group) | |
219 if not erased: #the group was already erased, we can add again the contacts | |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
220 contacts = [JID(contact) for contact in self.host.bridge.getContactsFromGroup(group, self.host.profile)] |
72 | 221 contacts.sort() |
222 id_insert = self.GetSelection()+1 | |
223 for contact in contacts: | |
1011 | 224 _present = self._presentItem(contact) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
225 if _present: |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
226 self.Insert(_present, id_insert, contact) |
72 | 227 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
|
228 self.ScrollToLine(first_visible) |
72 | 229 event.Skip(False) |
230 else: | |
231 event.Skip() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
232 |
72 | 233 def onActivated(self, event): |
234 """Called when a contact is clicked or activated with keyboard.""" | |
235 data = self.getSelection() | |
236 self.onActivatedCB(data) | |
237 event.Skip() | |
238 | |
239 def getSelection(self): | |
240 """Return the selected contact, or an empty string if there is not""" | |
241 if self.GetSelection() == wx.NOT_FOUND: | |
242 return None | |
243 data = self.GetClientData(self.GetSelection()) | |
244 if type(data) == Group: | |
245 return None | |
246 return data | |
247 | |
248 def registerActivatedCB(self, cb): | |
249 """Register a callback with manage contact activation.""" | |
250 self.onActivatedCB=cb | |
251 |