Fix the menu hack for Gajim ≥1.6

This commit is contained in:
Bohdan Horbeshko 2023-09-20 17:59:46 +03:00
parent d6b7575c4c
commit b538fa106e
2 changed files with 9 additions and 11 deletions

View file

@ -14,8 +14,8 @@
"win32"
],
"requirements": [
"gajim>=1.5,<1.9"
"gajim>=1.6,<1.9"
],
"short_name": "otrplugin",
"version": "0.5"
"version": "0.5.1"
}

View file

@ -56,7 +56,7 @@ class OTRPlugin(GajimPlugin):
self.modules = [module]
self.gui_extension_points = {
'encrypt' + self.encryption_name: (self._encrypt_message, None),
# 'message_actions_box': (self._message_actions_box_activate, self._message_actions_box_deactivate),
'message_actions_box': (self._message_actions_box_activate, self._message_actions_box_deactivate),
}
self._menuitem = None
@ -69,15 +69,13 @@ class OTRPlugin(GajimPlugin):
return grid._ui.encryption_menu_button.get_menu_model()
def activate(self):
pass
# if app.window is not None:
# grid = self._get_grid()
# self._actions_hack_activate(grid)
if app.window is not None and self._menuitem is None:
grid = self._get_grid()
self._actions_hack_activate(grid)
def deactivate(self):
pass
# grid = self._get_grid()
# self._actions_hack_deactivate(grid)
grid = self._get_grid()
self._actions_hack_deactivate(grid)
@staticmethod
def get_otr(account):
@ -109,7 +107,7 @@ class OTRPlugin(GajimPlugin):
def _actions_hack_activate(self, grid):
model = grid._ui.encryption_menu_button.get_menu_model()
menuitem = make_menu_item('OTR', 'win.set-encryption', '"OTR"')
menuitem = make_menu_item('OTR', 'win.set-encryption', 'OTR')
self._menuitem = menuitem.get_attribute_value(Gio.MENU_ATTRIBUTE_LABEL)
model.append_item(menuitem)