Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
1a44795e by wurstsalat at 2023-04-25T23:37:29+02:00
fix: ContactInfo: Improve behavior for connection changes
Fixes #11439
- - - - -
1 changed file:
- gajim/gtk/contact_info.py
Changes:
=====================================
gajim/gtk/contact_info.py
=====================================
@@ -33,7 +33,9 @@
from gajim.common import app
from gajim.common import ged
+from gajim.common import types
from gajim.common.const import AvatarSize
+from gajim.common.const import SimpleClientState
from gajim.common.events import SubscribedPresenceReceived
from gajim.common.events import UnsubscribedPresenceReceived
from gajim.common.ged import EventHelper
@@ -87,6 +89,8 @@ def __init__(self,
self.account = account
self.contact = contact
self._client = app.get_client(account)
+ self._client.connect_signal(
+ 'state-changed', self._on_client_state_changed)
self._ui = get_builder('contact_info.ui')
@@ -142,6 +146,17 @@ def _on_key_press(self, _widget: ContactInfo, event:
Gdk.EventKey) -> None:
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.edit_name_button.set_sensitive(state.is_connected)
+ self._ui.edit_name_button.set_tooltip_text(
+ _('Not connected') if not state.is_connected else _('Edit Name…'))
+ self._ui.subscription_listbox.set_sensitive(state.is_connected)
+
def _on_stack_child_changed(self,
_widget: Gtk.Stack,
_pspec: GObject.ParamSpec) -> None:
@@ -166,13 +181,17 @@ def _on_destroy(self, _widget: ContactInfo) -> None:
def _fill_information_page(self, contact: ContactT) -> None:
self._vcard_grid = VCardGrid(self.account)
self._ui.vcard_box.add(self._vcard_grid)
- self._client.get_module('VCard4').request_vcard(
- jid=self.contact.jid,
- callback=self._on_vcard_received)
+ if self._client.state.is_available:
+ self._client.get_module('VCard4').request_vcard(
+ jid=self.contact.jid,
+ callback=self._on_vcard_received)
jid = str(contact.get_address())
self._ui.contact_name_label.set_text(contact.name)
+ self._ui.edit_name_button.set_sensitive(
+ self._client.state.is_available)
+
self._ui.contact_jid_label.set_text(jid)
self._ui.contact_jid_label.set_tooltip_text(jid)
@@ -210,6 +229,9 @@ def _fill_settings_page(self, contact: BareContact) -> None:
self._ui.from_subscription_switch.set_state(contact.is_subscribed)
+ self._ui.subscription_listbox.set_sensitive(
+ self._client.state.is_available)
+
if contact.subscription in ('to', 'both'):
self._ui.to_subscription_stack.set_visible_child_name('checkmark')
@@ -231,7 +253,7 @@ def _fill_settings_page(self, contact: BareContact) -> None:
params.to_variant())
def _fill_groups_page(self, contact: BareContact) -> None:
- if not contact.is_in_roster:
+ if not contact.is_in_roster or not self._client.state.is_available:
return
model = self._ui.groups_treeview.get_model()
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/1a44795e6cb9f1ccaadbfc229f8ecfe806eb5198
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/1a44795e6cb9f1ccaadbfc229f8ecfe806eb5198
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits