awful.tag: add a new() helper function
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
5ad21d2931
commit
a800696a65
|
@ -12,6 +12,7 @@ local table = table
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local capi =
|
local capi =
|
||||||
{
|
{
|
||||||
|
tag = tag,
|
||||||
screen = screen,
|
screen = screen,
|
||||||
mouse = mouse,
|
mouse = mouse,
|
||||||
client = client
|
client = client
|
||||||
|
@ -55,6 +56,26 @@ local function compare_select(a, b)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Create a set of tags and attach it to a screen.
|
||||||
|
-- @param names The tag name, in a table
|
||||||
|
-- @param screen The tag screen, or 1 if not set.
|
||||||
|
-- @param layout The layout to set for this tags by default.
|
||||||
|
-- @return A table with all created tags.
|
||||||
|
function new(names, screen, layout)
|
||||||
|
local screen = screen or 1
|
||||||
|
local tags = {}
|
||||||
|
for id, name in ipairs(names) do
|
||||||
|
tags[#tags + 1] = capi.tag { name = name }
|
||||||
|
tags[#tags].screen = screen
|
||||||
|
-- Select the first tag.
|
||||||
|
if id == 1 then
|
||||||
|
tags[#tags].selected = true
|
||||||
|
end
|
||||||
|
setproperty(tags[#tags], "layout", layout)
|
||||||
|
end
|
||||||
|
return tags
|
||||||
|
end
|
||||||
|
|
||||||
--- Update the tag history.
|
--- Update the tag history.
|
||||||
-- @param screen The screen number.
|
-- @param screen The screen number.
|
||||||
function history.update(screen)
|
function history.update(screen)
|
||||||
|
@ -312,4 +333,6 @@ end
|
||||||
-- Register standards signals
|
-- Register standards signals
|
||||||
capi.client.add_signal("manage", withcurrent)
|
capi.client.add_signal("manage", withcurrent)
|
||||||
|
|
||||||
|
setmetatable(_M, { __call = function (_, ...) return new(...) end })
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue