1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
-- Authors: Etan Reisner <deryni@gmail.com>
-- License: MIT, see http://opensource.org/licenses/mit-license.php
-- Last Changed: 2007-01-29
--
--[[
Author: Etan Reisner
Email: deryni@gmail.com
Summary: Adds a submenu to the frame context menu which contains the cwins in that frame.
Version: 0.1
Last Updated: 2007-01-29
Copyright (c) Etan Reisner 2007
This software is released under the terms of the MIT license. For more
information, see http://opensource.org/licenses/mit-license.php .
--]]
-- Usage:
-- This will show the frame context query menu with the added submenu.
-- kpress(META.."M", "clientlist_menu(_, _sub)")
-- This will show the frame context popup menu with the added submenu.
-- kpress(META.."M", "clientlist_menu(_, _sub, true)")
--
-- Use frame_client_menu_set({start_on_current=true/false}) to control whether
-- the popup submenu will start on the current frame or index 1.
local settings = {start_on_current = false}
function frame_client_menu_set(tab)
settings.start_on_current = tab.start_on_current
end
function frame_client_menu_get()
return table.copy(settings)
end
function clientlist_menu(frame, sub, popup)
local start_on_current = false
if mod_menu then
local framemenu = ioncore.getmenu("ctxmenu")(frame, sub)
local myframemenu = {}
local initial = 1
frame:mx_i(function(reg)
if reg == sub then
initial = #myframemenu + 1
end
myframemenu[#myframemenu + 1] = ioncore.menuentry(reg:current():name(), function() reg:goto_focus() end)
return true
end)
if not settings.start_on_current then
initial = 1
end
framemenu[#framemenu + 1] = ioncore.submenu("Client windows", myframemenu, {initial=initial})
if popup then
mod_menu.menu(frame, sub, framemenu)
else
mod_query.query_menu(frame, framemenu, "Context menu:")
end
end
end
-- vim: set expandtab sw=4:
|