2 -- ion/share/ioncore_misc.lua
4 -- Copyright (c) Tuomo Valkonen 2004-2007.
6 -- See the included file LICENSE for details.
9 local group_tmpl = { type="WGroupWS" }
11 local default_tmpl = { switchto=true }
13 local empty = { type="WGroupWS", managed={} }
21 -- Define a new workspace layout with name \var{name}, and
22 -- attach/creation parameters given in \var{tab}. The layout
23 -- "empty" may not be defined.
24 function ioncore.deflayout(name, tab)
25 assert(layout ~= "empty")
27 if name=="default" and not tab then
30 layouts[name] = table.join(tab, group_tmpl)
35 -- Get named layout (or all of the latter parameter is set,
36 -- but this is for internal use only).
37 function ioncore.getlayout(name, all)
45 ioncore.set{_get_layout=ioncore.getlayout}
48 -- Create new workspace on screen \var{scr}. The table \var{tmpl}
49 -- may be used to override parts of the layout named with \code{layout}.
50 -- If no \var{layout} is given, "default" is used.
51 function ioncore.create_ws(scr, tmpl, layout)
52 local lo=ioncore.getlayout(layout or "default")
54 assert(lo, TR("Unknown layout"))
56 return scr:attach_new(table.join(tmpl or default_tmpl, lo))
61 -- Find an object with type name \var{t} managing \var{obj} or one of
63 function ioncore.find_manager(obj, t)
65 if obj_is(obj, t) then
74 -- gettext+string.format
75 function ioncore.TR(s, ...)
76 return string.format(ioncore.gettext(s), unpack(arg))
81 -- Attach tagged regions to \var{reg}. The method of attach
82 -- depends on the types of attached regions and whether \var{reg}
83 -- implements \code{attach_framed} and \code{attach}. If \var{param}
84 -- is not set, the default of \verb!{switchto=true}! is used.
85 -- The function returns \code{true} if all tagged regions were
86 -- succesfully attached, and \code{false} otherwisse.
87 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