Daniel Brötzmann pushed to branch master at gajim / gajim
Commits: 813143be by wurstsalat at 2021-12-22T21:04:46+01:00 AccountWizard: Typing
- - - - - 89450395 by wurstsalat at 2021-12-22T21:08:18+01:00 AppSideBar: Typing
- - - - - 51ad2f92 by wurstsalat at 2021-12-22T21:26:30+01:00 AvatarSelector: Typing
- - - - - 7c145ffa by wurstsalat at 2021-12-22T21:37:07+01:00 ChangePassword: Typing
- - - - - ca9aee26 by wurstsalat at 2021-12-22T21:45:48+01:00 ChatListStack: Typing
- - - - - d26bb934 by wurstsalat at 2021-12-22T21:56:04+01:00 AddContact: List connected accounts only
- - - - -
6 changed files:
- gajim/gtk/account_wizard.py - gajim/gtk/add_contact.py - gajim/gtk/app_side_bar.py - gajim/gtk/avatar_selector.py - gajim/gtk/change_password.py - gajim/gtk/chat_list_stack.py
Changes:
===================================== gajim/gtk/account_wizard.py ===================================== @@ -12,8 +12,9 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
-from typing import Optional +from typing import Any from typing import List +from typing import Optional from typing import Tuple from typing import Union
@@ -35,6 +36,7 @@ from nbxmpp.errors import StanzaError from nbxmpp.errors import MalformedStanzaError from nbxmpp.errors import RegisterStanzaError +from nbxmpp.task import Task
from gajim.common import app from gajim.common import configpaths @@ -101,7 +103,7 @@ def __init__(self) -> None: def get_currenct_method(self) -> str: return self._method
- def _on_button_clicked(self, _page, button_name): + def _on_button_clicked(self, _page: Gtk.Widget, button_name: str) -> None: if button_name == 'login': if self.get_page('login').is_advanced(): self.show_page('advanced', @@ -112,7 +114,10 @@ def _on_button_clicked(self, _page, button_name): elif button_name == 'signup': self.show_page('signup', Gtk.StackTransitionType.SLIDE_LEFT)
- def _on_assistant_button_clicked(self, _assistant, button_name): + def _on_assistant_button_clicked(self, + _assistant: Assistant, + button_name: str + ) -> None: page = self.get_current_page()
if button_name == 'login': @@ -185,7 +190,10 @@ def _on_assistant_button_clicked(self, _assistant, button_name): elif page == 'redirect': self.show_page('login', Gtk.StackTransitionType.SLIDE_RIGHT)
- def _on_page_changed(self, _assistant, page_name): + def _on_page_changed(self, + _assistant: Assistant, + page_name: str + ) -> None: if page_name == 'signup': self._method = page_name self.get_page('signup').focus() @@ -240,13 +248,19 @@ def _disconnect(self) -> None: self._client = None
@staticmethod - def _on_stanza_sent(_client, _signal_name, stanza): + def _on_stanza_sent(_client: Client, + _signal_name: str, + stanza: Any + ) -> None: app.nec.push_incoming_event(NetworkEvent('stanza-sent', account='AccountWizard', stanza=stanza))
@staticmethod - def _on_stanza_received(_client, _signal_name, stanza): + def _on_stanza_received(_client: Client, + _signal_name: str, + stanza: Any + ) -> None: app.nec.push_incoming_event(NetworkEvent('stanza-received', account='AccountWizard', stanza=stanza)) @@ -304,7 +318,7 @@ def _register_with_server(self, ignore_all_errors: bool = False) -> None:
self._client.connect()
- def _on_login_successful(self, client, _signal_name): + def _on_login_successful(self, client: Client, _signal_name: str) -> None: account = self._generate_account_name(client.domain) proxy_name = None if client.proxy is not None: @@ -319,11 +333,14 @@ def _on_login_successful(self, client, _signal_name): self.get_page('success').set_account(account) self.show_page('success', Gtk.StackTransitionType.SLIDE_LEFT)
- def _on_connected(self, client, _signal_name): + def _on_connected(self, client: Client, _signal_name: str) -> None: client.get_module('Register').request_register_form( callback=self._on_register_form)
- def _on_anonymous_supported(self, client, _signal_name): + def _on_anonymous_supported(self, + client: Client, + _signal_name: str + ) -> None: account = self._generate_account_name(client.domain) proxy_name = None if client.proxy is not None: @@ -339,7 +356,7 @@ def _on_anonymous_supported(self, client, _signal_name): self.get_page('success').set_account(account) self.show_page('success', Gtk.StackTransitionType.SLIDE_LEFT)
- def _on_disconnected(self, client, _signal_name): + def _on_disconnected(self, client: Client, _signal_name: str) -> None: domain, error, text = client.get_error() if domain == StreamError.SASL: if error == 'anonymous-not-supported': @@ -380,7 +397,10 @@ def _on_disconnected(self, client, _signal_name): self._client.destroy() self._client = None
- def _on_connection_failed(self, _client, _signal_name): + def _on_connection_failed(self, + _client: Client, + _signal_name: str + ) -> None: self._show_error_page(_('Connection failed'), _('Connection failed'), _('Gajim was not able to reach the server. ' @@ -407,7 +427,7 @@ def _generate_account_name(domain: str) -> str: i += 1 return domain
- def _on_register_form(self, task): + def _on_register_form(self, task: Task) -> None: try: result = task.finish() except (StanzaError, MalformedStanzaError) as error: @@ -446,7 +466,7 @@ def _submit_form(self) -> None: form, callback=self._on_register_result)
- def _on_register_result(self, task): + def _on_register_result(self, task: Task) -> None: try: task.finish() except RegisterStanzaError as error: @@ -505,7 +525,7 @@ def _set_error_text(self, 'without an error message') self._show_error_page(_('Error'), _('Error'), error_text)
- def _on_destroy(self, *args): + def _on_destroy(self, *args: Any) -> None: self._disconnect() self._destroyed = True
@@ -540,10 +560,10 @@ def __init__(self) -> None: def focus(self) -> None: self._ui.log_in_address_entry.grab_focus()
- def _on_login(self, *args): + def _on_login(self, *args: Any) -> None: self.emit('clicked', 'login')
- def _on_signup(self, *args): + def _on_signup(self, *args: Any) -> None: self.emit('clicked', 'signup')
def _create_server_completion(self) -> None: @@ -558,11 +578,11 @@ def _create_server_completion(self) -> None: address_model.append((server,)) self._ui.log_in_address_entry.get_completion().set_model(address_model)
- def _on_address_changed(self, entry): + def _on_address_changed(self, entry: Gtk.Entry) -> None: self._update_completion(entry) self._set_complete()
- def _update_completion(self, entry): + def _update_completion(self, entry: Gtk.Entry) -> None: text = entry.get_text() if '@' not in text: self._show_icon(False) @@ -580,10 +600,10 @@ def _show_icon(self, show: bool) -> None: self._ui.log_in_address_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, icon)
- def _on_address_entry_activate(self, _widget): + def _on_address_entry_activate(self, _entry: Gtk.Entry) -> None: GLib.idle_add(self._ui.log_in_password_entry.grab_focus)
- def _on_password_entry_activate(self, _widget): + def _on_password_entry_activate(self, _entry: Gtk.Entry) -> None: if self._ui.log_in_button.get_sensitive(): self._ui.log_in_button.activate()
@@ -605,7 +625,7 @@ def _validate_jid(self, address: str) -> bool: self._show_icon(False) return True
- def _set_complete(self, *args): + def _set_complete(self, *args: Any) -> None: address = self._validate_jid(self._ui.log_in_address_entry.get_text()) password = self._ui.log_in_password_entry.get_text() self._ui.log_in_button.set_sensitive(address and password) @@ -620,7 +640,7 @@ def get_credentials(self) -> Tuple[str, str]:
class Signup(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.complete: bool = False self.title: str = _('Create New Account') @@ -660,13 +680,13 @@ def _create_server_completion(self) -> None: self._ui.server_comboboxtext_sign_up_entry.get_completion().set_model( servers_model)
- def _on_visit_server(self, _widget): + def _on_visit_server(self, _button: Gtk.Button) -> int: server = self._ui.server_comboboxtext_sign_up_entry.get_text().strip() server = f'https://%7Bserver%7D' open_uri(server) return Gdk.EVENT_STOP
- def _set_complete(self, *args): + def _set_complete(self, *args: Any) -> None: try: self.get_server() except Exception: @@ -689,7 +709,7 @@ def get_server(self) -> str: self._ui.server_comboboxtext_sign_up_entry.get_text())
@staticmethod - def _on_activate_link(_label, uri): + def _on_activate_link(_label: Gtk.Label, uri: str) -> int: # We have to use this, because the default GTK handler # is not cross-platform compatible open_uri(uri) @@ -703,7 +723,7 @@ def get_default_button(self) -> str:
class AdvancedSettings(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.title: str = _('Advanced settings') self.complete: bool = False @@ -719,7 +739,7 @@ def __init__(self): self.show_all()
@staticmethod - def _on_proxy_manager(_widget): + def _on_proxy_manager(_button: Gtk.Button) -> None: app.app.activate_action('manage-proxies')
def update_proxy_list(self) -> None: @@ -811,7 +831,7 @@ def _is_custom_host_set(self) -> bool: def _is_proxy_set(self) -> bool: return self._ui.proxies_combobox.get_active() != 0
- def _set_complete(self, *args): + def _set_complete(self, *args: Any) -> None: self.complete = False if self._is_proxy_set(): self.complete = True @@ -875,7 +895,7 @@ def set_warning(self, self._ui.trust_cert_checkbutton.set_visible( Gio.TlsCertificateFlags.UNKNOWN_CA in errors)
- def _on_view_cert(self, _button): + def _on_view_cert(self, _button: Gtk.Button) -> None: open_window('CertificateDialog', account=self._domain, transient_for=self.get_toplevel(), @@ -896,9 +916,9 @@ class Form(Page): def __init__(self) -> None: Page.__init__(self) self.set_valign(Gtk.Align.FILL) - self.complete = False + self.complete: bool = False self.title: str = _('Create Account') - self._current_form = None + self._current_form: Optional[Any] = None
heading = Gtk.Label(label=_('Create Account')) heading.get_style_context().add_class('large-header') @@ -914,11 +934,11 @@ def __init__(self) -> None: def has_form(self) -> bool: return self._current_form is not None
- def _on_is_valid(self, _widget, is_valid): + def _on_is_valid(self, _widget: DataFormWidget, is_valid: bool) -> None: self.complete = is_valid self.update_page_complete()
- def add_form(self, form): + def add_form(self, form: Any) -> None: self.remove_form()
options = {'hide-fallback-fields': True, @@ -933,7 +953,7 @@ def get_credentials(self) -> Tuple[str, str]: return (self._current_form.get_form()['username'].value, self._current_form.get_form()['password'].value)
- def get_submit_form(self): + def get_submit_form(self) -> Any: return self._current_form.get_submit_form()
def remove_form(self) -> None: @@ -971,7 +991,7 @@ def set_redirect(self, link: str, instructions: str) -> None: self._ui.instructions.set_text(instructions) self._link = link
- def _on_link_button(self, _button): + def _on_link_button(self, _button:Gtk.Button) -> None: open_uri(self._link)
def get_visible_buttons(self) -> List[str]: @@ -985,9 +1005,9 @@ def __init__(self) -> None: self.set_heading(_('Account has been added successfully'))
self._account: Optional[str] = None - self._our_jid = None - self._label = None - self._color = None + self._our_jid: Optional[str] = None + self._label: Optional[str] = None + self._color: Optional[str] = None
self._ui = get_builder('account_wizard.ui') self.pack_start(self._ui.account_label_box, True, True, 0) @@ -1013,28 +1033,28 @@ def set_account(self, account: str) -> None: def account(self) -> Optional[str]: return self._account
- def _add_css_provider(self): + def _add_css_provider(self) -> Gtk.CssProvider: context = self._ui.badge_preview.get_style_context() provider = Gtk.CssProvider() context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) return provider
- def _on_name_changed(self, entry): + def _on_name_changed(self, entry: Gtk.Entry): self._label = entry.get_text() self._ui.badge_preview.set_text(self._label or self._our_jid) self._save_config()
- def _on_color_set(self, button): + def _on_color_set(self, button: Gtk.ColorButton): rgba = button.get_rgba() self._color = rgba.to_string() self._set_badge_color(self._color) self._save_config()
- def _set_badge_color(self, color): + def _set_badge_color(self, color: str) -> None: css = '.badge { background-color: %s; font-size: 100%%; }' % color self._provider.load_from_data(bytes(css.encode()))
- def _save_config(self): + def _save_config(self) -> None: app.settings.set_account_setting( self._account, 'account_color', self._color) if self._label:
===================================== gajim/gtk/add_contact.py ===================================== @@ -93,6 +93,7 @@ def _on_button_clicked(self, ) -> None: page = self.get_current_page() account, _ = self.get_page('address').get_account_and_jid() + assert account is not None
if button_name == 'next': self._start_disco() @@ -132,6 +133,7 @@ def _start_disco(self) -> None: self.show_page('progress', Gtk.StackTransitionType.SLIDE_LEFT)
account, jid = self.get_page('address').get_account_and_jid() + assert account is not None self._disco_info(account, jid)
@as_task @@ -213,7 +215,7 @@ def __init__(self, account: Optional[str], jid: Optional[JID]) -> None: self._ui.account_combo.connect('changed', self._on_account_changed) self._ui.address_entry.connect('changed', self._set_complete)
- accounts = app.get_enabled_accounts_with_labels() + accounts = app.get_enabled_accounts_with_labels(connected_only=True) liststore = self._ui.account_combo.get_model() for acc in accounts: liststore.append(acc)
===================================== gajim/gtk/app_side_bar.py ===================================== @@ -17,11 +17,12 @@
from gajim.common import app
-from gajim.gui.util import load_icon +from .app_page import AppPage +from .util import load_icon
class AppSideBar(Gtk.ListBox): - def __init__(self, app_page): + def __init__(self, app_page: AppPage) -> None: Gtk.ListBox.__init__(self) self.set_valign(Gtk.Align.START) self.set_selection_mode(Gtk.SelectionMode.SINGLE) @@ -40,15 +41,17 @@ def __init__(self, app_page): GLib.idle_add(self.unselect_all)
@staticmethod - def _on_app_row_activated(_listbox, _row): + def _on_app_row_activated(_listbox: Gtk.ListBox, + _row: Gtk.ListBoxRow + ) -> None: app.window.show_app_page()
- def _on_unread_count_changed(self, _app_page, count): + def _on_unread_count_changed(self, _app_page: AppPage, count: int) -> None: self._app_row.set_unread_count(count)
class AppRow(Gtk.ListBoxRow): - def __init__(self): + def __init__(self) -> None: Gtk.ListBoxRow.__init__(self) self.get_style_context().add_class('workspace-sidebar-item')
@@ -78,7 +81,7 @@ def __init__(self): self.add(overlay) self.show_all()
- def set_unread_count(self, count): + def set_unread_count(self, count: int) -> None: if count < 1000: self._unread_label.set_text(str(count)) else:
===================================== gajim/gtk/avatar_selector.py ===================================== @@ -109,7 +109,7 @@ def prepare_crop_area(self, path: str) -> None: self._helper_label.hide() self._crop_area.show()
- def _on_load_clicked(self, _button): + def _on_load_clicked(self, _button: Gtk.Button) -> None: def _on_file_selected(path): self.prepare_crop_area(path)
@@ -117,8 +117,15 @@ def _on_file_selected(path): transient_for=self.get_toplevel(), modal=True)
- def _on_drag_data_received(self, _widget, _context, _x_coord, _y_coord, - selection, target_type, _timestamp): + def _on_drag_data_received(self, + _widget: Gtk.Widget, + _context: Gdk.DragContext, + _x_coord: int, + _y_coord: int, + selection: Gtk.SelectionData, + target_type: int, + _timestamp: int + ) -> None: if not selection.get_data(): return
@@ -184,10 +191,10 @@ def __init__(self) -> None:
self._image = Gdk.Rectangle() self._crop = Gdk.Rectangle() - self._pixbuf = None - self._browse_pixbuf = None - self._color_shifted_pixbuf = None - self._current_cursor = None + self._pixbuf: Optional[GdkPixbuf.Pixbuf] = None + self._browse_pixbuf: Optional[GdkPixbuf.Pixbuf] = None + self._color_shifted_pixbuf: Optional[GdkPixbuf.Pixbuf] = None + self._current_cursor: Optional[Gdk.CursorType] = None
self._scale = float(0.0) self._image.x = 0 @@ -259,7 +266,7 @@ def get_pixbuf(self) -> Optional[GdkPixbuf.Pixbuf]: return GdkPixbuf.Pixbuf.new_subpixbuf( self._browse_pixbuf, self._crop.x, self._crop.y, width, height)
- def _on_draw(self, _widget, context): + def _on_draw(self, _widget: Gtk.Widget, context: cairo.Context) -> bool: if self._browse_pixbuf is None: return False
@@ -342,7 +349,10 @@ def _on_draw(self, _widget, context):
return False
- def _on_button_press(self, _widget, event): + def _on_button_press(self, + _widget: Gtk.Widget, + event: Gdk.EventButton + ) -> bool: if self._browse_pixbuf is None: return False
@@ -357,7 +367,10 @@ def _on_button_press(self, _widget, event):
return False
- def _on_button_release(self, _widget, _event): + def _on_button_release(self, + _widget: Gtk.Widget, + _event: Gdk.EventButton + ) -> bool: if self._browse_pixbuf is None: return False
@@ -371,7 +384,10 @@ def _on_button_release(self, _widget, _event):
return False
- def _on_motion_notify(self, _widget, event): + def _on_motion_notify(self, + _widget: Gtk.Widget, + event: Gdk.EventMotion + ) -> bool: # pylint: disable=too-many-boolean-expressions # pylint: disable=too-many-branches # pylint: disable=too-many-statements @@ -565,7 +581,7 @@ def _on_motion_notify(self, _widget, event):
return False
- def _update_pixbufs(self): + def _update_pixbufs(self) -> None: allocation = self.get_allocation() width = self._browse_pixbuf.get_width() height = self._browse_pixbuf.get_height() @@ -625,7 +641,7 @@ def _update_pixbufs(self): self._image.width = dest_width self._image.height = dest_height
- def _crop_to_widget(self): + def _crop_to_widget(self) -> Gdk.Rectangle: crop = Gdk.Rectangle() crop.x = self._image.x + self._crop.x * self._scale crop.y = self._image.y + self._crop.y * self._scale @@ -633,7 +649,7 @@ def _crop_to_widget(self): crop.height = self._crop.height * self._scale return crop
- def _update_cursor(self, x_coord, y_coord): + def _update_cursor(self, x_coord: float, y_coord: float) -> None: region = self._active_region if self._active_region == Loc.OUTSIDE: crop = self._crop_to_widget() @@ -668,7 +684,12 @@ def _update_cursor(self, x_coord, y_coord): self._current_cursor = cursor_type
@staticmethod - def _eval_radial_line(center_x, center_y, bounds_x, bounds_y, user_x): + def _eval_radial_line(center_x: float, + center_y: float, + bounds_x: int, + bounds_y: int, + user_x: int + ) -> int: slope_y = float(bounds_y - center_y) slope_x = bounds_x - center_x if slope_y == 0 or slope_x == 0: @@ -679,7 +700,11 @@ def _eval_radial_line(center_x, center_y, bounds_x, bounds_y, user_x): decision_intercept = - float(decision_slope * bounds_x) return int(decision_slope * user_x + decision_intercept)
- def _find_location(self, rect, x_coord, y_coord): + def _find_location(self, + rect: Gdk.Rectangle, + x_coord: float, + y_coord: float + ) -> Loc: # pylint: disable=line-too-long location = [ [Loc.OUTSIDE, Loc.OUTSIDE, Loc.OUTSIDE, Loc.OUTSIDE, Loc.OUTSIDE], @@ -696,7 +721,7 @@ def _find_location(self, rect, x_coord, y_coord): return location[y_range][x_range]
@staticmethod - def _find_range(coord, min_v, max_v): + def _find_range(coord: float, min_v: int, max_v: int) -> Range: tolerance = 12 if coord < min_v - tolerance: return Range.BELOW @@ -708,7 +733,7 @@ def _find_range(coord, min_v, max_v): return Range.UPPER return Range.ABOVE
- def _generate_color_shifted_pixbuf(self): + def _generate_color_shifted_pixbuf(self) -> None: # pylint: disable=no-member surface = cairo.ImageSurface( cairo.Format.ARGB32,
===================================== gajim/gtk/change_password.py ===================================== @@ -12,12 +12,17 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from typing import Any +from typing import List + import logging
from gi.repository import Gtk
from nbxmpp.errors import StanzaError from nbxmpp.errors import ChangePasswordStanzaError +from nbxmpp.modules.dataforms import SimpleDataForm +from nbxmpp.task import Task
from gajim.common import app from gajim.common.i18n import _ @@ -35,7 +40,7 @@
class ChangePassword(Assistant): - def __init__(self, account): + def __init__(self, account: str) -> None: Assistant.__init__(self)
self.account = account @@ -61,7 +66,10 @@ def __init__(self, account):
self.show_all()
- def _on_button_clicked(self, _assistant, button_name): + def _on_button_clicked(self, + _assistant: Assistant, + button_name: str + ) -> None: page = self.get_current_page() if button_name == 'apply': self.show_page('progress', Gtk.StackTransitionType.SLIDE_LEFT) @@ -73,7 +81,7 @@ def _on_button_clicked(self, _assistant, button_name): elif button_name == 'close': self.destroy()
- def _on_apply(self, next_stage=False): + def _on_apply(self, next_stage: bool = False) -> None: if next_stage: form = self.get_page('next_stage').get_submit_form() self._client.get_module('Register').change_password_with_form( @@ -84,7 +92,7 @@ def _on_apply(self, next_stage=False): password, callback=self._on_change_password)
@ensure_not_destroyed - def _on_change_password(self, task): + def _on_change_password(self, task: Task) -> None: try: task.finish() except ChangePasswordStanzaError as error: @@ -101,12 +109,12 @@ def _on_change_password(self, task): passwords.save_password(self.account, password) self.show_page('success')
- def _on_destroy(self, *args): + def _on_destroy(self, *args: Any) -> None: self._destroyed = True
class EnterPassword(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.complete = False self.title = _('Change Password') @@ -150,7 +158,7 @@ def __init__(self): self._show_icon(False) self.show_all()
- def _show_icon(self, show): + def _show_icon(self, show: bool) -> None: if show: self._password2_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, 'dialog-warning-symbolic') @@ -160,7 +168,7 @@ def _show_icon(self, show): self._password2_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, None)
- def _on_changed(self, _entry): + def _on_changed(self, _entry: Gtk.Entry) -> None: password1 = self._password1_entry.get_text() if not password1: self._show_icon(True) @@ -175,19 +183,19 @@ def _on_changed(self, _entry): self._show_icon(False) self._set_complete(True)
- def _set_complete(self, state): + def _set_complete(self, state: bool) -> None: self.complete = state self.update_page_complete()
- def get_password(self): + def get_password(self) -> str: return self._password1_entry.get_text()
- def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['apply']
class NextStage(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.set_valign(Gtk.Align.FILL) self.complete = False @@ -196,11 +204,11 @@ def __init__(self):
self.show_all()
- def _on_is_valid(self, _widget, is_valid): + def _on_is_valid(self, _widget: Gtk.Widget, is_valid: bool) -> None: self.complete = is_valid self.update_page_complete()
- def set_form(self, form): + def set_form(self, form: SimpleDataForm) -> None: if self._current_form is not None: self.remove(self._current_form) self._current_form.destroy() @@ -210,31 +218,31 @@ def set_form(self, form): self.pack_start(self._current_form, True, True, 0) self._current_form.show_all()
- def get_submit_form(self): + def get_submit_form(self) -> SimpleDataForm: return self._current_form.get_submit_form()
- def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['apply']
class Error(ErrorPage): - def __init__(self): + def __init__(self) -> None: ErrorPage.__init__(self) self.set_title(_('Password Change Failed')) self.set_heading(_('Password Change Failed')) self.set_text( _('An error occurred while trying to change your password.'))
- def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['back']
class Success(SuccessPage): - def __init__(self): + def __init__(self) -> None: SuccessPage.__init__(self) self.set_title(_('Password Changed')) self.set_heading(_('Password Changed')) self.set_text(_('Your password has successfully been changed.'))
- def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['close']
===================================== gajim/gtk/chat_list_stack.py ===================================== @@ -24,10 +24,10 @@
from gajim.common import app
+from .chat_filter import ChatFilter from .chat_list import ChatList from .chat_list import ChatRow
- HANDLED_EVENTS = [ 'message-received', 'mam-message-received', @@ -58,7 +58,10 @@ class ChatListStack(Gtk.Stack): (str, object, str)), }
- def __init__(self, chat_filter, search_entry): + def __init__(self, + chat_filter: ChatFilter, + search_entry: Gtk.SearchEntry + ) -> None: Gtk.Stack.__init__(self) self.set_hexpand(True) self.set_vexpand(True) @@ -77,7 +80,7 @@ def __init__(self, chat_filter, search_entry): self._add_actions() self.show_all()
- def _add_actions(self): + def _add_actions(self) -> None: actions = [ ('toggle-chat-pinned', 'as', self._toggle_chat_pinned), ('move-chat-to-workspace', 'as', self._move_chat_to_workspace), @@ -92,7 +95,7 @@ def _add_actions(self): act.connect('activate', func) app.window.add_action(act)
- def _on_visible_child_name(self, _stack, _param): + def _on_visible_child_name(self, _stack: Gtk.Stack, _param: str) -> None: if self._last_visible_child_name == self.get_visible_child_name(): return
@@ -125,11 +128,11 @@ def is_chat_active(self, account: str, jid: JID) -> bool: return False return chat.is_active
- def _on_filter_changed(self, _filter, name): + def _on_filter_changed(self, _filter: ChatFilter, name: str) -> None: chat_list = self.get_visible_child() chat_list.set_filter(name)
- def _on_search_changed(self, search_entry): + def _on_search_changed(self, search_entry: Gtk.SearchEntry) -> None: chat_list = self.get_visible_child() chat_list.set_filter_text(search_entry.get_text())
@@ -150,7 +153,10 @@ def remove_chat_list(self, workspace_id: str) -> None: self._chat_lists.pop(workspace_id) chat_list.destroy()
- def _on_row_selected(self, _chat_list, row): + def _on_row_selected(self, + _chat_list: ChatList, + row: Optional[ChatRow] + ) -> None: if row is None: self.emit('chat-unselected') return @@ -188,7 +194,10 @@ def store_open_chats(self, workspace_id: str) -> None: app.settings.set_workspace_setting( workspace_id, 'open_chats', open_chats)
- def _toggle_chat_pinned(self, _action, param): + def _toggle_chat_pinned(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: workspace_id, account, jid = param.unpack() jid = JID.from_string(jid)
@@ -196,7 +205,10 @@ def _toggle_chat_pinned(self, _action, param): chat_list.toggle_chat_pinned(account, jid) self.store_open_chats(workspace_id)
- def _move_chat_to_workspace(self, _action, param): + def _move_chat_to_workspace(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: new_workspace_id, account, jid = param.unpack() jid = JID.from_string(jid)
@@ -209,7 +221,10 @@ def _move_chat_to_workspace(self, _action, param): self.store_open_chats(current_chatlist.workspace_id) self.store_open_chats(new_workspace_id)
- def _mark_as_read(self, _action, param): + def _mark_as_read(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: _workspace_id, account, jid = param.unpack() self.mark_as_read(account, JID.from_string(jid))
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/0f1e4c61117b5f60e68e91f4bcd19363...