Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
9abfda2a
by Philipp Hörist at 2022-10-08T13:52:16+02:00
2 changed files:
Changes:
| ... | ... | @@ -568,7 +568,6 @@ def _schedule_reconnect(self) -> None: |
| 568 | 568 | def _abort_reconnect(self) -> None:
|
| 569 | 569 | self._set_state(ClientState.DISCONNECTED)
|
| 570 | 570 | self._disable_reconnect_timer()
|
| 571 | - self.notify('state-changed', SimpleClientState.DISCONNECTED)
|
|
| 572 | 571 | |
| 573 | 572 | if self._destroy_client:
|
| 574 | 573 | self._client.destroy()
|
| ... | ... | @@ -576,6 +575,8 @@ def _abort_reconnect(self) -> None: |
| 576 | 575 | self._destroy_client = False
|
| 577 | 576 | self._create_client()
|
| 578 | 577 | |
| 578 | + self.notify('state-changed', SimpleClientState.DISCONNECTED)
|
|
| 579 | + |
|
| 579 | 580 | def _disable_reconnect_timer(self) -> None:
|
| 580 | 581 | if self._reconnect_timer_source is not None:
|
| 581 | 582 | GLib.source_remove(self._reconnect_timer_source)
|
| ... | ... | @@ -28,9 +28,8 @@ |
| 28 | 28 | from gi.repository import GObject
|
| 29 | 29 | |
| 30 | 30 | from gajim.common import app
|
| 31 | -from gajim.common import ged
|
|
| 32 | 31 | from gajim.common import passwords
|
| 33 | -from gajim.common.events import AccountDisconnected
|
|
| 32 | +from gajim.common.const import ClientState
|
|
| 34 | 33 | from gajim.common.i18n import _
|
| 35 | 34 | from gajim.common.i18n import Q_
|
| 36 | 35 | from gajim.common.settings import AllSettingsT
|
| ... | ... | @@ -541,19 +540,10 @@ def _on_enable_switch(self, |
| 541 | 540 | state: bool,
|
| 542 | 541 | account: str
|
| 543 | 542 | ) -> int:
|
| 544 | - def _on_disconnect(event: AccountDisconnected) -> None:
|
|
| 545 | - if event.account != account:
|
|
| 546 | - return
|
|
| 547 | - app.ged.remove_event_handler('account-disconnected',
|
|
| 548 | - ged.POSTGUI,
|
|
| 549 | - _on_disconnect)
|
|
| 550 | - app.interface.disable_account(account)
|
|
| 551 | 543 | |
| 552 | 544 | def _disable() -> None:
|
| 553 | - app.ged.register_event_handler('account-disconnected',
|
|
| 554 | - ged.POSTGUI,
|
|
| 555 | - _on_disconnect)
|
|
| 556 | 545 | client = app.get_client(account)
|
| 546 | + client.connect_signal('state-changed', self._on_state_changed)
|
|
| 557 | 547 | client.change_status('offline', 'offline')
|
| 558 | 548 | switch.set_state(state)
|
| 559 | 549 | self._set_label(state)
|
| ... | ... | @@ -585,6 +575,15 @@ def _disable() -> None: |
| 585 | 575 | |
| 586 | 576 | return Gdk.EVENT_PROPAGATE
|
| 587 | 577 | |
| 578 | + def _on_state_changed(self,
|
|
| 579 | + client: types.Client,
|
|
| 580 | + _signal_name: str,
|
|
| 581 | + client_state: ClientState
|
|
| 582 | + ) -> None:
|
|
| 583 | + |
|
| 584 | + if client_state.is_disconnected:
|
|
| 585 | + app.interface.disable_account(client.account)
|
|
| 586 | + |
|
| 588 | 587 | |
| 589 | 588 | class AddNewAccountPage(Gtk.Box):
|
| 590 | 589 | def __init__(self) -> None:
|