Daniel Brötzmann pushed to branch gtk4 at gajim / gajim
Commits:
1187c9f7 by wurstsalat at 2024-11-14T21:43:12+01:00
refactor: ChatStack: Restore primary clipboard after switching chats
- - - - -
1 changed file:
- gajim/gtk/chat_stack.py
Changes:
=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -162,11 +162,8 @@ def get_message_input(self) -> MessageInputTextView:
def show_chat(self, account: str, jid: JID) -> None:
# Store (preserve) primary clipboard and restore it after switching
- # clipboard = self.get_primary_clipboard() TODO GTK4
- # provider = clipboard.get_content()
- # if provider is not None:
- # _, val = provider.get_value()
- # old_primary_clipboard = val
+ clipboard = self.get_primary_clipboard()
+ clipboard.read_text_async(None,
self._on_primary_clipboard_read_text_finished)
self._last_quoted_id = None
@@ -244,14 +241,22 @@ def show_chat(self, account: str, jid: JID) -> None:
app.plugin_manager.extension_point("switch_contact",
self._current_contact)
- # if old_primary_clipboard is not None: TODO GTK4
- # GLib.idle_add(clipboard.set_text,
- # old_primary_clipboard,
- # -1)
-
# TODO GTK4: This creates a loop raising CPU load
# GLib.idle_add(self._message_action_box.msg_textview.grab_focus)
+ def _on_primary_clipboard_read_text_finished(
+ self,
+ clipboard: Gdk.Clipboard,
+ result: Gio.AsyncResult,
+ ) -> None:
+ text = clipboard.read_text_finish(result)
+ if text is None:
+ return
+
+ # Reset primary clipboard to what it was before switching chats,
+ # otherwise it gets overridden.
+ clipboard.set(text)
+
def _on_room_password_required(
self, _contact: GroupchatContact, _signal_name: str
) -> None:
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/1187c9f7c0906d60bb26e29517dd6410b63d1935
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/1187c9f7c0906d60bb26e29517dd6410b63d1935
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]