diff options
author | wurstsalat <mailtrash@posteo.de> | 2022-08-22 21:21:07 +0300 |
---|---|---|
committer | wurstsalat <mailtrash@posteo.de> | 2022-08-22 21:22:13 +0300 |
commit | d2b54cb022f2a2c966a66b197af44cb2bbc687c2 (patch) | |
tree | 45b10473d3cda481f879a3954857566285361a45 | |
parent | ca38dd5ec54dc0134cc25d969e92fadac141c1a9 (diff) |
imprv: MessageActionsBox: Disable encryption button if MUC is publicpublic-encryption-button
Fixes #10959
-rw-r--r-- | gajim/common/modules/contacts.py | 9 | ||||
-rw-r--r-- | gajim/data/gui/message_actions_box.ui | 3 | ||||
-rw-r--r-- | gajim/gtk/message_actions_box.py | 22 |
3 files changed, 29 insertions, 5 deletions
diff --git a/gajim/common/modules/contacts.py b/gajim/common/modules/contacts.py index 6eb4e1bc6..e8e65fb39 100644 --- a/gajim/common/modules/contacts.py +++ b/gajim/common/modules/contacts.py @@ -671,6 +671,15 @@ class GroupchatContact(CommonContact): return False return disco_info.is_irc + @property + def encryption_available(self) -> bool: + disco_info = self.get_disco() + if disco_info is None: + return True + + return (disco_info.muc_is_members_only and + disco_info.muc_is_nonanonymous) + def get_config_value(self, field_name: str) -> Any: disco_info = self.get_disco() assert disco_info is not None diff --git a/gajim/data/gui/message_actions_box.ui b/gajim/data/gui/message_actions_box.ui index 29e94a00b..8a7c852bf 100644 --- a/gajim/data/gui/message_actions_box.ui +++ b/gajim/data/gui/message_actions_box.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 --> +<!-- Generated with glade 3.40.0 --> <interface> <requires lib="gtk+" version="3.24"/> <object class="GtkBox" id="box"> @@ -91,7 +91,6 @@ <property name="visible">True</property> <property name="can-focus">True</property> <property name="receives-default">True</property> - <property name="tooltip-text" translatable="yes">Choose encryption</property> <property name="relief">none</property> <child> <object class="GtkImage" id="encryption_image"> diff --git a/gajim/gtk/message_actions_box.py b/gajim/gtk/message_actions_box.py index 42a6be24b..10fcb31c2 100644 --- a/gajim/gtk/message_actions_box.py +++ b/gajim/gtk/message_actions_box.py @@ -219,9 +219,25 @@ class MessageActionsBox(Gtk.Grid, ged.EventHelper): self._set_settings_menu(contact) - encryption = self._contact.settings.get('encryption') - self._set_encryption_state(encryption) - self._set_encryption_details(encryption) + encryption_available = True + if isinstance(self._contact, GroupchatContact): + encryption_available = self._contact.encryption_available + if not encryption_available: + self._ui.encryption_details_button.set_visible(False) + self._ui.encryption_menu_button.set_sensitive(False) + self._ui.encryption_image.set_from_icon_name( + 'channel-insecure-symbolic', Gtk.IconSize.MENU) + self._ui.encryption_menu_button.set_tooltip_text( + _('This is a public group chat. ' + 'Encryption is not available.')) + + if encryption_available: + self._ui.encryption_menu_button.set_sensitive(True) + self._ui.encryption_menu_button.set_tooltip_text( + _('Choose encryption')) + encryption = self._contact.settings.get('encryption') + self._set_encryption_state(encryption) + self._set_encryption_details(encryption) self._set_chatstate(True) |