From 64d14013079c99673e8b9441c152b7d4c148f459 Mon Sep 17 00:00:00 2001 From: Marcin Mielniczuk Date: Sun, 7 Apr 2019 22:25:14 +0200 Subject: [PATCH] Add the possibility to paste as quote --- gajim/chat_control_base.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gajim/chat_control_base.py b/gajim/chat_control_base.py index f4736ce8f..435b40904 100644 --- a/gajim/chat_control_base.py +++ b/gajim/chat_control_base.py @@ -540,14 +540,27 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): id_ = item.connect('activate', self.msg_textview.clear) self.handlers[id_] = item + paste_item = Gtk.MenuItem.new_with_label(_('Paste as quote')) + id_ = paste_item.connect('activate', self.paste_clipboard_as_quote) + self.handlers[id_] = paste_item + menu.append(paste_item) + menu.show_all() - def on_quote(self, widget, text): + def insert_as_quote(self, text: str) -> None: self.msg_textview.remove_placeholder() - text = '>' + text.replace('\n', '\n>') + '\n' + text = '> ' + text.replace('\n', '\n> ') + '\n' message_buffer = self.msg_textview.get_buffer() message_buffer.insert_at_cursor(text) + def paste_clipboard_as_quote(self, _item: Gtk.MenuItem) -> None: + clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) + text = clipboard.wait_for_text() + self.insert_as_quote(text) + + def on_quote(self, widget, text): + self.insert_as_quote(text) + # moved from ChatControl def _on_banner_eventbox_button_press_event(self, widget, event): """