Philipp Hörist pushed to branch master at gajim / gajim
Commits:
cb62d049 by Philipp Hörist at 2025-03-21T22:04:58+01:00
fix: ChatList: Make sure chatlist sorts always after pin/unpin
- - - - -
3 changed files:
- gajim/gtk/chat_list.py
- gajim/gtk/chat_list_row.py
- gajim/gtk/widgets.py
Changes:
=====================================
gajim/gtk/chat_list.py
=====================================
@@ -70,7 +70,6 @@ def __init__(self, workspace_id: str) -> None:
self._rows_need_sort = False
self._context_menu_visible = False
self._mouseover = False
- self._pinned_order_change = False
hover_controller = Gtk.EventControllerMotion()
self._connect(hover_controller, "enter", self._on_cursor_enter)
@@ -189,7 +188,7 @@ def toggle_chat_pinned(self, account: str, jid: JID) ->
None:
row.position = self._chat_order.index(row)
row.toggle_pinned()
- self.invalidate_sort()
+ self.invalidate_sort(force=True)
def add_chat(
self,
@@ -414,9 +413,7 @@ def _change_pinned_order(
row.position = self._chat_order.index(row)
self.emit("chat-order-changed")
- self._pinned_order_change = True
- self.invalidate_sort()
- self._pinned_order_change = False
+ self.invalidate_sort(force=True)
def _update_row_state(self) -> bool:
for row in self._chats.values():
@@ -488,8 +485,8 @@ def _sort_func(self, row1: ChatListRow, row2: ChatListRow)
-> int:
# Sort by timestamp
return -1 if row1.timestamp > row2.timestamp else 1
- def invalidate_sort(self) -> None:
- if self._is_sort_inhibited():
+ def invalidate_sort(self, *, force: bool = False) -> None:
+ if not force and self._is_sort_inhibited():
return
self._rows_need_sort = False
@@ -497,8 +494,6 @@ def invalidate_sort(self) -> None:
Gtk.ListBox.invalidate_sort(self)
def _is_sort_inhibited(self) -> bool:
- if self._pinned_order_change:
- return False
return self._mouseover or self._context_menu_visible
def _schedule_check_sort_inhibit(self) -> None:
=====================================
gajim/gtk/chat_list_row.py
=====================================
@@ -101,6 +101,7 @@ def __init__(
self._connect(self._ui.close_button, "clicked",
self._on_close_button_clicked)
self._menu_popover = GajimPopover(None)
+ self._connect(self._menu_popover, "closed",
self._on_context_popover_closed)
self._ui.mainbox.append(self._menu_popover)
self._connect(self, "state-flags-changed",
self._on_state_flags_changed)
@@ -448,6 +449,7 @@ def do_unroot(self) -> None:
if isinstance(self.contact, GroupchatParticipant):
self.contact.room.disconnect_all_from_obj(self)
+ del self._menu_popover
Gtk.ListBoxRow.do_unroot(self)
app.check_finalize(self)
@@ -480,7 +482,6 @@ def _raise_context_popover(self, x: float, y: float):
self._menu_popover.set_menu_model(menu)
self._menu_popover.set_pointing_to_coord(x=x, y=y)
- self._connect(self._menu_popover, "closed",
self._on_context_popover_closed)
self.emit("context-menu-state-changed", True)
self._menu_popover.popup()
=====================================
gajim/gtk/widgets.py
=====================================
@@ -324,3 +324,7 @@ def set_pointing_from_event(self, event: Any) -> None:
def set_pointing_to_coord(self, x: float, y: float) -> None:
rectangle = GdkRectangle(x=int(x), y=int(y))
self.set_pointing_to(rectangle)
+
+ def do_unroot(self) -> None:
+ Gtk.PopoverMenu.do_unroot(self)
+ app.check_finalize(self)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/cb62d049f9cdc2678835ad9b43aeb7dfee60619c
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/cb62d049f9cdc2678835ad9b43aeb7dfee60619c
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]