awful.menu.clients: Fix API (FS#1200)

This gets rid of the unused first argument and adds a new second argument that
can influence individual items.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2014-01-11 21:23:23 +01:00
parent 56c5797905
commit 479f7b990c
1 changed files with 12 additions and 3 deletions

View File

@ -455,10 +455,12 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
--- Build a popup menu with running clients and shows it. --- Build a popup menu with running clients and shows it.
-- @param _menu Menu table, see new() function for more informations -- @param args Menu table, see new() function for more informations
-- @param item_args Table that will be merged into each item, see new() for more
-- informations.
-- @return The menu. -- @return The menu.
function menu:clients(args) -- FIXME crude api function menu.clients(args, item_args)
local _menu = self or {} local args = args or args1
local cls = capi.client.get() local cls = capi.client.get()
local cls_t = {} local cls_t = {}
for k, c in pairs(cls) do for k, c in pairs(cls) do
@ -472,6 +474,13 @@ function menu:clients(args) -- FIXME crude api
c:raise() c:raise()
end, end,
c.icon } c.icon }
if item_args then
if type(item_args) == "function" then
table_merge(cls_t[#cls_t], item_args(c))
else
table_merge(cls_t[#cls_t], item_args)
end
end
end end
args = args or {} args = args or {}
args.items = args.items or {} args.items = args.items or {}