Philipp Hörist pushed to branch gajim_1.1 at gajim / gajim
Commits: bf804f18 by Philipp Hörist at 2019-04-09T18:57:47Z Fix memory leak with spell checker
- Dont shadow widgets destroy() - Dont bind spell checker to class attribute, this prevents its finalize
Fixes #8822
- - - - - db942378 by Marcin Mielniczuk at 2019-04-09T18:58:16Z Add the possibility to paste as quote
- - - - -
2 changed files:
- gajim/chat_control_base.py - gajim/message_textview.py
Changes:
===================================== gajim/chat_control_base.py ===================================== @@ -323,7 +323,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.set_emoticon_popover()
# Attach speller - self.spell_checker = None self.set_speller() self.conv_textview.tv.show()
@@ -474,15 +473,15 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): if gspell_lang is None: return
- self.spell_checker = Gspell.Checker.new(gspell_lang) + spell_checker = Gspell.Checker.new(gspell_lang) spell_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer( self.msg_textview.get_buffer()) - spell_buffer.set_spell_checker(self.spell_checker) + spell_buffer.set_spell_checker(spell_checker) spell_view = Gspell.TextView.get_from_gtk_text_view(self.msg_textview) spell_view.set_inline_spell_checking(False) spell_view.set_enable_language_menu(True)
- self.spell_checker.connect('notify::language', self.on_language_changed) + spell_checker.connect('notify::language', self.on_language_changed)
def get_speller_language(self): per_type = 'contacts' @@ -560,14 +559,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): """
===================================== gajim/message_textview.py ===================================== @@ -17,8 +17,6 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
-import gc - from gi.repository import Gtk from gi.repository import GLib from gi.repository import GObject @@ -408,9 +406,6 @@ class MessageTextView(Gtk.TextView): self.add_child_at_anchor(image, anchor) buffer_.insert_at_cursor(' ')
- def destroy(self): - GLib.idle_add(gc.collect) - def clear(self, widget=None): """ Clear text in the textview
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/5f562fb0ab829c3d6e412ee723ebcbe9a5...