tasklist: Auto-call set_client on all template widgets

This commit also update one of the example to remove its now
redundant boilerplate code.
This commit is contained in:
Emmanuel Lepage Vallee 2019-03-06 22:57:34 -05:00
parent aa6ab69ffc
commit a081413339
2 changed files with 7 additions and 7 deletions

View File

@ -401,6 +401,11 @@ local function tasklist_label(c, args, tb)
return text, bg, bg_image, not tasklist_disable_icon and c.icon or nil, other_args
end
-- Remove some callback boilerplate from the user provided templates.
local function create_callback(w, t)
common._set_common_property(w, "client", t)
end
local function tasklist_update(s, w, buttons, filter, data, style, update_function, args)
local clients = {}
@ -419,6 +424,7 @@ local function tasklist_update(s, w, buttons, filter, data, style, update_functi
update_function(w, buttons, label, data, clients, {
widget_template = args.widget_template,
create_callback = create_callback,
})
end

View File

@ -52,17 +52,11 @@ end --DOC_HIDE
widget = wibox.container.background,
},
{
{
id = "clienticon",
widget = awful.widget.clienticon,
},
awful.widget.clienticon,
margins = 5,
widget = wibox.container.margin
},
nil,
create_callback = function(self, c, index, objects) --luacheck: no unused args
self:get_children_by_id("clienticon")[1].client = c
end,
layout = wibox.layout.align.vertical,
},
}