add more options to titlebar indicator

This commit is contained in:
undefinedDarkness 2021-08-30 23:53:44 +05:30
parent 7261f0ba40
commit a525299d4f
2 changed files with 44 additions and 104 deletions

View File

@ -16,9 +16,12 @@ To use the task list indicator:
```lua ```lua
bling.widget.tabbed_misc.titlebar_indicator(client, { bling.widget.tabbed_misc.titlebar_indicator(client, {
layout = wibox.layout.fixed.vertical,
layout_spacing = dpi(5), -- Set spacing in between items layout_spacing = dpi(5), -- Set spacing in between items
icon_size = dpi(24), icon_size = dpi(24),
icon_margin = 0, icon_margin = 0,
fg_color = "#cccccc", -- Normal color for text
fg_color_focus = "#ffffff", -- Color for focused text
bg_color_focus = "#282828", -- Color for the focused items bg_color_focus = "#282828", -- Color for the focused items
bg_color = "#1d2021", -- Color for normal / unfocused items bg_color = "#1d2021", -- Color for normal / unfocused items
icon_shape = gears.shape.circle -- Set icon shape, icon_shape = gears.shape.circle -- Set icon shape,
@ -35,7 +38,7 @@ bling.widget.tabbed_misc.titlebar_indicator(client, {
}, },
widget = wibox.container.margin, widget = wibox.container.margin,
margins = 2, margins = 2,
id = 'click_role', id = 'bg_role',
update_callback = function(self, client, group) update_callback = function(self, client, group)
if client == group.clients[group.focused_idx] then if client == group.clients[group.focused_idx] then
self.margins = 5 self.margins = 5

View File

@ -9,116 +9,54 @@ local tabbed_module = require(
-- Just check if a table contains a value. -- Just check if a table contains a value.
local function tbl_contains(tbl, item) local function tbl_contains(tbl, item)
for _, v in ipairs(tbl) do for _, v in ipairs(tbl) do
if v == item then if v == item then
return true return true
end end
end end
return false return false
end end
-- Needs to be run, every time a new titlbear is created -- Needs to be run, every time a new titlbear is created
return function(c, opts) return function(c, opts)
-- Args & Fallback -- Widget templates are in their original loactions -- Args & Fallback -- Widget templates are in their original loactions
opts = gears.table.crush({ opts = gears.table.crush({
layout_spacing = dpi(4), layout_spacing = dpi(4),
icon_size = dpi(20), icon_size = dpi(20),
icon_margin = dpi(4), icon_margin = dpi(4),
bg_color_focus = "#ff0000", bg_color_focus = "#ff0000",
bg_color = "#00000000", bg_color = "#00000000",
icon_shape = function(cr, w, h) fg_color = "#fafafa",
gears.shape.rounded_rect(cr, w, h, 0) fg_color_focus = "#e0e0e0",
end, icon_shape = function(cr, w, h)
}, gears.table.join( gears.shape.rounded_rect(cr, w, h, 0)
opts, end,
beautiful.bling_tabbed_misc_titlebar_indicator layout = wibox.layout.fixed.horizontal,
)) }, gears.table.join(
opts,
beautiful.bling_tabbed_misc_titlebar_indicator
))
-- Container to store icons -- Container to store icons
local tabbed_icons = wibox.widget({ local tabbed_icons = wibox.widget({
layout = wibox.layout.fixed.horizontal, layout = opts.layout,
spacing = opts.layout_spacing, spacing = opts.layout_spacing,
}) })
awesome.connect_signal("bling::tabbed::client_removed", function(_, removed_c) awesome.connect_signal("bling::tabbed::client_removed", function(_, removed_c)
-- Remove from list -- Remove from list
for idx, icon in ipairs(tabbed_icons.children) do for idx, icon in ipairs(tabbed_icons.children) do
if icon._client == removed_c then if icon._client == removed_c then
tabbed_icons:remove(idx) tabbed_icons:remove(idx)
end end
end
-- Empty list -- Empty list
if removed_c == c then if removed_c == c then
tabbed_icons:reset() tabbed_icons:reset()
end end
end
end) end)
<<<<<<< HEAD
local function recreate(group)
if tbl_contains(group.clients, c) then
tabbed_icons:reset()
local focused = group.clients[group.focused_idx]
-- Autohide?
if #group.clients == 1 then
return
end
for idx, client in ipairs(group.clients) do
local widget = wibox.widget(opts.widget_template or {
{
{
{
id = "icon_role",
forced_width = opts.icon_size,
forced_height = opts.icon_size,
widget = awful.widget.clienticon,
},
margins = opts.icon_margin,
widget = wibox.container.margin,
},
bg = (client == focused) and opts.bg_color_focus
or opts.bg_color,
shape = opts.icon_shape,
id = "click_role",
widget = wibox.container.background,
},
halign = "center",
valign = "center",
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?
w.image = client.icon
w.client = client
end
for _, w in ipairs(widget:get_children_by_id("click_role")) do
w:add_button(awful.button({}, 1, function()
tabbed_module.switch_to(group, idx)
end))
end
tabbed_icons:add(widget)
end
end
end
awesome.connect_signal("bling::tabbed::client_added", recreate)
awesome.connect_signal("bling::tabbed::changed_focus", recreate)
return tabbed_icons
=======
local function recreate(group) local function recreate(group)
if tbl_contains(group.clients, c) then if tbl_contains(group.clients, c) then
tabbed_icons:reset() tabbed_icons:reset()
@ -144,7 +82,7 @@ return function(c, opts)
widget = wibox.container.margin, widget = wibox.container.margin,
}, },
shape = opts.icon_shape, shape = opts.icon_shape,
id = "bg_role", id = "background_role",
widget = wibox.container.background, widget = wibox.container.background,
}, },
halign = "center", halign = "center",
@ -192,5 +130,4 @@ return function(c, opts)
awesome.connect_signal("bling::tabbed::changed_focus", recreate) awesome.connect_signal("bling::tabbed::changed_focus", recreate)
return tabbed_icons return tabbed_icons
>>>>>>> 848ddd9 (Use grid layout in custom_tasklist)
end end