Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits: cb37eae0 by lovetox at 2021-03-06T13:36:12+01:00 Dont show empty groups when filtering - - - - - 1 changed file: - gajim/gtk/roster.py Changes: ===================================== gajim/gtk/roster.py ===================================== @@ -80,7 +80,7 @@ def __init__(self, account): ]) self._modelfilter = self._store.filter_new() - self._modelfilter.set_visible_func(self._visible_func) + self._modelfilter.set_visible_column(Column.VISIBLE) self._filter_enabled = False self._filter_string = '' @@ -145,7 +145,7 @@ def _on_theme_update(self, _event): def _on_show_offline(self, action, param): action.set_state(param) app.settings.set('showoffline', param.get_boolean()) - self._draw_contacts() + self._refilter() def _on_contact_info(self, _action, param): app.window.contact_info(self._account, param.get_string()) @@ -213,7 +213,7 @@ def _show_contact_menu(self, jid, treeview, event): def set_search_string(self, text): self._filter_string = text self._filter_enabled = bool(text) - self._draw_contacts() + self._refilter() def _get_contact_visible(self, contact): if self._filter_enabled: @@ -227,20 +227,6 @@ def _get_contact_visible(self, contact): return True - def _visible_func(self, model, iter_, _data): - visible = model[iter_][Column.VISIBLE] - is_contact = model[iter_][Column.IS_CONTACT] - name = model[iter_][Column.TEXT] - - if not is_contact: - # Always show groups - return True - - if self._filter_enabled: - return self._filter_string in name.lower() - - return visible - def set_model(self): self._roster.set_model(self._modelfilter) @@ -261,10 +247,6 @@ def enable_sort(self, enable): self._store.set_sort_column_id(column, Gtk.SortType.ASCENDING) - def invalidate_sort(self): - self.enable_sort(False) - self.enable_sort(True) - def _initial_draw(self): for contact in self._client.get_module('Roster').iter_contacts(): contact.connect('presence-update', self._on_presence_update) @@ -387,11 +369,18 @@ def _draw_group(self, group_name): group_name += f' ({group_users}/{total_users})' self._store[group_iter][Column.TEXT] = group_name - self._store[group_iter][Column.VISIBLE] = True - def _draw_contacts(self): - for jid in self._contact_refs: - self._draw_contact(self._get_contact(jid)) + def _refilter(self): + for group in self._store: + group_is_visible = False + for child in group.iterchildren(): + contact = self._get_contact(child[Column.JID_OR_GROUP]) + is_visible = self._get_contact_visible(contact) + child[Column.VISIBLE] = is_visible + if is_visible: + group_is_visible = True + + group[Column.VISIBLE] = group_is_visible self._roster.expand_all() def _draw_contact(self, contact): @@ -406,8 +395,6 @@ def _draw_contact_row(self, ref, contact): if jid_is_blocked(self._account, contact.jid): name = f'<span strikethrough="true">{name}</span>' self._store[iter_][Column.TEXT] = name - visible = self._get_contact_visible(contact) - self._store[iter_][Column.VISIBLE] = visible surface = contact.get_avatar( AvatarSize.ROSTER, self.get_scale_factor()) View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/cb37eae0dd53c7166a7097b35432f7ecaa8669fd -- View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/cb37eae0dd53c7166a7097b35432f7ecaa8669fd You're receiving this email because of your account on dev.gajim.org.
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits