comparison frontends/src/wix/contact_list.py @ 587:952322b1d490

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:34 +0100
parents ca13633d3b6b
children 84a6e83157c2
comparison
equal deleted inserted replaced
586:6a718ede8be1 587:952322b1d490
50 self.__typeSwitch() 50 self.__typeSwitch()
51 self.groups = {} #list contacts in each groups, key = group 51 self.groups = {} #list contacts in each groups, key = group
52 self.empty_avatar = join(host.media_dir, 'misc/empty_avatar') 52 self.empty_avatar = join(host.media_dir, 'misc/empty_avatar')
53 self.Bind(wx.EVT_LISTBOX, self.onSelected) 53 self.Bind(wx.EVT_LISTBOX, self.onSelected)
54 self.Bind(wx.EVT_LISTBOX_DCLICK, self.onActivated) 54 self.Bind(wx.EVT_LISTBOX_DCLICK, self.onActivated)
55 55
56 def __contains__(self, jid): 56 def __contains__(self, jid):
57 return bool(self.__find_idx(jid)) 57 return bool(self.__find_idx(jid))
58 58
59 def __typeSwitch(self): 59 def __typeSwitch(self):
60 if self.type == "JID": 60 if self.type == "JID":
105 return html 105 return html
106 106
107 def __presentItemDefault(self, contact): 107 def __presentItemDefault(self, contact):
108 """Make a basic presentation of string contacts in the list.""" 108 """Make a basic presentation of string contacts in the list."""
109 return contact 109 return contact
110 110
111 def __presentItemJID(self, jid): 111 def __presentItemJID(self, jid):
112 """Make a nice presentation of the contact in the list for JID contacts.""" 112 """Make a nice presentation of the contact in the list for JID contacts."""
113 name = self.getCache(jid,'name') 113 name = self.getCache(jid,'name')
114 nick = self.getCache(jid,'nick') 114 nick = self.getCache(jid,'nick')
115 _show = self.getCache(jid,'show') 115 _show = self.getCache(jid,'show')
116 if _show == None or _show == 'unavailable': 116 if _show == None or _show == 'unavailable':
117 return None 117 return None
118 show = filter(lambda x : x[0] == _show, const_STATUS)[0] 118 show = filter(lambda x : x[0] == _show, const_STATUS)[0]
119 119
120 #show[0]==shortcut 120 #show[0]==shortcut
121 #show[1]==human readable 121 #show[1]==human readable
122 #show[2]==color (or None) 122 #show[2]==color (or None)
123 show_html = "<font color='%s'>[%s]</font>" % (show[2], show[1]) if show[2] else "" 123 show_html = "<font color='%s'>[%s]</font>" % (show[2], show[1]) if show[2] else ""
124 status = self.getCache(jid,'status') or '' 124 status = self.getCache(jid,'status') or ''
125 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), 125 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),
126 #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 126 #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
127 #to WxPython dev. Anyway, the program crash with a segfault, not a python exception, so there is definitely something wrong with WxPython. 127 #to WxPython dev. Anyway, the program crash with a segfault, not a python exception, so there is definitely something wrong with WxPython.
128 #The case seems to happen when SimpleHtmlListBox parse the HTML with the <img> tag 128 #The case seems to happen when SimpleHtmlListBox parse the HTML with the <img> tag
129 129
130 html = """ 130 html = """
131 <table border='0'> 131 <table border='0'>
132 <td> 132 <td>
133 <img height='64' width='64' src='%s' /> 133 <img height='64' width='64' src='%s' />
134 </td> 134 </td>
138 </td> 138 </td>
139 </table> 139 </table>
140 """ % (avatar, 140 """ % (avatar,
141 escape(nick or name or jid.node or jid.short), 141 escape(nick or name or jid.node or jid.short),
142 show_html, 142 show_html,
143 escape(status)) 143 escape(status))
144 144
145 return html 145 return html
146 146
147 def clearContacts(self): 147 def clearContacts(self):
148 """Clear all the contact list""" 148 """Clear all the contact list"""
161 gp_idx = 0 161 gp_idx = 0
162 if not indexes: #this is a new group, we have to create it 162 if not indexes: #this is a new group, we have to create it
163 gp_idx = self.Append(self.__presentGroup(group), Group(group)) 163 gp_idx = self.Append(self.__presentGroup(group), Group(group))
164 else: 164 else:
165 gp_idx = indexes[0] 165 gp_idx = indexes[0]
166 166
167 _present = self.__presentItem(contact) 167 _present = self.__presentItem(contact)
168 if _present: 168 if _present:
169 self.Insert(_present, gp_idx+1, contact) 169 self.Insert(_present, gp_idx+1, contact)
170 170
171 def setSpecial(self, special_jid, special_type): 171 def setSpecial(self, special_jid, special_type):
197 self.SetSelection(wx.NOT_FOUND) 197 self.SetSelection(wx.NOT_FOUND)
198 self.ScrollToLine(first_visible) 198 self.ScrollToLine(first_visible)
199 event.Skip(False) 199 event.Skip(False)
200 else: 200 else:
201 event.Skip() 201 event.Skip()
202 202
203 def onActivated(self, event): 203 def onActivated(self, event):
204 """Called when a contact is clicked or activated with keyboard.""" 204 """Called when a contact is clicked or activated with keyboard."""
205 data = self.getSelection() 205 data = self.getSelection()
206 self.onActivatedCB(data) 206 self.onActivatedCB(data)
207 event.Skip() 207 event.Skip()