From 4c00ad63a97bd94bfe995f5096bd77e373b1b970 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pierre=20Mazi=C3=A8re?= 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=utf8 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 Signed-off-by: Julien Danjou --- lib/awful/menu.lua.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/awful/menu.lua.in b/lib/awful/menu.lua.in index 9df7fb07..6fb714bd 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) -- 2.11.4.GIT