Philipp Hörist pushed to branch gajim_1.1 at gajim / gajim

Commits:

2 changed files:

Changes:

  • gajim/chat_control_base.py
    ... ... @@ -323,7 +323,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    323 323
             self.set_emoticon_popover()
    
    324 324
     
    
    325 325
             # Attach speller
    
    326
    -        self.spell_checker = None
    
    327 326
             self.set_speller()
    
    328 327
             self.conv_textview.tv.show()
    
    329 328
     
    
    ... ... @@ -474,15 +473,15 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    474 473
             if gspell_lang is None:
    
    475 474
                 return
    
    476 475
     
    
    477
    -        self.spell_checker = Gspell.Checker.new(gspell_lang)
    
    476
    +        spell_checker = Gspell.Checker.new(gspell_lang)
    
    478 477
             spell_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer(
    
    479 478
                 self.msg_textview.get_buffer())
    
    480
    -        spell_buffer.set_spell_checker(self.spell_checker)
    
    479
    +        spell_buffer.set_spell_checker(spell_checker)
    
    481 480
             spell_view = Gspell.TextView.get_from_gtk_text_view(self.msg_textview)
    
    482 481
             spell_view.set_inline_spell_checking(False)
    
    483 482
             spell_view.set_enable_language_menu(True)
    
    484 483
     
    
    485
    -        self.spell_checker.connect('notify::language', self.on_language_changed)
    
    484
    +        spell_checker.connect('notify::language', self.on_language_changed)
    
    486 485
     
    
    487 486
         def get_speller_language(self):
    
    488 487
             per_type = 'contacts'
    
    ... ... @@ -560,14 +559,27 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    560 559
             id_ = item.connect('activate', self.msg_textview.clear)
    
    561 560
             self.handlers[id_] = item
    
    562 561
     
    
    562
    +        paste_item = Gtk.MenuItem.new_with_label(_('Paste as quote'))
    
    563
    +        id_ = paste_item.connect('activate', self.paste_clipboard_as_quote)
    
    564
    +        self.handlers[id_] = paste_item
    
    565
    +        menu.append(paste_item)
    
    566
    +
    
    563 567
             menu.show_all()
    
    564 568
     
    
    565
    -    def on_quote(self, widget, text):
    
    569
    +    def insert_as_quote(self, text: str) -> None:
    
    566 570
             self.msg_textview.remove_placeholder()
    
    567
    -        text = '>' + text.replace('\n', '\n>') + '\n'
    
    571
    +        text = '> ' + text.replace('\n', '\n> ') + '\n'
    
    568 572
             message_buffer = self.msg_textview.get_buffer()
    
    569 573
             message_buffer.insert_at_cursor(text)
    
    570 574
     
    
    575
    +    def paste_clipboard_as_quote(self, _item: Gtk.MenuItem) -> None:
    
    576
    +        clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    
    577
    +        text = clipboard.wait_for_text()
    
    578
    +        self.insert_as_quote(text)
    
    579
    +
    
    580
    +    def on_quote(self, widget, text):
    
    581
    +        self.insert_as_quote(text)
    
    582
    +
    
    571 583
         # moved from ChatControl
    
    572 584
         def _on_banner_eventbox_button_press_event(self, widget, event):
    
    573 585
             """
    

  • gajim/message_textview.py
    ... ... @@ -17,8 +17,6 @@
    17 17
     # You should have received a copy of the GNU General Public License
    
    18 18
     # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    19 19
     
    
    20
    -import gc
    
    21
    -
    
    22 20
     from gi.repository import Gtk
    
    23 21
     from gi.repository import GLib
    
    24 22
     from gi.repository import GObject
    
    ... ... @@ -408,9 +406,6 @@ class MessageTextView(Gtk.TextView):
    408 406
                 self.add_child_at_anchor(image, anchor)
    
    409 407
             buffer_.insert_at_cursor(' ')
    
    410 408
     
    
    411
    -    def destroy(self):
    
    412
    -        GLib.idle_add(gc.collect)
    
    413
    -
    
    414 409
         def clear(self, widget=None):
    
    415 410
             """
    
    416 411
             Clear text in the textview