Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits: f2f6eb1a by lovetox at 2021-02-07T15:24:23+01:00 Sort with activity
- - - - -
1 changed file:
- gajim/gtk/chat_list.py
Changes:
===================================== gajim/gtk/chat_list.py ===================================== @@ -27,6 +27,7 @@ def __init__(self, workspace_id):
self.get_style_context().add_class('chatlist') self.set_filter_func(self._filter_func) + self.set_sort_func(self._sort_func) self.set_has_tooltip(True)
self.connect('destroy', self._on_destroy) @@ -91,6 +92,12 @@ def _filter_func(self, row): return True return self._current_filter_text in row.jid
+ @staticmethod + def _sort_func(row1, row2): + if row1.is_recent == row2.is_recent: + return 0 + return -1 if row1.is_recent else 1 + def set_filter_text(self, text): self._current_filter_text = text self.invalidate_filter() @@ -278,6 +285,12 @@ def is_active(self): return (self.is_selected() and self.get_toplevel().get_property('is-active'))
+ @property + def is_recent(self): + if self._unread_count: + return True + return False + def _on_state_flags_changed(self, _listboxrow, *args): state = self.get_state_flags() if (state & Gtk.StateFlags.PRELIGHT) != 0: @@ -304,8 +317,12 @@ def add_unread(self): if self.is_active: return self.unread_count += 1 + if self.unread_count == 1: + self.changed()
def reset_unread(self): + if not self.unread_count: + return self.unread_count = 0
def set_last_message_text(self, nickname, text):
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/f2f6eb1aa935375ab3b7fbcefcab8c908...