add usage example for awful.menu

Added a very simple example to show the usage, and applicability of
awful.menu by dynamically constructing a menu of clients that match a
particular rule.

Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Anurag Priyam 2011-01-27 02:12:58 +05:30 committed by Uli Schlachter
parent 2a4503ef04
commit 514fd796f3
1 changed files with 26 additions and 0 deletions

View File

@ -398,6 +398,32 @@ end
-- </ul> -- </ul>
-- @param parent Specify the parent menu if we want to open a submenu, this value should never be set by the user. -- @param parent Specify the parent menu if we want to open a submenu, this value should never be set by the user.
-- @param num Specify the parent's clicked item number if we want to open a submenu, this value should never be set by the user. -- @param num Specify the parent's clicked item number if we want to open a submenu, this value should never be set by the user.
-- @usage The following function builds, and shows a menu of clients that match
-- a particular rule. Bound to a key, it can for example be used to select from
-- dozens of terminals open on several tags. With the use of
-- <code>match_any</code> instead of <code>match</code>, menu of clients with
-- different classes can also be build.
--
-- <p><code>
-- function terminal_menu () <br/>
-- &nbsp; terms = {} <br/>
-- &nbsp; for i, c in pairs(client.get()) do <br/>
-- &nbsp;&nbsp; if awful.rules.match(c, {class = "URxvt"}) then <br/>
-- &nbsp;&nbsp;&nbsp; terms[i] = <br/>
-- &nbsp;&nbsp;&nbsp; {c.name, <br/>
-- &nbsp;&nbsp;&nbsp; function() <br/>
-- &nbsp;&nbsp;&nbsp;&nbsp; awful.tag.viewonly(c:tags()[1]) <br/>
-- &nbsp;&nbsp;&nbsp;&nbsp; client.focus = c <br/>
-- &nbsp;&nbsp;&nbsp; end, <br/>
-- &nbsp;&nbsp;&nbsp; c.icon <br/>
-- &nbsp;&nbsp;&nbsp; } <br/>
-- &nbsp;&nbsp; end <br/>
-- &nbsp; end <br/>
-- &nbsp; m = awful.menu({items = terms}) <br/>
-- &nbsp; m:show({keygrabber=true}) <br/>
-- &nbsp; return m <br/>
-- end <br/>
--</code></p>
function new(menu, parent, num) function new(menu, parent, num)
-- Create a table to store our menu informations -- Create a table to store our menu informations
local data = {} local data = {}