Daniel Brötzmann pushed to branch public-encryption-button at gajim / gajim
Commits: 7fd1302e by Yann Leboulanger at 2022-08-22T21:24:44+02:00 ci: Fix debian build
- - - - - 9015e908 by lovetox at 2022-08-22T22:03:32+02:00 ci: Remove deprecated report type
- - - - - 846a5a11 by wurstsalat at 2022-08-23T11:49:15+02:00 imprv: Increase contrast for message row meta elements
- - - - - b3c6005b by wurstsalat at 2022-08-24T19:53:19+02:00 imprv: MessageActionsBox: Disable encryption button if MUC is public
Fixes #10959
- - - - -
7 changed files:
- .gitlab-ci.yml - + debian/compat - debian/control - gajim/common/modules/contacts.py - gajim/data/gui/message_actions_box.ui - gajim/data/style/gajim.css - gajim/gtk/message_actions_box.py
Changes:
===================================== .gitlab-ci.yml ===================================== @@ -62,7 +62,9 @@ test-unittest: coverage: "/TOTAL.+ ([0-9]{1,3}%)/" artifacts: reports: - cobertura: coverage.xml + coverage_report: + coverage_format: cobertura + path: coverage.xml interruptible: true
build-linux:
===================================== debian/compat ===================================== @@ -0,0 +1 @@ +13
===================================== debian/control ===================================== @@ -3,7 +3,7 @@ Section: net Priority: optional Maintainer: Gajim Maintainers ci@gajim.org Build-Depends: - debhelper-compat (= 13), + debhelper (>= 13), dh-python, gettext (>= 0.17-4), libglib2.0-dev, @@ -13,6 +13,7 @@ Build-Depends: python3-gi-cairo, python3-nbxmpp-nightly (>=20220727), python3-setuptools, + python3-packaging, python3-pil, gir1.2-gtk-3.0 (>=3.24.30), Rules-Requires-Root: no
===================================== 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/data/style/gajim.css ===================================== @@ -95,7 +95,7 @@ .conversation-call-box label { font-size: 90%; } .conversation-meta { - color: @insensitive_fg_color; + opacity: 0.6; font-size: 90%; } .conversation-read-marker {
===================================== gajim/gtk/message_actions_box.py ===================================== @@ -219,9 +219,22 @@ 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._update_encryption_button( + False, + _('This is a public group chat. ' + 'Encryption is not available.'), + 'channel-insecure-symbolic') + + self._update_encryption_details_button(False) + + if encryption_available: + encryption = self._contact.settings.get('encryption') + self._set_encryption_state(encryption) + self._set_encryption_details(encryption)
self._set_chatstate(True)
@@ -295,8 +308,10 @@ def _set_encryption_state(self, state: str) -> None: else: icon_name = 'channel-insecure-symbolic'
- self._ui.encryption_image.set_from_icon_name(icon_name, - Gtk.IconSize.MENU) + self._update_encryption_button( + True, + _('Choose encryption'), + icon_name)
def _change_encryption(self, action: Gio.SimpleAction, @@ -341,19 +356,38 @@ def _set_encryption_details(self, state: str) -> None:
if authenticated: authenticated_string = _('and authenticated') - self._ui.encryption_details_image.set_from_icon_name( - 'security-high-symbolic', Gtk.IconSize.MENU) + icon_name = 'security-high-symbolic' else: authenticated_string = _('and NOT authenticated') - self._ui.encryption_details_image.set_from_icon_name( - 'security-low-symbolic', Gtk.IconSize.MENU) + icon_name = 'security-low-symbolic'
tooltip = _('%(type)s encryption is active %(authenticated)s.') % { - 'type': enc_type, 'authenticated': authenticated_string} + 'type': enc_type, + 'authenticated': authenticated_string} + + self._update_encryption_details_button(visible, tooltip, icon_name) + + def _update_encryption_button(self, + sensitive: bool, + tooltip: str, + icon_name: str + ) -> None: + + self._ui.encryption_menu_button.set_sensitive(sensitive) + self._ui.encryption_menu_button.set_tooltip_text(tooltip) + self._ui.encryption_image.set_from_icon_name( + icon_name, Gtk.IconSize.MENU) + + def _update_encryption_details_button(self, + visible: bool, + tooltip: Optional[str] = None, + icon_name: Optional[str] = None + ) -> None:
- self._ui.encryption_details_button.set_tooltip_text(tooltip) self._ui.encryption_details_button.set_visible(visible) - self._ui.encryption_details_image.set_sensitive(visible) + self._ui.encryption_details_button.set_tooltip_text(tooltip) + self._ui.encryption_details_image.set_from_icon_name( + icon_name, Gtk.IconSize.MENU)
def _on_encryption_details_clicked(self, _button: Gtk.Button) -> None: contact = self.get_current_contact()
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/d2b54cb022f2a2c966a66b197af44cb2...