aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-06 18:57:34 +1000
committerDavid Walter Seikel2014-05-06 18:57:34 +1000
commit531eb79446860230aec4cdbcad550c14a38ea4df (patch)
tree97182c8c1418b6290422551dcf05f4e4a3a938d0 /src
parentNow that everything is a winFang, GuiLua doesn't have to track it's own child... (diff)
downloadSledjHamr-531eb79446860230aec4cdbcad550c14a38ea4df.zip
SledjHamr-531eb79446860230aec4cdbcad550c14a38ea4df.tar.gz
SledjHamr-531eb79446860230aec4cdbcad550c14a38ea4df.tar.bz2
SledjHamr-531eb79446860230aec4cdbcad550c14a38ea4df.tar.xz
GuiLua's self delete when their first window gets deleted.
Diffstat (limited to 'src')
-rw-r--r--src/GuiLua/GuiLua.c41
-rw-r--r--src/GuiLua/GuiLua.h3
-rw-r--r--src/extantz/extantz.c2
3 files changed, 41 insertions, 5 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c
index 5c76e15..643a9d5 100644
--- a/src/GuiLua/GuiLua.c
+++ b/src/GuiLua/GuiLua.c
@@ -229,6 +229,15 @@ static int colour(lua_State *L)
229 Light user data an actual pointer. 229 Light user data an actual pointer.
230*/ 230*/
231 231
232static void _on_us_del(void *data, Evas_Object *obj, void *event_info)
233{
234 winFang *win = data;
235 GuiLua *gl = win->data;
236
237 gl->inDel = 1;
238 GuiLuaDel(gl);
239}
240
232static int window(lua_State *L) 241static int window(lua_State *L)
233{ 242{
234 winFang *win = NULL; 243 winFang *win = NULL;
@@ -247,8 +256,21 @@ static int window(lua_State *L)
247 256
248 win = winFangAdd(parent, 25, 25, w, h, title, name); 257 win = winFangAdd(parent, 25, 25, w, h, title, name);
249 // If there's no parent, we become the parent. 258 // If there's no parent, we become the parent.
250 if (gl && !parent) 259 if (gl)
251 gl->parent = win; 260 {
261 // If there's no parent, we become the parent.
262 if (!parent)
263 gl->parent = win;
264 // If there's no us, we must be the first, so we are us.
265 if (!gl->us)
266 {
267 gl->us = win;
268 // TODO - If this invocation of GuiLuaDo never opens a window, then this GuiLua will never get deleted.
269 // Also, who ever opened this window might have other plans for on_del or data.
270 win->data = gl;
271 win->on_del = _on_us_del;
272 }
273 }
252 lua_pushlightuserdata(L, win); 274 lua_pushlightuserdata(L, win);
253 275
254 return 1; 276 return 1;
@@ -399,8 +421,8 @@ GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent)
399 // This does nothing if no module opened a window. 421 // This does nothing if no module opened a window.
400 if (0 != luaL_dostring(L, "skang.loopWindow()")) 422 if (0 != luaL_dostring(L, "skang.loopWindow()"))
401 PE("Error running - skang.loopWindow()"); 423 PE("Error running - skang.loopWindow()");
402 lua_pop(L, closeWindow(L)); 424 GuiLuaDel(result);
403 lua_close(L); 425 result = NULL;
404 if (logDom >= 0) 426 if (logDom >= 0)
405 { 427 {
406 eina_log_domain_unregister(logDom); 428 eina_log_domain_unregister(logDom);
@@ -416,3 +438,14 @@ GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent)
416 438
417 return result; 439 return result;
418} 440}
441
442void GuiLuaDel(GuiLua *gl)
443{
444 if (gl)
445 {
446 gl->us->on_del = NULL;
447 if (!gl->inDel) winFangDel(gl->us);
448 if (gl->L) lua_close(gl->L);
449 free(gl);
450 }
451}
diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h
index 4fd1617..2a4a3f0 100644
--- a/src/GuiLua/GuiLua.h
+++ b/src/GuiLua/GuiLua.h
@@ -18,7 +18,9 @@
18typedef struct _GuiLua 18typedef struct _GuiLua
19{ 19{
20 lua_State *L; 20 lua_State *L;
21 winFang *us; // Our window, if it exists.
21 winFang *parent; // Our parent window, if it exists. 22 winFang *parent; // Our parent window, if it exists.
23 int inDel;
22 24
23 Eina_Clist node; 25 Eina_Clist node;
24 void *data; 26 void *data;
@@ -26,5 +28,6 @@ typedef struct _GuiLua
26} GuiLua; 28} GuiLua;
27 29
28GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent); 30GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent);
31void GuiLuaDel(GuiLua *gl);
29 32
30#endif 33#endif
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index aceebe7..9f8eaef 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -474,7 +474,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
474 chat_add(&ourGlobals); 474 chat_add(&ourGlobals);
475 ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); 475 ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE);
476 char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL}; 476 char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL};
477 GuiLua *test = GuiLuaDo(5, args, ourGlobals.mainWindow); 477 GuiLuaDo(5, args, ourGlobals.mainWindow);
478 478
479 // Gotta do this after adding the windows, otherwise the menu renders under the window. 479 // Gotta do this after adding the windows, otherwise the menu renders under the window.
480 // This sucks, gotta redefine this menu each time we create a new window? 480 // This sucks, gotta redefine this menu each time we create a new window?