From 5b86896c906815524fc87baf53b867b3d294f857 Mon Sep 17 00:00:00 2001 From: Perry Hargrave Date: Fri, 28 May 2010 00:29:23 -0700 Subject: [PATCH] tag.lua: add() create tags with full table of properties tag.add(name, props): make tags and pass a table of properties to apply to it tag.new: modified to use add() instead of calling capi.tag Signed-off-by: Perry Hargrave Signed-off-by: Julien Danjou --- lib/awful/tag.lua.in | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index e28b94ef1..de624df87 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -52,6 +52,22 @@ function move(new_index, target_tag) capi.screen[scr]:tags(tmp_tags) end +--- Add a tag. +-- @param name The tag name, a string +-- @param props The tags properties, a table +-- @return The created tag +function add(name, props) + local properties = props or {} + local newtag = capi.tag{name = name} + newtag.screen = properties.screen or capi.mouse.screen + + for k, v in pairs(properties) do + setproperty(newtag, k, v) + end + + return newtag +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. @@ -61,14 +77,15 @@ 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 + table.insert(tags, id, add(name, {screen = screen, + layout = (layout and layout[id]) or + layout})) -- Select the first tag. if id == 1 then - tags[#tags].selected = true + tags[id].selected = true end - setproperty(tags[#tags], "layout", layout and (layout[#tags] or layout[1]) or layout) end + return tags end