Philipp Hörist pushed to branch newcontrol at gajim / gajim
Commits:
-
81288b2d
by lovetox at 2022-08-03T23:49:08+02:00
4 changed files:
Changes:
| ... | ... | @@ -580,12 +580,10 @@ def _on_send_message(self) -> None: |
| 580 | 580 | control = self._control_stack.get_current_control()
|
| 581 | 581 | assert control is not None
|
| 582 | 582 | |
| 583 | - action = app.window.lookup_action('set-encryption')
|
|
| 584 | - assert action is not None
|
|
| 585 | - state = action.get_state()
|
|
| 586 | - assert state is not None
|
|
| 587 | - encryption = state.get_string()
|
|
| 583 | + contact = self._current_contact
|
|
| 584 | + assert contact is not None
|
|
| 588 | 585 | |
| 586 | + encryption = contact.settings.get('encryption')
|
|
| 589 | 587 | if encryption:
|
| 590 | 588 | self.sendmessage = True
|
| 591 | 589 | app.plugin_manager.extension_point(
|
| ... | ... | @@ -594,8 +592,6 @@ def _on_send_message(self) -> None: |
| 594 | 592 | if not self.sendmessage:
|
| 595 | 593 | return
|
| 596 | 594 | |
| 597 | - contact = self._current_contact
|
|
| 598 | - assert contact is not None
|
|
| 599 | 595 | client = app.get_client(contact.account)
|
| 600 | 596 | |
| 601 | 597 | message = helpers.remove_invalid_xml_chars(message)
|
| ... | ... | @@ -219,12 +219,6 @@ def __str__(self): |
| 219 | 219 | ]
|
| 220 | 220 | |
| 221 | 221 | |
| 222 | -MAIN_WIN_STATEFUL_ACTIONS = [
|
|
| 223 | - # action name, variant type, default state, enabled
|
|
| 224 | - ('set-encryption', 's', 'disabled', False),
|
|
| 225 | -]
|
|
| 226 | - |
|
| 227 | - |
|
| 228 | 222 | ACCOUNT_ACTIONS = [
|
| 229 | 223 | ('add-contact', 'as'),
|
| 230 | 224 | ('block-contact', 's'),
|
| ... | ... | @@ -39,7 +39,6 @@ |
| 39 | 39 | from gajim.common.i18n import _
|
| 40 | 40 | from gajim.common.modules.bytestream import is_transfer_active
|
| 41 | 41 | from gajim.gtk.const import MAIN_WIN_ACTIONS
|
| 42 | -from gajim.gtk.const import MAIN_WIN_STATEFUL_ACTIONS
|
|
| 43 | 42 | from gajim.plugins.pluginmanager import PluginManifest
|
| 44 | 43 | from gajim.plugins.repository import PluginRepository
|
| 45 | 44 | |
| ... | ... | @@ -347,6 +346,13 @@ def _add_stateful_actions(self) -> None: |
| 347 | 346 | |
| 348 | 347 | self.add_action(action)
|
| 349 | 348 | |
| 349 | + action = Gio.SimpleAction.new_stateful(
|
|
| 350 | + 'set-encryption',
|
|
| 351 | + GLib.VariantType('s'),
|
|
| 352 | + GLib.Variant('s', 'disabled'))
|
|
| 353 | + |
|
| 354 | + self.add_action(action)
|
|
| 355 | + |
|
| 350 | 356 | def _add_actions2(self) -> None:
|
| 351 | 357 | for action, variant_type, enabled in MAIN_WIN_ACTIONS:
|
| 352 | 358 | if variant_type is not None:
|
| ... | ... | @@ -355,14 +361,6 @@ def _add_actions2(self) -> None: |
| 355 | 361 | act.set_enabled(enabled)
|
| 356 | 362 | self.add_action(act)
|
| 357 | 363 | |
| 358 | - for action, variant_type, default, enabled in MAIN_WIN_STATEFUL_ACTIONS:
|
|
| 359 | - action = Gio.SimpleAction.new_stateful(
|
|
| 360 | - action,
|
|
| 361 | - None,
|
|
| 362 | - GLib.Variant(variant_type, default))
|
|
| 363 | - action.set_enabled(enabled)
|
|
| 364 | - self.add_action(action)
|
|
| 365 | - |
|
| 366 | 364 | actions = [
|
| 367 | 365 | 'change-nickname',
|
| 368 | 366 | 'change-subject',
|
| ... | ... | @@ -323,7 +323,7 @@ def _change_encryption(self, |
| 323 | 323 | # TODO: Add GUI error here
|
| 324 | 324 | return
|
| 325 | 325 | |
| 326 | - if not plugin.activate_encryption(self):
|
|
| 326 | + if not plugin.activate_encryption(app.window.get_active_control()):
|
|
| 327 | 327 | return
|
| 328 | 328 | |
| 329 | 329 | self._set_encryption_state(new_state)
|
| ... | ... | @@ -365,7 +365,7 @@ def _on_encryption_details_clicked(self, _button: Gtk.Button) -> None: |
| 365 | 365 | contact = self.get_current_contact()
|
| 366 | 366 | encryption = contact.settings.get('encryption')
|
| 367 | 367 | app.plugin_manager.extension_point(
|
| 368 | - f'encryption_dialog{encryption}', contact)
|
|
| 368 | + f'encryption_dialog{encryption}', app.window.get_active_control())
|
|
| 369 | 369 | |
| 370 | 370 | def _set_settings_menu(self, contact: ChatContactT) -> None:
|
| 371 | 371 | if isinstance(contact, GroupchatContact):
|