taglist: Auto-call set_tag on each widgets of the template.

This reduced the boilerplate code.
This commit is contained in:
Emmanuel Lepage Vallee 2019-03-06 22:56:58 -05:00
parent e452ec8e27
commit aa6ab69ffc
1 changed files with 6 additions and 0 deletions

View File

@ -386,6 +386,11 @@ function taglist.taglist_label(t, args)
return text, bg_color, bg_image, not taglist_disable_icon and icon or nil, other_args return text, bg_color, bg_image, not taglist_disable_icon and icon or nil, other_args
end end
-- Remove some callback boilerplate from the user provided templates.
local function create_callback(w, t)
common._set_common_property(w, "tag", t)
end
local function taglist_update(s, w, buttons, filter, data, style, update_function, args) local function taglist_update(s, w, buttons, filter, data, style, update_function, args)
local tags = {} local tags = {}
@ -402,6 +407,7 @@ local function taglist_update(s, w, buttons, filter, data, style, update_functio
update_function(w, buttons, label, data, tags, { update_function(w, buttons, label, data, tags, {
widget_template = args.widget_template, widget_template = args.widget_template,
create_callback = create_callback,
}) })
end end