Move the tag menu to a new file (issue #21)

This commit is contained in:
Emmanuel Lepage Vallee 2014-03-23 23:34:44 -04:00
parent f746a8b347
commit 801d2ca2b4
2 changed files with 28 additions and 19 deletions

27
impl/common/tag.lua Normal file
View File

@ -0,0 +1,27 @@
local radical = require("radical")
local capi = { screen = screen, }
local awful = require( "awful" )
local module = {}
local function createTagList(aScreen)
local tagList = radical.context({autodiscard = true})
for _, v in ipairs(awful.tag.gettags(aScreen)) do
tagList:add_item({text = v.name,icon=awful.tag.geticon(v)})
end
return tagList
end
function module.listTags()
if capi.screen.count() == 1 then
return createTagList(1)
else
local screenSelect = radical.context(({autodiscard = true}))
for i=1, capi.screen.count() do
screenSelect:add_item({text="Screen "..i , sub_menu = createTagList(i)})
end
return screenSelect
end
end
return setmetatable(module, { __call = function(_, ...) return module.listTags(...) end })
-- kate: space-indent on; indent-width 2; replace-tabs on;

View File

@ -7,28 +7,10 @@ local beautiful = require( "beautiful" )
local awful = require( "awful" ) local awful = require( "awful" )
local util = require( "awful.util" ) local util = require( "awful.util" )
local wibox = require( "wibox" ) local wibox = require( "wibox" )
local listTags = require( "radical.impl.common.tag" ).listTags
local module,mainMenu = {},nil local module,mainMenu = {},nil
local function listTags()
function createTagList(aScreen)
local tagList = radical.context({autodiscard = true})
for _, v in ipairs(awful.tag.gettags(aScreen)) do
tagList:add_item({text = v.name,icon=awful.tag.geticon(v)})
end
return tagList
end
if capi.screen.count() == 1 then
return createTagList(1)
else
local screenSelect = radical.context(({autodiscard = true}))
for i=1, capi.screen.count() do
screenSelect:add_item({text="Screen "..i , sub_menu = createTagList(i)})
end
return screenSelect
end
end
local function createNewTag() local function createNewTag()
return awful.tag.add(module.client.class,{}) return awful.tag.add(module.client.class,{})
end end