Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwurstsalat <mailtrash@posteo.de>2023-10-23 21:10:01 +0300
committerwurstsalat <mailtrash@posteo.de>2023-10-23 21:10:12 +0300
commit78315d84de5db2148db30126ff837ea6f4adb8a2 (patch)
tree0e2e3c293f756c7076d314f175c351fede1899ed
parent8cbe7cf2e20613c5f4ecfa923d5333dc3030e6f9 (diff)
fix: SynchronizeAccounts: Adapt to connection state changes
Fixes #11650 and #11651
-rw-r--r--gajim/data/gui/synchronize_accounts.ui50
-rw-r--r--gajim/gtk/builder.pyi2
-rw-r--r--gajim/gtk/synchronize_accounts.py25
3 files changed, 61 insertions, 16 deletions
diff --git a/gajim/data/gui/synchronize_accounts.ui b/gajim/data/gui/synchronize_accounts.ui
index 1215291c8..cb3049a4e 100644
--- a/gajim/data/gui/synchronize_accounts.ui
+++ b/gajim/data/gui/synchronize_accounts.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
- <requires lib="gtk+" version="3.12"/>
+ <requires lib="gtk+" version="3.24"/>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -47,16 +47,48 @@
</packing>
</child>
<child>
- <object class="GtkButton">
- <property name="label" translatable="yes">Select Contacts</property>
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="receives-default">False</property>
- <property name="halign">end</property>
- <signal name="clicked" handler="_on_next_clicked" swapped="no"/>
- <style>
- <class name="suggested-action"/>
- </style>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkButton" id="select_contacts_button">
+ <property name="label" translatable="yes">Select Contacts</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="receives-default">False</property>
+ <property name="halign">end</property>
+ <property name="valign">end</property>
+ <signal name="clicked" handler="_on_next_clicked" swapped="no"/>
+ <style>
+ <class name="suggested-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="connection_warning_label">
+ <property name="can-focus">False</property>
+ <property name="no-show-all">True</property>
+ <property name="label" translatable="yes">You are not connected to the server</property>
+ <property name="wrap">True</property>
+ <property name="max-width-chars">52</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="warning-color"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/gajim/gtk/builder.pyi b/gajim/gtk/builder.pyi
index 326075a6a..f11125ffe 100644
--- a/gajim/gtk/builder.pyi
+++ b/gajim/gtk/builder.pyi
@@ -909,6 +909,8 @@ class SynchronizeAccountsBuilder(Builder):
stack: Gtk.Stack
sync_accounts_box: Gtk.Box
accounts_treeview: Gtk.TreeView
+ select_contacts_button: Gtk.Button
+ connection_warning_label: Gtk.Label
sync_contacts_box: Gtk.Box
contacts_treeview: Gtk.TreeView
diff --git a/gajim/gtk/synchronize_accounts.py b/gajim/gtk/synchronize_accounts.py
index f4aa6fbaa..2783a6dbf 100644
--- a/gajim/gtk/synchronize_accounts.py
+++ b/gajim/gtk/synchronize_accounts.py
@@ -12,11 +12,14 @@
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import annotations
+
from gi.repository import Gdk
from gi.repository import Gtk
from gajim.common import app
-from gajim.common.exceptions import GajimGeneralException
+from gajim.common import types
+from gajim.common.const import SimpleClientState
from gajim.common.i18n import _
from gajim.common.modules.contacts import BareContact
@@ -37,15 +40,14 @@ class SynchronizeAccounts(Gtk.ApplicationWindow):
self.set_title(_('Synchronize Accounts'))
self.set_transient_for(get_app_window('AccountsWindow'))
+ self.account = account
if not app.account_is_available(account):
- ErrorDialog(
- _('You are not connected to the server'),
- _('You cannot synchronize with an account unless it is '
- 'connected.'))
- raise GajimGeneralException('You are not connected to the server')
+ self._ui.connection_warning_label.show()
+ self._ui.select_contacts_button.set_sensitive(False)
- self.account = account
self._local_client = app.get_client(account)
+ self._local_client.connect_signal(
+ 'state-changed', self._on_client_state_changed)
self._remote_account = None
self._remote_client = None
@@ -87,6 +89,15 @@ class SynchronizeAccounts(Gtk.ApplicationWindow):
if event.keyval == Gdk.KEY_Escape:
self.destroy()
+ def _on_client_state_changed(self,
+ _client: types.Client,
+ _signal_name: str,
+ state: SimpleClientState
+ ) -> None:
+
+ self._ui.select_contacts_button.set_sensitive(state.is_connected)
+ self._ui.connection_warning_label.set_visible(not state.is_connected)
+
def _init_accounts(self) -> None:
'''
Initialize listStore with existing accounts