Philipp Hörist pushed to branch refactor_view at gajim / gajim
Commits:
-
8e88bb56
by Philipp Hörist at 2022-09-18T22:24:15+02:00
-
7ab50205
by Philipp Hörist at 2022-09-18T22:24:15+02:00
6 changed files:
- gajim/data/other/shortcuts.json
- gajim/gtk/const.py
- gajim/gtk/control.py
- − gajim/gtk/conversation/scrolled.py
- gajim/gtk/conversation/view.py
- gajim/gtk/message_actions_box.py
Changes:
| ... | ... | @@ -37,5 +37,7 @@ |
| 37 | 37 | "win.switch-workspace-7": ["<Primary>7", "<Primary>KP_7"],
|
| 38 | 38 | "win.switch-workspace-8": ["<Primary>8", "<Primary>KP_8"],
|
| 39 | 39 | "win.switch-workspace-9": ["<Primary>9", "<Primary>KP_9"],
|
| 40 | - "win.toggle-chat-list": ["<Primary>R"]
|
|
| 40 | + "win.toggle-chat-list": ["<Primary>R"],
|
|
| 41 | + "win.scroll-view-up": ["<Shift>Page_Up"],
|
|
| 42 | + "win.scroll-view-down": ["<Shift>Page_Down"]
|
|
| 41 | 43 | } |
| ... | ... | @@ -214,6 +214,8 @@ def __str__(self): |
| 214 | 214 | ('muc-change-role', 'as', False),
|
| 215 | 215 | ('muc-change-affiliation', 'as', False),
|
| 216 | 216 | ('muc-request-voice', None, False),
|
| 217 | + ('scroll-view-up', None, True),
|
|
| 218 | + ('scroll-view-down', None, True),
|
|
| 217 | 219 | ]
|
| 218 | 220 | |
| 219 | 221 |
| ... | ... | @@ -48,8 +48,8 @@ |
| 48 | 48 | from gajim.common.modules.contacts import GroupchatContact
|
| 49 | 49 | from gajim.common.modules.httpupload import HTTPFileTransfer
|
| 50 | 50 | from gajim.common.storage.archive import ConversationRow
|
| 51 | +from gajim.gtk.conversation.view import ConversationView
|
|
| 51 | 52 | |
| 52 | -from gajim.gui.conversation.scrolled import ScrolledView
|
|
| 53 | 53 | from gajim.gui.conversation.jump_to_end_button import JumpToEndButton
|
| 54 | 54 | from gajim.gui.builder import get_builder
|
| 55 | 55 | from gajim.gui.groupchat_roster import GroupchatRoster
|
| ... | ... | @@ -69,15 +69,13 @@ def __init__(self) -> None: |
| 69 | 69 | |
| 70 | 70 | self._ui = get_builder('chat_control.ui')
|
| 71 | 71 | |
| 72 | - self._scrolled_view = ScrolledView()
|
|
| 72 | + self._scrolled_view = ConversationView()
|
|
| 73 | 73 | self._scrolled_view.connect('autoscroll-changed',
|
| 74 | 74 | self._on_autoscroll_changed)
|
| 75 | 75 | self._scrolled_view.connect('request-history',
|
| 76 | 76 | self._fetch_n_lines_history, 20)
|
| 77 | 77 | self._ui.conv_view_overlay.add(self._scrolled_view)
|
| 78 | 78 | |
| 79 | - self.conversation_view = self._scrolled_view.get_view()
|
|
| 80 | - |
|
| 81 | 79 | self._groupchat_state = GroupchatState()
|
| 82 | 80 | self._ui.conv_view_overlay.add_overlay(self._groupchat_state)
|
| 83 | 81 | |
| ... | ... | @@ -136,7 +134,6 @@ def clear(self) -> None: |
| 136 | 134 | |
| 137 | 135 | self._contact = None
|
| 138 | 136 | self._client = None
|
| 139 | - self.reset_view()
|
|
| 140 | 137 | self._scrolled_view.clear()
|
| 141 | 138 | self._groupchat_state.clear()
|
| 142 | 139 | self._roster.clear()
|
| ... | ... | @@ -199,7 +196,7 @@ def switch_contact(self, contact: Union[BareContact, |
| 199 | 196 | muc_data = self._client.get_module('MUC').get_muc_data(
|
| 200 | 197 | str(contact.jid))
|
| 201 | 198 | if muc_data is not None and muc_data.subject is not None:
|
| 202 | - self.conversation_view.add_muc_subject(
|
|
| 199 | + self._scrolled_view.add_muc_subject(
|
|
| 203 | 200 | muc_data.subject, muc_data.last_subject_timestamp)
|
| 204 | 201 | |
| 205 | 202 | def _register_events(self) -> None:
|
| ... | ... | @@ -245,9 +242,9 @@ def _on_presence_received(self, event: events.PresenceReceived) -> None: |
| 245 | 242 | contact = self.client.get_module('Contacts').get_contact(event.fjid)
|
| 246 | 243 | if isinstance(contact, BareContact):
|
| 247 | 244 | return
|
| 248 | - self.conversation_view.add_user_status(self.contact.name,
|
|
| 249 | - contact.show.value,
|
|
| 250 | - contact.status)
|
|
| 245 | + self._scrolled_view.add_user_status(self.contact.name,
|
|
| 246 | + contact.show.value,
|
|
| 247 | + contact.status)
|
|
| 251 | 248 | |
| 252 | 249 | def _on_message_sent(self, event: events.MessageSent) -> None:
|
| 253 | 250 | if not self._is_event_processable(event):
|
| ... | ... | @@ -267,7 +264,7 @@ def _on_message_sent(self, event: events.MessageSent) -> None: |
| 267 | 264 | displaymarking = None
|
| 268 | 265 | |
| 269 | 266 | if event.correct_id:
|
| 270 | - self.conversation_view.correct_message(
|
|
| 267 | + self._scrolled_view.correct_message(
|
|
| 271 | 268 | event.correct_id, event.message, self.get_our_nick())
|
| 272 | 269 | return
|
| 273 | 270 | |
| ... | ... | @@ -363,7 +360,7 @@ def _on_message_updated(self, event: events.MessageUpdated) -> None: |
| 363 | 360 | if not self._is_event_processable(event):
|
| 364 | 361 | return
|
| 365 | 362 | |
| 366 | - self.conversation_view.correct_message(
|
|
| 363 | + self._scrolled_view.correct_message(
|
|
| 367 | 364 | event.correct_id, event.msgtxt, event.nickname)
|
| 368 | 365 | |
| 369 | 366 | def _on_message_moderated(self, event: events.MessageModerated) -> None:
|
| ... | ... | @@ -374,32 +371,32 @@ def _on_message_moderated(self, event: events.MessageModerated) -> None: |
| 374 | 371 | self.contact.account,
|
| 375 | 372 | event.moderation.moderator_jid,
|
| 376 | 373 | event.moderation.reason)
|
| 377 | - self.conversation_view.show_message_retraction(
|
|
| 374 | + self._scrolled_view.show_message_retraction(
|
|
| 378 | 375 | event.moderation.stanza_id, text)
|
| 379 | 376 | |
| 380 | 377 | def _on_receipt_received(self, event: events.ReceiptReceived) -> None:
|
| 381 | 378 | if not self._is_event_processable(event):
|
| 382 | 379 | return
|
| 383 | 380 | |
| 384 | - self.conversation_view.show_receipt(event.receipt_id)
|
|
| 381 | + self._scrolled_view.show_receipt(event.receipt_id)
|
|
| 385 | 382 | |
| 386 | 383 | def _on_displayed_received(self, event: events.DisplayedReceived) -> None:
|
| 387 | 384 | if not self._is_event_processable(event):
|
| 388 | 385 | return
|
| 389 | 386 | |
| 390 | - self.conversation_view.set_read_marker(event.marker_id)
|
|
| 387 | + self._scrolled_view.set_read_marker(event.marker_id)
|
|
| 391 | 388 | |
| 392 | 389 | def _on_message_error(self, event: events.MessageError) -> None:
|
| 393 | 390 | if not self._is_event_processable(event):
|
| 394 | 391 | return
|
| 395 | 392 | |
| 396 | - self.conversation_view.show_error(event.message_id, event.error)
|
|
| 393 | + self._scrolled_view.show_error(event.message_id, event.error)
|
|
| 397 | 394 | |
| 398 | 395 | def _on_call_stopped(self, event: events.CallStopped) -> None:
|
| 399 | 396 | if not self._is_event_processable(event):
|
| 400 | 397 | return
|
| 401 | 398 | |
| 402 | - self.conversation_view.update_call_rows()
|
|
| 399 | + self._scrolled_view.update_call_rows()
|
|
| 403 | 400 | |
| 404 | 401 | def _on_jingle_request_received(self,
|
| 405 | 402 | event: events.JingleRequestReceived
|
| ... | ... | @@ -439,7 +436,7 @@ def mark_as_read(self, send_marker: bool = True) -> None: |
| 439 | 436 | self._jump_to_end_button.reset_unread_count()
|
| 440 | 437 | |
| 441 | 438 | def _on_autoscroll_changed(self,
|
| 442 | - _widget: ScrolledView,
|
|
| 439 | + _widget: ConversationView,
|
|
| 443 | 440 | autoscroll: bool
|
| 444 | 441 | ) -> None:
|
| 445 | 442 | |
| ... | ... | @@ -480,17 +477,17 @@ def _allow_add_message(self) -> bool: |
| 480 | 477 | return self._scrolled_view.get_lower_complete()
|
| 481 | 478 | |
| 482 | 479 | def add_command_output(self, text: str, is_error: bool) -> None:
|
| 483 | - self.conversation_view.add_command_output(text, is_error)
|
|
| 480 | + self._scrolled_view.add_command_output(text, is_error)
|
|
| 484 | 481 | |
| 485 | 482 | def add_info_message(self,
|
| 486 | 483 | text: str,
|
| 487 | 484 | timestamp: Optional[float] = None
|
| 488 | 485 | ) -> None:
|
| 489 | 486 | |
| 490 | - self.conversation_view.add_info_message(text, timestamp)
|
|
| 487 | + self._scrolled_view.add_info_message(text, timestamp)
|
|
| 491 | 488 | |
| 492 | 489 | def add_file_transfer(self, transfer: HTTPFileTransfer) -> None:
|
| 493 | - self.conversation_view.add_file_transfer(transfer)
|
|
| 490 | + self._scrolled_view.add_file_transfer(transfer)
|
|
| 494 | 491 | |
| 495 | 492 | def add_jingle_file_transfer(self,
|
| 496 | 493 | event: Union[
|
| ... | ... | @@ -499,11 +496,11 @@ def add_jingle_file_transfer(self, |
| 499 | 496 | None]
|
| 500 | 497 | ) -> None:
|
| 501 | 498 | if self._allow_add_message():
|
| 502 | - self.conversation_view.add_jingle_file_transfer(event)
|
|
| 499 | + self._scrolled_view.add_jingle_file_transfer(event)
|
|
| 503 | 500 | |
| 504 | 501 | def add_call_message(self, event: events.JingleRequestReceived) -> None:
|
| 505 | 502 | if self._allow_add_message():
|
| 506 | - self.conversation_view.add_call_message(event=event)
|
|
| 503 | + self._scrolled_view.add_call_message(event=event)
|
|
| 507 | 504 | |
| 508 | 505 | def _add_message(self,
|
| 509 | 506 | text: str,
|
| ... | ... | @@ -521,7 +518,7 @@ def _add_message(self, |
| 521 | 518 | additional_data = AdditionalDataDict()
|
| 522 | 519 | |
| 523 | 520 | if self._allow_add_message():
|
| 524 | - self.conversation_view.add_message(
|
|
| 521 | + self._scrolled_view.add_message(
|
|
| 525 | 522 | text,
|
| 526 | 523 | kind,
|
| 527 | 524 | name,
|
| ... | ... | @@ -547,7 +544,7 @@ def get_autoscroll(self) -> bool: |
| 547 | 544 | return self._scrolled_view.get_autoscroll()
|
| 548 | 545 | |
| 549 | 546 | def scroll_to_message(self, log_line_id: int, timestamp: float) -> None:
|
| 550 | - row = self.conversation_view.get_row_by_log_line_id(log_line_id)
|
|
| 547 | + row = self._scrolled_view.get_row_by_log_line_id(log_line_id)
|
|
| 551 | 548 | if row is None:
|
| 552 | 549 | # Clear view and reload conversation around timestamp
|
| 553 | 550 | self._scrolled_view.block_signals(True)
|
| ... | ... | @@ -558,7 +555,7 @@ def scroll_to_message(self, log_line_id: int, timestamp: float) -> None: |
| 558 | 555 | self.add_messages(at_after)
|
| 559 | 556 | |
| 560 | 557 | GLib.idle_add(
|
| 561 | - self.conversation_view.scroll_to_message_and_highlight,
|
|
| 558 | + self._scrolled_view.scroll_to_message_and_highlight,
|
|
| 562 | 559 | log_line_id)
|
| 563 | 560 | GLib.idle_add(self._scrolled_view.block_signals, False)
|
| 564 | 561 | |
| ... | ... | @@ -571,9 +568,9 @@ def _fetch_n_lines_history(self, |
| 571 | 568 | self._scrolled_view.block_signals(True)
|
| 572 | 569 | |
| 573 | 570 | if before:
|
| 574 | - row = self.conversation_view.get_first_message_row()
|
|
| 571 | + row = self._scrolled_view.get_first_message_row()
|
|
| 575 | 572 | else:
|
| 576 | - row = self.conversation_view.get_last_message_row()
|
|
| 573 | + row = self._scrolled_view.get_last_message_row()
|
|
| 577 | 574 | |
| 578 | 575 | if row is None:
|
| 579 | 576 | timestamp = time.time()
|
| ... | ... | @@ -598,7 +595,7 @@ def _fetch_n_lines_history(self, |
| 598 | 595 | self._scrolled_view.set_history_complete(before, True)
|
| 599 | 596 | |
| 600 | 597 | # if self._scrolled_view.get_autoscroll():
|
| 601 | - # if self.conversation_view.reduce_message_count(before):
|
|
| 598 | + # if self._scrolled_view.reduce_message_count(before):
|
|
| 602 | 599 | # self._scrolled_view.set_history_complete(before, False)
|
| 603 | 600 | |
| 604 | 601 | assert self._contact is not None
|
| ... | ... | @@ -645,13 +642,13 @@ def add_messages(self, messages: list[ConversationRow]): |
| 645 | 642 | if msg.kind in (KindConstant.FILE_TRANSFER_INCOMING,
|
| 646 | 643 | KindConstant.FILE_TRANSFER_OUTGOING):
|
| 647 | 644 | if msg.additional_data.get_value('gajim', 'type') == 'jingle':
|
| 648 | - self.conversation_view.add_jingle_file_transfer(
|
|
| 645 | + self._scrolled_view.add_jingle_file_transfer(
|
|
| 649 | 646 | db_message=msg)
|
| 650 | 647 | continue
|
| 651 | 648 | |
| 652 | 649 | if msg.kind in (KindConstant.CALL_INCOMING,
|
| 653 | 650 | KindConstant.CALL_OUTGOING):
|
| 654 | - self.conversation_view.add_call_message(db_message=msg)
|
|
| 651 | + self._scrolled_view.add_call_message(db_message=msg)
|
|
| 655 | 652 | continue
|
| 656 | 653 | |
| 657 | 654 | if not msg.message:
|
| ... | ... | @@ -683,7 +680,7 @@ def add_messages(self, messages: list[ConversationRow]): |
| 683 | 680 | message_text = get_retraction_text(
|
| 684 | 681 | self.contact.account, retracted_by, reason)
|
| 685 | 682 | |
| 686 | - self.conversation_view.add_message(
|
|
| 683 | + self._scrolled_view.add_message(
|
|
| 687 | 684 | message_text,
|
| 688 | 685 | kind,
|
| 689 | 686 | contact_name,
|
| ... | ... | @@ -1041,7 +1038,7 @@ def _process_muc_user_joined(self, event: events.MUCUserJoined) -> None: |
| 1041 | 1038 | |
| 1042 | 1039 | if not event.is_self:
|
| 1043 | 1040 | if self.contact.is_joined:
|
| 1044 | - self.conversation_view.add_muc_user_joined(event)
|
|
| 1041 | + self._scrolled_view.add_muc_user_joined(event)
|
|
| 1045 | 1042 | return
|
| 1046 | 1043 | |
| 1047 | 1044 | status_codes = event.status_codes or []
|
| ... | ... | @@ -1083,7 +1080,7 @@ def _process_muc_user_left(self, event: events.MUCUserLeft) -> None: |
| 1083 | 1080 | |
| 1084 | 1081 | if StatusCode.REMOVED_ERROR in status_codes:
|
| 1085 | 1082 | # Handle 333 before 307, some MUCs add both
|
| 1086 | - self.conversation_view.add_muc_user_left(event, error=True)
|
|
| 1083 | + self._scrolled_view.add_muc_user_left(event, error=True)
|
|
| 1087 | 1084 | return
|
| 1088 | 1085 | |
| 1089 | 1086 | reason = event.reason
|
| ... | ... | @@ -1118,7 +1115,7 @@ def _process_muc_user_left(self, event: events.MUCUserLeft) -> None: |
| 1118 | 1115 | message = message.format(nick=nick, by=actor, reason=reason)
|
| 1119 | 1116 | |
| 1120 | 1117 | else:
|
| 1121 | - self.conversation_view.add_muc_user_left(event)
|
|
| 1118 | + self._scrolled_view.add_muc_user_left(event)
|
|
| 1122 | 1119 | return
|
| 1123 | 1120 | |
| 1124 | 1121 | self.add_info_message(message, event.timestamp)
|
| ... | ... | @@ -1158,4 +1155,4 @@ def _on_room_subject(self, |
| 1158 | 1155 | |
| 1159 | 1156 | if (app.settings.get('show_subject_on_join') or
|
| 1160 | 1157 | not contact.is_joining):
|
| 1161 | - self.conversation_view.add_muc_subject(subject) |
|
| 1158 | + self._scrolled_view.add_muc_subject(subject) |
| 1 | -# This file is part of Gajim.
|
|
| 2 | -#
|
|
| 3 | -# Gajim is free software; you can redistribute it and/or modify
|
|
| 4 | -# it under the terms of the GNU General Public License as published
|
|
| 5 | -# by the Free Software Foundation; version 3 only.
|
|
| 6 | -#
|
|
| 7 | -# Gajim is distributed in the hope that it will be useful,
|
|
| 8 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 9 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 10 | -# GNU General Public License for more details.
|
|
| 11 | -#
|
|
| 12 | -# You should have received a copy of the GNU General Public License
|
|
| 13 | -# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
| 14 | - |
|
| 15 | -from __future__ import annotations
|
|
| 16 | - |
|
| 17 | -from typing import Any
|
|
| 18 | -from typing import Optional
|
|
| 19 | - |
|
| 20 | -from gi.repository import Gtk
|
|
| 21 | -from gi.repository import GObject
|
|
| 22 | - |
|
| 23 | -from gajim.common.types import ChatContactT
|
|
| 24 | - |
|
| 25 | -from .view import ConversationView
|
|
| 26 | - |
|
| 27 | - |
|
| 28 | -class ScrolledView(Gtk.ScrolledWindow):
|
|
| 29 | - |
|
| 30 | - __gsignals__ = {
|
|
| 31 | - 'request-history': (
|
|
| 32 | - GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION,
|
|
| 33 | - None,
|
|
| 34 | - (bool, )
|
|
| 35 | - ),
|
|
| 36 | - 'autoscroll-changed': (
|
|
| 37 | - GObject.SignalFlags.RUN_LAST,
|
|
| 38 | - None,
|
|
| 39 | - (bool,)
|
|
| 40 | - )
|
|
| 41 | - }
|
|
| 42 | - |
|
| 43 | - def __init__(self) -> None:
|
|
| 44 | - Gtk.ScrolledWindow.__init__(self)
|
|
| 45 | - |
|
| 46 | - self.set_overlay_scrolling(False)
|
|
| 47 | - self.get_style_context().add_class('scrolled-no-border')
|
|
| 48 | - self.get_style_context().add_class('no-scroll-indicator')
|
|
| 49 | - self.get_style_context().add_class('scrollbar-style')
|
|
| 50 | - self.set_shadow_type(Gtk.ShadowType.IN)
|
|
| 51 | - self.set_vexpand(True)
|
|
| 52 | - |
|
| 53 | - self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
|
| 54 | - |
|
| 55 | - # This is a workaround: as soon as a line break occurs in Gtk.TextView
|
|
| 56 | - # with word-char wrapping enabled, a hyphen character is automatically
|
|
| 57 | - # inserted before the line break. This triggers the hscrollbar to show,
|
|
| 58 | - # see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2384
|
|
| 59 | - # Using set_hscroll_policy(Gtk.Scrollable.Policy.NEVER) would cause bad
|
|
| 60 | - # performance during resize, and prevent the window from being shrunk
|
|
| 61 | - # horizontally under certain conditions (applies to GroupchatControl)
|
|
| 62 | - self.get_hscrollbar().hide()
|
|
| 63 | - |
|
| 64 | - self._current_upper: float = 0
|
|
| 65 | - self._autoscroll: bool = True
|
|
| 66 | - self._request_history_at_upper: Optional[float] = None
|
|
| 67 | - self._upper_complete: bool = False
|
|
| 68 | - self._lower_complete: bool = False
|
|
| 69 | - self._requesting: Optional[str] = None
|
|
| 70 | - self._block_signals = False
|
|
| 71 | - |
|
| 72 | - vadjustment = self.get_vadjustment()
|
|
| 73 | - vadjustment.connect('notify::upper', self._on_adj_upper_changed)
|
|
| 74 | - vadjustment.connect('notify::value', self._on_adj_value_changed)
|
|
| 75 | - |
|
| 76 | - self._view = ConversationView()
|
|
| 77 | - self.add(self._view)
|
|
| 78 | - self.set_focus_vadjustment(Gtk.Adjustment())
|
|
| 79 | - |
|
| 80 | - def clear(self) -> None:
|
|
| 81 | - self._block_signals = True
|
|
| 82 | - self._reset()
|
|
| 83 | - self._view.clear()
|
|
| 84 | - |
|
| 85 | - def switch_contact(self, contact: ChatContactT) -> None:
|
|
| 86 | - self._block_signals = True
|
|
| 87 | - self._reset()
|
|
| 88 | - self._view.switch_contact(contact)
|
|
| 89 | - self._block_signals = False
|
|
| 90 | - self._emit('request-history', True)
|
|
| 91 | - |
|
| 92 | - def get_autoscroll(self) -> bool:
|
|
| 93 | - return self._autoscroll
|
|
| 94 | - |
|
| 95 | - def get_view(self) -> ConversationView:
|
|
| 96 | - return self._view
|
|
| 97 | - |
|
| 98 | - def block_signals(self, value: bool) -> None:
|
|
| 99 | - self._block_signals = value
|
|
| 100 | - |
|
| 101 | - def _emit(self, signal_name: str, *args: Any) -> None:
|
|
| 102 | - if not self._block_signals:
|
|
| 103 | - self.emit(signal_name, *args)
|
|
| 104 | - |
|
| 105 | - def _reset(self) -> None:
|
|
| 106 | - self._current_upper = 0
|
|
| 107 | - self._request_history_at_upper = None
|
|
| 108 | - self._upper_complete = False
|
|
| 109 | - self._lower_complete = False
|
|
| 110 | - self._requesting = None
|
|
| 111 | - self.set_history_complete(True, False)
|
|
| 112 | - |
|
| 113 | - def reset(self) -> None:
|
|
| 114 | - self._reset()
|
|
| 115 | - self._view.reset()
|
|
| 116 | - |
|
| 117 | - def set_history_complete(self, before: bool, complete: bool) -> None:
|
|
| 118 | - if before:
|
|
| 119 | - self._upper_complete = complete
|
|
| 120 | - self._view.set_history_complete(complete)
|
|
| 121 | - else:
|
|
| 122 | - self._lower_complete = complete
|
|
| 123 | - |
|
| 124 | - def get_lower_complete(self) -> bool:
|
|
| 125 | - return self._lower_complete
|
|
| 126 | - |
|
| 127 | - def _on_adj_upper_changed(self,
|
|
| 128 | - adj: Gtk.Adjustment,
|
|
| 129 | - _pspec: GObject.ParamSpec) -> None:
|
|
| 130 | - |
|
| 131 | - upper = adj.get_upper()
|
|
| 132 | - diff = upper - self._current_upper
|
|
| 133 | - |
|
| 134 | - if diff != 0:
|
|
| 135 | - self._current_upper = upper
|
|
| 136 | - if self._autoscroll:
|
|
| 137 | - adj.set_value(adj.get_upper() - adj.get_page_size())
|
|
| 138 | - else:
|
|
| 139 | - # Workaround
|
|
| 140 | - # https://gitlab.gnome.org/GNOME/gtk/merge_requests/395
|
|
| 141 | - self.set_kinetic_scrolling(True)
|
|
| 142 | - if self._requesting == 'before':
|
|
| 143 | - adj.set_value(adj.get_value() + diff)
|
|
| 144 | - |
|
| 145 | - if upper == adj.get_page_size():
|
|
| 146 | - # There is no scrollbar
|
|
| 147 | - if not self._block_signals:
|
|
| 148 | - self._emit('request-history', True)
|
|
| 149 | - self._lower_complete = True
|
|
| 150 | - self._autoscroll = True
|
|
| 151 | - self._emit('autoscroll-changed', self._autoscroll)
|
|
| 152 | - |
|
| 153 | - self._requesting = None
|
|
| 154 | - |
|
| 155 | - def _on_adj_value_changed(self,
|
|
| 156 | - adj: Gtk.Adjustment,
|
|
| 157 | - _pspec: GObject.ParamSpec) -> None:
|
|
| 158 | - |
|
| 159 | - if self._requesting is not None:
|
|
| 160 | - return
|
|
| 161 | - |
|
| 162 | - bottom = adj.get_upper() - adj.get_page_size()
|
|
| 163 | - if (bottom - adj.get_value()) < 1:
|
|
| 164 | - self._autoscroll = True
|
|
| 165 | - self._emit('autoscroll-changed', self._autoscroll)
|
|
| 166 | - else:
|
|
| 167 | - self._autoscroll = False
|
|
| 168 | - self._emit('autoscroll-changed', self._autoscroll)
|
|
| 169 | - |
|
| 170 | - if self._upper_complete:
|
|
| 171 | - self._request_history_at_upper = None
|
|
| 172 | - if self._lower_complete:
|
|
| 173 | - return
|
|
| 174 | - |
|
| 175 | - if self._request_history_at_upper == adj.get_upper():
|
|
| 176 | - # Abort here if we already did a history request and the upper
|
|
| 177 | - # did not change. This can happen if we scroll very fast and the
|
|
| 178 | - # value changes while the request has not been fulfilled.
|
|
| 179 | - return
|
|
| 180 | - |
|
| 181 | - self._request_history_at_upper = None
|
|
| 182 | - |
|
| 183 | - distance = adj.get_page_size() * 2
|
|
| 184 | - if adj.get_value() < distance:
|
|
| 185 | - # Load messages when we are near the top
|
|
| 186 | - if self._upper_complete:
|
|
| 187 | - return
|
|
| 188 | - self._request_history_at_upper = adj.get_upper()
|
|
| 189 | - # Workaround: https://gitlab.gnome.org/GNOME/gtk/merge_requests/395
|
|
| 190 | - self.set_kinetic_scrolling(False)
|
|
| 191 | - if not self._block_signals:
|
|
| 192 | - self._emit('request-history', True)
|
|
| 193 | - self._requesting = 'before'
|
|
| 194 | - elif (adj.get_upper() - (adj.get_value() + adj.get_page_size()) <
|
|
| 195 | - distance):
|
|
| 196 | - # ..or near the bottom
|
|
| 197 | - if self._lower_complete:
|
|
| 198 | - return
|
|
| 199 | - # Workaround: https://gitlab.gnome.org/GNOME/gtk/merge_requests/395
|
|
| 200 | - self.set_kinetic_scrolling(False)
|
|
| 201 | - if not self._block_signals:
|
|
| 202 | - self._emit('request-history', False)
|
|
| 203 | - self._requesting = 'after' |
| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | from __future__ import annotations
|
| 16 | 16 | |
| 17 | 17 | from typing import Any
|
| 18 | +from typing import Literal
|
|
| 18 | 19 | from typing import Optional
|
| 19 | 20 | from typing import Union
|
| 20 | 21 | from typing import Generator
|
| ... | ... | @@ -28,6 +29,8 @@ |
| 28 | 29 | |
| 29 | 30 | from gi.repository import GLib
|
| 30 | 31 | from gi.repository import Gtk
|
| 32 | +from gi.repository import GObject
|
|
| 33 | +from gi.repository import Gio
|
|
| 31 | 34 | |
| 32 | 35 | from nbxmpp.errors import StanzaError
|
| 33 | 36 | from nbxmpp.modules.security_labels import Displaymarking
|
| ... | ... | @@ -64,13 +67,47 @@ |
| 64 | 67 | log = logging.getLogger('gajim.gui.conversation_view')
|
| 65 | 68 | |
| 66 | 69 | |
| 67 | -class ConversationView(Gtk.ListBox):
|
|
| 68 | - def __init__(self) -> None:
|
|
| 69 | - Gtk.ListBox.__init__(self)
|
|
| 70 | - self.set_selection_mode(Gtk.SelectionMode.NONE)
|
|
| 71 | - self.set_sort_func(self._sort_func)
|
|
| 70 | +class ConversationView(Gtk.ScrolledWindow):
|
|
| 72 | 71 | |
| 73 | - self._contact = None
|
|
| 72 | + __gsignals__ = {
|
|
| 73 | + 'request-history': (
|
|
| 74 | + GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION,
|
|
| 75 | + None,
|
|
| 76 | + (bool, )
|
|
| 77 | + ),
|
|
| 78 | + 'autoscroll-changed': (
|
|
| 79 | + GObject.SignalFlags.RUN_LAST,
|
|
| 80 | + None,
|
|
| 81 | + (bool,)
|
|
| 82 | + )
|
|
| 83 | + }
|
|
| 84 | + |
|
| 85 | + def __init__(self) -> None:
|
|
| 86 | + Gtk.ScrolledWindow.__init__(self)
|
|
| 87 | + |
|
| 88 | + self.set_overlay_scrolling(False)
|
|
| 89 | + self.get_style_context().add_class('scrolled-no-border')
|
|
| 90 | + self.get_style_context().add_class('no-scroll-indicator')
|
|
| 91 | + self.get_style_context().add_class('scrollbar-style')
|
|
| 92 | + self.set_shadow_type(Gtk.ShadowType.IN)
|
|
| 93 | + self.set_vexpand(True)
|
|
| 94 | + |
|
| 95 | + self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
|
| 96 | + |
|
| 97 | + # This is a workaround: as soon as a line break occurs in Gtk.TextView
|
|
| 98 | + # with word-char wrapping enabled, a hyphen character is automatically
|
|
| 99 | + # inserted before the line break. This triggers the hscrollbar to show,
|
|
| 100 | + # see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2384
|
|
| 101 | + # Using set_hscroll_policy(Gtk.Scrollable.Policy.NEVER) would cause bad
|
|
| 102 | + # performance during resize, and prevent the window from being shrunk
|
|
| 103 | + # horizontally under certain conditions (applies to GroupchatControl)
|
|
| 104 | + self.get_hscrollbar().hide()
|
|
| 105 | + |
|
| 106 | + self._list_box = Gtk.ListBox()
|
|
| 107 | + self._list_box.set_selection_mode(Gtk.SelectionMode.NONE)
|
|
| 108 | + self._list_box.set_sort_func(self._sort_func)
|
|
| 109 | + |
|
| 110 | + self._contact: Optional[ChatContactT] = None
|
|
| 74 | 111 | self._client = None
|
| 75 | 112 | |
| 76 | 113 | # Keeps track of the number of rows shown in ConversationView
|
| ... | ... | @@ -86,24 +123,70 @@ def __init__(self) -> None: |
| 86 | 123 | self._read_marker_row = None
|
| 87 | 124 | self._scroll_hint_row = None
|
| 88 | 125 | |
| 89 | - @property
|
|
| 90 | - def contact(self) -> types.ChatContactT:
|
|
| 91 | - assert self._contact is not None
|
|
| 92 | - return self._contact
|
|
| 126 | + self._current_upper: float = 0
|
|
| 127 | + self._autoscroll: bool = True
|
|
| 128 | + self._request_history_at_upper: Optional[float] = None
|
|
| 129 | + self._upper_complete: bool = False
|
|
| 130 | + self._lower_complete: bool = True
|
|
| 131 | + self._requesting: Optional[str] = None
|
|
| 132 | + self._block_signals = False
|
|
| 93 | 133 | |
| 94 | - def clear(self) -> None:
|
|
| 95 | - self._contact = None
|
|
| 96 | - self._client = None
|
|
| 134 | + self._signal_handlers_enabled = False
|
|
| 135 | + self._signal_handler_ids = (0, 0)
|
|
| 136 | + |
|
| 137 | + self.add(self._list_box)
|
|
| 138 | + self.set_focus_vadjustment(Gtk.Adjustment())
|
|
| 139 | + |
|
| 140 | + app.window.get_action('scroll-view-up').connect(
|
|
| 141 | + 'activate', self._on_scroll_view)
|
|
| 142 | + app.window.get_action('scroll-view-down').connect(
|
|
| 143 | + 'activate', self._on_scroll_view)
|
|
| 144 | + |
|
| 145 | + def _on_scroll_view(self,
|
|
| 146 | + action: Gio.SimpleAction,
|
|
| 147 | + _param: Literal[None]) -> None:
|
|
| 148 | + |
|
| 149 | + action_name = action.get_name()
|
|
| 150 | + if action_name == 'scroll-view-down':
|
|
| 151 | + self.emit('scroll-child', Gtk.ScrollType.PAGE_DOWN, False)
|
|
| 97 | 152 | |
| 153 | + elif action_name == 'scroll-view-up':
|
|
| 154 | + self.emit('scroll-child', Gtk.ScrollType.PAGE_UP, False)
|
|
| 155 | + |
|
| 156 | + def _enable_signal_handlers(self, enable: bool) -> None:
|
|
| 157 | + if self._signal_handlers_enabled == enable:
|
|
| 158 | + return
|
|
| 159 | + |
|
| 160 | + vadjustment = self.get_vadjustment()
|
|
| 161 | + |
|
| 162 | + if enable:
|
|
| 163 | + upper_id = vadjustment.connect('notify::upper',
|
|
| 164 | + self._on_adj_upper_changed)
|
|
| 165 | + value_id = vadjustment.connect('notify::value',
|
|
| 166 | + self._on_adj_value_changed)
|
|
| 167 | + self._signal_handler_ids = (upper_id, value_id)
|
|
| 168 | + else:
|
|
| 169 | + upper_id, value_id = self._signal_handler_ids
|
|
| 170 | + vadjustment.disconnect(upper_id)
|
|
| 171 | + vadjustment.disconnect(value_id)
|
|
| 172 | + |
|
| 173 | + self._signal_handlers_enabled = enable
|
|
| 174 | + |
|
| 175 | + def clear(self) -> None:
|
|
| 98 | 176 | app.settings.disconnect_signals(self)
|
| 177 | + self._enable_signal_handlers(False)
|
|
| 178 | + self._reset()
|
|
| 99 | 179 | |
| 100 | - self.reset()
|
|
| 180 | + self._contact = None
|
|
| 181 | + self._client = None
|
|
| 101 | 182 | |
| 102 | 183 | def switch_contact(self, contact: ChatContactT) -> None:
|
| 103 | 184 | self._contact = contact
|
| 104 | 185 | self._client = app.get_client(contact.account)
|
| 105 | 186 | |
| 106 | - self.reset()
|
|
| 187 | + self._enable_signal_handlers(False)
|
|
| 188 | + self._block_signals = True
|
|
| 189 | + self._reset()
|
|
| 107 | 190 | |
| 108 | 191 | app.settings.disconnect_signals(self)
|
| 109 | 192 | |
| ... | ... | @@ -117,11 +200,30 @@ def switch_contact(self, contact: ChatContactT) -> None: |
| 117 | 200 | account=contact.account,
|
| 118 | 201 | jid=contact.jid)
|
| 119 | 202 | |
| 120 | - def get_row_at_index(self, index: int) -> BaseRow:
|
|
| 121 | - return cast(BaseRow, Gtk.ListBox.get_row_at_index(self, index))
|
|
| 203 | + self._block_signals = False
|
|
| 204 | + self._enable_signal_handlers(True)
|
|
| 205 | + self._emit('request-history', True)
|
|
| 122 | 206 | |
| 123 | - def reset(self) -> None:
|
|
| 124 | - for row in self.get_children():
|
|
| 207 | + def get_autoscroll(self) -> bool:
|
|
| 208 | + return self._autoscroll
|
|
| 209 | + |
|
| 210 | + def block_signals(self, value: bool) -> None:
|
|
| 211 | + self._block_signals = value
|
|
| 212 | + |
|
| 213 | + def _emit(self, signal_name: str, *args: Any) -> None:
|
|
| 214 | + if not self._block_signals:
|
|
| 215 | + log.debug('emit %s, %s', signal_name, args)
|
|
| 216 | + self.emit(signal_name, *args)
|
|
| 217 | + |
|
| 218 | + def _reset(self) -> None:
|
|
| 219 | + self._current_upper = 0
|
|
| 220 | + self._request_history_at_upper = None
|
|
| 221 | + self._upper_complete = False
|
|
| 222 | + self._lower_complete = True
|
|
| 223 | + self._requesting = None
|
|
| 224 | + self.set_history_complete(True, False)
|
|
| 225 | + |
|
| 226 | + for row in self._list_box.get_children():
|
|
| 125 | 227 | row.destroy()
|
| 126 | 228 | |
| 127 | 229 | self._row_count = 0
|
| ... | ... | @@ -134,30 +236,125 @@ def reset(self) -> None: |
| 134 | 236 | # These need to be present if ConversationView is reset
|
| 135 | 237 | # without switch_contact being invoked
|
| 136 | 238 | self._read_marker_row = ReadMarkerRow(self._contact)
|
| 137 | - self.add(self._read_marker_row)
|
|
| 239 | + self._list_box.add(self._read_marker_row)
|
|
| 138 | 240 | |
| 139 | 241 | self._scroll_hint_row = ScrollHintRow(self._contact.account)
|
| 140 | - self.add(self._scroll_hint_row)
|
|
| 242 | + self._list_box.add(self._scroll_hint_row)
|
|
| 243 | + |
|
| 244 | + def reset(self) -> None:
|
|
| 245 | + assert self._contact is not None
|
|
| 246 | + self.switch_contact(self._contact)
|
|
| 247 | + |
|
| 248 | + def set_history_complete(self, before: bool, complete: bool) -> None:
|
|
| 249 | + if before:
|
|
| 250 | + self._upper_complete = complete
|
|
| 251 | + if self._scroll_hint_row is None:
|
|
| 252 | + return
|
|
| 253 | + self._scroll_hint_row.set_history_complete(complete)
|
|
| 254 | + else:
|
|
| 255 | + self._lower_complete = complete
|
|
| 256 | + |
|
| 257 | + def get_lower_complete(self) -> bool:
|
|
| 258 | + return self._lower_complete
|
|
| 259 | + |
|
| 260 | + def _on_adj_upper_changed(self,
|
|
| 261 | + adj: Gtk.Adjustment,
|
|
| 262 | + _pspec: GObject.ParamSpec) -> None:
|
|
| 263 | + |
|
| 264 | + upper = adj.get_upper()
|
|
| 265 | + diff = upper - self._current_upper
|
|
| 266 | + |
|
| 267 | + if diff != 0:
|
|
| 268 | + self._current_upper = upper
|
|
| 269 | + if self._autoscroll:
|
|
| 270 | + adj.set_value(adj.get_upper() - adj.get_page_size())
|
|
| 271 | + else:
|
|
| 272 | + # Workaround
|
|
| 273 | + # https://gitlab.gnome.org/GNOME/gtk/merge_requests/395
|
|
| 274 | + self.set_kinetic_scrolling(True)
|
|
| 275 | + if self._requesting == 'before':
|
|
| 276 | + adj.set_value(adj.get_value() + diff)
|
|
| 277 | + |
|
| 278 | + if upper == adj.get_page_size():
|
|
| 279 | + # There is no scrollbar
|
|
| 280 | + if not self._block_signals:
|
|
| 281 | + self._emit('request-history', True)
|
|
| 282 | + self._lower_complete = True
|
|
| 283 | + self._autoscroll = True
|
|
| 284 | + self._emit('autoscroll-changed', self._autoscroll)
|
|
| 285 | + |
|
| 286 | + self._requesting = None
|
|
| 287 | + |
|
| 288 | + def _on_adj_value_changed(self,
|
|
| 289 | + adj: Gtk.Adjustment,
|
|
| 290 | + _pspec: GObject.ParamSpec) -> None:
|
|
| 291 | + |
|
| 292 | + if self._requesting is not None:
|
|
| 293 | + return
|
|
| 294 | + |
|
| 295 | + bottom = adj.get_upper() - adj.get_page_size()
|
|
| 296 | + |
|
| 297 | + self._autoscroll = bottom - adj.get_value() < 1
|
|
| 298 | + self._emit('autoscroll-changed', self._autoscroll)
|
|
| 299 | + |
|
| 300 | + if self._upper_complete:
|
|
| 301 | + self._request_history_at_upper = None
|
|
| 302 | + if self._lower_complete:
|
|
| 303 | + return
|
|
| 304 | + |
|
| 305 | + if self._request_history_at_upper == adj.get_upper():
|
|
| 306 | + # Abort here if we already did a history request and the upper
|
|
| 307 | + # did not change. This can happen if we scroll very fast and the
|
|
| 308 | + # value changes while the request has not been fulfilled.
|
|
| 309 | + return
|
|
| 310 | + |
|
| 311 | + self._request_history_at_upper = None
|
|
| 312 | + |
|
| 313 | + distance = adj.get_page_size() * 2
|
|
| 314 | + if adj.get_value() < distance:
|
|
| 315 | + # Load messages when we are near the top
|
|
| 316 | + if self._upper_complete:
|
|
| 317 | + return
|
|
| 318 | + self._request_history_at_upper = adj.get_upper()
|
|
| 319 | + # Workaround: https://gitlab.gnome.org/GNOME/gtk/merge_requests/395
|
|
| 320 | + self.set_kinetic_scrolling(False)
|
|
| 321 | + if not self._block_signals:
|
|
| 322 | + self._emit('request-history', True)
|
|
| 323 | + self._requesting = 'before'
|
|
| 324 | + |
|
| 325 | + elif (adj.get_upper() - (adj.get_value() + adj.get_page_size()) <
|
|
| 326 | + distance):
|
|
| 327 | + # ..or near the bottom
|
|
| 328 | + if self._lower_complete:
|
|
| 329 | + return
|
|
| 330 | + # Workaround: https://gitlab.gnome.org/GNOME/gtk/merge_requests/395
|
|
| 331 | + self.set_kinetic_scrolling(False)
|
|
| 332 | + if not self._block_signals:
|
|
| 333 | + self._emit('request-history', False)
|
|
| 334 | + self._requesting = 'after'
|
|
| 335 | + |
|
| 336 | + @property
|
|
| 337 | + def contact(self) -> types.ChatContactT:
|
|
| 338 | + assert self._contact is not None
|
|
| 339 | + return self._contact
|
|
| 340 | + |
|
| 341 | + def _get_row_at_index(self, index: int) -> BaseRow:
|
|
| 342 | + return cast(BaseRow, self._list_box.get_row_at_index(index))
|
|
| 141 | 343 | |
| 142 | 344 | def get_first_message_row(self) -> Optional[MessageRow]:
|
| 143 | - for row in self.get_children():
|
|
| 345 | + for row in self._list_box.get_children():
|
|
| 144 | 346 | if isinstance(row, MessageRow):
|
| 145 | 347 | return row
|
| 146 | 348 | return None
|
| 147 | 349 | |
| 148 | 350 | def get_last_message_row(self) -> Optional[MessageRow]:
|
| 149 | - children = self.get_children()
|
|
| 351 | + children = self._list_box.get_children()
|
|
| 150 | 352 | children.reverse()
|
| 151 | 353 | for row in children:
|
| 152 | 354 | if isinstance(row, MessageRow):
|
| 153 | 355 | return row
|
| 154 | 356 | return None
|
| 155 | 357 | |
| 156 | - def set_history_complete(self, complete: bool) -> None:
|
|
| 157 | - if self._scroll_hint_row is None:
|
|
| 158 | - return
|
|
| 159 | - self._scroll_hint_row.set_history_complete(complete)
|
|
| 160 | - |
|
| 161 | 358 | @staticmethod
|
| 162 | 359 | def _sort_func(row1: BaseRow, row2: BaseRow) -> int:
|
| 163 | 360 | if row1.timestamp == row2.timestamp:
|
| ... | ... | @@ -293,7 +490,7 @@ def add_message(self, |
| 293 | 490 | self._insert_message(message_row)
|
| 294 | 491 | |
| 295 | 492 | def _insert_message(self, message: BaseRow) -> None:
|
| 296 | - self.add(message)
|
|
| 493 | + self._list_box.add(message)
|
|
| 297 | 494 | self._add_date_row(message.timestamp)
|
| 298 | 495 | self._check_for_merge(message)
|
| 299 | 496 | assert self._read_marker_row is not None
|
| ... | ... | @@ -311,9 +508,9 @@ def _add_date_row(self, timestamp: datetime) -> None: |
| 311 | 508 | |
| 312 | 509 | date_row = DateRow(self.contact.account, start_of_day)
|
| 313 | 510 | self._active_date_rows.add(start_of_day)
|
| 314 | - self.add(date_row)
|
|
| 511 | + self._list_box.add(date_row)
|
|
| 315 | 512 | |
| 316 | - row = self.get_row_at_index(date_row.get_index() + 1)
|
|
| 513 | + row = self._get_row_at_index(date_row.get_index() + 1)
|
|
| 317 | 514 | if row is None:
|
| 318 | 515 | return
|
| 319 | 516 | |
| ... | ... | @@ -340,7 +537,7 @@ def _find_ancestor(self, message: MessageRow) -> Optional[MessageRow]: |
| 340 | 537 | index = message.get_index()
|
| 341 | 538 | while index != 0:
|
| 342 | 539 | index -= 1
|
| 343 | - row = self.get_row_at_index(index)
|
|
| 540 | + row = self._get_row_at_index(index)
|
|
| 344 | 541 | if row is None:
|
| 345 | 542 | return None
|
| 346 | 543 | |
| ... | ... | @@ -361,7 +558,7 @@ def _update_descendants(self, message: MessageRow) -> None: |
| 361 | 558 | index = message.get_index()
|
| 362 | 559 | while True:
|
| 363 | 560 | index += 1
|
| 364 | - row = self.get_row_at_index(index)
|
|
| 561 | + row = self._get_row_at_index(index)
|
|
| 365 | 562 | if row is None:
|
| 366 | 563 | return
|
| 367 | 564 | |
| ... | ... | @@ -382,7 +579,7 @@ def _update_descendants(self, message: MessageRow) -> None: |
| 382 | 579 | |
| 383 | 580 | def reduce_message_count(self, before: bool) -> bool:
|
| 384 | 581 | success = False
|
| 385 | - row_count = len(self.get_children())
|
|
| 582 | + row_count = len(self._list_box.get_children())
|
|
| 386 | 583 | while row_count > self._max_row_count:
|
| 387 | 584 | if before:
|
| 388 | 585 | if self._reduce_messages_before():
|
| ... | ... | @@ -399,8 +596,8 @@ def _reduce_messages_before(self) -> bool: |
| 399 | 596 | success = False
|
| 400 | 597 | |
| 401 | 598 | # We want to keep relevant DateRows when removing rows
|
| 402 | - row1 = self.get_row_at_index(2)
|
|
| 403 | - row2 = self.get_row_at_index(3)
|
|
| 599 | + row1 = self._get_row_at_index(2)
|
|
| 600 | + row2 = self._get_row_at_index(3)
|
|
| 404 | 601 | |
| 405 | 602 | if row1.type == 'date' and row2.type == 'date':
|
| 406 | 603 | # First two rows are date rows,
|
| ... | ... | @@ -422,12 +619,12 @@ def _reduce_messages_before(self) -> bool: |
| 422 | 619 | return success
|
| 423 | 620 | |
| 424 | 621 | def _reduce_messages_after(self) -> None:
|
| 425 | - row = self.get_row_at_index(len(self.get_children()) - 1)
|
|
| 622 | + row = self._get_row_at_index(len(self._list_box.get_children()) - 1)
|
|
| 426 | 623 | row.destroy()
|
| 427 | 624 | |
| 428 | 625 | def scroll_to_message_and_highlight(self, log_line_id: int) -> None:
|
| 429 | 626 | highlight_row = None
|
| 430 | - for row in cast(list[BaseRow], self.get_children()):
|
|
| 627 | + for row in cast(list[BaseRow], self._list_box.get_children()):
|
|
| 431 | 628 | row.get_style_context().remove_class(
|
| 432 | 629 | 'conversation-search-highlight')
|
| 433 | 630 | if row.log_line_id == log_line_id:
|
| ... | ... | @@ -443,7 +640,7 @@ def _get_row_by_message_id(self, id_: str) -> Optional[MessageRow]: |
| 443 | 640 | return self._message_id_row_map.get(id_)
|
| 444 | 641 | |
| 445 | 642 | def get_row_by_log_line_id(self, log_line_id: int) -> Optional[MessageRow]:
|
| 446 | - for row in cast(list[BaseRow], self.get_children()):
|
|
| 643 | + for row in cast(list[BaseRow], self._list_box.get_children()):
|
|
| 447 | 644 | if not isinstance(row, MessageRow):
|
| 448 | 645 | continue
|
| 449 | 646 | if row.log_line_id == log_line_id:
|
| ... | ... | @@ -451,7 +648,7 @@ def get_row_by_log_line_id(self, log_line_id: int) -> Optional[MessageRow]: |
| 451 | 648 | return None
|
| 452 | 649 | |
| 453 | 650 | def get_row_by_stanza_id(self, stanza_id: str) -> Optional[MessageRow]:
|
| 454 | - for row in cast(list[BaseRow], self.get_children()):
|
|
| 651 | + for row in cast(list[BaseRow], self._list_box.get_children()):
|
|
| 455 | 652 | if not isinstance(row, MessageRow):
|
| 456 | 653 | continue
|
| 457 | 654 | if row.stanza_id == stanza_id:
|
| ... | ... | @@ -459,7 +656,7 @@ def get_row_by_stanza_id(self, stanza_id: str) -> Optional[MessageRow]: |
| 459 | 656 | return None
|
| 460 | 657 | |
| 461 | 658 | def iter_rows(self) -> Generator[BaseRow, None, None]:
|
| 462 | - for row in cast(list[BaseRow], self.get_children()):
|
|
| 659 | + for row in cast(list[BaseRow], self._list_box.get_children()):
|
|
| 463 | 660 | yield row
|
| 464 | 661 | |
| 465 | 662 | def remove_rows_by_type(self, row_type: str) -> None:
|
| ... | ... | @@ -468,7 +665,7 @@ def remove_rows_by_type(self, row_type: str) -> None: |
| 468 | 665 | row.destroy()
|
| 469 | 666 | |
| 470 | 667 | def update_call_rows(self) -> None:
|
| 471 | - for row in cast(list[BaseRow], self.get_children()):
|
|
| 668 | + for row in cast(list[BaseRow], self._list_box.get_children()):
|
|
| 472 | 669 | if isinstance(row, CallRow):
|
| 473 | 670 | row.update()
|
| 474 | 671 | |
| ... | ... | @@ -489,7 +686,7 @@ def set_read_marker(self, id_: str) -> None: |
| 489 | 686 | self._read_marker_row.set_timestamp(timestamp)
|
| 490 | 687 | |
| 491 | 688 | def update_avatars(self) -> None:
|
| 492 | - for row in cast(list[BaseRow], self.get_children()):
|
|
| 689 | + for row in cast(list[BaseRow], self._list_box.get_children()):
|
|
| 493 | 690 | if isinstance(row, MessageRow):
|
| 494 | 691 | row.update_avatar()
|
| 495 | 692 | |
| ... | ... | @@ -538,5 +735,5 @@ def _on_contact_setting_changed(self, |
| 538 | 735 | self.remove_rows_by_type('muc-user-status')
|
| 539 | 736 | |
| 540 | 737 | def remove(self, widget: Gtk.Widget) -> None:
|
| 541 | - super().remove(widget)
|
|
| 738 | + self._list_box.remove(widget)
|
|
| 542 | 739 | widget.destroy() |
| ... | ... | @@ -515,12 +515,6 @@ def _on_msg_textview_key_press_event(self, |
| 515 | 515 | Direction.PREV, unread_first=True)
|
| 516 | 516 | return True
|
| 517 | 517 | |
| 518 | - if event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up):
|
|
| 519 | - control = app.window.get_control()
|
|
| 520 | - if control.has_active_chat():
|
|
| 521 | - control.conversation_view.event(event)
|
|
| 522 | - return True
|
|
| 523 | - |
|
| 524 | 518 | if event_state & Gdk.ModifierType.CONTROL_MASK:
|
| 525 | 519 | if event.keyval == Gdk.KEY_Tab:
|
| 526 | 520 | app.window.select_next_chat(Direction.NEXT, unread_first=True)
|