]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/ioncore_misc.lua
Imported Upstream version 20090110
[ion3.git] / ioncore / ioncore_misc.lua
index 3b24b668e5ac2507f120e79199ae650a925aef2c..7dc63535b1c00cd31a43dd000cff177d3ba5f9b3 100644 (file)
@@ -1,12 +1,9 @@
 --
 -- ion/share/ioncore_misc.lua
 -- 
--- 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 group_tmpl = { type="WGroupWS" }
@@ -25,7 +22,7 @@ local layouts={
 -- attach/creation parameters given in \var{tab}. The layout
 -- "empty" may not be defined.
 function ioncore.deflayout(name, tab)
-    assert(layout ~= "empty")
+    assert(name ~= "empty")
     
     if name=="default" and not tab then
         layouts[name] = empty
@@ -76,14 +73,31 @@ end
 --DOC
 -- gettext+string.format
 function ioncore.TR(s, ...)
-    return string.format(ioncore.gettext(s), unpack(arg))
+    return string.format(ioncore.gettext(s), ...)
 end
 
 
---[[DOC
--- Run \var{cmd} with the environment variable DISPLAY set to point to the
--- root window of the X screen \var{reg} is on.
-function ioncore.exec_on(reg, cmd)
-    return ioncore.do_exec_rw(reg:rootwin_of(), cmd)
+--DOC
+-- Attach tagged regions to \var{reg}. The method of attach
+-- depends on the types of attached regions and whether \var{reg} 
+-- implements \code{attach_framed} and \code{attach}. If \var{param}
+-- is not set, the default of \verb!{switchto=true}! is used.
+-- The function returns \code{true} if all tagged regions were
+-- succesfully attached, and \code{false} otherwisse.
+function ioncore.tagged_attach(reg, param)
+    local errors=false
+    if not param then
+        param={switchto=true}
+    end
+    local tagged=function() return ioncore.tagged_first(true) end
+    for r in tagged do
+        local fn=((not obj_is(r, "WWindow") and reg.attach_framed) 
+                  or reg.attach)
+        
+        if not (fn and fn(reg, r, param)) then
+            errors=true
+        end
+    end
+    return not errors
 end
---]]
+