2 Author: James Gray, Etan Reisner
3 Email: james at solitaryfield dot org, deryni@unreliablesource.net
5 Summary: Allows locking
7 Last Updated: Fri Jun 22 00:59:06 EDT 2007
11 -- F11 toggles the lock of keyboard close and resize on the currently active
13 -- META-F11 will save the name of the frame and lock it again in subsequent
16 -- You will need to rebind your close and kill bindings to use the
17 -- check_before_close and check_before_kill functions for this script to do
21 -- de.substyle("*-*-*-locked", {
22 -- background_colour = "yellow",
25 -- de.substyle("*-*-*-*-locked_saved", {
26 -- background_colour = "white",
28 -- to your theme's de.defstyle("tab-frame", {...}) style will cause locked and
29 -- locked+saved frames to be highlighted.
31 local locks
= setmetatable({}, {__mode
="k"})
34 function lock_frame(frame
, save
)
35 local name
= frame
:name()
39 frame
:set_grattr("locked", "unset")
41 frame
:set_grattr("locked_saved", "unset")
46 frame
:set_grattr("locked", "set")
48 frame
:set_grattr("locked_saved", "set")
54 function check_before_kill(reg
)
55 if not locks
[reg
] then
60 function check_before_close(reg
, sub
)
61 if (not locks
[reg
]) and (not locks
[sub
]) then
62 WRegion
.rqclose_propagate(reg
, sub
)
66 ioncore
.defbindings("WFrame",{
67 kpress("F11", "lock_frame(_)"),
68 kpress(META
.."F11", "lock_frame(_, true)")
71 function save_locked()
72 ioncore
.write_savefile("saved_lock_frame", saved
)
75 function load_locked()
76 local locked
= ioncore
.read_savefile("saved_lock_frame") or {}
78 for k
,v
in pairs(locked
) do
79 local reg
= ioncore
.lookup_region(k
)
84 local hook
= ioncore
.get_hook("ioncore_deinit_hook")