Use grid layout in custom_tasklist
Export draw_widget from tag_preview
This commit is contained in:
parent
1f8c3bdcd7
commit
7261f0ba40
|
@ -5,51 +5,47 @@ local beautiful = require("beautiful")
|
||||||
local dpi = require("beautiful.xresources").apply_dpi
|
local dpi = require("beautiful.xresources").apply_dpi
|
||||||
|
|
||||||
local function tabobj_support(self, c, index, clients)
|
local function tabobj_support(self, c, index, clients)
|
||||||
-- Self is the background widget in this context
|
-- Self is the background widget in this context
|
||||||
if not c.bling_tabbed then
|
if not c.bling_tabbed and #c.bling_tabbed.clients > 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local group = c.bling_tabbed
|
local group = c.bling_tabbed
|
||||||
|
|
||||||
|
-- TODO: Allow customization here
|
||||||
|
local layout_v = wibox.widget {
|
||||||
|
vertical_spacing = dpi(2),
|
||||||
|
horizontal_spacing = dpi(2),
|
||||||
|
layout = wibox.layout.grid.horizontal,
|
||||||
|
forced_num_rows = 2,
|
||||||
|
forced_num_cols = 2,
|
||||||
|
homogeneous = true
|
||||||
|
}
|
||||||
|
|
||||||
-- Single item tabbed group's dont get special rendering
|
local wrapper = wibox.widget({
|
||||||
if #group.clients > 1 then
|
layout_v,
|
||||||
local wrapper = wibox.widget({
|
id = "click_role",
|
||||||
{
|
widget = wibox.container.margin,
|
||||||
-- This is so dumb... but it works so meh
|
margins = dpi(5),
|
||||||
{
|
})
|
||||||
id = "row1",
|
|
||||||
layout = wibox.layout.flex.horizontal,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = "row2",
|
|
||||||
layout = wibox.layout.flex.horizontal,
|
|
||||||
},
|
|
||||||
spacing = dpi(2),
|
|
||||||
layout = wibox.layout.fixed.vertical,
|
|
||||||
},
|
|
||||||
id = "click_role",
|
|
||||||
widget = wibox.container.margin,
|
|
||||||
margins = dpi(5),
|
|
||||||
})
|
|
||||||
|
|
||||||
for idx, c in ipairs(group.clients) do
|
-- To get the ball rolling.
|
||||||
if c and c.icon then
|
for idx, c in ipairs(group.clients) do
|
||||||
-- TODO: Don't do this in a -1iq way
|
if not (c and c.icon) then goto skip end
|
||||||
if idx <= 2 then
|
|
||||||
wrapper
|
|
||||||
:get_children_by_id("row1")[1]
|
|
||||||
:add(awful.widget.clienticon(c))
|
|
||||||
else
|
|
||||||
wrapper
|
|
||||||
:get_children_by_id("row2")[1]
|
|
||||||
:add(awful.widget.clienticon(c))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.widget = wrapper
|
-- Add to the last layout
|
||||||
end
|
layout_v:add(wibox.widget {
|
||||||
|
{
|
||||||
|
widget = awful.widget.clienticon,
|
||||||
|
client = c
|
||||||
|
},
|
||||||
|
widget = wibox.container.constraint,
|
||||||
|
width = dpi(24),
|
||||||
|
height = dpi(24)
|
||||||
|
})
|
||||||
|
::skip::
|
||||||
|
end
|
||||||
|
self.widget = wrapper
|
||||||
end
|
end
|
||||||
|
|
||||||
return tabobj_support
|
return tabobj_support
|
||||||
|
|
|
@ -54,6 +54,7 @@ return function(c, opts)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
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()
|
||||||
|
@ -117,4 +118,79 @@ 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
|
||||||
|
=======
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
shape = opts.icon_shape,
|
||||||
|
id = "bg_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 and 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("bg_role")) do
|
||||||
|
w:add_button(awful.button({}, 1, function()
|
||||||
|
tabbed_module.switch_to(group, idx)
|
||||||
|
end))
|
||||||
|
if client == focused then
|
||||||
|
w.bg = opts.bg_color_focus
|
||||||
|
w.fg = opts.fg_color_focus
|
||||||
|
else
|
||||||
|
w.bg = opts.bg_color
|
||||||
|
w.fg = opts.fg_color
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, w in ipairs(widget:get_children_by_id("text_role")) do
|
||||||
|
w.text = client.name
|
||||||
|
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
|
||||||
|
>>>>>>> 848ddd9 (Use grid layout in custom_tasklist)
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,8 @@ local function draw_widget(
|
||||||
local tag_screen = t.screen
|
local tag_screen = t.screen
|
||||||
for i, c in ipairs(t:clients()) do
|
for i, c in ipairs(t:clients()) do
|
||||||
if not c.hidden and not c.minimized then
|
if not c.hidden and not c.minimized then
|
||||||
local img_box = wibox.widget({
|
|
||||||
|
local img_box = wibox.widget({
|
||||||
image = gears.surface.load(c.icon),
|
image = gears.surface.load(c.icon),
|
||||||
resize = true,
|
resize = true,
|
||||||
forced_height = 100 * scale,
|
forced_height = 100 * scale,
|
||||||
|
@ -182,24 +183,15 @@ local enable = function(opts)
|
||||||
|
|
||||||
tag_preview_box.maximum_width = scale * geo.width + margin * 2
|
tag_preview_box.maximum_width = scale * geo.width + margin * 2
|
||||||
tag_preview_box.maximum_height = scale * geo.height + margin * 2
|
tag_preview_box.maximum_height = scale * geo.height + margin * 2
|
||||||
tag_preview_box:setup(
|
|
||||||
draw_widget(
|
-- TODO: Use a table here
|
||||||
t,
|
tag_preview_box:setup(draw_widget(t, tag_preview_image, scale,
|
||||||
tag_preview_image,
|
screen_radius, client_radius,
|
||||||
scale,
|
client_opacity, client_bg,
|
||||||
screen_radius,
|
client_border_color,
|
||||||
client_radius,
|
client_border_width, widget_bg,
|
||||||
client_opacity,
|
widget_border_color,
|
||||||
client_bg,
|
widget_border_width, geo, margin))
|
||||||
client_border_color,
|
|
||||||
client_border_width,
|
|
||||||
widget_bg,
|
|
||||||
widget_border_color,
|
|
||||||
widget_border_width,
|
|
||||||
geo,
|
|
||||||
margin
|
|
||||||
)
|
|
||||||
)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
awesome.connect_signal("bling::tag_preview::visibility", function(s, v)
|
awesome.connect_signal("bling::tag_preview::visibility", function(s, v)
|
||||||
|
@ -212,4 +204,4 @@ local enable = function(opts)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return { enable = enable }
|
return {enable = enable, draw_widget = draw_widget}
|
||||||
|
|
Loading…
Reference in New Issue