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

Commits:

4 changed files:

Changes:

  • gajim/gtk/chat_stack.py
    ... ... @@ -397,7 +397,10 @@ def _on_send_message(self) -> None:
    397 397
             control = self._control_stack.get_current_control()
    
    398 398
     
    
    399 399
             action = app.window.lookup_action('set-encryption')
    
    400
    -        encryption = action.get_state().get_string()
    
    400
    +        assert action is not None
    
    401
    +        state = action.get_state()
    
    402
    +        assert state is not None
    
    403
    +        encryption = state.get_string()
    
    401 404
     
    
    402 405
             if encryption:
    
    403 406
                 self.sendmessage = True
    

  • gajim/gtk/controls/base.py
    ... ... @@ -217,9 +217,6 @@ def __init__(self, widget_name: str, account: str, jid: JID) -> None:
    217 217
         def _connect_contact_signals(self) -> None:
    
    218 218
             raise NotImplementedError
    
    219 219
     
    
    220
    -    def _get_action(self, name: str) -> Gio.SimpleAction:
    
    221
    -        return app.window.lookup_action(f'{name}{self.control_id}')
    
    222
    -
    
    223 220
         def process_event(self, event: events.ApplicationEvent) -> None:
    
    224 221
             if event.account != self.account:
    
    225 222
                 return
    

  • gajim/gtk/message_actions_box.py
    ... ... @@ -309,9 +309,10 @@ def _set_encryption_details(self, state: str) -> None:
    309 309
     
    
    310 310
             if state:
    
    311 311
                 app.plugin_manager.extension_point(
    
    312
    -                'encryption_state' + state, self, encryption_state)
    
    312
    +                f'encryption_state{state}', self, encryption_state)
    
    313 313
     
    
    314 314
             visible, enc_type, authenticated = encryption_state.values()
    
    315
    +        assert isinstance(visible, bool)
    
    315 316
     
    
    316 317
             if authenticated:
    
    317 318
                 authenticated_string = _('and authenticated')
    
    ... ... @@ -333,7 +334,7 @@ def _on_encryption_details_clicked(self, _button: Gtk.Button) -> None:
    333 334
             contact = self.get_current_contact()
    
    334 335
             encryption = contact.settings.get('encryption')
    
    335 336
             app.plugin_manager.extension_point(
    
    336
    -            'encryption_dialog' + encryption, contact)
    
    337
    +            f'encryption_dialog{encryption}', contact)
    
    337 338
     
    
    338 339
         def _set_settings_menu(self, contact: ChatContactT) -> None:
    
    339 340
             if isinstance(contact, GroupchatContact):
    
    ... ... @@ -481,13 +482,16 @@ def _update_send_file_button_tooltip(self):
    481 482
     
    
    482 483
         def _on_buffer_changed(self, textbuffer: Gtk.TextBuffer) -> None:
    
    483 484
             has_text = self.msg_textview.has_text()
    
    484
    -        app.window.lookup_action('send-message').set_enabled(has_text)
    
    485
    +        send_message_action = app.window.lookup_action('send-message')
    
    486
    +        assert send_message_action is not None
    
    487
    +        send_message_action.set_enabled(has_text)
    
    485 488
     
    
    486 489
             encryption_enabled, encryption_name = self._get_encryption_state()
    
    487 490
     
    
    488 491
             if has_text and encryption_enabled:
    
    489 492
                 app.plugin_manager.extension_point('typing' + encryption_name, self)
    
    490 493
     
    
    494
    +        assert self._contact
    
    491 495
             client = app.get_client(self._contact.account)
    
    492 496
             client.get_module('Chatstate').set_keyboard_activity(self._contact)
    
    493 497
             if not has_text:
    

  • gajim/gtk/message_input.py
    ... ... @@ -30,6 +30,8 @@
    30 30
     from gi.repository import GLib
    
    31 31
     from gi.repository import Pango
    
    32 32
     
    
    33
    +from nbxmpp.protocol import JID
    
    34
    +
    
    33 35
     from gajim.common import app
    
    34 36
     from gajim.common.i18n import _
    
    35 37
     from gajim.common.styling import process
    
    ... ... @@ -75,7 +77,7 @@ def __init__(self) -> None:
    75 77
             self.undo_pressed: bool = False
    
    76 78
     
    
    77 79
             self._contact: Optional[ChatContactT] = None
    
    78
    -        self._drafts: dict[str, str] = {}
    
    80
    +        self._drafts: dict[JID, str] = {}
    
    79 81
     
    
    80 82
             self._chat_action_processor = ChatActionProcessor(self)
    
    81 83
     
    
    ... ... @@ -94,12 +96,12 @@ def __init__(self) -> None:
    94 96
         def switch_contact(self, contact: ChatContactT) -> None:
    
    95 97
             if self._contact is not None:
    
    96 98
                 if self.has_text():
    
    97
    -                self._drafts[str(self._contact.jid)] = self.get_text()
    
    99
    +                self._drafts[self._contact.jid] = self.get_text()
    
    98 100
                 else:
    
    99
    -                self._drafts.pop(str(self._contact.jid), None)
    
    101
    +                self._drafts.pop(self._contact.jid, None)
    
    100 102
     
    
    101 103
             self.clear()
    
    102
    -        draft = self._drafts.get(str(contact.jid))
    
    104
    +        draft = self._drafts.get(contact.jid)
    
    103 105
             if draft is not None:
    
    104 106
                 self.insert_text(draft)
    
    105 107
     
    
    ... ... @@ -345,7 +347,6 @@ def _on_populate_popup(self,
    345 347
                                _textview: MessageInputTextView,
    
    346 348
                                menu: Gtk.Widget
    
    347 349
                                ) -> None:
    
    348
    -
    
    349 350
             assert isinstance(menu, Gtk.Menu)
    
    350 351
             item = Gtk.MenuItem.new_with_mnemonic(_('_Undo'))
    
    351 352
             menu.prepend(item)