tests: Test the layoutlist

This commit is contained in:
Emmanuel Lepage Vallee 2018-01-13 03:33:27 -05:00
parent 8b60c05118
commit 4524a7880d
5 changed files with 211 additions and 12 deletions

View File

@ -55,9 +55,8 @@ wb:setup {
-- The popup -- The popup
awful.popup { awful.popup {
widget = wibox.widget { widget = wibox.widget {
--TODO use the layoutlist for this example awful.widget.layoutlist {
awful.widget.taglist { filter = awful.widget.layoutlist.source.for_screen,
filter = awful.widget.taglist.filter.all,
screen = 1, screen = 1,
base_layout = wibox.widget { base_layout = wibox.widget {
spacing = 5, spacing = 5,
@ -66,18 +65,11 @@ awful.popup {
}, },
widget_template = { widget_template = {
{ {
--TODO use the layoutlist for this example
-- {
-- id = 'icon_role',
-- forced_height = 22,
-- forced_width = 22,
-- widget = wibox.widget.imagebox,
-- },
{ {
id = "text_role", id = 'icon_role',
forced_height = 22, forced_height = 22,
forced_width = 22, forced_width = 22,
widget = wibox.widget.textbox widget = wibox.widget.imagebox,
}, },
margins = 4, margins = 4,
widget = wibox.container.margin, widget = wibox.container.margin,

View File

@ -0,0 +1,65 @@
local awful = { --DOC_HIDE --DOC_GEN_IMAGE --DOC_NO_USAGE
popup = require("awful.popup"), --DOC_HIDE
placement = require("awful.placement"), --DOC_HIDE
wibar = require("awful.wibar"), --DOC_HIDE
widget = {layoutlist = require("awful.widget.layoutlist"),--DOC_HIDE
layoutbox= require("awful.widget.layoutbox")} --DOC_HIDE
} --DOC_HIDE
local gears = { shape = require("gears.shape") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
-- Normally you would use your existing bars, but for this example, we add one
local lb = awful.widget.layoutbox(screen[1])
local l = wibox.layout.align.horizontal(nil, lb, nil)
l.expand = "outside"
awful.wibar { widget = l }
--DOC_NEWLINE
--DOC_HIDE cheat a bit, the show on widget click doesn't work with the shims
local p = awful.popup {
widget = wibox.widget {
awful.widget.layoutlist {
source = awful.widget.layoutlist.source.default_layouts,
screen = 1,
base_layout = wibox.widget {
spacing = 5,
forced_num_cols = 3,
layout = wibox.layout.grid.vertical,
},
widget_template = {
{
{
id = 'icon_role',
forced_height = 22,
forced_width = 22,
widget = wibox.widget.imagebox,
},
margins = 4,
widget = wibox.container.margin,
},
id = 'background_role',
forced_width = 24,
forced_height = 24,
shape = gears.shape.rounded_rect,
widget = wibox.container.background,
},
},
margins = 4,
widget = wibox.container.margin,
},
preferred_anchors = "middle",
border_color = beautiful.border_color,
border_width = beautiful.border_width,
shape = gears.shape.infobubble,
placement = function(d) return awful.placement.top(d, { --DOC_HIDE
honor_workarea = true, --DOC_HIDE
}) end, --DOC_HIDE
}
p:bind_to_widget(lb)
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,20 @@
local awful = { --DOC_HIDE --DOC_GEN_IMAGE --DOC_NO_USAGE
popup = require("awful.popup"), --DOC_HIDE
placement = require("awful.placement"), --DOC_HIDE
widget = {layoutlist = require("awful.widget.layoutlist")}, --DOC_HIDE
layout = require("awful.layout") --DOC_HIDE
} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
awful.popup {
widget = awful.widget.layoutlist {
source = awful.widget.layoutlist.source.default_layouts, --DOC_HIDE
screen = 1,
base_layout = wibox.layout.flex.vertical
},
maximum_height = #awful.layout.layouts * 24,
minimum_height = #awful.layout.layouts * 24,
placement = awful.placement.centered,
}
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,74 @@
local awful = { --DOC_HIDE --DOC_GEN_IMAGE --DOC_NO_USAGE
popup = require("awful.popup"), --DOC_HIDE
keygrabber = require("awful.keygrabber"), --DOC_HIDE
placement = require("awful.placement"), --DOC_HIDE
widget = {layoutlist = require("awful.widget.layoutlist")} --DOC_HIDE
} --DOC_HIDE
local gears = { shape = require("gears.shape") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
local modkey = "mod4" --DOC_HIDE
local ll = awful.widget.layoutlist {
source = awful.widget.layoutlist.source.default_layouts, --DOC_HIDE
base_layout = wibox.widget {
spacing = 5,
forced_num_cols = 5,
layout = wibox.layout.grid.vertical,
},
widget_template = {
{
{
id = 'icon_role',
forced_height = 22,
forced_width = 22,
widget = wibox.widget.imagebox,
},
margins = 4,
widget = wibox.container.margin,
},
id = 'background_role',
forced_width = 24,
forced_height = 24,
shape = gears.shape.rounded_rect,
widget = wibox.container.background,
},
}
--DOC_NEWLINE
local layout_popup = awful.popup {
widget = wibox.widget {
ll,
margins = 4,
widget = wibox.container.margin,
},
border_color = beautiful.border_color,
border_width = beautiful.border_width,
placement = awful.placement.centered,
ontop = true,
visible = false,
shape = gears.shape.rounded_rect
}
--DOC_NEWLINE
-- Make sure you remove the default `Mod4+Space` and `Mod4+Shift+Space`
-- keybindings before adding this.
awful.keygrabber {
start_callback = function() layout_popup.visible = true end,
stop_callback = function() layout_popup.visible = false end,
export_keybindings = true,
release_event = "release",
stop_key = {"Escape", "Super_L", "Super_R"},
keybindings = {
{{ modkey } , " " , function()
awful.layout.set(gears.table.iterate_value(ll.layouts, ll.current_layout, 1))
end},
{{ modkey, "Shift" } , " " , function()
awful.layout.set(gears.table.iterate_value(ll.layouts, ll.current_layout, -1), nil)
end},
}
}
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,48 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = require("awful") --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
screen[1]._resize {width = 480, height = 100} --DOC_HIDE
local wb = awful.wibar { position = "top", } --DOC_HIDE
--DOC_HIDE Create the same number of tags as the default config
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.layouts[1]) --DOC_HIDE
--DOC_HIDE Only bother with widgets that are visible by default
local mykeyboardlayout = awful.widget.keyboardlayout() --DOC_HIDE
local mytextclock = wibox.widget.textclock() --DOC_HIDE
local mylayoutbox = awful.widget.layoutbox(screen[1]) --DOC_HIDE
local mytaglist = awful.widget.taglist(screen[1], awful.widget.taglist.filter.all, {}) --DOC_HIDE
local mytasklist = awful.widget.tasklist(screen[1], awful.widget.tasklist.filter.currenttags, {}) --DOC_HIDE
wb:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
mytaglist,
awful.widget.layoutlist {
screen = 1,
style = {
disable_name = true,
spacing = 3,
},
source = function() return {
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
} end
},
layout = wibox.layout.fixed.horizontal,
},
mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
mykeyboardlayout,
mytextclock,
mylayoutbox,
},
}
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80