add-create-callback to titlebar_indicator

This commit is contained in:
undefinedDarkness 2021-11-04 21:19:44 +05:30
parent 7277f57730
commit 1f8c3bdcd7
3 changed files with 31 additions and 12 deletions

View File

@ -75,4 +75,16 @@ theme.task_preview_widget_border_color = "#ffffff" -- The border color of the
theme.task_preview_widget_border_width = 3 -- The border width of the widget
theme.task_preview_widget_margin = 0 -- The margin of the widget
-- tabbed misc widget(s)
theme.bling_tabbed_misc_titlebar_indicator = {
layout_spacing = dpi(4),
icon_size = dpi(20),
icon_margin = dpi(4),
bg_color_focus = "#ff0000",
bg_color = "#00000000",
icon_shape = function(cr, w, h)
gears.shape.rounded_rect(cr, w, h, 0)
end,
layout = wibox.layout.fixed.horizontal
}
```

View File

@ -35,7 +35,12 @@ bling.widget.tabbed_misc.titlebar_indicator(client, {
},
widget = wibox.container.margin,
margins = 2,
id = 'click_role'
id = 'click_role',
update_callback = function(self, client, group)
if client == group.clients[group.focused_idx] then
self.margins = 5
end
end
}
})
```

View File

@ -40,16 +40,11 @@ return function(c, opts)
spacing = opts.layout_spacing,
})
awesome.connect_signal(
"bling::tabbed::client_removed",
function(_, removed_c)
-- Remove from list
for idx, icon in ipairs(tabbed_icons.children) do
if
icon:get_children_by_id("icon_role")[1].client == removed_c
then
tabbed_icons:remove(idx)
end
awesome.connect_signal("bling::tabbed::client_removed", function(_, removed_c)
-- Remove from list
for idx, icon in ipairs(tabbed_icons.children) do
if icon._client == removed_c then
tabbed_icons:remove(idx)
end
-- Empty list
@ -57,7 +52,7 @@ return function(c, opts)
tabbed_icons:reset()
end
end
)
end)
local function recreate(group)
if tbl_contains(group.clients, c) then
@ -93,6 +88,13 @@ return function(c, opts)
widget = wibox.container.place,
})
widget._client = client
-- No creation call back since this would be called on creation & every time the widget updated.
if opts.widget_template.update_callback then
opts.widget_template.update_callback(widget, client, group)
end
-- Add icons & etc
for _, w in ipairs(widget:get_children_by_id("icon_role")) do
-- TODO: Allow fallback icon?