Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
-
f5069e82
by wurstsalat at 2022-01-11T15:19:17+01:00
-
57525a54
by wurstsalat at 2022-01-11T15:26:22+01:00
-
fe4e4d2a
by wurstsalat at 2022-01-11T15:32:50+01:00
-
024433fb
by wurstsalat at 2022-01-11T15:34:33+01:00
7 changed files:
- gajim/common/helpers.py
- gajim/gtk/notification_manager.py
- gajim/gtk/password_dialog.py
- gajim/gtk/preferences.py
- gajim/gtk/ssl_error_dialog.py
- gajim/gtk/themes.py
- gajim/gui_interface.py
Changes:
| ... | ... | @@ -1053,7 +1053,7 @@ def open_uri(uri: Union[URI, str], account: Optional[str] = None) -> None: |
| 1053 | 1053 |
|
| 1054 | 1054 |
|
| 1055 | 1055 |
@catch_exceptions
|
| 1056 |
-def open_file(path: str) -> None:
|
|
| 1056 |
+def open_file(path: Union[str, Path]) -> None:
|
|
| 1057 | 1057 |
if os.name == 'nt':
|
| 1058 | 1058 |
os.startfile(path)
|
| 1059 | 1059 |
else:
|
| ... | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 |
from typing import Any
|
| 17 | 17 |
from typing import Optional
|
| 18 | 18 |
from typing import Union
|
| 19 |
+from typing import cast
|
|
| 19 | 20 |
|
| 20 | 21 |
from gi.repository import Gio
|
| 21 | 22 |
from gi.repository import GLib
|
| ... | ... | @@ -153,7 +154,8 @@ def _deny_request(self, jid: str) -> None: |
| 153 | 154 |
self._client.get_module('Presence').unsubscribed(jid)
|
| 154 | 155 |
|
| 155 | 156 |
def _get_notification_row(self, jid: str) -> Optional[NotificationRow]:
|
| 156 |
- for row in self.get_children():
|
|
| 157 |
+ rows = cast(list[NotificationRow], self.get_children())
|
|
| 158 |
+ for row in rows:
|
|
| 157 | 159 |
if row.jid == jid:
|
| 158 | 160 |
return row
|
| 159 | 161 |
return None
|
| ... | ... | @@ -291,7 +293,7 @@ def __init__(self, |
| 291 | 293 |
accept_button.set_valign(Gtk.Align.CENTER)
|
| 292 | 294 |
accept_button.set_action_name(
|
| 293 | 295 |
f'win.subscription-accept-{self._account}')
|
| 294 |
- accept_button.set_action_target_value(GLib.Variant('s', str(self.jid)))
|
|
| 296 |
+ accept_button.set_action_target_value(GLib.Variant('s', self.jid))
|
|
| 295 | 297 |
self.grid.attach(accept_button, 3, 1, 1, 2)
|
| 296 | 298 |
|
| 297 | 299 |
more_image = Gtk.Image.new_from_icon_name(
|
| ... | ... | @@ -299,7 +301,8 @@ def __init__(self, |
| 299 | 301 |
more_button = Gtk.MenuButton()
|
| 300 | 302 |
more_button.set_valign(Gtk.Align.CENTER)
|
| 301 | 303 |
more_button.add(more_image)
|
| 302 |
- subscription_menu = get_subscription_menu(self._account, self.jid)
|
|
| 304 |
+ subscription_menu = get_subscription_menu(
|
|
| 305 |
+ self._account, JID.from_string(self.jid))
|
|
| 303 | 306 |
more_button.set_menu_model(subscription_menu)
|
| 304 | 307 |
self.grid.attach(more_button, 4, 1, 1, 2)
|
| 305 | 308 |
|
| ... | ... | @@ -18,6 +18,7 @@ |
| 18 | 18 |
from gi.repository import Gdk
|
| 19 | 19 |
|
| 20 | 20 |
from gajim.common import app
|
| 21 |
+from gajim.common.events import PasswordRequired
|
|
| 21 | 22 |
from gajim.common.i18n import _
|
| 22 | 23 |
from gajim.common.passwords import save_password
|
| 23 | 24 |
from gajim.common.passwords import KEYRING_AVAILABLE
|
| ... | ... | @@ -28,7 +29,7 @@ |
| 28 | 29 |
|
| 29 | 30 |
|
| 30 | 31 |
class PasswordDialog(Gtk.ApplicationWindow):
|
| 31 |
- def __init__(self, account, event):
|
|
| 32 |
+ def __init__(self, account: str, event: PasswordRequired) -> None:
|
|
| 32 | 33 |
Gtk.ApplicationWindow.__init__(self)
|
| 33 | 34 |
self.set_application(app.app)
|
| 34 | 35 |
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
| ... | ... | @@ -43,7 +44,7 @@ def __init__(self, account, event): |
| 43 | 44 |
|
| 44 | 45 |
self.account = account
|
| 45 | 46 |
self._client = app.get_client(account)
|
| 46 |
- self.event = event
|
|
| 47 |
+ self._event = event
|
|
| 47 | 48 |
|
| 48 | 49 |
self.connect('key-press-event', self._on_key_press)
|
| 49 | 50 |
self._ui.connect_signals(self)
|
| ... | ... | @@ -52,16 +53,16 @@ def __init__(self, account, event): |
| 52 | 53 |
|
| 53 | 54 |
self._process_event()
|
| 54 | 55 |
|
| 55 |
- def _on_key_press(self, _widget, event):
|
|
| 56 |
+ def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> None:
|
|
| 56 | 57 |
if event.keyval == Gdk.KEY_Escape:
|
| 57 | 58 |
self.destroy()
|
| 58 | 59 |
|
| 59 |
- def _process_event(self):
|
|
| 60 |
+ def _process_event(self) -> None:
|
|
| 60 | 61 |
own_jid = self._client.get_own_jid().bare
|
| 61 | 62 |
account_name = app.settings.get_account_setting(
|
| 62 | 63 |
self.account, 'name')
|
| 63 | 64 |
|
| 64 |
- if self.event.name == 'password-required':
|
|
| 65 |
+ if self._event.name == 'password-required':
|
|
| 65 | 66 |
self._ui.header.set_text(_('Password Required'))
|
| 66 | 67 |
self._ui.message_label.set_text(
|
| 67 | 68 |
_('Please enter your password for\n'
|
| ... | ... | @@ -74,7 +75,7 @@ def _process_event(self): |
| 74 | 75 |
if not KEYRING_AVAILABLE:
|
| 75 | 76 |
self._ui.keyring_hint.show()
|
| 76 | 77 |
|
| 77 |
- if self.event.name == 'client-cert-passphrase':
|
|
| 78 |
+ if self._event.name == 'client-cert-passphrase':
|
|
| 78 | 79 |
self._ui.header.set_text(_('Certificate Password Required'))
|
| 79 | 80 |
self._ui.message_label.set_text(
|
| 80 | 81 |
_('Please enter your certificate password for '
|
| ... | ... | @@ -82,32 +83,32 @@ def _process_event(self): |
| 82 | 83 |
'jid': own_jid,
|
| 83 | 84 |
'account': account_name})
|
| 84 | 85 |
|
| 85 |
- def _on_ok(self, _button):
|
|
| 86 |
+ def _on_ok(self, _button: Gtk.Button) -> None:
|
|
| 86 | 87 |
password = self._ui.pass_entry.get_text()
|
| 87 | 88 |
|
| 88 |
- if self.event.name == 'password-required':
|
|
| 89 |
+ if self._event.name == 'password-required':
|
|
| 89 | 90 |
app.settings.set_account_setting(
|
| 90 | 91 |
self.account,
|
| 91 | 92 |
'savepass',
|
| 92 | 93 |
self._ui.save_pass_checkbutton.get_active())
|
| 93 | 94 |
save_password(self.account, password)
|
| 94 |
- self.event.on_password(password)
|
|
| 95 |
+ self._event.on_password(password)
|
|
| 95 | 96 |
self.destroy()
|
| 96 | 97 |
|
| 97 |
- if self.event.name == 'client-cert-passphrase':
|
|
| 98 |
- self.event.conn.on_client_cert_passphrase(
|
|
| 98 |
+ if self._event.name == 'client-cert-passphrase':
|
|
| 99 |
+ self._event.conn.on_client_cert_passphrase(
|
|
| 99 | 100 |
password,
|
| 100 |
- self.event.con,
|
|
| 101 |
- self.event.port,
|
|
| 102 |
- self.event.secure_tuple)
|
|
| 101 |
+ self._event.con,
|
|
| 102 |
+ self._event.port,
|
|
| 103 |
+ self._event.secure_tuple)
|
|
| 103 | 104 |
self.destroy()
|
| 104 | 105 |
|
| 105 |
- def _on_cancel(self, _button):
|
|
| 106 |
- if self.event.name == 'client-cert-passphrase':
|
|
| 107 |
- self.event.conn.on_client_cert_passphrase(
|
|
| 106 |
+ def _on_cancel(self, _button: Gtk.Button) -> None:
|
|
| 107 |
+ if self._event.name == 'client-cert-passphrase':
|
|
| 108 |
+ self._event.conn.on_client_cert_passphrase(
|
|
| 108 | 109 |
'',
|
| 109 |
- self.event.con,
|
|
| 110 |
- self.event.port,
|
|
| 111 |
- self.event.secure_tuple)
|
|
| 110 |
+ self._event.con,
|
|
| 111 |
+ self._event.port,
|
|
| 112 |
+ self._event.secure_tuple)
|
|
| 112 | 113 |
|
| 113 | 114 |
self.destroy()
|
| ... | ... | @@ -12,6 +12,11 @@ |
| 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 Optional
|
|
| 18 |
+from typing import cast
|
|
| 19 |
+ |
|
| 15 | 20 |
import logging
|
| 16 | 21 |
import sys
|
| 17 | 22 |
|
| ... | ... | @@ -49,7 +54,7 @@ |
| 49 | 54 |
|
| 50 | 55 |
|
| 51 | 56 |
class Preferences(Gtk.ApplicationWindow):
|
| 52 |
- def __init__(self):
|
|
| 57 |
+ def __init__(self) -> None:
|
|
| 53 | 58 |
Gtk.ApplicationWindow.__init__(self)
|
| 54 | 59 |
self.set_application(app.app)
|
| 55 | 60 |
self.set_position(Gtk.WindowPosition.CENTER)
|
| ... | ... | @@ -61,7 +66,7 @@ def __init__(self): |
| 61 | 66 |
|
| 62 | 67 |
self._ui = get_builder('preferences.ui')
|
| 63 | 68 |
|
| 64 |
- self._video_preview = None
|
|
| 69 |
+ self._video_preview: Optional[VideoPreview] = None
|
|
| 65 | 70 |
self._prefs = {}
|
| 66 | 71 |
|
| 67 | 72 |
side_bar_switcher = SideBarSwitcher()
|
| ... | ... | @@ -116,44 +121,46 @@ def _add_prefs(self, prefs): |
| 116 | 121 |
pref_box.add(pref)
|
| 117 | 122 |
self._prefs[ui_name] = pref
|
| 118 | 123 |
|
| 119 |
- def _add_video_preview(self):
|
|
| 124 |
+ def _add_video_preview(self) -> None:
|
|
| 120 | 125 |
if sys.platform == 'win32':
|
| 121 | 126 |
return
|
| 122 | 127 |
self._video_preview = VideoPreview()
|
| 123 | 128 |
self._ui.video.add(self._video_preview.widget)
|
| 124 | 129 |
|
| 125 |
- def _on_key_press(self, _widget, event):
|
|
| 130 |
+ def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> None:
|
|
| 126 | 131 |
if event.keyval == Gdk.KEY_Escape:
|
| 127 | 132 |
self.destroy()
|
| 128 | 133 |
|
| 129 |
- def get_video_preview(self):
|
|
| 134 |
+ def get_video_preview(self) -> Optional[VideoPreview]:
|
|
| 130 | 135 |
return self._video_preview
|
| 131 | 136 |
|
| 132 | 137 |
@staticmethod
|
| 133 |
- def _on_features_clicked(_widget, _response):
|
|
| 138 |
+ def _on_features_clicked(_widget: Gtk.InfoBar,
|
|
| 139 |
+ _response: Gtk.ResponseType
|
|
| 140 |
+ ) -> None:
|
|
| 134 | 141 |
open_window('Features')
|
| 135 | 142 |
|
| 136 |
- def update_theme_list(self):
|
|
| 143 |
+ def update_theme_list(self) -> None:
|
|
| 137 | 144 |
self._prefs['themes'].update_theme_list()
|
| 138 | 145 |
|
| 139 |
- def update_proxy_list(self):
|
|
| 146 |
+ def update_proxy_list(self) -> None:
|
|
| 140 | 147 |
self._prefs['miscellaneous'].update_proxy_list()
|
| 141 | 148 |
|
| 142 | 149 |
@staticmethod
|
| 143 |
- def _check_emoji_theme():
|
|
| 150 |
+ def _check_emoji_theme() -> None:
|
|
| 144 | 151 |
# Ensure selected emoji theme is valid
|
| 145 | 152 |
emoji_themes = helpers.get_available_emoticon_themes()
|
| 146 | 153 |
settings_theme = app.settings.get('emoticons_theme')
|
| 147 | 154 |
if settings_theme not in emoji_themes:
|
| 148 | 155 |
app.settings.set('emoticons_theme', 'font')
|
| 149 | 156 |
|
| 150 |
- def _on_destroy(self, _widget):
|
|
| 157 |
+ def _on_destroy(self, _widget: Gtk.Widget) -> None:
|
|
| 151 | 158 |
self._prefs.clear()
|
| 152 | 159 |
app.check_finalize(self)
|
| 153 | 160 |
|
| 154 | 161 |
|
| 155 | 162 |
class PreferenceBox(SettingsBox):
|
| 156 |
- def __init__(self, settings):
|
|
| 163 |
+ def __init__(self, settings: list[Setting]) -> None:
|
|
| 157 | 164 |
SettingsBox.__init__(self, None)
|
| 158 | 165 |
self.get_style_context().add_class('settings-border')
|
| 159 | 166 |
self.set_selection_mode(Gtk.SelectionMode.NONE)
|
| ... | ... | @@ -166,7 +173,7 @@ def __init__(self, settings): |
| 166 | 173 |
|
| 167 | 174 |
|
| 168 | 175 |
class WindowBehaviour(PreferenceBox):
|
| 169 |
- def __init__(self, *args):
|
|
| 176 |
+ def __init__(self, *args: Any) -> None:
|
|
| 170 | 177 |
|
| 171 | 178 |
main_window_on_startup_items = {
|
| 172 | 179 |
'always': _('Always'),
|
| ... | ... | @@ -193,7 +200,7 @@ def __init__(self, *args): |
| 193 | 200 |
|
| 194 | 201 |
|
| 195 | 202 |
class Chats(PreferenceBox):
|
| 196 |
- def __init__(self, *args):
|
|
| 203 |
+ def __init__(self, *args: Any) -> None:
|
|
| 197 | 204 |
|
| 198 | 205 |
speller_desc = None
|
| 199 | 206 |
if not app.is_installed('GSPELL'):
|
| ... | ... | @@ -243,11 +250,11 @@ def __init__(self, *args): |
| 243 | 250 |
PreferenceBox.__init__(self, settings)
|
| 244 | 251 |
|
| 245 | 252 |
@staticmethod
|
| 246 |
- def _speller_available():
|
|
| 253 |
+ def _speller_available() -> bool:
|
|
| 247 | 254 |
return app.is_installed('GSPELL')
|
| 248 | 255 |
|
| 249 | 256 |
@staticmethod
|
| 250 |
- def _on_use_speller(value, *args):
|
|
| 257 |
+ def _on_use_speller(value: bool, *args: Any) -> None:
|
|
| 251 | 258 |
if not value:
|
| 252 | 259 |
return
|
| 253 | 260 |
|
| ... | ... | @@ -261,7 +268,7 @@ def _on_use_speller(value, *args): |
| 261 | 268 |
|
| 262 | 269 |
|
| 263 | 270 |
class GroupChats(PreferenceBox):
|
| 264 |
- def __init__(self, *args):
|
|
| 271 |
+ def __init__(self, *args: Any) -> None:
|
|
| 265 | 272 |
|
| 266 | 273 |
settings = [
|
| 267 | 274 |
Setting(SettingKind.POPOVER,
|
| ... | ... | @@ -320,30 +327,30 @@ def __init__(self, *args): |
| 320 | 327 |
PreferenceBox.__init__(self, settings)
|
| 321 | 328 |
|
| 322 | 329 |
@staticmethod
|
| 323 |
- def _on_sort_by_show_in_muc(*args):
|
|
| 330 |
+ def _on_sort_by_show_in_muc(_value: bool, *args: Any) -> None:
|
|
| 324 | 331 |
for ctrl in app.window.get_controls():
|
| 325 | 332 |
if ctrl.is_groupchat:
|
| 326 | 333 |
ctrl.roster.invalidate_sort()
|
| 327 | 334 |
|
| 328 | 335 |
@staticmethod
|
| 329 |
- def _on_show_status_in_roster(*args):
|
|
| 336 |
+ def _on_show_status_in_roster(_value: bool, *args: Any) -> None:
|
|
| 330 | 337 |
for ctrl in app.window.get_controls():
|
| 331 | 338 |
if ctrl.is_groupchat:
|
| 332 | 339 |
ctrl.roster.draw_contacts()
|
| 333 | 340 |
|
| 334 | 341 |
@staticmethod
|
| 335 |
- def _reset_join_left(button):
|
|
| 342 |
+ def _reset_join_left(button: Gtk.Button) -> None:
|
|
| 336 | 343 |
button.set_sensitive(False)
|
| 337 | 344 |
app.settings.set_group_chat_settings('print_join_left', None)
|
| 338 | 345 |
|
| 339 | 346 |
@staticmethod
|
| 340 |
- def _reset_print_status(button):
|
|
| 347 |
+ def _reset_print_status(button: Gtk.Button) -> None:
|
|
| 341 | 348 |
button.set_sensitive(False)
|
| 342 | 349 |
app.settings.set_group_chat_settings('print_status', None)
|
| 343 | 350 |
|
| 344 | 351 |
|
| 345 | 352 |
class FilePreview(PreferenceBox):
|
| 346 |
- def __init__(self, *args):
|
|
| 353 |
+ def __init__(self, *args: Any) -> None:
|
|
| 347 | 354 |
sizes = {
|
| 348 | 355 |
262144: '256 KiB',
|
| 349 | 356 |
524288: '512 KiB',
|
| ... | ... | @@ -407,7 +414,7 @@ def __init__(self, *args): |
| 407 | 414 |
|
| 408 | 415 |
|
| 409 | 416 |
class VisualNotifications(PreferenceBox):
|
| 410 |
- def __init__(self, *args):
|
|
| 417 |
+ def __init__(self, *args: Any) -> None:
|
|
| 411 | 418 |
trayicon_items = {
|
| 412 | 419 |
'never': _('Hide icon'),
|
| 413 | 420 |
'on_event': _('Only show for pending events'),
|
| ... | ... | @@ -431,7 +438,7 @@ def __init__(self, *args): |
| 431 | 438 |
PreferenceBox.__init__(self, settings)
|
| 432 | 439 |
|
| 433 | 440 |
@staticmethod
|
| 434 |
- def _on_trayicon(value, *args):
|
|
| 441 |
+ def _on_trayicon(value: str, *args: Any) -> None:
|
|
| 435 | 442 |
if value == 'never':
|
| 436 | 443 |
app.interface.hide_systray()
|
| 437 | 444 |
elif value == 'on_event':
|
| ... | ... | @@ -441,7 +448,7 @@ def _on_trayicon(value, *args): |
| 441 | 448 |
|
| 442 | 449 |
|
| 443 | 450 |
class NotificationsDialog(SettingsDialog):
|
| 444 |
- def __init__(self, account, parent):
|
|
| 451 |
+ def __init__(self, account: str, parent: Preferences) -> None:
|
|
| 445 | 452 |
|
| 446 | 453 |
settings = [
|
| 447 | 454 |
Setting(SettingKind.SWITCH,
|
| ... | ... | @@ -463,7 +470,7 @@ def __init__(self, account, parent): |
| 463 | 470 |
|
| 464 | 471 |
|
| 465 | 472 |
class Sounds(PreferenceBox):
|
| 466 |
- def __init__(self, *args):
|
|
| 473 |
+ def __init__(self, *args: Any) -> None:
|
|
| 467 | 474 |
|
| 468 | 475 |
settings = [
|
| 469 | 476 |
Setting(SettingKind.SWITCH,
|
| ... | ... | @@ -484,12 +491,12 @@ def __init__(self, *args): |
| 484 | 491 |
|
| 485 | 492 |
PreferenceBox.__init__(self, settings)
|
| 486 | 493 |
|
| 487 |
- def _on_manage_sounds(self, *args):
|
|
| 494 |
+ def _on_manage_sounds(self, _button: Gtk.Button) -> None:
|
|
| 488 | 495 |
open_window('ManageSounds', transient_for=self.get_toplevel())
|
| 489 | 496 |
|
| 490 | 497 |
|
| 491 | 498 |
class StatusMessage(PreferenceBox):
|
| 492 |
- def __init__(self, *args):
|
|
| 499 |
+ def __init__(self, *args: Any) -> None:
|
|
| 493 | 500 |
|
| 494 | 501 |
settings = [
|
| 495 | 502 |
Setting(SettingKind.SWITCH,
|
| ... | ... | @@ -512,7 +519,7 @@ def __init__(self, *args): |
| 512 | 519 |
|
| 513 | 520 |
|
| 514 | 521 |
class AutomaticStatus(PreferenceBox):
|
| 515 |
- def __init__(self, *args):
|
|
| 522 |
+ def __init__(self, *args: Any) -> None:
|
|
| 516 | 523 |
|
| 517 | 524 |
settings = [
|
| 518 | 525 |
Setting(SettingKind.AUTO_AWAY,
|
| ... | ... | @@ -534,16 +541,16 @@ def __init__(self, *args): |
| 534 | 541 |
PreferenceBox.__init__(self, settings)
|
| 535 | 542 |
|
| 536 | 543 |
@staticmethod
|
| 537 |
- def _get_auto_away():
|
|
| 544 |
+ def _get_auto_away() -> bool:
|
|
| 538 | 545 |
return app.settings.get('autoaway')
|
| 539 | 546 |
|
| 540 | 547 |
@staticmethod
|
| 541 |
- def _get_auto_xa():
|
|
| 548 |
+ def _get_auto_xa() -> bool:
|
|
| 542 | 549 |
return app.settings.get('autoxa')
|
| 543 | 550 |
|
| 544 | 551 |
|
| 545 | 552 |
class AutoAwayDialog(SettingsDialog):
|
| 546 |
- def __init__(self, account, parent):
|
|
| 553 |
+ def __init__(self, account: str, parent: Preferences) -> None:
|
|
| 547 | 554 |
|
| 548 | 555 |
settings = [
|
| 549 | 556 |
Setting(SettingKind.SWITCH,
|
| ... | ... | @@ -571,7 +578,7 @@ def __init__(self, account, parent): |
| 571 | 578 |
|
| 572 | 579 |
|
| 573 | 580 |
class AutoExtendedAwayDialog(SettingsDialog):
|
| 574 |
- def __init__(self, account, parent):
|
|
| 581 |
+ def __init__(self, account: str, parent: Preferences) -> None:
|
|
| 575 | 582 |
|
| 576 | 583 |
settings = [
|
| 577 | 584 |
Setting(SettingKind.SWITCH,
|
| ... | ... | @@ -599,7 +606,7 @@ def __init__(self, account, parent): |
| 599 | 606 |
|
| 600 | 607 |
|
| 601 | 608 |
class Themes(PreferenceBox):
|
| 602 |
- def __init__(self, *args):
|
|
| 609 |
+ def __init__(self, *args: Any) -> None:
|
|
| 603 | 610 |
|
| 604 | 611 |
theme_items = self._get_theme_items()
|
| 605 | 612 |
|
| ... | ... | @@ -631,37 +638,37 @@ def __init__(self, *args): |
| 631 | 638 |
PreferenceBox.__init__(self, settings)
|
| 632 | 639 |
|
| 633 | 640 |
@staticmethod
|
| 634 |
- def _get_theme_items():
|
|
| 641 |
+ def _get_theme_items() -> list[str]:
|
|
| 635 | 642 |
theme_items = ['default']
|
| 636 | 643 |
for settings_theme in app.css_config.themes:
|
| 637 | 644 |
theme_items.append(settings_theme)
|
| 638 | 645 |
return theme_items
|
| 639 | 646 |
|
| 640 |
- def update_theme_list(self):
|
|
| 647 |
+ def update_theme_list(self) -> None:
|
|
| 641 | 648 |
self.get_setting('roster_theme').update_entries(self._get_theme_items())
|
| 642 | 649 |
|
| 643 |
- def _on_edit_themes(self, *args):
|
|
| 650 |
+ def _on_edit_themes(self, _button: Gtk.Button) -> None:
|
|
| 644 | 651 |
open_window('Themes', transient=self.get_toplevel())
|
| 645 | 652 |
|
| 646 | 653 |
@staticmethod
|
| 647 |
- def _on_theme_changed(value, *args):
|
|
| 654 |
+ def _on_theme_changed(value: str, *args: Any) -> None:
|
|
| 648 | 655 |
app.css_config.change_theme(value)
|
| 649 | 656 |
app.ged.raise_event(ThemeUpdate())
|
| 650 | 657 |
app.ged.raise_event(StyleChanged())
|
| 651 | 658 |
|
| 652 | 659 |
@staticmethod
|
| 653 |
- def _on_dark_theme(value, *args):
|
|
| 660 |
+ def _on_dark_theme(value: str, *args: Any) -> None:
|
|
| 654 | 661 |
app.css_config.set_dark_theme(int(value))
|
| 655 | 662 |
app.ged.raise_event(StyleChanged())
|
| 656 | 663 |
|
| 657 | 664 |
|
| 658 | 665 |
class Emoji(PreferenceBox):
|
| 659 |
- def __init__(self, *args):
|
|
| 666 |
+ def __init__(self, *args: Any) -> None:
|
|
| 660 | 667 |
if sys.platform not in ('win32', 'darwin'):
|
| 661 | 668 |
PreferenceBox.__init__(self, [])
|
| 662 | 669 |
return
|
| 663 | 670 |
|
| 664 |
- emoji_themes_items = []
|
|
| 671 |
+ emoji_themes_items: list[str] = []
|
|
| 665 | 672 |
for theme in helpers.get_available_emoticon_themes():
|
| 666 | 673 |
emoji_themes_items.append(theme)
|
| 667 | 674 |
|
| ... | ... | @@ -677,18 +684,18 @@ def __init__(self, *args): |
| 677 | 684 |
|
| 678 | 685 |
PreferenceBox.__init__(self, settings)
|
| 679 | 686 |
|
| 680 |
- def _on_emoticons_theme(self, *args):
|
|
| 687 |
+ def _on_emoticons_theme(self, *args: Any) -> None:
|
|
| 681 | 688 |
emoji_chooser.load()
|
| 682 | 689 |
self._toggle_emoticons()
|
| 683 | 690 |
|
| 684 | 691 |
@staticmethod
|
| 685 |
- def _toggle_emoticons():
|
|
| 692 |
+ def _toggle_emoticons() -> None:
|
|
| 686 | 693 |
for ctrl in app.window.get_controls():
|
| 687 | 694 |
ctrl.toggle_emoticons()
|
| 688 | 695 |
|
| 689 | 696 |
|
| 690 | 697 |
class Server(PreferenceBox):
|
| 691 |
- def __init__(self, *args):
|
|
| 698 |
+ def __init__(self, *args: Any) -> None:
|
|
| 692 | 699 |
|
| 693 | 700 |
settings = [
|
| 694 | 701 |
|
| ... | ... | @@ -705,7 +712,7 @@ def __init__(self, *args): |
| 705 | 712 |
|
| 706 | 713 |
|
| 707 | 714 |
class StunServerDialog(SettingsDialog):
|
| 708 |
- def __init__(self, account, parent):
|
|
| 715 |
+ def __init__(self, account: str, parent: Preferences) -> None:
|
|
| 709 | 716 |
|
| 710 | 717 |
settings = [
|
| 711 | 718 |
Setting(SettingKind.SWITCH,
|
| ... | ... | @@ -725,7 +732,7 @@ def __init__(self, account, parent): |
| 725 | 732 |
|
| 726 | 733 |
|
| 727 | 734 |
class Audio(PreferenceBox):
|
| 728 |
- def __init__(self, *args):
|
|
| 735 |
+ def __init__(self, *args: Any) -> None:
|
|
| 729 | 736 |
|
| 730 | 737 |
deps_installed = app.is_installed('AV')
|
| 731 | 738 |
|
| ... | ... | @@ -760,18 +767,18 @@ def __init__(self, *args): |
| 760 | 767 |
self.set_sensitive(deps_installed)
|
| 761 | 768 |
|
| 762 | 769 |
@staticmethod
|
| 763 |
- def _create_av_combo_items(items_dict):
|
|
| 770 |
+ def _create_av_combo_items(items_dict: dict[str, str]) -> dict[str, str]:
|
|
| 764 | 771 |
items = enumerate(sorted(
|
| 765 | 772 |
items_dict.items(),
|
| 766 | 773 |
key=lambda x: '' if x[1].startswith('auto') else x[0].lower()))
|
| 767 |
- combo_items = {}
|
|
| 774 |
+ combo_items: dict[str, str] = {}
|
|
| 768 | 775 |
for _index, (name, value) in items:
|
| 769 | 776 |
combo_items[value] = name
|
| 770 | 777 |
return combo_items
|
| 771 | 778 |
|
| 772 | 779 |
|
| 773 | 780 |
class Video(PreferenceBox):
|
| 774 |
- def __init__(self, *args):
|
|
| 781 |
+ def __init__(self, *args: Any) -> None:
|
|
| 775 | 782 |
|
| 776 | 783 |
deps_installed = app.is_installed('AV')
|
| 777 | 784 |
|
| ... | ... | @@ -836,31 +843,33 @@ def __init__(self, *args): |
| 836 | 843 |
self.set_sensitive(deps_installed)
|
| 837 | 844 |
|
| 838 | 845 |
@staticmethod
|
| 839 |
- def _on_video_input_changed(_value, *args):
|
|
| 840 |
- preview = get_app_window('Preferences').get_video_preview()
|
|
| 846 |
+ def _on_video_input_changed(_value: str, *args: Any) -> None:
|
|
| 847 |
+ pref_win = cast(Preferences, get_app_window('Preferences'))
|
|
| 848 |
+ preview = pref_win.get_video_preview()
|
|
| 841 | 849 |
if preview is None or not preview.is_active:
|
| 842 | 850 |
# changed signal gets triggered when we fill the combobox
|
| 843 | 851 |
return
|
| 844 | 852 |
preview.refresh()
|
| 845 | 853 |
|
| 846 | 854 |
@staticmethod
|
| 847 |
- def _toggle_live_preview(value, *args):
|
|
| 848 |
- preview = get_app_window('Preferences').get_video_preview()
|
|
| 855 |
+ def _toggle_live_preview(value: bool, *args: Any) -> None:
|
|
| 856 |
+ pref_win = cast(Preferences, get_app_window('Preferences'))
|
|
| 857 |
+ preview = pref_win.get_video_preview()
|
|
| 849 | 858 |
preview.toggle_preview(value)
|
| 850 | 859 |
|
| 851 | 860 |
@staticmethod
|
| 852 |
- def _create_av_combo_items(items_dict):
|
|
| 861 |
+ def _create_av_combo_items(items_dict: dict[str, str]) -> dict[str, str]:
|
|
| 853 | 862 |
items = enumerate(sorted(
|
| 854 | 863 |
items_dict.items(),
|
| 855 | 864 |
key=lambda x: '' if x[1].startswith('auto') else x[0].lower()))
|
| 856 |
- combo_items = {}
|
|
| 865 |
+ combo_items: dict[str, str] = {}
|
|
| 857 | 866 |
for _index, (name, value) in items:
|
| 858 | 867 |
combo_items[value] = name
|
| 859 | 868 |
return combo_items
|
| 860 | 869 |
|
| 861 | 870 |
|
| 862 | 871 |
class Miscellaneous(PreferenceBox):
|
| 863 |
- def __init__(self, pref_window):
|
|
| 872 |
+ def __init__(self, pref_window: Preferences) -> None:
|
|
| 864 | 873 |
self._hints_list = [
|
| 865 | 874 |
'start_chat',
|
| 866 | 875 |
]
|
| ... | ... | @@ -898,30 +907,30 @@ def __init__(self, pref_window): |
| 898 | 907 |
reset_button.set_sensitive(self._check_hints_reset)
|
| 899 | 908 |
|
| 900 | 909 |
@staticmethod
|
| 901 |
- def _get_proxies():
|
|
| 910 |
+ def _get_proxies() -> dict[str, str]:
|
|
| 902 | 911 |
return {proxy: proxy for proxy in app.settings.get_proxies()}
|
| 903 | 912 |
|
| 904 | 913 |
@staticmethod
|
| 905 |
- def _on_proxy_edit(*args):
|
|
| 914 |
+ def _on_proxy_edit(*args: Any) -> None:
|
|
| 906 | 915 |
open_window('ManageProxies')
|
| 907 | 916 |
|
| 908 |
- def update_proxy_list(self):
|
|
| 917 |
+ def update_proxy_list(self) -> None:
|
|
| 909 | 918 |
self.get_setting('global_proxy').update_entries(self._get_proxies())
|
| 910 | 919 |
|
| 911 |
- def _check_hints_reset(self):
|
|
| 920 |
+ def _check_hints_reset(self) -> bool:
|
|
| 912 | 921 |
for hint in self._hints_list:
|
| 913 |
- if app.settings.get('show_help_%s' % hint) is False:
|
|
| 922 |
+ if app.settings.get(f'show_help_{hint}') is False:
|
|
| 914 | 923 |
return True
|
| 915 | 924 |
return False
|
| 916 | 925 |
|
| 917 |
- def _on_reset_hints(self, button):
|
|
| 926 |
+ def _on_reset_hints(self, button: Gtk.Button) -> None:
|
|
| 918 | 927 |
for hint in self._hints_list:
|
| 919 |
- app.settings.set('show_help_%s' % hint, True)
|
|
| 928 |
+ app.settings.set(f'show_help_{hint}', True)
|
|
| 920 | 929 |
button.set_sensitive(False)
|
| 921 | 930 |
|
| 922 | 931 |
|
| 923 | 932 |
class Advanced(PreferenceBox):
|
| 924 |
- def __init__(self, pref_window):
|
|
| 933 |
+ def __init__(self, pref_window: Preferences) -> None:
|
|
| 925 | 934 |
|
| 926 | 935 |
settings = [
|
| 927 | 936 |
Setting(SettingKind.SWITCH,
|
| ... | ... | @@ -939,13 +948,13 @@ def __init__(self, pref_window): |
| 939 | 948 |
'clicked', self._on_advanced_config_editor)
|
| 940 | 949 |
|
| 941 | 950 |
@staticmethod
|
| 942 |
- def _on_debug_logging(value, *args):
|
|
| 951 |
+ def _on_debug_logging(value: bool, *args: Any) -> None:
|
|
| 943 | 952 |
app.set_debug_mode(value)
|
| 944 | 953 |
|
| 945 | 954 |
@staticmethod
|
| 946 |
- def _on_open_debug_logs(*args):
|
|
| 955 |
+ def _on_open_debug_logs(*args: Any) -> None:
|
|
| 947 | 956 |
open_file(configpaths.get('DEBUG'))
|
| 948 | 957 |
|
| 949 | 958 |
@staticmethod
|
| 950 |
- def _on_advanced_config_editor(*args):
|
|
| 959 |
+ def _on_advanced_config_editor(*args: Any) -> None:
|
|
| 951 | 960 |
open_window('AdvancedConfig')
|
| ... | ... | @@ -74,16 +74,18 @@ def _process_error(self) -> None: |
| 74 | 74 |
self._ui.connect_button.set_no_show_all(True)
|
| 75 | 75 |
self._ui.connect_button.hide()
|
| 76 | 76 |
|
| 77 |
- def _on_view_cert_clicked(self, _button):
|
|
| 77 |
+ def _on_view_cert_clicked(self, _button: Gtk.Button) -> None:
|
|
| 78 | 78 |
open_window('CertificateDialog',
|
| 79 | 79 |
account=self.account,
|
| 80 | 80 |
transient_for=self,
|
| 81 | 81 |
cert=self._cert)
|
| 82 | 82 |
|
| 83 |
- def _on_add_certificate_toggled(self, checkbutton):
|
|
| 83 |
+ def _on_add_certificate_toggled(self,
|
|
| 84 |
+ checkbutton: Gtk.CheckButton
|
|
| 85 |
+ ) -> None:
|
|
| 84 | 86 |
self._ui.connect_button.set_sensitive(checkbutton.get_active())
|
| 85 | 87 |
|
| 86 |
- def _on_connect_clicked(self, _button):
|
|
| 88 |
+ def _on_connect_clicked(self, _button: Gtk.Button) -> None:
|
|
| 87 | 89 |
if self._ui.add_certificate_checkbutton.get_active():
|
| 88 | 90 |
app.cert_store.add_certificate(self._cert)
|
| 89 | 91 |
|
| ... | ... | @@ -16,8 +16,10 @@ |
| 16 | 16 |
|
| 17 | 17 |
from __future__ import annotations
|
| 18 | 18 |
from typing import NamedTuple
|
| 19 |
+from typing import Optional
|
|
| 19 | 20 |
from typing import Any
|
| 20 | 21 |
from typing import Union
|
| 22 |
+from typing import cast
|
|
| 21 | 23 |
|
| 22 | 24 |
from enum import IntEnum
|
| 23 | 25 |
|
| ... | ... | @@ -35,6 +37,7 @@ |
| 35 | 37 |
from .dialogs import DialogButton
|
| 36 | 38 |
from .dialogs import ConfirmationDialog
|
| 37 | 39 |
from .builder import get_builder
|
| 40 |
+from .preferences import Preferences
|
|
| 38 | 41 |
from .util import get_app_window
|
| 39 | 42 |
|
| 40 | 43 |
|
| ... | ... | @@ -239,7 +242,7 @@ def _load_options(self) -> None: |
| 239 | 242 |
row = Option(option, value)
|
| 240 | 243 |
self._ui.option_listbox.add(row)
|
| 241 | 244 |
|
| 242 |
- def _add_option(self, _listbox: Gtk.ListBox, row: Gtk.ListBoxRow) -> None:
|
|
| 245 |
+ def _add_option(self, _listbox: Gtk.ListBox, row: Option) -> None:
|
|
| 243 | 246 |
# Add theme if there is none
|
| 244 | 247 |
store, _ = self._ui.theme_treeview.get_selection().get_selected()
|
| 245 | 248 |
first = store.get_iter_first()
|
| ... | ... | @@ -298,7 +301,7 @@ def _apply_theme(theme: str) -> None: |
| 298 | 301 |
|
| 299 | 302 |
@staticmethod
|
| 300 | 303 |
def _update_preferences_window() -> None:
|
| 301 |
- window = get_app_window('Preferences')
|
|
| 304 |
+ window = cast(Optional[Preferences], get_app_window('Preferences'))
|
|
| 302 | 305 |
if window is not None:
|
| 303 | 306 |
window.update_theme_list()
|
| 304 | 307 |
|
| ... | ... | @@ -76,6 +76,7 @@ |
| 76 | 76 |
from gajim.common.events import FileProgress
|
| 77 | 77 |
from gajim.common.events import FileError
|
| 78 | 78 |
from gajim.common.events import MucAdded
|
| 79 |
+from gajim.common.events import PasswordRequired
|
|
| 79 | 80 |
from gajim.common.zeroconf import connection_zeroconf
|
| 80 | 81 |
from gajim.common.helpers import ask_for_status_message
|
| 81 | 82 |
from gajim.common.structs import OutgoingMessage
|
| ... | ... | @@ -291,7 +292,7 @@ def handle_event_client_cert_passphrase(event): |
| 291 | 292 |
open_window('PasswordDialog', account=event.conn.name, event=event)
|
| 292 | 293 |
|
| 293 | 294 |
@staticmethod
|
| 294 |
- def handle_event_password_required(event):
|
|
| 295 |
+ def handle_event_password_required(event: PasswordRequired) -> None:
|
|
| 295 | 296 |
open_window('PasswordDialog', account=event.conn.name, event=event)
|
| 296 | 297 |
|
| 297 | 298 |
@staticmethod
|