From 1f8c3bdcd7f79dc3ef4c1a7fb5b039d9597db7e3 Mon Sep 17 00:00:00 2001 From: undefinedDarkness Date: Thu, 4 Nov 2021 21:19:44 +0530 Subject: [PATCH] add-create-callback to titlebar_indicator --- docs/theme.md | 12 ++++++++++++ docs/widgets/tabbed_misc.md | 7 ++++++- widget/tabbed_misc/titlebar_indicator.lua | 24 ++++++++++++----------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/docs/theme.md b/docs/theme.md index 592d771..916f839 100644 --- a/docs/theme.md +++ b/docs/theme.md @@ -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 +} ``` diff --git a/docs/widgets/tabbed_misc.md b/docs/widgets/tabbed_misc.md index 2fbdb48..9ae8df5 100644 --- a/docs/widgets/tabbed_misc.md +++ b/docs/widgets/tabbed_misc.md @@ -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 } }) ``` diff --git a/widget/tabbed_misc/titlebar_indicator.lua b/widget/tabbed_misc/titlebar_indicator.lua index af86ad2..2549d83 100644 --- a/widget/tabbed_misc/titlebar_indicator.lua +++ b/widget/tabbed_misc/titlebar_indicator.lua @@ -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?