Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
1c98f8e2 by wurstsalat at 2024-06-17T22:38:20+02:00
imprv: ConversationView: Use better method for scrolling to row
This method makes sure to always center the highlighted row withing the view.
Fixes #11094 and #11840
- - - - -
1 changed file:
- gajim/gtk/conversation/view.py
Changes:
=====================================
gajim/gtk/conversation/view.py
=====================================
@@ -689,15 +689,26 @@ def scroll_to_message_and_highlight(self, pk: int) ->
None:
highlight_row = row
break
- if highlight_row is not None:
- highlight_row.get_style_context().remove_class(
- 'conversation-row-highlight')
- highlight_row.get_style_context().add_class(
- 'conversation-row-highlight')
- # This scrolls the ListBox to the highlighted row
- highlight_row.grab_focus()
-
- GLib.timeout_add(1500, self._remove_highligh_class, highlight_row)
+ if highlight_row is None:
+ return
+
+ # Scroll ListBox to row and highlight it
+ coordinates = highlight_row.translate_coordinates(self._list_box, 0, 0)
+ if coordinates is None:
+ return
+
+ _x_coord, y_coord = coordinates
+ _minimum_height, natural_height = highlight_row.get_preferred_height()
+ adjustment = self._list_box.get_adjustment()
+ adjustment.set_value(
+ y_coord - (adjustment.get_page_size() - natural_height) / 2)
+
+ highlight_row.get_style_context().remove_class(
+ 'conversation-row-highlight')
+ highlight_row.get_style_context().add_class(
+ 'conversation-row-highlight')
+
+ GLib.timeout_add(1500, self._remove_highligh_class, highlight_row)
def _remove_highligh_class(self, highlight_row: BaseRow) -> None:
highlight_row.get_style_context().remove_class(
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/1c98f8e2583a85b88ed2a7c82f41334fec3a38ee
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/1c98f8e2583a85b88ed2a7c82f41334fec3a38ee
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]