It also fixes a typo in menu.lua.in luadoc
From 347a5732f531d162519375e12a5cf8a3158b9a29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= <[email protected]>
Date: Wed, 17 Mar 2010 13:22:45 +0100
Subject: [PATCH] Add the possibity for dynamic menu
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Return the label of the selected menu item as an argument for the
callback function

Signed-off-by: Pierre Mazière <[email protected]>
---
 lib/awful/menu.lua.in |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/awful/menu.lua.in b/lib/awful/menu.lua.in
index 9df7fb0..6fb714b 100644
--- a/lib/awful/menu.lua.in
+++ b/lib/awful/menu.lua.in
@@ -126,7 +126,7 @@ local function exec(menu, num, mouse_event)
         util.spawn(cmd)
     elseif type(cmd) == "function" then
         get_parents(menu):hide()
-        cmd()
+        cmd(menu.items[num].returned_value)
     end
 end
 
@@ -265,7 +265,7 @@ local function add_item(data, num, item_info)
     item.height = label:extents().height + 2
     item.ontop = true
 
-    return { wibox = item, akey= key, cmd = item_info[2] }
+    return { wibox = item, akey= key, cmd = item_info[2], returned_value=item_info[1] }
 end
 
 --- Build a popup menu with running clients and shows it.
@@ -367,7 +367,7 @@ function toggle(menu, keygrabber)
 end
 
 --- Open a menu popup.
--- @param menu Table containing the menu informations. Key items: Table containing the displayed items, each element is a tab containing: item name, tiggered action, submenu table or function, item icon (optional). Keys [fg|bg]_[focus|normal], border, border_width, submenu_icon, height and width override the default display for your menu, each of them are optional. Key auto_expand controls the submenu auto expand behaviour by setting it to true (default) or false.
+-- @param menu Table containing the menu informations. Key items: Table containing the displayed items, each element is a tab containing: item name, triggered action, submenu table or function, item icon (optional). Keys [fg|bg]_[focus|normal], border, border_width, submenu_icon, height and width override the default display for your menu, each of them are optional. Key auto_expand controls the submenu auto expand behaviour by setting it to true (default) or false.
 -- @param parent Specify the parent menu if we want to open a submenu, this value should never be set by the user.
 -- @param num Specify the parent's clicked item number if we want to open a submenu, this value should never be set by the user.
 function new(menu, parent, num)
-- 
1.7.0

Reply via email to