]> git.decadent.org.uk Git - ion3.git/blobdiff - mod_menu/mod_menu.lua
[svn-upgrade] Integrating new upstream version, ion3 (20070506)
[ion3.git] / mod_menu / mod_menu.lua
index 6375e9f76423ada9fe59e9c9f70053810b516d8f..368115bcfd16f9f13c2d910470230abe9e4ae356 100644 (file)
@@ -1,12 +1,9 @@
 --
 -- ion/mod_menu/mod_menu.lua -- Menu opening helper routines.
 -- 
--- Copyright (c) Tuomo Valkonen 2004-2006.
+-- Copyright (c) Tuomo Valkonen 2004-2007.
 --
--- 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.
 --
 
 -- This is a slight abuse of the package.loaded variable perhaps, but
@@ -29,15 +26,15 @@ assert(mod_menu and menudb)
 local function menu_(reg, sub, menu_or_name, fn, check)
     if check then
         -- Check that no other menus are open in reg.
-        local l=reg:managed_list()
-        for i, r in pairs(l) do
-            if obj_is(r, "WMenu") then
-                return
-            end
+        local ok=reg:managed_i(function(r) 
+                                   return not obj_is(r, "WMenu") 
+                               end)
+        if not ok then
+            return
         end
     end
 
-    menu=menudb.evalmenu(menu_or_name, {reg, sub})
+    menu=menudb.evalmenu(menu_or_name, reg, sub)
     
     return fn(reg, function(e) e.func(reg, sub) end, menu)
 end
@@ -57,17 +54,15 @@ end
 -- to use a bigger style by setting the field \var{big} to \code{true}.
 function mod_menu.menu(mplex, sub, menu_or_name, param) 
    local function menu_stdmenu(m, s, menu)
-      return mod_menu.do_menu(m, s, menu, param)
+        return ioncore.unsqueeze(mod_menu.do_menu(m, s, menu, param))
    end
    return menu_(mplex, sub, menu_or_name, menu_stdmenu, true)
 end
 
 -- Compatibility
 function mod_menu.bigmenu(mplex, sub, menu_or_name, initial) 
-    local function menu_bigmenu(m, s, menu)
-      return mod_menu.do_menu(m, s, menu, {big=true, initial=initial})
-    end
-    return menu_(mplex, sub, menu_or_name, menu_bigmenu, true)
+    local param={big=true, initial=initial}
+    return mod_menu.menu(mplex, sub, menu_or_name, param)
 end
 
 --DOC