| ... |
... |
@@ -80,7 +80,7 @@ def __init__(self, account): |
|
80
|
80
|
])
|
|
81
|
81
|
|
|
82
|
82
|
self._modelfilter = self._store.filter_new()
|
|
83
|
|
- self._modelfilter.set_visible_func(self._visible_func)
|
|
|
83
|
+ self._modelfilter.set_visible_column(Column.VISIBLE)
|
|
84
|
84
|
self._filter_enabled = False
|
|
85
|
85
|
self._filter_string = ''
|
|
86
|
86
|
|
| ... |
... |
@@ -145,7 +145,7 @@ def _on_theme_update(self, _event): |
|
145
|
145
|
def _on_show_offline(self, action, param):
|
|
146
|
146
|
action.set_state(param)
|
|
147
|
147
|
app.settings.set('showoffline', param.get_boolean())
|
|
148
|
|
- self._draw_contacts()
|
|
|
148
|
+ self._refilter()
|
|
149
|
149
|
|
|
150
|
150
|
def _on_contact_info(self, _action, param):
|
|
151
|
151
|
app.window.contact_info(self._account, param.get_string())
|
| ... |
... |
@@ -213,7 +213,7 @@ def _show_contact_menu(self, jid, treeview, event): |
|
213
|
213
|
def set_search_string(self, text):
|
|
214
|
214
|
self._filter_string = text
|
|
215
|
215
|
self._filter_enabled = bool(text)
|
|
216
|
|
- self._draw_contacts()
|
|
|
216
|
+ self._refilter()
|
|
217
|
217
|
|
|
218
|
218
|
def _get_contact_visible(self, contact):
|
|
219
|
219
|
if self._filter_enabled:
|
| ... |
... |
@@ -227,20 +227,6 @@ def _get_contact_visible(self, contact): |
|
227
|
227
|
|
|
228
|
228
|
return True
|
|
229
|
229
|
|
|
230
|
|
- def _visible_func(self, model, iter_, _data):
|
|
231
|
|
- visible = model[iter_][Column.VISIBLE]
|
|
232
|
|
- is_contact = model[iter_][Column.IS_CONTACT]
|
|
233
|
|
- name = model[iter_][Column.TEXT]
|
|
234
|
|
-
|
|
235
|
|
- if not is_contact:
|
|
236
|
|
- # Always show groups
|
|
237
|
|
- return True
|
|
238
|
|
-
|
|
239
|
|
- if self._filter_enabled:
|
|
240
|
|
- return self._filter_string in name.lower()
|
|
241
|
|
-
|
|
242
|
|
- return visible
|
|
243
|
|
-
|
|
244
|
230
|
def set_model(self):
|
|
245
|
231
|
self._roster.set_model(self._modelfilter)
|
|
246
|
232
|
|
| ... |
... |
@@ -261,10 +247,6 @@ def enable_sort(self, enable): |
|
261
|
247
|
|
|
262
|
248
|
self._store.set_sort_column_id(column, Gtk.SortType.ASCENDING)
|
|
263
|
249
|
|
|
264
|
|
- def invalidate_sort(self):
|
|
265
|
|
- self.enable_sort(False)
|
|
266
|
|
- self.enable_sort(True)
|
|
267
|
|
-
|
|
268
|
250
|
def _initial_draw(self):
|
|
269
|
251
|
for contact in self._client.get_module('Roster').iter_contacts():
|
|
270
|
252
|
contact.connect('presence-update', self._on_presence_update)
|
| ... |
... |
@@ -387,11 +369,18 @@ def _draw_group(self, group_name): |
|
387
|
369
|
group_name += f' ({group_users}/{total_users})'
|
|
388
|
370
|
|
|
389
|
371
|
self._store[group_iter][Column.TEXT] = group_name
|
|
390
|
|
- self._store[group_iter][Column.VISIBLE] = True
|
|
391
|
372
|
|
|
392
|
|
- def _draw_contacts(self):
|
|
393
|
|
- for jid in self._contact_refs:
|
|
394
|
|
- self._draw_contact(self._get_contact(jid))
|
|
|
373
|
+ def _refilter(self):
|
|
|
374
|
+ for group in self._store:
|
|
|
375
|
+ group_is_visible = False
|
|
|
376
|
+ for child in group.iterchildren():
|
|
|
377
|
+ contact = self._get_contact(child[Column.JID_OR_GROUP])
|
|
|
378
|
+ is_visible = self._get_contact_visible(contact)
|
|
|
379
|
+ child[Column.VISIBLE] = is_visible
|
|
|
380
|
+ if is_visible:
|
|
|
381
|
+ group_is_visible = True
|
|
|
382
|
+
|
|
|
383
|
+ group[Column.VISIBLE] = group_is_visible
|
|
395
|
384
|
self._roster.expand_all()
|
|
396
|
385
|
|
|
397
|
386
|
def _draw_contact(self, contact):
|
| ... |
... |
@@ -406,8 +395,6 @@ def _draw_contact_row(self, ref, contact): |
|
406
|
395
|
if jid_is_blocked(self._account, contact.jid):
|
|
407
|
396
|
name = f'<span strikethrough="true">{name}</span>'
|
|
408
|
397
|
self._store[iter_][Column.TEXT] = name
|
|
409
|
|
- visible = self._get_contact_visible(contact)
|
|
410
|
|
- self._store[iter_][Column.VISIBLE] = visible
|
|
411
|
398
|
|
|
412
|
399
|
surface = contact.get_avatar(
|
|
413
|
400
|
AvatarSize.ROSTER, self.get_scale_factor())
|