1 -- Authors: Tuomo Valkonen
7 -- By Tuomo Valkonen, 2007.
9 -- This script introduces a tabmenu function that can be used to
10 -- display a grabmenu corresponding to the tabs of a frame. It can
11 -- be useful if you choose to disable the tab-bars of frames, to
12 -- replace the META+K N/P bindings with the following:
14 -- ioncore.defbindings("WFrame.toplevel", {
15 -- submap(META.."K", {
16 -- kpress("N", "tabmenu.tabmenu(_, _sub, 'next')"),
17 -- kpress("P", "tabmenu.tabmenu(_, _sub, 'prev')"),
25 -- WRegion.displayname isn't exported ATM, so here's a hacky
27 function tabmenu
.hack_displayname(reg
)
29 if obj_is(reg
, "WGroupCW") then
39 function tabmenu
.tabmenu(_
, _sub
, index
)
43 local e
=menuentry(tabmenu
.hack_displayname(r
),
44 function() r
:goto() end)
53 table.insert(m
, menuentry("<empty frame>", function() end))
55 elseif index
=='next' then
56 i
=((i
==#m
and 1) or i
+1)
57 elseif index
=='prev' then
58 i
=((i
==1 and #m
) or i
-1)
59 elseif index
=='first' then
61 elseif index
=='last' then
65 mod_menu
.grabmenu(_
, nil, m
, {initial
=i
})