Philipp Hörist pushed to branch master at gajim / gajim

Commits:

1 changed file:

Changes:

  • gajim/chat_control_base.py
    ... ... @@ -540,14 +540,27 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    540 540
             id_ = item.connect('activate', self.msg_textview.clear)
    
    541 541
             self.handlers[id_] = item
    
    542 542
     
    
    543
    +        paste_item = Gtk.MenuItem.new_with_label(_('Paste as quote'))
    
    544
    +        id_ = paste_item.connect('activate', self.paste_clipboard_as_quote)
    
    545
    +        self.handlers[id_] = paste_item
    
    546
    +        menu.append(paste_item)
    
    547
    +
    
    543 548
             menu.show_all()
    
    544 549
     
    
    545
    -    def on_quote(self, widget, text):
    
    550
    +    def insert_as_quote(self, text: str) -> None:
    
    546 551
             self.msg_textview.remove_placeholder()
    
    547
    -        text = '>' + text.replace('\n', '\n>') + '\n'
    
    552
    +        text = '> ' + text.replace('\n', '\n> ') + '\n'
    
    548 553
             message_buffer = self.msg_textview.get_buffer()
    
    549 554
             message_buffer.insert_at_cursor(text)
    
    550 555
     
    
    556
    +    def paste_clipboard_as_quote(self, _item: Gtk.MenuItem) -> None:
    
    557
    +        clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    
    558
    +        text = clipboard.wait_for_text()
    
    559
    +        self.insert_as_quote(text)
    
    560
    +
    
    561
    +    def on_quote(self, widget, text):
    
    562
    +        self.insert_as_quote(text)
    
    563
    +
    
    551 564
         # moved from ChatControl
    
    552 565
         def _on_banner_eventbox_button_press_event(self, widget, event):
    
    553 566
             """