Daniel Brötzmann pushed to branch newcontrol at gajim / gajim


Commits:
ae457655 by wurstsalat at 2022-07-23T21:59:56+02:00
fix: Preserve primary clipboard throughout switching chats

- - - - -


1 changed file:

- gajim/gtk/chat_stack.py


Changes:

=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -20,6 +20,7 @@
 import sys
 import logging
 
+from gi.repository import Gdk
 from gi.repository import GLib
 from gi.repository import Gio
 from gi.repository import Gtk
@@ -97,6 +98,10 @@ def get_control_stack(self) -> ControlStack:
         return self._control_stack
 
     def show_chat(self, account: str, jid: JID) -> None:
+        # Store (preserve) primary clipboard and restore it after switching
+        clipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
+        old_primary_clipboard = clipboard.wait_for_text()
+
         if self._current_contact is not None:
             self._current_contact.disconnect_all_from_obj(self)
 
@@ -151,6 +156,10 @@ def show_chat(self, account: str, jid: JID) -> None:
 
         self.set_transition_type(Gtk.StackTransitionType.NONE)
         self.set_visible_child_name('controls')
+
+        if old_primary_clipboard is not None:
+            GLib.idle_add(clipboard.set_text, old_primary_clipboard, -1)
+
         GLib.idle_add(self._message_action_box.msg_textview.grab_focus)
 
     def _on_room_password_required(self,



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/ae45765584c4a0ff321ea37aef49a92c8158e93a

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/ae45765584c4a0ff321ea37aef49a92c8158e93a
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to