-rw-r--r-- | window-refs.c | 19 |
diff --git a/window-refs.c b/window-refs.c index 4cbfa1d3..0d1c40cb 100644 --- a/window-refs.c +++ b/window-refs.c @@ -3,6 +3,7 @@ #include <lauxlib.h> #include "window-refs.h" +#include "canvas-window.h" static char const * const window_ref_table_name = "GSL.windows"; @@ -30,10 +31,26 @@ window_ref_add(lua_State *L, int index) } void -window_ref_remove(lua_State *L, int id) +window_ref_remove (lua_State *L, int id) { lua_getfield (L, LUA_REGISTRYINDEX, window_ref_table_name); lua_pushnil (L); lua_rawseti (L, -2, id); lua_pop (L, 1); } + +void +window_ref_close_all (lua_State *L) +{ + lua_getfield (L, LUA_REGISTRYINDEX, window_ref_table_name); + + lua_pushnil (L); /* first key */ + while (lua_next(L, -2) != 0) + { + lua_pushcfunction (L, canvas_window_close); + lua_insert (L, -2); + lua_call (L, 1, 0); + } + + lua_pop (L, 1); +} |