Philipp Hörist pushed to branch newcontrol at gajim / gajim


Commits:
81288b2d by lovetox at 2022-08-03T23:49:08+02:00
fix: Fix encryption action and dialogs

- - - - -


4 changed files:

- gajim/gtk/chat_stack.py
- gajim/gtk/const.py
- gajim/gtk/main.py
- gajim/gtk/message_actions_box.py


Changes:

=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -580,12 +580,10 @@ def _on_send_message(self) -> None:
         control = self._control_stack.get_current_control()
         assert control is not None
 
-        action = app.window.lookup_action('set-encryption')
-        assert action is not None
-        state = action.get_state()
-        assert state is not None
-        encryption = state.get_string()
+        contact = self._current_contact
+        assert contact is not None
 
+        encryption = contact.settings.get('encryption')
         if encryption:
             self.sendmessage = True
             app.plugin_manager.extension_point(
@@ -594,8 +592,6 @@ def _on_send_message(self) -> None:
             if not self.sendmessage:
                 return
 
-        contact = self._current_contact
-        assert contact is not None
         client = app.get_client(contact.account)
 
         message = helpers.remove_invalid_xml_chars(message)


=====================================
gajim/gtk/const.py
=====================================
@@ -219,12 +219,6 @@ def __str__(self):
 ]
 
 
-MAIN_WIN_STATEFUL_ACTIONS = [
-    # action name, variant type, default state, enabled
-    ('set-encryption', 's', 'disabled', False),
-]
-
-
 ACCOUNT_ACTIONS = [
     ('add-contact', 'as'),
     ('block-contact', 's'),


=====================================
gajim/gtk/main.py
=====================================
@@ -39,7 +39,6 @@
 from gajim.common.i18n import _
 from gajim.common.modules.bytestream import is_transfer_active
 from gajim.gtk.const import MAIN_WIN_ACTIONS
-from gajim.gtk.const import MAIN_WIN_STATEFUL_ACTIONS
 from gajim.plugins.pluginmanager import PluginManifest
 from gajim.plugins.repository import PluginRepository
 
@@ -347,6 +346,13 @@ def _add_stateful_actions(self) -> None:
 
         self.add_action(action)
 
+        action = Gio.SimpleAction.new_stateful(
+            'set-encryption',
+            GLib.VariantType('s'),
+            GLib.Variant('s', 'disabled'))
+
+        self.add_action(action)
+
     def _add_actions2(self) -> None:
         for action, variant_type, enabled in MAIN_WIN_ACTIONS:
             if variant_type is not None:
@@ -355,14 +361,6 @@ def _add_actions2(self) -> None:
             act.set_enabled(enabled)
             self.add_action(act)
 
-        for action, variant_type, default, enabled in 
MAIN_WIN_STATEFUL_ACTIONS:
-            action = Gio.SimpleAction.new_stateful(
-                action,
-                None,
-                GLib.Variant(variant_type, default))
-            action.set_enabled(enabled)
-            self.add_action(action)
-
         actions = [
             'change-nickname',
             'change-subject',


=====================================
gajim/gtk/message_actions_box.py
=====================================
@@ -323,7 +323,7 @@ def _change_encryption(self,
                 # TODO: Add GUI error here
                 return
 
-            if not plugin.activate_encryption(self):
+            if not plugin.activate_encryption(app.window.get_active_control()):
                 return
 
         self._set_encryption_state(new_state)
@@ -365,7 +365,7 @@ def _on_encryption_details_clicked(self, _button: 
Gtk.Button) -> None:
         contact = self.get_current_contact()
         encryption = contact.settings.get('encryption')
         app.plugin_manager.extension_point(
-            f'encryption_dialog{encryption}', contact)
+            f'encryption_dialog{encryption}', app.window.get_active_control())
 
     def _set_settings_menu(self, contact: ChatContactT) -> None:
         if isinstance(contact, GroupchatContact):



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/81288b2dc0aabbb522d3085bf699671169084ec2

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/81288b2dc0aabbb522d3085bf699671169084ec2
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to