Daniel Brötzmann pushed to branch master at gajim / gajim
Commits: f80a1658 by wurstsalat at 2021-12-12T19:32:40+01:00 Remove obsolete Account module
- - - - - 1a7295d1 by wurstsalat at 2021-12-12T19:41:37+01:00 FileTransfer: Typing
- - - - - 668381a6 by wurstsalat at 2021-12-12T19:51:08+01:00 AppPage: Typing
- - - - -
3 changed files:
- − gajim/common/account.py - gajim/common/filetransfer.py - gajim/gtk/app_page.py
Changes:
===================================== gajim/common/account.py deleted ===================================== @@ -1,32 +0,0 @@ -# Copyright (C) 2009 Stephan Erb <steve-e AT h3c.de> -# -# This file is part of Gajim. -# -# Gajim is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation; version 3 only. -# -# Gajim is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Gajim. If not, see http://www.gnu.org/licenses/. - - -class Account: - - def __init__(self, name, contacts, gc_contacts): - self.name = name - self.contacts = contacts - self.gc_contacts = gc_contacts - - def change_contact_jid(self, old_jid, new_jid): - self.contacts.change_contact_jid(old_jid, new_jid) - - def __repr__(self): - return self.name - - def __hash__(self): - return hash(self.name)
===================================== gajim/common/filetransfer.py ===================================== @@ -13,40 +13,41 @@ # along with Gajim. If not, see http://www.gnu.org/licenses/.
from typing import Dict +from typing import Optional
from gajim.common.helpers import Observable from gajim.common.const import FTState
class FileTransfer(Observable):
- _state_descriptions = {} # type: Dict[FTState, str] + _state_descriptions: Dict[FTState, str] = {}
- def __init__(self, account): + def __init__(self, account: str) -> None: Observable.__init__(self)
self._account = account
- self._seen = 0 - self.size = 0 + self._seen: int = 0 + self.size: int = 0
- self._state = None - self._error_text = '' - self._error_domain = None + self._state: Optional[FTState] = None + self._error_text: str = '' + self._error_domain: Optional[str] = None
@property - def account(self): + def account(self) -> str: return self._account
@property - def state(self): + def state(self) -> Optional[FTState]: return self._state
@property - def seen(self): + def seen(self) -> int: return self._seen
@property - def is_complete(self): + def is_complete(self) -> bool: if self.size == 0: return False return self._seen >= self.size @@ -56,55 +57,55 @@ def filename(self): raise NotImplementedError
@property - def error_text(self): + def error_text(self) -> str: return self._error_text
@property - def error_domain(self): + def error_domain(self) -> Optional[str]: return self._error_domain
- def get_state_description(self): + def get_state_description(self) -> str: return self._state_descriptions.get(self._state, '')
- def set_preparing(self): + def set_preparing(self) -> None: self._state = FTState.PREPARING self.notify('state-changed', FTState.PREPARING)
- def set_encrypting(self): + def set_encrypting(self) -> None: self._state = FTState.ENCRYPTING self.notify('state-changed', FTState.ENCRYPTING)
- def set_decrypting(self): + def set_decrypting(self) -> None: self._state = FTState.DECRYPTING self.notify('state-changed', FTState.DECRYPTING)
- def set_started(self): + def set_started(self) -> None: self._state = FTState.STARTED self.notify('state-changed', FTState.STARTED)
- def set_error(self, domain, text=''): + def set_error(self, domain: str, text: str = '') -> None: self._error_text = text self._error_domain = domain self._state = FTState.ERROR self.notify('state-changed', FTState.ERROR) self.disconnect_signals()
- def set_cancelled(self): + def set_cancelled(self) -> None: self._state = FTState.CANCELLED self.notify('state-changed', FTState.CANCELLED) self.disconnect_signals()
- def set_in_progress(self): + def set_in_progress(self) -> None: self._state = FTState.IN_PROGRESS self.notify('state-changed', FTState.IN_PROGRESS)
- def set_finished(self): + def set_finished(self) -> None: self._state = FTState.FINISHED self.notify('state-changed', FTState.FINISHED) self.disconnect_signals()
- def update_progress(self): + def update_progress(self) -> None: self.notify('progress')
- def cancel(self): + def cancel(self) -> None: self.notify('cancel')
===================================== gajim/gtk/app_page.py ===================================== @@ -12,6 +12,8 @@ # 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 gi.repository import GObject from gi.repository import Gtk
@@ -32,12 +34,12 @@ class AppPage(Gtk.Box): (int, )), }
- def __init__(self): + def __init__(self) -> None: Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=18) self.get_style_context().add_class('app-page') - self._unread_count = 0 + self._unread_count: int = 0
status_header = Gtk.Label(label=_('Status')) status_header.get_style_context().add_class('large-header') @@ -65,13 +67,13 @@ def __init__(self):
self.show_all()
- def add_app_message(self, category, message): + def add_app_message(self, category: str, message: Optional[str]) -> None: self._app_message_listbox.add_app_message(category, message)
self._unread_count += 1 self.emit('unread-count-changed', self._unread_count)
- def remove_app_message(self): + def remove_app_message(self) -> None: self._unread_count -= 1 self.emit('unread-count-changed', self._unread_count)
@@ -80,7 +82,7 @@ def process_event(self, event):
class AppMessageListBox(Gtk.ListBox): - def __init__(self): + def __init__(self) -> None: Gtk.ListBox.__init__(self) self.set_selection_mode(Gtk.SelectionMode.NONE) self.set_halign(Gtk.Align.CENTER) @@ -94,17 +96,17 @@ def __init__(self):
self.show_all()
- def add_app_message(self, category, message): + def add_app_message(self, category: str, message: Optional[str]) -> None: row = AppMessageRow(category, message) self.add(row)
- def remove_app_message(self, row): + def remove_app_message(self, row: Gtk.ListBoxRow) -> None: self.remove(row) self.get_parent().remove_app_message()
class AppMessageRow(Gtk.ListBoxRow): - def __init__(self, category, message=None): + def __init__(self, category: str, message: Optional[str] = None) -> None: Gtk.ListBoxRow.__init__(self) self._ui = get_builder('app_page.ui')
@@ -119,17 +121,17 @@ def __init__(self, category, message=None): self._ui.connect_signals(self) self.show_all()
- def _on_check_clicked(self, _button): + def _on_check_clicked(self, _button: Gtk.Button) -> None: app.interface.get_latest_release() self.get_parent().remove_app_message(self)
- def _on_dismiss_check_clicked(self, _button): + def _on_dismiss_check_clicked(self, _button: Gtk.Button) -> None: app.settings.set('check_for_update', False) self.get_parent().remove_app_message(self)
- def _on_visit_website_clicked(self, _button): + def _on_visit_website_clicked(self, _button: Gtk.Button) -> None: open_uri('https://gajim.org/download') self.get_parent().remove_app_message(self)
- def _on_dismiss_update_clicked(self, _button): + def _on_dismiss_update_clicked(self, _button: Gtk.Button) -> None: self.get_parent().remove_app_message(self)
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/3cf9543c86ab5e9df4996da634ee7b0b...