Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2023-11-14 23:06:58 +0300
committerPhilipp Hörist <philipp@hoerist.com>2023-11-14 23:06:58 +0300
commite21fe0558de49425573fd3bf72386af73f6af3fc (patch)
treeb19b26ba8b36b8d611b1b7e99fd78231dd108df8 /gajim/gtk/conversation/view.py
parentf6cfa352d2a32fe2b5311f735a6c836ebe62770c (diff)
feat: Add shortcuts for quoting previous messages
Diffstat (limited to 'gajim/gtk/conversation/view.py')
-rw-r--r--gajim/gtk/conversation/view.py49
1 files changed, 47 insertions, 2 deletions
diff --git a/gajim/gtk/conversation/view.py b/gajim/gtk/conversation/view.py
index d7cc32dff..fdbe85e4b 100644
--- a/gajim/gtk/conversation/view.py
+++ b/gajim/gtk/conversation/view.py
@@ -37,6 +37,7 @@ from nbxmpp.structs import MucSubject
from gajim.common import app
from gajim.common import events
from gajim.common import types
+from gajim.common.const import Direction
from gajim.common.helpers import AdditionalDataDict
from gajim.common.helpers import get_start_of_day
from gajim.common.helpers import to_user_string
@@ -390,8 +391,7 @@ class ConversationView(Gtk.ScrolledWindow):
return None
def get_last_message_row(self) -> MessageRow | None:
- children = self._list_box.get_children()
- children.reverse()
+ children = reversed(self._list_box.get_children())
for row in children:
if isinstance(row, MessageRow):
return row
@@ -710,6 +710,51 @@ class ConversationView(Gtk.ScrolledWindow):
def _get_row_by_message_id(self, id_: str) -> MessageRow | None:
return self._message_id_row_map.get(id_)
+ def _get_message_row_by_direction(
+ self,
+ log_line_id: int,
+ direction: Direction | None = None
+ ) -> MessageRow | None:
+
+ row = self.get_row_by_log_line_id(log_line_id)
+ if row is None:
+ return None
+
+ if direction is None:
+ return row
+
+ index = row.get_index()
+ while True:
+ if direction == Direction.PREV:
+ index -= 1
+ else:
+ index += 1
+
+ row = self._list_box.get_row_at_index(index)
+ if row is None:
+ return None
+
+ if isinstance(row, MessageRow):
+ return row
+
+ def get_prev_message_row(
+ self,
+ log_line_id: int | None
+ ) -> MessageRow | None:
+ if log_line_id is None:
+ return self.get_last_message_row()
+ return self._get_message_row_by_direction(
+ log_line_id, direction=Direction.PREV)
+
+ def get_next_message_row(
+ self,
+ log_line_id: int | None
+ ) -> MessageRow | None:
+ if log_line_id is None:
+ return None
+ return self._get_message_row_by_direction(
+ log_line_id, direction=Direction.NEXT)
+
def get_row_by_log_line_id(self, log_line_id: int) -> MessageRow | None:
for row in cast(list[BaseRow], self._list_box.get_children()):
if not isinstance(row, MessageRow):