Daniel Brötzmann pushed to branch public-encryption-button at gajim / gajim

Commits:

3 changed files:

Changes:

  • gajim/common/modules/contacts.py
    ... ... @@ -671,6 +671,15 @@ def is_irc(self) -> bool:
    671 671
                 return False
    
    672 672
             return disco_info.is_irc
    
    673 673
     
    
    674
    +    @property
    
    675
    +    def encryption_available(self) -> bool:
    
    676
    +        disco_info = self.get_disco()
    
    677
    +        if disco_info is None:
    
    678
    +            return True
    
    679
    +
    
    680
    +        return (disco_info.muc_is_members_only and
    
    681
    +                disco_info.muc_is_nonanonymous)
    
    682
    +
    
    674 683
         def get_config_value(self, field_name: str) -> Any:
    
    675 684
             disco_info = self.get_disco()
    
    676 685
             assert disco_info is not None
    

  • gajim/data/gui/message_actions_box.ui
    1 1
     <?xml version="1.0" encoding="UTF-8"?>
    
    2
    -<!-- Generated with glade 3.38.2 -->
    
    2
    +<!-- Generated with glade 3.40.0 -->
    
    3 3
     <interface>
    
    4 4
       <requires lib="gtk+" version="3.24"/>
    
    5 5
       <object class="GtkBox" id="box">
    
    ... ... @@ -91,7 +91,6 @@
    91 91
             <property name="visible">True</property>
    
    92 92
             <property name="can-focus">True</property>
    
    93 93
             <property name="receives-default">True</property>
    
    94
    -        <property name="tooltip-text" translatable="yes">Choose encryption</property>
    
    95 94
             <property name="relief">none</property>
    
    96 95
             <child>
    
    97 96
               <object class="GtkImage" id="encryption_image">
    

  • gajim/gtk/message_actions_box.py
    ... ... @@ -219,9 +219,25 @@ def switch_contact(self, contact: ChatContactT) -> None:
    219 219
     
    
    220 220
             self._set_settings_menu(contact)
    
    221 221
     
    
    222
    -        encryption = self._contact.settings.get('encryption')
    
    223
    -        self._set_encryption_state(encryption)
    
    224
    -        self._set_encryption_details(encryption)
    
    222
    +        encryption_available = True
    
    223
    +        if isinstance(self._contact, GroupchatContact):
    
    224
    +            encryption_available = self._contact.encryption_available
    
    225
    +            if not encryption_available:
    
    226
    +                self._ui.encryption_details_button.set_visible(False)
    
    227
    +                self._ui.encryption_menu_button.set_sensitive(False)
    
    228
    +                self._ui.encryption_image.set_from_icon_name(
    
    229
    +                    'channel-insecure-symbolic', Gtk.IconSize.MENU)
    
    230
    +                self._ui.encryption_menu_button.set_tooltip_text(
    
    231
    +                    _('This is a public group chat. '
    
    232
    +                      'Encryption is not available.'))
    
    233
    +
    
    234
    +        if encryption_available:
    
    235
    +            self._ui.encryption_menu_button.set_sensitive(True)
    
    236
    +            self._ui.encryption_menu_button.set_tooltip_text(
    
    237
    +                _('Choose encryption'))
    
    238
    +            encryption = self._contact.settings.get('encryption')
    
    239
    +            self._set_encryption_state(encryption)
    
    240
    +            self._set_encryption_details(encryption)
    
    225 241
     
    
    226 242
             self._set_chatstate(True)
    
    227 243