]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/ioncore_misc.lua
[svn-upgrade] Integrating new upstream version, ion3 (20070203)
[ion3.git] / ioncore / ioncore_misc.lua
index fd72b4d96b0af1ee620d4637f2bbbbae5c3b71df..3b24b668e5ac2507f120e79199ae650a925aef2c 100644 (file)
@@ -1,7 +1,7 @@
 --
 -- ion/share/ioncore_misc.lua
 -- 
--- 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
@@ -9,18 +9,54 @@
 -- (at your option) any later version.
 --
 
+local group_tmpl = { type="WGroupWS" }
 
-local group_tmpl={type="WGroupWS", switchto=true}
+local default_tmpl = { switchto=true }
+
+local empty = { type="WGroupWS", managed={} }
+
+local layouts={
+    empty = empty,
+    default = empty,
+}
+
+--DOC 
+-- Define a new workspace layout with name \var{name}, and
+-- attach/creation parameters given in \var{tab}. The layout
+-- "empty" may not be defined.
+function ioncore.deflayout(name, tab)
+    assert(layout ~= "empty")
+    
+    if name=="default" and not tab then
+        layouts[name] = empty
+    else
+        layouts[name] = table.join(tab, group_tmpl)
+    end
+end
+
+--DOC
+-- Get named layout (or all of the latter parameter is set,
+-- but this is for internal use only).
+function ioncore.getlayout(name, all)
+    if all then
+        return layouts
+    else
+        return layouts[name]
+    end
+end
+
+ioncore.set{_get_layout=ioncore.getlayout}
 
 --DOC
 -- Create new workspace on screen \var{scr}. The table \var{tmpl}
--- may be used to override parts of \code{default_ws_params},
--- and \var{no_default} may be set to \code{true} to complete ignore it.
-function ioncore.create_ws(scr, tmpl, no_default)
-    local dflt=(not no_default and ioncore.get().default_ws_params) or {}
-    local t=table.join(table.join(tmpl or {}, dflt), group_tmpl)
+-- may be used to override parts of the layout named with \code{layout}.
+-- If no \var{layout} is given, "default" is used.
+function ioncore.create_ws(scr, tmpl, layout)
+    local lo=ioncore.getlayout(layout or "default")
+    
+    assert(lo, TR("Unknown layout"))
     
-    return scr:attach_new(t)
+    return scr:attach_new(table.join(tmpl or default_tmpl, lo))
 end