2 -- ion/share/ioncore_misc.lua
4 -- Copyright (c) Tuomo Valkonen 2004-2007.
6 -- Ion is free software; you can redistribute it and/or modify it under
7 -- the terms of the GNU Lesser General Public License as published by
8 -- the Free Software Foundation; either version 2.1 of the License, or
9 -- (at your option) any later version.
12 local group_tmpl = { type="WGroupWS" }
14 local default_tmpl = { switchto=true }
16 local empty = { type="WGroupWS", managed={} }
24 -- Define a new workspace layout with name \var{name}, and
25 -- attach/creation parameters given in \var{tab}. The layout
26 -- "empty" may not be defined.
27 function ioncore.deflayout(name, tab)
28 assert(layout ~= "empty")
30 if name=="default" and not tab then
33 layouts[name] = table.join(tab, group_tmpl)
38 -- Get named layout (or all of the latter parameter is set,
39 -- but this is for internal use only).
40 function ioncore.getlayout(name, all)
48 ioncore.set{_get_layout=ioncore.getlayout}
51 -- Create new workspace on screen \var{scr}. The table \var{tmpl}
52 -- may be used to override parts of the layout named with \code{layout}.
53 -- If no \var{layout} is given, "default" is used.
54 function ioncore.create_ws(scr, tmpl, layout)
55 local lo=ioncore.getlayout(layout or "default")
57 assert(lo, TR("Unknown layout"))
59 return scr:attach_new(table.join(tmpl or default_tmpl, lo))
64 -- Find an object with type name \var{t} managing \var{obj} or one of
66 function ioncore.find_manager(obj, t)
68 if obj_is(obj, t) then
77 -- gettext+string.format
78 function ioncore.TR(s, ...)
79 return string.format(ioncore.gettext(s), unpack(arg))
84 -- Attach tagged regions to \var{reg}. The method of attach
85 -- depends on the types of attached regions and whether \var{reg}
86 -- implements \code{attach_framed} and \code{attach}. If \var{param}
87 -- is not set, the default of \verb!{switchto=true}! is used.
88 function ioncore.tagged_attach(reg, param)
92 local tagged=function() return ioncore.tagged_first(true) end
94 local fn=((not obj_is(r, "WWindow") and reg.attach_framed)
97 if not (fn and fn(reg, r, param)) then