From a800696a651e0e4bb545bf3196febefd72a2cce4 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 21 Aug 2009 15:50:01 +0200 Subject: [PATCH] awful.tag: add a new() helper function Signed-off-by: Julien Danjou --- lib/awful/tag.lua.in | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index 30c9ceaf..b216283c 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -12,6 +12,7 @@ local table = table local setmetatable = setmetatable local capi = { + tag = tag, screen = screen, mouse = mouse, client = client @@ -55,6 +56,26 @@ local function compare_select(a, b) return true 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. -- @param screen The screen number. function history.update(screen) @@ -312,4 +333,6 @@ end -- Register standards signals 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