]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/ioncore_menudb.lua
Imported Upstream version 20090110
[ion3.git] / ioncore / ioncore_menudb.lua
index 42860548298e9712d6f302b8560e3d6bab1c7052..1d8100b7c3b9635f92fc522295f75eb2e752f15a 100644 (file)
@@ -1,12 +1,9 @@
 --
 -- ion/ioncore/ioncore_menudb.lua -- Routines for defining menus.
 -- 
--- Copyright (c) Tuomo Valkonen 2004-2007.
+-- Copyright (c) Tuomo Valkonen 2004-2009.
 --
--- Ion is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License as published by
--- the Free Software Foundation; either version 2.1 of the License, or
--- (at your option) any later version.
+-- See the included file LICENSE for details.
 --
 
 local ioncore=_G.ioncore
@@ -48,11 +45,12 @@ end
 -- of menu entries.
 function ioncore.defctxmenu(ctx, ...)
     local tab, add
-    if #arg>1 and type(arg[1])=="string" then
-        tab=arg[2]
-        tab.label=ioncore.gettext(arg[1])
+    local a1, a2 = ...
+    if a2 and type(a1)=="string" then
+        tab=a2
+        tab.label=ioncore.gettext(a1)
     else
-        tab=arg[1]
+        tab=a1
     end
     ioncore.defmenu("ctxmenu-"..ctx, tab)
 end
@@ -263,7 +261,7 @@ local function receive_styles(str)
     local styles={}
     local stylemenu={}
     
-    for look in string.gfind(data, "(look[-_][^\n]*)%.lua\n") do
+    for look in string.gmatch(data, "(look[-_][^\n]*)%.lua\n") do
         if not found[look] then
             found[look]=true
             table.insert(styles, look)
@@ -405,12 +403,16 @@ local function sortmenu(m)
 end
 
 
-function menus.ctxmenu(reg, sub_or_chld)
+function menus.ctxmenu(reg, sub)
     local m, r, s
     
+    if obj_is(sub, "WGroup") then
+        sub=(sub:bottom() or sub)
+    end
+    
     -- First, stuff between reg (inclusive) and sub_or_chld (inclusive)
     -- at the top level in the menu.
-    r=(sub_or_chld or reg)
+    r=(sub or reg)
     while r and s~=reg do
         local mm=get_ctxmenu(r, s)
         m=((m and table.icat(mm, m)) or mm)