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

Commits:

4 changed files:

Changes:

  • gajim/common/app.py
    ... ... @@ -399,12 +399,12 @@ def get_accounts_sorted() -> list[str]:
    399 399
     def get_enabled_accounts_with_labels(
    
    400 400
             exclude_local: bool = True,
    
    401 401
             connected_only: bool = False,
    
    402
    -        private_storage_only: bool = False) -> list[str]:
    
    402
    +        private_storage_only: bool = False) -> list[list[str]]:
    
    403 403
         """
    
    404 404
         Returns a list with [account, account_label] entries.
    
    405 405
         Order by account_label
    
    406 406
         """
    
    407
    -    accounts: list[str] = []
    
    407
    +    accounts = []
    
    408 408
         for acc in connections:
    
    409 409
             if exclude_local and account_is_zeroconf(acc):
    
    410 410
                 continue
    

  • gajim/gtk/add_contact.py
    ... ... @@ -12,9 +12,12 @@
    12 12
     # You should have received a copy of the GNU General Public License
    
    13 13
     # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    14 14
     
    
    15
    -from typing import Tuple
    
    16
    -from typing import Optional
    
    17 15
     from typing import Any
    
    16
    +from typing import Dict
    
    17
    +from typing import List
    
    18
    +from typing import Optional
    
    19
    +from typing import Tuple
    
    20
    +from typing import Union
    
    18 21
     
    
    19 22
     import logging
    
    20 23
     
    
    ... ... @@ -23,8 +26,11 @@
    23 26
     from nbxmpp import JID
    
    24 27
     from nbxmpp import Namespace
    
    25 28
     from nbxmpp.errors import is_error
    
    29
    +from nbxmpp.errors import StanzaError
    
    30
    +from nbxmpp.structs import DiscoInfo
    
    26 31
     
    
    27 32
     from gajim.common import app
    
    33
    +from gajim.common import types
    
    28 34
     from gajim.common.helpers import get_subscription_request_msg
    
    29 35
     from gajim.common.helpers import validate_jid
    
    30 36
     from gajim.common.i18n import _
    
    ... ... @@ -45,13 +51,13 @@ class AddContact(Assistant):
    45 51
         def __init__(self,
    
    46 52
                      account: Optional[str] = None,
    
    47 53
                      jid: Optional[JID] = None,
    
    48
    -                 nick: str = None):
    
    54
    +                 nick: Optional[str] = None):
    
    49 55
             Assistant.__init__(self)
    
    50 56
             self.account = account
    
    51 57
             self.jid = jid
    
    52 58
             self._nick = nick
    
    53 59
     
    
    54
    -        self._result = None
    
    60
    +        self._result: Union[DiscoInfo, StanzaError, None] = None
    
    55 61
     
    
    56 62
             self.add_button('next', _('Next'), complete=True,
    
    57 63
                             css_class='suggested-action')
    
    ... ... @@ -74,14 +80,17 @@ def __init__(self,
    74 80
             progress.set_text(_('Trying to gather information on this address…'))
    
    75 81
     
    
    76 82
             self.connect('button-clicked', self._on_button_clicked)
    
    83
    +        self.connect('destroy', self._on_destroy)
    
    77 84
     
    
    78 85
             self.show_all()
    
    79
    -        self.connect('destroy', self._on_destroy)
    
    80 86
     
    
    81
    -    def _on_destroy(self, *args):
    
    87
    +    def _on_destroy(self, *args: Any) -> None:
    
    82 88
             app.check_finalize(self)
    
    83 89
     
    
    84
    -    def _on_button_clicked(self, _assistant, button_name):
    
    90
    +    def _on_button_clicked(self,
    
    91
    +                           _assistant: Assistant,
    
    92
    +                           button_name: str
    
    93
    +                           ) -> None:
    
    85 94
             page = self.get_current_page()
    
    86 95
             account, _ = self.get_page('address').get_account_and_jid()
    
    87 96
     
    
    ... ... @@ -126,7 +135,7 @@ def _start_disco(self) -> None:
    126 135
             self._disco_info(account, jid)
    
    127 136
     
    
    128 137
         @as_task
    
    129
    -    def _disco_info(self, account, address):
    
    138
    +    def _disco_info(self, account: str, address: str) -> None:
    
    130 139
             _task = yield
    
    131 140
     
    
    132 141
             client = app.get_client(account)
    
    ... ... @@ -139,7 +148,7 @@ def _disco_info(self, account, address):
    139 148
             log.info('Disco Info received: %s', address)
    
    140 149
             self._process_info(account, result)
    
    141 150
     
    
    142
    -    def _process_error(self, account, result):
    
    151
    +    def _process_error(self, account: str, result: StanzaError) -> None:
    
    143 152
             log.debug('Error received: %s', result)
    
    144 153
             self._result = result
    
    145 154
     
    
    ... ... @@ -155,7 +164,7 @@ def _process_error(self, account, result):
    155 164
                 self.get_page('error').set_text(result.get_text())
    
    156 165
                 self.show_page('error', Gtk.StackTransitionType.SLIDE_LEFT)
    
    157 166
     
    
    158
    -    def _process_info(self, account, result):
    
    167
    +    def _process_info(self, account: str, result: DiscoInfo) -> None:
    
    159 168
             log.debug('Info received: %s', result)
    
    160 169
             self._result = result
    
    161 170
     
    
    ... ... @@ -186,14 +195,8 @@ def _process_info(self, account, result):
    186 195
                 self.show_page('gateway', Gtk.StackTransitionType.SLIDE_LEFT)
    
    187 196
                 return
    
    188 197
     
    
    189
    -        if result.has_category('client'):
    
    190
    -            self.get_page('contact').prepare(account, result)
    
    191
    -            self.show_page('contact', Gtk.StackTransitionType.SLIDE_LEFT)
    
    192
    -            return
    
    193
    -
    
    194
    -        self.get_page('error').set_text(
    
    195
    -            _('This address does not seem to offer any gateway service.'))
    
    196
    -        self.show_page('error')
    
    198
    +        self.get_page('contact').prepare(account, result)
    
    199
    +        self.show_page('contact', Gtk.StackTransitionType.SLIDE_LEFT)
    
    197 200
     
    
    198 201
     
    
    199 202
     class Address(Page):
    
    ... ... @@ -218,12 +221,12 @@ def __init__(self, account: Optional[str], jid: Optional[JID]) -> None:
    218 221
             if len(accounts) > 1:
    
    219 222
                 self._ui.account_box.show()
    
    220 223
     
    
    221
    -            if self._account is not None:
    
    224
    +            if account is not None:
    
    222 225
                     self._ui.account_combo.set_active_id(account)
    
    223 226
                 else:
    
    224 227
                     self._ui.account_combo.set_active(0)
    
    225 228
             else:
    
    226
    -            # Set to first (and only) item; sets self._account as well
    
    229
    +            # Set to first (and only) item; sets self._account automatically
    
    227 230
                 self._ui.account_combo.set_active(0)
    
    228 231
     
    
    229 232
             if jid is not None:
    
    ... ... @@ -233,29 +236,29 @@ def __init__(self, account: Optional[str], jid: Optional[JID]) -> None:
    233 236
     
    
    234 237
             self.show_all()
    
    235 238
     
    
    236
    -    def get_visible_buttons(self):
    
    239
    +    def get_visible_buttons(self) -> List[str]:
    
    237 240
             return ['next']
    
    238 241
     
    
    239
    -    def get_default_button(self):
    
    242
    +    def get_default_button(self) -> str:
    
    240 243
             return 'next'
    
    241 244
     
    
    242
    -    def get_account_and_jid(self) -> Tuple[Optional[str], Any]:
    
    245
    +    def get_account_and_jid(self) -> Tuple[str, str]:
    
    243 246
             return self._account, self._ui.address_entry.get_text()
    
    244 247
     
    
    245 248
         def focus(self) -> None:
    
    246 249
             self._ui.address_entry.grab_focus()
    
    247 250
     
    
    248
    -    def _on_account_changed(self, combobox):
    
    251
    +    def _on_account_changed(self, combobox: Gtk.ComboBox) -> None:
    
    249 252
             account = combobox.get_active_id()
    
    250 253
             self._account = account
    
    251 254
             self._set_complete()
    
    252 255
     
    
    253
    -    def _show_icon(self, show):
    
    256
    +    def _show_icon(self, show: bool) -> None:
    
    254 257
             icon = 'dialog-warning-symbolic' if show else None
    
    255 258
             self._ui.address_entry.set_icon_from_icon_name(
    
    256 259
                 Gtk.EntryIconPosition.SECONDARY, icon)
    
    257 260
     
    
    258
    -    def _set_complete(self, *args):
    
    261
    +    def _set_complete(self, *args: Any) -> None:
    
    259 262
             if self._account is None:
    
    260 263
                 self.complete = False
    
    261 264
                 self.update_page_complete()
    
    ... ... @@ -306,26 +309,26 @@ def _validate_address(self, address: str) -> bool:
    306 309
     
    
    307 310
     
    
    308 311
     class Error(ErrorPage):
    
    309
    -    def __init__(self):
    
    312
    +    def __init__(self) -> None:
    
    310 313
             ErrorPage.__init__(self)
    
    311 314
             self.set_title(_('Add Contact'))
    
    312 315
             self.set_heading(_('An Error Occurred'))
    
    313 316
     
    
    314
    -    def get_visible_buttons(self):
    
    317
    +    def get_visible_buttons(self) -> List[str]:
    
    315 318
             return ['back']
    
    316 319
     
    
    317
    -    def get_default_button(self):
    
    320
    +    def get_default_button(self) -> str:
    
    318 321
             return 'back'
    
    319 322
     
    
    320 323
     
    
    321 324
     class Contact(Page):
    
    322
    -    def __init__(self):
    
    325
    +    def __init__(self) -> None:
    
    323 326
             Page.__init__(self)
    
    324 327
             self.title = _('Add Contact')
    
    325 328
     
    
    326
    -        self._result = None
    
    327
    -        self._account = None
    
    328
    -        self._contact = None
    
    329
    +        self._result: Union[DiscoInfo, StanzaError, None] = None
    
    330
    +        self._account: Optional[str] = None
    
    331
    +        self._contact: Optional[types.BareContact] = None
    
    329 332
     
    
    330 333
             self._ui = get_builder('add_contact.ui')
    
    331 334
             self.add(self._ui.contact_grid)
    
    ... ... @@ -334,13 +337,13 @@ def __init__(self):
    334 337
     
    
    335 338
             self.show_all()
    
    336 339
     
    
    337
    -    def get_visible_buttons(self):
    
    340
    +    def get_visible_buttons(self) -> List[str]:
    
    338 341
             return ['back', 'add']
    
    339 342
     
    
    340
    -    def get_default_button(self):
    
    343
    +    def get_default_button(self) -> str:
    
    341 344
             return 'add'
    
    342 345
     
    
    343
    -    def prepare(self, account, result):
    
    346
    +    def prepare(self, account: str, result: Union[DiscoInfo, StanzaError]):
    
    344 347
             self._result = result
    
    345 348
             self._account = account
    
    346 349
     
    
    ... ... @@ -357,11 +360,11 @@ def _update_groups(self, account: str) -> None:
    357 360
             for group in client.get_module('Roster').get_groups():
    
    358 361
                 self._ui.group_combo.append_text(group)
    
    359 362
     
    
    360
    -    def _on_info_clicked(self, _button):
    
    363
    +    def _on_info_clicked(self, _button: Gtk.Button) -> None:
    
    361 364
             open_window(
    
    362 365
                 'ContactInfo', account=self._account, contact=self._contact)
    
    363 366
     
    
    364
    -    def get_subscription_data(self):
    
    367
    +    def get_subscription_data(self) -> Dict[str, Union[str, List[str], bool]]:
    
    365 368
             group = self._ui.group_combo.get_child().get_text()
    
    366 369
             groups = [group] if group else []
    
    367 370
             return {
    
    ... ... @@ -372,12 +375,12 @@ def get_subscription_data(self):
    372 375
     
    
    373 376
     
    
    374 377
     class Gateway(Page):
    
    375
    -    def __init__(self):
    
    378
    +    def __init__(self) -> None:
    
    376 379
             Page.__init__(self)
    
    377 380
             self.title = _('Service Gateway')
    
    378 381
     
    
    379
    -        self._account = None
    
    380
    -        self._result = None
    
    382
    +        self._account: Optional[str] = None
    
    383
    +        self._result: Optional[DiscoInfo] = None
    
    381 384
     
    
    382 385
             self._ui = get_builder('add_contact.ui')
    
    383 386
             self.add(self._ui.gateway_box)
    
    ... ... @@ -387,13 +390,13 @@ def __init__(self):
    387 390
     
    
    388 391
             self.show_all()
    
    389 392
     
    
    390
    -    def get_visible_buttons(self):
    
    393
    +    def get_visible_buttons(self) -> List[str]:
    
    391 394
             return ['back', 'add']
    
    392 395
     
    
    393
    -    def get_default_button(self):
    
    396
    +    def get_default_button(self) -> str:
    
    394 397
             return 'add'
    
    395 398
     
    
    396
    -    def prepare(self, account, result):
    
    399
    +    def prepare(self, account: str, result: DiscoInfo) -> None:
    
    397 400
             self._account = account
    
    398 401
             self._result = result
    
    399 402
     
    
    ... ... @@ -447,22 +450,22 @@ def prepare(self, account, result):
    447 450
                 self._ui.commands_button.set_tooltip_text(
    
    448 451
                     _('This gateway does not support Ad-Hoc Commands.'))
    
    449 452
     
    
    450
    -    def _on_register_clicked(self, _button):
    
    453
    +    def _on_register_clicked(self, _button: Gtk.Button) -> None:
    
    451 454
             open_window(
    
    452 455
                 'ServiceRegistration',
    
    453 456
                 account=self._account,
    
    454 457
                 address=self._result.jid)
    
    455 458
     
    
    456
    -    def _on_command_clicked(self, _button):
    
    459
    +    def _on_command_clicked(self, _button: Gtk.Button) -> None:
    
    457 460
             AdHocCommand(self._account, self._result.jid)
    
    458 461
     
    
    459 462
     
    
    460 463
     class GroupChat(Page):
    
    461
    -    def __init__(self):
    
    464
    +    def __init__(self) -> None:
    
    462 465
             Page.__init__(self)
    
    463 466
             self.title = _('Join Group Chat?')
    
    464 467
     
    
    465
    -        self._result = None
    
    468
    +        self._result: Optional[DiscoInfo] = None
    
    466 469
     
    
    467 470
             heading = Gtk.Label(label=_('Join Group Chat?'))
    
    468 471
             heading.get_style_context().add_class('large-header')
    
    ... ... @@ -477,13 +480,13 @@ def __init__(self):
    477 480
     
    
    478 481
             self.show_all()
    
    479 482
     
    
    480
    -    def get_visible_buttons(self):
    
    483
    +    def get_visible_buttons(self) -> List[str]:
    
    481 484
             return ['back', 'join']
    
    482 485
     
    
    483
    -    def get_default_button(self):
    
    486
    +    def get_default_button(self) -> str:
    
    484 487
             return 'join'
    
    485 488
     
    
    486
    -    def prepare(self, account, result):
    
    489
    +    def prepare(self, account: str, result: DiscoInfo) -> None:
    
    487 490
             self._result = result
    
    488 491
     
    
    489 492
             self._info_box.set_account(account)
    

  • gajim/gtk/advanced_config.py
    ... ... @@ -19,6 +19,8 @@
    19 19
     # You should have received a copy of the GNU General Public License
    
    20 20
     # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    21 21
     
    
    22
    +from typing import Optional
    
    23
    +
    
    22 24
     from enum import IntEnum
    
    23 25
     from enum import unique
    
    24 26
     
    
    ... ... @@ -32,6 +34,7 @@
    32 34
     
    
    33 35
     from gajim.common.setting_values import ADVANCED_SETTINGS
    
    34 36
     from gajim.common.setting_values import APP_SETTINGS
    
    37
    +
    
    35 38
     from .builder import get_builder
    
    36 39
     
    
    37 40
     
    
    ... ... @@ -56,7 +59,7 @@ class Column(IntEnum):
    56 59
     
    
    57 60
     
    
    58 61
     class AdvancedConfig(Gtk.ApplicationWindow):
    
    59
    -    def __init__(self):
    
    62
    +    def __init__(self) -> None:
    
    60 63
             Gtk.ApplicationWindow.__init__(self)
    
    61 64
             self.set_application(app.app)
    
    62 65
             self.set_position(Gtk.WindowPosition.CENTER)
    
    ... ... @@ -107,7 +110,7 @@ def __init__(self):
    107 110
             self._ui.connect_signals(self)
    
    108 111
             self.show_all()
    
    109 112
     
    
    110
    -    def _on_key_press(self, _widget, event):
    
    113
    +    def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> None:
    
    111 114
             if event.keyval != Gdk.KEY_Escape:
    
    112 115
                 return
    
    113 116
     
    
    ... ... @@ -117,11 +120,18 @@ def _on_key_press(self, _widget, event):
    117 120
     
    
    118 121
             self.destroy()
    
    119 122
     
    
    120
    -    def _value_column_data_callback(self, _col, cell, model, iter_, _data):
    
    123
    +    def _value_column_data_callback(self,
    
    124
    +                                    _col: Gtk.TreeViewColumn,
    
    125
    +                                    cell: Gtk.CellRenderer,
    
    126
    +                                    model: Gtk.TreeModel,
    
    127
    +                                    iter_: Gtk.TreeIter,
    
    128
    +                                    _data: Optional[object]):
    
    121 129
             opttype = model[iter_][Column.TYPE]
    
    122 130
             cell.set_property('editable', opttype != SETTING_TYPES[bool])
    
    123 131
     
    
    124
    -    def _on_treeview_selection_changed(self, treeselection):
    
    132
    +    def _on_treeview_selection_changed(self,
    
    133
    +                                       treeselection: Gtk.TreeSelection
    
    134
    +                                       ) -> None:
    
    125 135
             model, iter_ = treeselection.get_selected()
    
    126 136
             if not iter_:
    
    127 137
                 self._ui.reset_button.set_sensitive(False)
    
    ... ... @@ -133,7 +143,11 @@ def _on_treeview_selection_changed(self, treeselection):
    133 143
             self._ui.description.set_text(desc or Q_('?config description:None'))
    
    134 144
             self._ui.reset_button.set_sensitive(True)
    
    135 145
     
    
    136
    -    def _on_treeview_row_activated(self, _treeview, path, _column):
    
    146
    +    def _on_treeview_row_activated(self,
    
    147
    +                                   _treeview: Gtk.TreeView,
    
    148
    +                                   path: Gtk.TreePath,
    
    149
    +                                   _column: Gtk.TreeViewColumn
    
    150
    +                                   ) -> None:
    
    137 151
             modelpath = self.modelfilter.convert_path_to_child_path(path)
    
    138 152
             modelrow = self.model[modelpath]
    
    139 153
             setting = modelrow[Column.NAME]
    
    ... ... @@ -147,7 +161,11 @@ def _on_treeview_row_activated(self, _treeview, path, _column):
    147 161
             app.settings.set(setting, setting_value)
    
    148 162
             modelrow[Column.VALUE] = column_value
    
    149 163
     
    
    150
    -    def _on_config_edited(self, _cell, path, text):
    
    164
    +    def _on_config_edited(self,
    
    165
    +                          _cell: Gtk.CellRendererText,
    
    166
    +                          path: str,
    
    167
    +                          text: str
    
    168
    +                          ) -> None:
    
    151 169
             path = Gtk.TreePath.new_from_string(path)
    
    152 170
             modelpath = self.modelfilter.convert_path_to_child_path(path)
    
    153 171
             modelrow = self.model[modelpath]
    
    ... ... @@ -160,7 +178,7 @@ def _on_config_edited(self, _cell, path, text):
    160 178
             app.settings.set(setting, value)
    
    161 179
             modelrow[Column.VALUE] = text
    
    162 180
     
    
    163
    -    def _on_reset_button_clicked(self, button):
    
    181
    +    def _on_reset_button_clicked(self, button: Gtk.Button) -> None:
    
    164 182
             model, iter_ = self.treeview.get_selection().get_selected()
    
    165 183
             if not iter_:
    
    166 184
                 return
    
    ... ... @@ -176,7 +194,7 @@ def _on_reset_button_clicked(self, button):
    176 194
             app.settings.set(setting, default)
    
    177 195
             button.set_sensitive(False)
    
    178 196
     
    
    179
    -    def _fill_model(self, node=None, parent=None):
    
    197
    +    def _fill_model(self, parent=None) -> None:
    
    180 198
             for category, settings in ADVANCED_SETTINGS.items():
    
    181 199
                 if category != 'app':
    
    182 200
                     continue
    
    ... ... @@ -199,7 +217,11 @@ def _fill_model(self, node=None, parent=None):
    199 217
     
    
    200 218
                     self.model.append(parent, [setting, value, type_])
    
    201 219
     
    
    202
    -    def _visible_func(self, model, treeiter, _data):
    
    220
    +    def _visible_func(self,
    
    221
    +                      model: Gtk.TreeModel,
    
    222
    +                      treeiter: Gtk.TreeIter,
    
    223
    +                      _data: Optional[object]
    
    224
    +                      ) -> bool:
    
    203 225
             search_string = self._ui.search_entry.get_text().lower()
    
    204 226
             if not search_string:
    
    205 227
                 return True
    
    ... ... @@ -211,5 +233,5 @@ def _visible_func(self, model, treeiter, _data):
    211 233
                 return True
    
    212 234
             return False
    
    213 235
     
    
    214
    -    def _on_search_entry_changed(self, _widget):
    
    236
    +    def _on_search_entry_changed(self, _entry: Gtk.SearchEntry) -> None:
    
    215 237
             self.modelfilter.refilter()

  • gajim/gtk/assistant.py
    ... ... @@ -12,6 +12,12 @@
    12 12
     # You should have received a copy of the GNU General Public License
    
    13 13
     # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    14 14
     
    
    15
    +from __future__ import annotations
    
    16
    +from typing import Any
    
    17
    +from typing import Dict
    
    18
    +from typing import Optional
    
    19
    +from typing import Tuple
    
    20
    +
    
    15 21
     from gi.repository import Gdk
    
    16 22
     from gi.repository import Gtk
    
    17 23
     from gi.repository import Gio
    
    ... ... @@ -36,10 +42,10 @@ class Assistant(Gtk.ApplicationWindow, EventHelper):
    36 42
             ))
    
    37 43
     
    
    38 44
         def __init__(self,
    
    39
    -                 transient_for=None,
    
    40
    -                 width=550,
    
    41
    -                 height=400,
    
    42
    -                 transition_duration=200):
    
    45
    +                 transient_for: Optional[Gtk.Window] = None,
    
    46
    +                 width: int = 550,
    
    47
    +                 height: int = 400,
    
    48
    +                 transition_duration: int = 200) -> None:
    
    43 49
             Gtk.ApplicationWindow.__init__(self)
    
    44 50
             EventHelper.__init__(self)
    
    45 51
             self.set_application(Gio.Application.get_default())
    
    ... ... @@ -51,8 +57,8 @@ def __init__(self,
    51 57
             self.set_transient_for(transient_for)
    
    52 58
             self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
    
    53 59
     
    
    54
    -        self._pages = {}
    
    55
    -        self._buttons = {}
    
    60
    +        self._pages: Dict[str, Page] = {}
    
    61
    +        self._buttons: Dict[str, Tuple[Gtk.Button, bool]] = {}
    
    56 62
             self._button_visible_func = None
    
    57 63
     
    
    58 64
             self._ui = get_builder('assistant.ui')
    
    ... ... @@ -64,29 +70,32 @@ def __init__(self,
    64 70
             self.connect('destroy', self.__on_destroy)
    
    65 71
             self._ui.connect_signals(self)
    
    66 72
     
    
    67
    -    def show_all(self):
    
    73
    +    def show_all(self) -> None:
    
    68 74
             page_name = self._ui.stack.get_visible_child_name()
    
    69 75
             self.emit('page-changed', page_name)
    
    70 76
             Gtk.ApplicationWindow.show_all(self)
    
    71 77
     
    
    72
    -    def _on_key_press_event(self, _widget, event):
    
    78
    +    def _on_key_press_event(self,
    
    79
    +                            _widget: Gtk.Widget,
    
    80
    +                            event: Gdk.EventKey
    
    81
    +                            ) -> None:
    
    73 82
             if event.keyval == Gdk.KEY_Escape:
    
    74 83
                 self.destroy()
    
    75 84
     
    
    76
    -    def _update_page_complete(self, *args):
    
    85
    +    def _update_page_complete(self, *args: Any) -> None:
    
    77 86
             page_widget = self._ui.stack.get_visible_child()
    
    78 87
             for button, complete in self._buttons.values():
    
    79 88
                 if complete:
    
    80 89
                     button.set_sensitive(page_widget.complete)
    
    81 90
     
    
    82
    -    def update_title(self):
    
    91
    +    def update_title(self) -> None:
    
    83 92
             self.set_title(self._ui.stack.get_visible_child().title)
    
    84 93
     
    
    85
    -    def _hide_buttons(self):
    
    94
    +    def _hide_buttons(self) -> None:
    
    86 95
             for button, _ in self._buttons.values():
    
    87 96
                 button.hide()
    
    88 97
     
    
    89
    -    def _set_buttons_visible(self):
    
    98
    +    def _set_buttons_visible(self) -> None:
    
    90 99
             page_name = self._ui.stack.get_visible_child_name()
    
    91 100
             if self._button_visible_func is None:
    
    92 101
                 buttons = self.get_page(page_name).get_visible_buttons()
    
    ... ... @@ -112,11 +121,16 @@ def _set_buttons_visible(self):
    112 121
         def set_button_visible_func(self, func):
    
    113 122
             self._button_visible_func = func
    
    114 123
     
    
    115
    -    def set_default_button(self, button_name):
    
    124
    +    def set_default_button(self, button_name: str) -> None:
    
    116 125
             button, _ = self._buttons[button_name]
    
    117 126
             button.grab_default()
    
    118 127
     
    
    119
    -    def add_button(self, name, label, css_class=None, complete=False):
    
    128
    +    def add_button(self,
    
    129
    +                   name: str,
    
    130
    +                   label: str,
    
    131
    +                   css_class: Optional[str] = None,
    
    132
    +                   complete: bool = False
    
    133
    +                   ) -> None:
    
    120 134
             button = Gtk.Button(label=label,
    
    121 135
                                 can_default=True,
    
    122 136
                                 no_show_all=True)
    
    ... ... @@ -126,13 +140,13 @@ def add_button(self, name, label, css_class=None, complete=False):
    126 140
             self._buttons[name] = (button, complete)
    
    127 141
             self._ui.action_area.pack_end(button, False, False, 0)
    
    128 142
     
    
    129
    -    def add_pages(self, pages):
    
    143
    +    def add_pages(self, pages: Dict[str, Page]):
    
    130 144
             self._pages = pages
    
    131 145
             for name, widget in pages.items():
    
    132 146
                 widget.connect('update-page-complete', self._update_page_complete)
    
    133 147
                 self._ui.stack.add_named(widget, name)
    
    134 148
     
    
    135
    -    def add_default_page(self, name):
    
    149
    +    def add_default_page(self, name: str) -> Page:
    
    136 150
             if name == 'success':
    
    137 151
                 page = SuccessPage()
    
    138 152
             elif name == 'error':
    
    ... ... @@ -146,19 +160,22 @@ def add_default_page(self, name):
    146 160
             self._ui.stack.add_named(page, name)
    
    147 161
             return page
    
    148 162
     
    
    149
    -    def get_current_page(self):
    
    163
    +    def get_current_page(self) -> str:
    
    150 164
             return self._ui.stack.get_visible_child_name()
    
    151 165
     
    
    152
    -    def show_page(self, name, transition=Gtk.StackTransitionType.NONE):
    
    166
    +    def show_page(self,
    
    167
    +                  name: str,
    
    168
    +                  transition: Gtk.StackTransitionType = Gtk.StackTransitionType.NONE
    
    169
    +                  ) -> None:
    
    153 170
             if self._ui.stack.get_visible_child_name() == name:
    
    154 171
                 return
    
    155 172
             self._hide_buttons()
    
    156 173
             self._ui.stack.set_visible_child_full(name, transition)
    
    157 174
     
    
    158
    -    def get_page(self, name):
    
    175
    +    def get_page(self, name: str) -> Page:
    
    159 176
             return self._pages[name]
    
    160 177
     
    
    161
    -    def _on_visible_child_name(self, stack, _param):
    
    178
    +    def _on_visible_child_name(self, stack: Gtk.Stack, _param: str) -> None:
    
    162 179
             if stack.get_visible_child_name() is None:
    
    163 180
                 # Happens for some reason when adding the first page
    
    164 181
                 return
    
    ... ... @@ -166,14 +183,14 @@ def _on_visible_child_name(self, stack, _param):
    166 183
             self._set_buttons_visible()
    
    167 184
             self.emit('page-changed', stack.get_visible_child_name())
    
    168 185
     
    
    169
    -    def __on_button_clicked(self, button):
    
    186
    +    def __on_button_clicked(self, button: Gtk.Button) -> None:
    
    170 187
             for button_name, button_data in self._buttons.items():
    
    171 188
                 button_ = button_data[0]
    
    172 189
                 if button_ == button:
    
    173 190
                     self.emit('button-clicked', button_name)
    
    174 191
                     return
    
    175 192
     
    
    176
    -    def __on_destroy(self, *args):
    
    193
    +    def __on_destroy(self, *args: Any) -> None:
    
    177 194
             self._pages.clear()
    
    178 195
             self._buttons.clear()
    
    179 196
     
    
    ... ... @@ -184,26 +201,26 @@ class Page(Gtk.Box):
    184 201
             'update-page-complete': (GObject.SignalFlags.RUN_LAST, None, ()),
    
    185 202
         }
    
    186 203
     
    
    187
    -    def __init__(self):
    
    204
    +    def __init__(self) -> None:
    
    188 205
             Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
    
    189 206
             self.set_spacing(18)
    
    190 207
             self.set_valign(Gtk.Align.CENTER)
    
    191 208
     
    
    192
    -        self.title = ''
    
    193
    -        self.complete = True
    
    209
    +        self.title: str = ''
    
    210
    +        self.complete: bool = True
    
    194 211
     
    
    195
    -    def get_visible_buttons(self):
    
    212
    +    def get_visible_buttons(self) -> None:
    
    196 213
             return None
    
    197 214
     
    
    198
    -    def get_default_button(self):
    
    215
    +    def get_default_button(self) -> None:
    
    199 216
             return None
    
    200 217
     
    
    201
    -    def update_page_complete(self):
    
    218
    +    def update_page_complete(self) -> None:
    
    202 219
             self.emit('update-page-complete')
    
    203 220
     
    
    204 221
     
    
    205 222
     class DefaultPage(Page):
    
    206
    -    def __init__(self, icon_name, icon_css_class):
    
    223
    +    def __init__(self, icon_name: str, icon_css_class: str) -> None:
    
    207 224
             Page.__init__(self)
    
    208 225
     
    
    209 226
             self._heading = Gtk.Label()
    
    ... ... @@ -227,32 +244,32 @@ def __init__(self, icon_name, icon_css_class):
    227 244
             self.pack_start(self._label, False, True, 0)
    
    228 245
             self.show_all()
    
    229 246
     
    
    230
    -    def set_heading(self, heading):
    
    247
    +    def set_heading(self, heading: str) -> None:
    
    231 248
             self._heading.set_text(heading)
    
    232 249
     
    
    233
    -    def set_text(self, text):
    
    250
    +    def set_text(self, text: str) -> None:
    
    234 251
             self._label.set_text(text)
    
    235 252
     
    
    236
    -    def set_title(self, title):
    
    253
    +    def set_title(self, title: str) -> None:
    
    237 254
             self.title = title
    
    238 255
     
    
    239 256
     
    
    240 257
     class ErrorPage(DefaultPage):
    
    241
    -    def __init__(self):
    
    258
    +    def __init__(self) -> None:
    
    242 259
             DefaultPage.__init__(self,
    
    243 260
                                  icon_name='dialog-error-symbolic',
    
    244 261
                                  icon_css_class='error-color')
    
    245 262
     
    
    246 263
     
    
    247 264
     class SuccessPage(DefaultPage):
    
    248
    -    def __init__(self):
    
    265
    +    def __init__(self) -> None:
    
    249 266
             DefaultPage.__init__(self,
    
    250 267
                                  icon_name='object-select-symbolic',
    
    251 268
                                  icon_css_class='success-color')
    
    252 269
     
    
    253 270
     
    
    254 271
     class ProgressPage(Page):
    
    255
    -    def __init__(self):
    
    272
    +    def __init__(self) -> None:
    
    256 273
             Page.__init__(self)
    
    257 274
     
    
    258 275
             self._label = Gtk.Label()
    
    ... ... @@ -269,8 +286,8 @@ def __init__(self):
    269 286
     
    
    270 287
             self.show_all()
    
    271 288
     
    
    272
    -    def set_text(self, text):
    
    289
    +    def set_text(self, text: str) -> None:
    
    273 290
             self._label.set_text(text)
    
    274 291
     
    
    275
    -    def set_title(self, title):
    
    292
    +    def set_title(self, title: str) -> None:
    
    276 293
             self.title = title