Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
-
f80a1658
by wurstsalat at 2021-12-12T19:32:40+01:00
-
1a7295d1
by wurstsalat at 2021-12-12T19:41:37+01:00
-
668381a6
by wurstsalat at 2021-12-12T19:51:08+01:00
3 changed files:
Changes:
| 1 |
-# Copyright (C) 2009 Stephan Erb <steve-e AT h3c.de>
|
|
| 2 |
-#
|
|
| 3 |
-# This file is part of Gajim.
|
|
| 4 |
-#
|
|
| 5 |
-# Gajim is free software; you can redistribute it and/or modify
|
|
| 6 |
-# it under the terms of the GNU General Public License as published
|
|
| 7 |
-# by the Free Software Foundation; version 3 only.
|
|
| 8 |
-#
|
|
| 9 |
-# Gajim is distributed in the hope that it will be useful,
|
|
| 10 |
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 11 |
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 12 |
-# GNU General Public License for more details.
|
|
| 13 |
-#
|
|
| 14 |
-# You should have received a copy of the GNU General Public License
|
|
| 15 |
-# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
| 16 |
- |
|
| 17 |
- |
|
| 18 |
-class Account:
|
|
| 19 |
- |
|
| 20 |
- def __init__(self, name, contacts, gc_contacts):
|
|
| 21 |
- self.name = name
|
|
| 22 |
- self.contacts = contacts
|
|
| 23 |
- self.gc_contacts = gc_contacts
|
|
| 24 |
- |
|
| 25 |
- def change_contact_jid(self, old_jid, new_jid):
|
|
| 26 |
- self.contacts.change_contact_jid(old_jid, new_jid)
|
|
| 27 |
- |
|
| 28 |
- def __repr__(self):
|
|
| 29 |
- return self.name
|
|
| 30 |
- |
|
| 31 |
- def __hash__(self):
|
|
| 32 |
- return hash(self.name)
|
| ... | ... | @@ -13,40 +13,41 @@ |
| 13 | 13 |
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
| 14 | 14 |
|
| 15 | 15 |
from typing import Dict
|
| 16 |
+from typing import Optional
|
|
| 16 | 17 |
|
| 17 | 18 |
from gajim.common.helpers import Observable
|
| 18 | 19 |
from gajim.common.const import FTState
|
| 19 | 20 |
|
| 20 | 21 |
class FileTransfer(Observable):
|
| 21 | 22 |
|
| 22 |
- _state_descriptions = {} # type: Dict[FTState, str]
|
|
| 23 |
+ _state_descriptions: Dict[FTState, str] = {}
|
|
| 23 | 24 |
|
| 24 |
- def __init__(self, account):
|
|
| 25 |
+ def __init__(self, account: str) -> None:
|
|
| 25 | 26 |
Observable.__init__(self)
|
| 26 | 27 |
|
| 27 | 28 |
self._account = account
|
| 28 | 29 |
|
| 29 |
- self._seen = 0
|
|
| 30 |
- self.size = 0
|
|
| 30 |
+ self._seen: int = 0
|
|
| 31 |
+ self.size: int = 0
|
|
| 31 | 32 |
|
| 32 |
- self._state = None
|
|
| 33 |
- self._error_text = ''
|
|
| 34 |
- self._error_domain = None
|
|
| 33 |
+ self._state: Optional[FTState] = None
|
|
| 34 |
+ self._error_text: str = ''
|
|
| 35 |
+ self._error_domain: Optional[str] = None
|
|
| 35 | 36 |
|
| 36 | 37 |
@property
|
| 37 |
- def account(self):
|
|
| 38 |
+ def account(self) -> str:
|
|
| 38 | 39 |
return self._account
|
| 39 | 40 |
|
| 40 | 41 |
@property
|
| 41 |
- def state(self):
|
|
| 42 |
+ def state(self) -> Optional[FTState]:
|
|
| 42 | 43 |
return self._state
|
| 43 | 44 |
|
| 44 | 45 |
@property
|
| 45 |
- def seen(self):
|
|
| 46 |
+ def seen(self) -> int:
|
|
| 46 | 47 |
return self._seen
|
| 47 | 48 |
|
| 48 | 49 |
@property
|
| 49 |
- def is_complete(self):
|
|
| 50 |
+ def is_complete(self) -> bool:
|
|
| 50 | 51 |
if self.size == 0:
|
| 51 | 52 |
return False
|
| 52 | 53 |
return self._seen >= self.size
|
| ... | ... | @@ -56,55 +57,55 @@ def filename(self): |
| 56 | 57 |
raise NotImplementedError
|
| 57 | 58 |
|
| 58 | 59 |
@property
|
| 59 |
- def error_text(self):
|
|
| 60 |
+ def error_text(self) -> str:
|
|
| 60 | 61 |
return self._error_text
|
| 61 | 62 |
|
| 62 | 63 |
@property
|
| 63 |
- def error_domain(self):
|
|
| 64 |
+ def error_domain(self) -> Optional[str]:
|
|
| 64 | 65 |
return self._error_domain
|
| 65 | 66 |
|
| 66 |
- def get_state_description(self):
|
|
| 67 |
+ def get_state_description(self) -> str:
|
|
| 67 | 68 |
return self._state_descriptions.get(self._state, '')
|
| 68 | 69 |
|
| 69 |
- def set_preparing(self):
|
|
| 70 |
+ def set_preparing(self) -> None:
|
|
| 70 | 71 |
self._state = FTState.PREPARING
|
| 71 | 72 |
self.notify('state-changed', FTState.PREPARING)
|
| 72 | 73 |
|
| 73 |
- def set_encrypting(self):
|
|
| 74 |
+ def set_encrypting(self) -> None:
|
|
| 74 | 75 |
self._state = FTState.ENCRYPTING
|
| 75 | 76 |
self.notify('state-changed', FTState.ENCRYPTING)
|
| 76 | 77 |
|
| 77 |
- def set_decrypting(self):
|
|
| 78 |
+ def set_decrypting(self) -> None:
|
|
| 78 | 79 |
self._state = FTState.DECRYPTING
|
| 79 | 80 |
self.notify('state-changed', FTState.DECRYPTING)
|
| 80 | 81 |
|
| 81 |
- def set_started(self):
|
|
| 82 |
+ def set_started(self) -> None:
|
|
| 82 | 83 |
self._state = FTState.STARTED
|
| 83 | 84 |
self.notify('state-changed', FTState.STARTED)
|
| 84 | 85 |
|
| 85 |
- def set_error(self, domain, text=''):
|
|
| 86 |
+ def set_error(self, domain: str, text: str = '') -> None:
|
|
| 86 | 87 |
self._error_text = text
|
| 87 | 88 |
self._error_domain = domain
|
| 88 | 89 |
self._state = FTState.ERROR
|
| 89 | 90 |
self.notify('state-changed', FTState.ERROR)
|
| 90 | 91 |
self.disconnect_signals()
|
| 91 | 92 |
|
| 92 |
- def set_cancelled(self):
|
|
| 93 |
+ def set_cancelled(self) -> None:
|
|
| 93 | 94 |
self._state = FTState.CANCELLED
|
| 94 | 95 |
self.notify('state-changed', FTState.CANCELLED)
|
| 95 | 96 |
self.disconnect_signals()
|
| 96 | 97 |
|
| 97 |
- def set_in_progress(self):
|
|
| 98 |
+ def set_in_progress(self) -> None:
|
|
| 98 | 99 |
self._state = FTState.IN_PROGRESS
|
| 99 | 100 |
self.notify('state-changed', FTState.IN_PROGRESS)
|
| 100 | 101 |
|
| 101 |
- def set_finished(self):
|
|
| 102 |
+ def set_finished(self) -> None:
|
|
| 102 | 103 |
self._state = FTState.FINISHED
|
| 103 | 104 |
self.notify('state-changed', FTState.FINISHED)
|
| 104 | 105 |
self.disconnect_signals()
|
| 105 | 106 |
|
| 106 |
- def update_progress(self):
|
|
| 107 |
+ def update_progress(self) -> None:
|
|
| 107 | 108 |
self.notify('progress')
|
| 108 | 109 |
|
| 109 |
- def cancel(self):
|
|
| 110 |
+ def cancel(self) -> None:
|
|
| 110 | 111 |
self.notify('cancel')
|
| ... | ... | @@ -12,6 +12,8 @@ |
| 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 Optional
|
|
| 16 |
+ |
|
| 15 | 17 |
from gi.repository import GObject
|
| 16 | 18 |
from gi.repository import Gtk
|
| 17 | 19 |
|
| ... | ... | @@ -32,12 +34,12 @@ class AppPage(Gtk.Box): |
| 32 | 34 |
(int, )),
|
| 33 | 35 |
}
|
| 34 | 36 |
|
| 35 |
- def __init__(self):
|
|
| 37 |
+ def __init__(self) -> None:
|
|
| 36 | 38 |
Gtk.Box.__init__(self,
|
| 37 | 39 |
orientation=Gtk.Orientation.VERTICAL,
|
| 38 | 40 |
spacing=18)
|
| 39 | 41 |
self.get_style_context().add_class('app-page')
|
| 40 |
- self._unread_count = 0
|
|
| 42 |
+ self._unread_count: int = 0
|
|
| 41 | 43 |
|
| 42 | 44 |
status_header = Gtk.Label(label=_('Status'))
|
| 43 | 45 |
status_header.get_style_context().add_class('large-header')
|
| ... | ... | @@ -65,13 +67,13 @@ def __init__(self): |
| 65 | 67 |
|
| 66 | 68 |
self.show_all()
|
| 67 | 69 |
|
| 68 |
- def add_app_message(self, category, message):
|
|
| 70 |
+ def add_app_message(self, category: str, message: Optional[str]) -> None:
|
|
| 69 | 71 |
self._app_message_listbox.add_app_message(category, message)
|
| 70 | 72 |
|
| 71 | 73 |
self._unread_count += 1
|
| 72 | 74 |
self.emit('unread-count-changed', self._unread_count)
|
| 73 | 75 |
|
| 74 |
- def remove_app_message(self):
|
|
| 76 |
+ def remove_app_message(self) -> None:
|
|
| 75 | 77 |
self._unread_count -= 1
|
| 76 | 78 |
self.emit('unread-count-changed', self._unread_count)
|
| 77 | 79 |
|
| ... | ... | @@ -80,7 +82,7 @@ def process_event(self, event): |
| 80 | 82 |
|
| 81 | 83 |
|
| 82 | 84 |
class AppMessageListBox(Gtk.ListBox):
|
| 83 |
- def __init__(self):
|
|
| 85 |
+ def __init__(self) -> None:
|
|
| 84 | 86 |
Gtk.ListBox.__init__(self)
|
| 85 | 87 |
self.set_selection_mode(Gtk.SelectionMode.NONE)
|
| 86 | 88 |
self.set_halign(Gtk.Align.CENTER)
|
| ... | ... | @@ -94,17 +96,17 @@ def __init__(self): |
| 94 | 96 |
|
| 95 | 97 |
self.show_all()
|
| 96 | 98 |
|
| 97 |
- def add_app_message(self, category, message):
|
|
| 99 |
+ def add_app_message(self, category: str, message: Optional[str]) -> None:
|
|
| 98 | 100 |
row = AppMessageRow(category, message)
|
| 99 | 101 |
self.add(row)
|
| 100 | 102 |
|
| 101 |
- def remove_app_message(self, row):
|
|
| 103 |
+ def remove_app_message(self, row: Gtk.ListBoxRow) -> None:
|
|
| 102 | 104 |
self.remove(row)
|
| 103 | 105 |
self.get_parent().remove_app_message()
|
| 104 | 106 |
|
| 105 | 107 |
|
| 106 | 108 |
class AppMessageRow(Gtk.ListBoxRow):
|
| 107 |
- def __init__(self, category, message=None):
|
|
| 109 |
+ def __init__(self, category: str, message: Optional[str] = None) -> None:
|
|
| 108 | 110 |
Gtk.ListBoxRow.__init__(self)
|
| 109 | 111 |
self._ui = get_builder('app_page.ui')
|
| 110 | 112 |
|
| ... | ... | @@ -119,17 +121,17 @@ def __init__(self, category, message=None): |
| 119 | 121 |
self._ui.connect_signals(self)
|
| 120 | 122 |
self.show_all()
|
| 121 | 123 |
|
| 122 |
- def _on_check_clicked(self, _button):
|
|
| 124 |
+ def _on_check_clicked(self, _button: Gtk.Button) -> None:
|
|
| 123 | 125 |
app.interface.get_latest_release()
|
| 124 | 126 |
self.get_parent().remove_app_message(self)
|
| 125 | 127 |
|
| 126 |
- def _on_dismiss_check_clicked(self, _button):
|
|
| 128 |
+ def _on_dismiss_check_clicked(self, _button: Gtk.Button) -> None:
|
|
| 127 | 129 |
app.settings.set('check_for_update', False)
|
| 128 | 130 |
self.get_parent().remove_app_message(self)
|
| 129 | 131 |
|
| 130 |
- def _on_visit_website_clicked(self, _button):
|
|
| 132 |
+ def _on_visit_website_clicked(self, _button: Gtk.Button) -> None:
|
|
| 131 | 133 |
open_uri('https://gajim.org/download')
|
| 132 | 134 |
self.get_parent().remove_app_message(self)
|
| 133 | 135 |
|
| 134 |
- def _on_dismiss_update_clicked(self, _button):
|
|
| 136 |
+ def _on_dismiss_update_clicked(self, _button: Gtk.Button) -> None:
|
|
| 135 | 137 |
self.get_parent().remove_app_message(self)
|