File: collapse.lua

package info (click to toggle)
ion2 20040729-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,828 kB
  • ctags: 3,466
  • sloc: ansic: 28,432; makefile: 473; sh: 230; perl: 16
file content (43 lines) | stat: -rw-r--r-- 972 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-- Move all windows on a WIonWS to a single frame and destroy the rest.

collapse={}

function collapse.move_managed(tgt, src)
    local l=src:managed_list()
    for _, m in l do
        tgt:attach(m)
    end
end

function collapse.collapse(ws)
    local l=ws:managed_list()
    -- Move everything to current frame if set,
    -- otherwise the first one found.
    local tgt=ws:current()
    for _, f in l do
        if obj_is(f, "WIonFrame") then
            if not tgt then
                tgt=f
            else
                collapse.move_managed(tgt, f)
                f:close()
            end
        end
    end
end

-- Simpler, but moves the windows around 
-- more, which doesn't look good.
function collapse.collapse2(ws)
    local l=ws:managed_list()
    local prevf
    for _, f in l do
        if obj_is(f, "WIonFrame") then
            if prevf then
                prevf:relocate_and_close()
            end
            prevf=f
        end
    end
end