Add a basic tag switching menu
This commit is contained in:
parent
31e5c3dd5c
commit
79dcd66b7b
|
@ -0,0 +1,53 @@
|
|||
local radical = require( "radical" )
|
||||
local com_tag = require( "radical.impl.common.tag" )
|
||||
local beautiful = require( "beautiful" )
|
||||
local tag = require( "awful.tag" )
|
||||
local capi = { client = client, mouse = mouse, screen = screen}
|
||||
|
||||
local module = {}
|
||||
|
||||
local function is_checked(m,i)
|
||||
local t = i._tag
|
||||
return true
|
||||
end
|
||||
|
||||
local function select_tag(i,m)
|
||||
local t = i._tag
|
||||
tag.viewonly(t)
|
||||
end
|
||||
|
||||
local function toggle_tag(i,m)
|
||||
local t = i._tag
|
||||
t.selected = not t.selected
|
||||
i.checked = t.selected
|
||||
end
|
||||
|
||||
local function new(args)
|
||||
local args = args or {}
|
||||
|
||||
local t,auto_release = tag.selected(capi.client.focus and capi.client.focus.screen or capi.mouse.screen),args.auto_release
|
||||
local currentMenu = radical.box({filter = true, show_filter=not auto_release, autodiscard = true,
|
||||
disable_markup=true,fkeys_prefix=not auto_release,width=(((capi.screen[capi.client.focus and capi.client.focus.screen or capi.mouse.screen]).geometry.width)/2),
|
||||
icon_transformation = beautiful.alttab_icon_transformation,filter_underlay="Use [Shift] and [Control] to toggle clients",filter_underlay_color=beautiful.menu_bg_normal,
|
||||
filter_placeholder="<span fgcolor='".. (beautiful.menu_fg_disabled or beautiful.fg_disabled or "#777777") .."'>Type to filter</span>"})
|
||||
|
||||
com_tag.listTags({menu=currentMenu,checkable=true,checked=is_checked,button1=select_tag})
|
||||
|
||||
currentMenu:add_key_hook({}, "Shift_L", "press", function()
|
||||
local item = currentMenu._current_item
|
||||
toggle_tag(item,currentMenu)
|
||||
return true
|
||||
end)
|
||||
|
||||
currentMenu:add_key_hook({}, "Control_L", "press", function()
|
||||
local item = currentMenu._current_item
|
||||
item.checked = not item.checked
|
||||
return true
|
||||
end)
|
||||
|
||||
currentMenu.visible = true
|
||||
return currentMenu
|
||||
end
|
||||
|
||||
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
|
@ -26,7 +26,7 @@ local function createTagList(aScreen,args)
|
|||
if not tag_list then
|
||||
tag_list = require("radical.impl.taglist")
|
||||
end
|
||||
local tagList = radical.context {}
|
||||
local tagList = args.menu or radical.context {}
|
||||
local ret = {}
|
||||
for _, v in ipairs(awful.tag.gettags(aScreen)) do
|
||||
args.text,args.icon = v.name,awful.tag.geticon(v)
|
||||
|
@ -45,9 +45,10 @@ local function createTagList(aScreen,args)
|
|||
return tagList,ret
|
||||
end
|
||||
|
||||
function module.listTags(args)
|
||||
if capi.screen.count() == 1 then
|
||||
return createTagList(1,args or {})
|
||||
function module.listTags(args, menu)
|
||||
local args = args or {}
|
||||
if capi.screen.count() == 1 or args.screen then
|
||||
return createTagList(args.screen or 1,args or {})
|
||||
else
|
||||
local screenSelect = radical.context {}
|
||||
for i=1, capi.screen.count() do
|
||||
|
|
Loading…
Reference in New Issue