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

Commits:

1 changed file:

Changes:

  • gajim/gtk/main.py
    ... ... @@ -14,6 +14,7 @@
    14 14
     
    
    15 15
     from __future__ import annotations
    
    16 16
     
    
    17
    +from typing import Any
    
    17 18
     from typing import Optional
    
    18 19
     from typing import Generator
    
    19 20
     
    
    ... ... @@ -31,6 +32,11 @@
    31 32
     from gajim.common import ged
    
    32 33
     from gajim.common.const import Display
    
    33 34
     from gajim.common.const import Direction
    
    35
    +from gajim.common.events import ApplicationEvent
    
    36
    +from gajim.common.events import AccountEnabled
    
    37
    +from gajim.common.events import AccountDisabled
    
    38
    +from gajim.common.events import ShowChanged
    
    39
    +from gajim.common.events import SignedIn
    
    34 40
     from gajim.common.helpers import ask_for_status_message
    
    35 41
     from gajim.common.i18n import _
    
    36 42
     from gajim.common.ged import EventHelper
    
    ... ... @@ -39,7 +45,6 @@
    39 45
     from .adhoc import AdHocCommand
    
    40 46
     from .account_side_bar import AccountSideBar
    
    41 47
     from .app_side_bar import AppSideBar
    
    42
    -from .workspace_side_bar import Workspace
    
    43 48
     from .workspace_side_bar import WorkspaceSideBar
    
    44 49
     from .main_stack import MainStack
    
    45 50
     from .chat_list import ChatList
    
    ... ... @@ -59,7 +64,7 @@
    59 64
     
    
    60 65
     
    
    61 66
     class MainWindow(Gtk.ApplicationWindow, EventHelper):
    
    62
    -    def __init__(self):
    
    67
    +    def __init__(self) -> None:
    
    63 68
             Gtk.ApplicationWindow.__init__(self)
    
    64 69
             EventHelper.__init__(self)
    
    65 70
             self.set_application(app.app)
    
    ... ... @@ -134,7 +139,7 @@ def __init__(self):
    134 139
                 app.interface.systray.connect_unread_changed(
    
    135 140
                     self._chat_page.get_chat_list_stack())
    
    136 141
     
    
    137
    -    def _start_timers(self):
    
    142
    +    def _start_timers(self) -> None:
    
    138 143
             GLib.timeout_add_seconds(UNLOAD_CHAT_TIME,
    
    139 144
                                      self._chat_page.unload_idle_chats)
    
    140 145
     
    
    ... ... @@ -159,11 +164,11 @@ def _prepare_window(self) -> None:
    159 164
                         app.settings.get('trayicon') != 'always'):
    
    160 165
                     self.show_all()
    
    161 166
     
    
    162
    -    def _on_account_enabled(self, event):
    
    167
    +    def _on_account_enabled(self, event: AccountEnabled) -> None:
    
    163 168
             self._account_side_bar.add_account(event.account)
    
    164 169
             self._main_stack.add_account_page(event.account)
    
    165 170
     
    
    166
    -    def _on_account_disabled(self, event):
    
    171
    +    def _on_account_disabled(self, event: AccountDisabled) -> None:
    
    167 172
             workspace_id = self._workspace_side_bar.get_first_workspace()
    
    168 173
             self.activate_workspace(workspace_id)
    
    169 174
             self._account_side_bar.remove_account(event.account)
    
    ... ... @@ -171,17 +176,17 @@ def _on_account_disabled(self, event):
    171 176
             self._main_stack.remove_chats_for_account(event.account)
    
    172 177
     
    
    173 178
         @staticmethod
    
    174
    -    def _on_our_show(event):
    
    179
    +    def _on_our_show(event: ShowChanged) -> None:
    
    175 180
             if event.show == 'offline':
    
    176 181
                 app.app.set_account_actions_state(event.account)
    
    177 182
                 app.app.update_app_actions_state()
    
    178 183
     
    
    179 184
         @staticmethod
    
    180
    -    def _on_signed_in(event):
    
    185
    +    def _on_signed_in(event: SignedIn) -> None:
    
    181 186
             app.app.set_account_actions_state(event.account, True)
    
    182 187
             app.app.update_app_actions_state()
    
    183 188
     
    
    184
    -    def _add_actions(self):
    
    189
    +    def _add_actions(self) -> None:
    
    185 190
             actions = [
    
    186 191
                 ('add-workspace', 's', self._add_workspace),
    
    187 192
                 ('edit-workspace', 's', self._edit_workspace),
    
    ... ... @@ -200,7 +205,7 @@ def _add_actions(self):
    200 205
                 act.connect('activate', func)
    
    201 206
                 self.add_action(act)
    
    202 207
     
    
    203
    -    def _add_actions2(self):
    
    208
    +    def _add_actions2(self) -> None:
    
    204 209
             actions = [
    
    205 210
                 'change-nickname',
    
    206 211
                 'change-subject',
    
    ... ... @@ -243,7 +248,7 @@ def _add_actions2(self):
    243 248
     
    
    244 249
         def _on_action(self,
    
    245 250
                        action: Gio.SimpleAction,
    
    246
    -                   _param: Optional[GLib.Variant]) -> None:
    
    251
    +                   _param: Optional[GLib.Variant]) -> Optional[int]:
    
    247 252
     
    
    248 253
             control = self.get_active_control()
    
    249 254
             if control is None:
    
    ... ... @@ -287,7 +292,10 @@ def _on_action(self,
    287 292
     
    
    288 293
             return None
    
    289 294
     
    
    290
    -    def _on_window_motion_notify(self, _widget, _event):
    
    295
    +    def _on_window_motion_notify(self,
    
    296
    +                                 _widget: Gtk.ApplicationWindow,
    
    297
    +                                 _event: Gdk.EventMotion
    
    298
    +                                 ) -> None:
    
    291 299
             control = self.get_active_control()
    
    292 300
             if control is None:
    
    293 301
                 return
    
    ... ... @@ -297,7 +305,10 @@ def _on_window_motion_notify(self, _widget, _event):
    297 305
                 client.get_module('Chatstate').set_mouse_activity(
    
    298 306
                     control.contact, control.msg_textview.has_text())
    
    299 307
     
    
    300
    -    def _on_window_delete(self, _widget, _event):
    
    308
    +    def _on_window_delete(self,
    
    309
    +                          _widget: Gtk.ApplicationWindow,
    
    310
    +                          _event: Gdk.Event
    
    311
    +                          ) -> bool:
    
    301 312
             # Main window X button was clicked
    
    302 313
             if app.settings.get('quit_on_main_window_x_button'):
    
    303 314
                 self.quit()
    
    ... ... @@ -313,7 +324,7 @@ def _on_window_delete(self, _widget, _event):
    313 324
                         self.iconify()
    
    314 325
                     return True
    
    315 326
     
    
    316
    -            def _on_ok(is_checked):
    
    327
    +            def _on_ok(is_checked: bool) -> None:
    
    317 328
                     if is_checked:
    
    318 329
                         app.settings.set('quit_on_main_window_x_button', True)
    
    319 330
                     self.quit()
    
    ... ... @@ -329,7 +340,7 @@ def _on_ok(is_checked):
    329 340
                                        callback=_on_ok)]).show()
    
    330 341
             return True
    
    331 342
     
    
    332
    -    def _set_startup_finished(self):
    
    343
    +    def _set_startup_finished(self) -> None:
    
    333 344
             self._startup_finished = True
    
    334 345
             self._chat_page.set_startup_finished()
    
    335 346
     
    
    ... ... @@ -563,7 +574,10 @@ def mark_as_read(self, account: str, jid: JID,
    563 574
             chat_list_stack = self._chat_page.get_chat_list_stack()
    
    564 575
             chat_list_stack.mark_as_read(account, jid)
    
    565 576
     
    
    566
    -    def _on_window_active(self, window, _param):
    
    577
    +    def _on_window_active(self,
    
    578
    +                          window: Gtk.ApplicationWindow,
    
    579
    +                          _param: Any
    
    580
    +                          ) -> None:
    
    567 581
             is_active = window.get_property('is-active')
    
    568 582
             if not is_active:
    
    569 583
                 return
    
    ... ... @@ -596,7 +610,7 @@ def block_contact(self, account: str, jid: str) -> None:
    596 610
                 return
    
    597 611
     
    
    598 612
             # TODO: Keep "confirm_block" setting?
    
    599
    -        def _block_contact(report=None):
    
    613
    +        def _block_contact(report: Optional[str] = None) -> None:
    
    600 614
                 client.get_module('Blocking').block([contact.jid], report)
    
    601 615
                 self._chat_page.remove_chat(account, contact.jid)
    
    602 616
     
    
    ... ... @@ -657,7 +671,7 @@ def _load_chats(self) -> None:
    657 671
     
    
    658 672
             self._set_startup_finished()
    
    659 673
     
    
    660
    -    def _on_event(self, event):
    
    674
    +    def _on_event(self, event: ApplicationEvent) -> None:
    
    661 675
             if event.name == 'update-roster-avatar':
    
    662 676
                 return
    
    663 677
     
    
    ... ... @@ -688,7 +702,7 @@ def _on_event(self, event):
    688 702
     
    
    689 703
             self._main_stack.process_event(event)
    
    690 704
     
    
    691
    -    def quit(self):
    
    705
    +    def quit(self) -> None:
    
    692 706
             accounts = list(app.connections.keys())
    
    693 707
             get_msg = False
    
    694 708
             for acct in accounts:
    
    ... ... @@ -704,7 +718,7 @@ def quit(self):
    704 718
                 'last_main_window_visible', self.get_property('visible'))
    
    705 719
             app.settings.save()
    
    706 720
     
    
    707
    -        def on_continue2(message):
    
    721
    +        def on_continue2(message: Optional[str]) -> None:
    
    708 722
                 if 'file_transfers' not in app.interface.instances:
    
    709 723
                     app.app.start_shutdown(message=message)
    
    710 724
                     return
    
    ... ... @@ -733,7 +747,7 @@ def on_continue2(message):
    733 747
                     return
    
    734 748
                 app.app.start_shutdown(message=message)
    
    735 749
     
    
    736
    -        def on_continue(message):
    
    750
    +        def on_continue(message: Optional[str]) -> None:
    
    737 751
                 if message is None:
    
    738 752
                     # user pressed Cancel to change status message dialog
    
    739 753
                     return