diff options
author | lovetox <philipp@hoerist.com> | 2022-08-20 15:19:10 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2022-08-20 15:19:10 +0300 |
commit | 923a07f4b5084b9cf38d63739ae51d6f97d05a22 (patch) | |
tree | 1c801d932e77535343bee24f5fd62fdbb3103f72 | |
parent | 801bec063d8160a1c43cc2535562354379e7d2e3 (diff) |
refactor: WorkspaceSidebar: Move building menu to menu module
-rw-r--r-- | gajim/gtk/menus.py | 8 | ||||
-rw-r--r-- | gajim/gtk/workspace_side_bar.py | 20 |
2 files changed, 10 insertions, 18 deletions
diff --git a/gajim/gtk/menus.py b/gajim/gtk/menus.py index 105655871..2febedfb5 100644 --- a/gajim/gtk/menus.py +++ b/gajim/gtk/menus.py @@ -574,6 +574,14 @@ def get_format_menu() -> GajimMenu: return GajimMenu.from_list(menuitems) +def get_workspace_menu(workspace_id: str) -> GajimMenu: + menuitems: MenuItemListT = [ + (_('Edit…'), 'win.edit-workspace', f'"{workspace_id}"'), + ] + + return GajimMenu.from_list(menuitems) + + def escape_mnemonic(label: Optional[str]) -> Optional[str]: if label is None: return None diff --git a/gajim/gtk/workspace_side_bar.py b/gajim/gtk/workspace_side_bar.py index eca26eac1..60c7aafda 100644 --- a/gajim/gtk/workspace_side_bar.py +++ b/gajim/gtk/workspace_side_bar.py @@ -15,7 +15,6 @@ from __future__ import annotations from typing import Any -from typing import List from typing import Optional from typing import cast @@ -23,8 +22,6 @@ import logging import pickle from gi.repository import Gdk -from gi.repository import Gio -from gi.repository import GLib from gi.repository import Gtk from nbxmpp.protocol import JID @@ -34,6 +31,7 @@ from gajim.common.i18n import _ from .chat_list_stack import ChatListStack from .chat_page import ChatPage +from .menus import get_workspace_menu from .structs import ChatListEntryParam from .util import open_window @@ -323,7 +321,7 @@ class Workspace(CommonWorkspace): if event.button != 3: # right click return - menu = self._get_workspace_menu() + menu = get_workspace_menu(self.workspace_id) rectangle = Gdk.Rectangle() rectangle.x = int(event.x) @@ -336,20 +334,6 @@ class Workspace(CommonWorkspace): popover.set_pointing_to(rectangle) popover.popup() - def _get_workspace_menu(self) -> Gio.Menu: - menu_items: List[Any] = [ - ('edit-workspace', _('Edit…')), - ] - menu = Gio.Menu() - for item in menu_items: - action, label = item - action = f'win.{action}' - menuitem = Gio.MenuItem.new(label, action) - variant = GLib.Variant('s', self.workspace_id) - menuitem.set_action_and_target_value(action, variant) - menu.append_item(menuitem) - return menu - def update_avatar(self) -> None: self._image.update() |