Merge pull request #2735 from psychon/common_default_template

awful.widget.common: Use a template for the default template
This commit is contained in:
mergify[bot] 2019-04-01 23:51:52 +00:00 committed by GitHub
commit c02ad71b0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 26 deletions

View File

@ -38,32 +38,6 @@ function common.create_buttons(buttons, object)
end
end
local function default_template()
local ib = wibox.widget.imagebox()
local tb = wibox.widget.textbox()
local bgb = wibox.container.background()
local tbm = wibox.container.margin(tb, dpi(4), dpi(4))
local ibm = wibox.container.margin(ib, dpi(4))
local l = wibox.layout.fixed.horizontal()
-- All of this is added in a fixed widget
l:fill_space(true)
l:add(ibm)
l:add(tbm)
-- And all of this gets a background
bgb:set_widget(l)
return {
ib = ib,
tb = tb,
bgb = bgb,
tbm = tbm,
ibm = ibm,
primary = bgb,
}
end
local function custom_template(args)
local l = base.make_widget_from_value(args.widget_template)
@ -84,6 +58,38 @@ local function custom_template(args)
}
end
local function default_template()
return custom_template {
widget_template = {
id = 'background_role',
widget = wibox.container.background,
{
widget = wibox.layout.fixed.horizontal,
fill_space = true,
{
id = 'icon_margin_role',
widget = wibox.container.margin,
{
id = 'icon_role',
widget = wibox.widget.imagebox,
left = dpi(4),
},
},
{
id = 'text_margin_role',
widget = wibox.container.margin,
left = dpi(4),
right = dpi(4),
{
id = 'text_role',
widget = wibox.widget.textbox,
},
}
}
}
}
end
--- Common update method.
-- @param w The widget.
-- @tab buttons