| ... |
... |
@@ -33,7 +33,9 @@ |
|
33
|
33
|
|
|
34
|
34
|
from gajim.common import app
|
|
35
|
35
|
from gajim.common import ged
|
|
|
36
|
+from gajim.common import types
|
|
36
|
37
|
from gajim.common.const import AvatarSize
|
|
|
38
|
+from gajim.common.const import SimpleClientState
|
|
37
|
39
|
from gajim.common.events import SubscribedPresenceReceived
|
|
38
|
40
|
from gajim.common.events import UnsubscribedPresenceReceived
|
|
39
|
41
|
from gajim.common.ged import EventHelper
|
| ... |
... |
@@ -87,6 +89,8 @@ def __init__(self, |
|
87
|
89
|
self.account = account
|
|
88
|
90
|
self.contact = contact
|
|
89
|
91
|
self._client = app.get_client(account)
|
|
|
92
|
+ self._client.connect_signal(
|
|
|
93
|
+ 'state-changed', self._on_client_state_changed)
|
|
90
|
94
|
|
|
91
|
95
|
self._ui = get_builder('contact_info.ui')
|
|
92
|
96
|
|
| ... |
... |
@@ -142,6 +146,17 @@ def _on_key_press(self, _widget: ContactInfo, event: Gdk.EventKey) -> None: |
|
142
|
146
|
if event.keyval == Gdk.KEY_Escape:
|
|
143
|
147
|
self.destroy()
|
|
144
|
148
|
|
|
|
149
|
+ def _on_client_state_changed(self,
|
|
|
150
|
+ _client: types.Client,
|
|
|
151
|
+ _signal_name: str,
|
|
|
152
|
+ state: SimpleClientState
|
|
|
153
|
+ ) -> None:
|
|
|
154
|
+
|
|
|
155
|
+ self._ui.edit_name_button.set_sensitive(state.is_connected)
|
|
|
156
|
+ self._ui.edit_name_button.set_tooltip_text(
|
|
|
157
|
+ _('Not connected') if not state.is_connected else _('Edit Name…'))
|
|
|
158
|
+ self._ui.subscription_listbox.set_sensitive(state.is_connected)
|
|
|
159
|
+
|
|
145
|
160
|
def _on_stack_child_changed(self,
|
|
146
|
161
|
_widget: Gtk.Stack,
|
|
147
|
162
|
_pspec: GObject.ParamSpec) -> None:
|
| ... |
... |
@@ -166,13 +181,17 @@ def _on_destroy(self, _widget: ContactInfo) -> None: |
|
166
|
181
|
def _fill_information_page(self, contact: ContactT) -> None:
|
|
167
|
182
|
self._vcard_grid = VCardGrid(self.account)
|
|
168
|
183
|
self._ui.vcard_box.add(self._vcard_grid)
|
|
169
|
|
- self._client.get_module('VCard4').request_vcard(
|
|
170
|
|
- jid=self.contact.jid,
|
|
171
|
|
- callback=self._on_vcard_received)
|
|
|
184
|
+ if self._client.state.is_available:
|
|
|
185
|
+ self._client.get_module('VCard4').request_vcard(
|
|
|
186
|
+ jid=self.contact.jid,
|
|
|
187
|
+ callback=self._on_vcard_received)
|
|
172
|
188
|
|
|
173
|
189
|
jid = str(contact.get_address())
|
|
174
|
190
|
|
|
175
|
191
|
self._ui.contact_name_label.set_text(contact.name)
|
|
|
192
|
+ self._ui.edit_name_button.set_sensitive(
|
|
|
193
|
+ self._client.state.is_available)
|
|
|
194
|
+
|
|
176
|
195
|
self._ui.contact_jid_label.set_text(jid)
|
|
177
|
196
|
self._ui.contact_jid_label.set_tooltip_text(jid)
|
|
178
|
197
|
|
| ... |
... |
@@ -210,6 +229,9 @@ def _fill_settings_page(self, contact: BareContact) -> None: |
|
210
|
229
|
|
|
211
|
230
|
self._ui.from_subscription_switch.set_state(contact.is_subscribed)
|
|
212
|
231
|
|
|
|
232
|
+ self._ui.subscription_listbox.set_sensitive(
|
|
|
233
|
+ self._client.state.is_available)
|
|
|
234
|
+
|
|
213
|
235
|
if contact.subscription in ('to', 'both'):
|
|
214
|
236
|
self._ui.to_subscription_stack.set_visible_child_name('checkmark')
|
|
215
|
237
|
|
| ... |
... |
@@ -231,7 +253,7 @@ def _fill_settings_page(self, contact: BareContact) -> None: |
|
231
|
253
|
params.to_variant())
|
|
232
|
254
|
|
|
233
|
255
|
def _fill_groups_page(self, contact: BareContact) -> None:
|
|
234
|
|
- if not contact.is_in_roster:
|
|
|
256
|
+ if not contact.is_in_roster or not self._client.state.is_available:
|
|
235
|
257
|
return
|
|
236
|
258
|
|
|
237
|
259
|
model = self._ui.groups_treeview.get_model()
|