Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Execute actions through menu

  • Loading branch information...
commit e25ef9ab34b97b5ca7dfd6a59907f2568d74a310 1 parent 308ab51
@baverman authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 uxie/actions.py
View
10 uxie/actions.py
@@ -86,6 +86,10 @@ def activate(self, group, window, key, modifier):
return False
+ def activate_action(self, item, ctx, name, ctx_obj):
+ cb, args = self.actions[ctx][name]
+ cb(ctx_obj, *args)
+
def _find_context(self, ctx, cache):
try:
return cache[ctx]
@@ -149,7 +153,7 @@ def get_allowed_actions(self, window, path):
for r in items[:-1]:
p = p.setdefault(r, {})
- p[items[-1]] = ctx, name
+ p[items[-1]] = ctx, name, ctx_obj
return actions
@@ -169,7 +173,7 @@ def activate_sub_menu(item, items):
for label, v in sorted(actions.items(), key=lambda r: r[0].replace('_', '')):
if isinstance(v, tuple):
- km = activator.get_km_for_action(*v)
+ km = activator.get_km_for_action(*v[:2])
submenu = None
else:
km = None
@@ -195,6 +199,8 @@ def activate_sub_menu(item, items):
if submenu:
item.set_submenu(submenu)
item.connect('activate', activate_sub_menu, v)
+ else:
+ item.connect('activate', activator.activate_action, *v)
menu.append(item)
Please sign in to comment.
Something went wrong with that request. Please try again.