Daniel Brötzmann pushed to branch public-encryption-button at gajim / gajim
Commits:
d2b54cb0 by wurstsalat at 2022-08-22T20:22:13+02:00
imprv: MessageActionsBox: Disable encryption button if MUC is public
Fixes #10959
- - - - -
3 changed files:
- gajim/common/modules/contacts.py
- gajim/data/gui/message_actions_box.ui
- gajim/gtk/message_actions_box.py
Changes:
=====================================
gajim/common/modules/contacts.py
=====================================
@@ -671,6 +671,15 @@ def is_irc(self) -> bool:
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
=====================================
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">
=====================================
gajim/gtk/message_actions_box.py
=====================================
@@ -219,9 +219,25 @@ def switch_contact(self, contact: ChatContactT) -> None:
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)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/d2b54cb022f2a2c966a66b197af44cb2bbc687c2
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/d2b54cb022f2a2c966a66b197af44cb2bbc687c2
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