Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Müller <fmueller@owncloud.com>2021-04-22 14:34:49 +0300
committerHannah von Reth <vonreth@kde.org>2021-04-30 14:25:49 +0300
commit018dc2a7be5a098ab35d40dcfc688528da4cef17 (patch)
treecf5d389f774caa96b032441a47bd5cc2025f0028 /shell_integration
parent70ddd079643d444891fe3964640fd220306edc7d (diff)
Improve submenu creation
Removes the need for parsing a list of 3-tuples into menu items later on, and allows adding non-"menu item" items like, e.g., separators.
Diffstat (limited to 'shell_integration')
-rw-r--r--shell_integration/nautilus/syncstate.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/shell_integration/nautilus/syncstate.py b/shell_integration/nautilus/syncstate.py
index 1c8fafe8d..2b7fa8334 100644
--- a/shell_integration/nautilus/syncstate.py
+++ b/shell_integration/nautilus/syncstate.py
@@ -262,7 +262,15 @@ class MenuExtension_ownCloud(GObject.GObject, Nautilus.MenuProvider):
elif line.startswith('MENU_ITEM:'):
args = line.split(':')
if len(args) >= 4:
- menu_items.append([args[1], 'd' not in args[2], ':'.join(args[3:])])
+ action = args[1]
+ label = ':'.join(args[3:])
+ enabled = 'd' not in args[2]
+
+ item = Nautilus.MenuItem(name=action, label=label, sensitive=enabled)
+ item.connect("activate", self.context_menu_action, action, filesstring)
+
+ menu_items.append(item)
+
line_handled = True
if line_handled:
@@ -275,19 +283,19 @@ class MenuExtension_ownCloud(GObject.GObject, Nautilus.MenuProvider):
if not done:
return self.legacy_menu_items(files)
- if len(menu_items) == 0:
+ # if there are no items for the submenu, we don't have to create it at all
+ if not menu_items:
return []
# Set up the 'ownCloud...' submenu
item_owncloud = Nautilus.MenuItem(
name='IntegrationMenu', label=self.strings.get('CONTEXT_MENU_TITLE', appname))
- menu = Nautilus.Menu()
- item_owncloud.set_submenu(menu)
- for action, enabled, label in menu_items:
- item = Nautilus.MenuItem(name=action, label=label, sensitive=enabled)
- item.connect("activate", self.context_menu_action, action, filesstring)
- menu.append_item(item)
+ submenu = Nautilus.Menu()
+ item_owncloud.set_submenu(submenu)
+
+ for item in menu_items:
+ submenu.append_item(item)
return [item_owncloud]