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

Commits:

1 changed file:

Changes:

  • gajim/gtk/chat_stack.py
    ... ... @@ -20,6 +20,7 @@
    20 20
     import sys
    
    21 21
     import logging
    
    22 22
     
    
    23
    +from gi.repository import Gdk
    
    23 24
     from gi.repository import GLib
    
    24 25
     from gi.repository import Gio
    
    25 26
     from gi.repository import Gtk
    
    ... ... @@ -97,6 +98,10 @@ def get_control_stack(self) -> ControlStack:
    97 98
             return self._control_stack
    
    98 99
     
    
    99 100
         def show_chat(self, account: str, jid: JID) -> None:
    
    101
    +        # Store (preserve) primary clipboard and restore it after switching
    
    102
    +        clipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
    
    103
    +        old_primary_clipboard = clipboard.wait_for_text()
    
    104
    +
    
    100 105
             if self._current_contact is not None:
    
    101 106
                 self._current_contact.disconnect_all_from_obj(self)
    
    102 107
     
    
    ... ... @@ -151,6 +156,10 @@ def show_chat(self, account: str, jid: JID) -> None:
    151 156
     
    
    152 157
             self.set_transition_type(Gtk.StackTransitionType.NONE)
    
    153 158
             self.set_visible_child_name('controls')
    
    159
    +
    
    160
    +        if old_primary_clipboard is not None:
    
    161
    +            GLib.idle_add(clipboard.set_text, old_primary_clipboard, -1)
    
    162
    +
    
    154 163
             GLib.idle_add(self._message_action_box.msg_textview.grab_focus)
    
    155 164
     
    
    156 165
         def _on_room_password_required(self,