From 969f1968f2f74f8f09c4788bc7f7b1c9655ad354 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 5 May 2014 20:04:08 +1000 Subject: Call skang modules from extantz. Needs some clean up. --- src/GuiLua/GuiLua.c | 33 ++++++++++++++++++++------------- src/GuiLua/GuiLua.h | 10 ++-------- src/GuiLua/skang.c | 4 ++++ src/GuiLua/test.lua | 5 +++-- src/GuiLua/test.skang | 2 +- src/GuiLua/test_c.c | 4 ++++ 6 files changed, 34 insertions(+), 24 deletions(-) (limited to 'src/GuiLua') diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index 2b09675..4bed9ca 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c @@ -139,8 +139,12 @@ and ordinary elementary widgets. Proper introspection can come later. */ - +#include "SledjHamr.h" +#include "LumbrJack.h" +#include "Runnr.h" +#include "winFang.h" #include "GuiLua.h" +//#include static int logDom; // Our logging domain. @@ -232,17 +236,20 @@ static int colour(lua_State *L) static int window(lua_State *L) { winFang *win = NULL; + Evas_Object *parent = NULL; char *name = "GuiLua"; char *title = "GuiLua test harness"; int w = WIDTH, h = HEIGHT; GuiLua *gl; + pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); + lua_getfield(L, LUA_REGISTRYINDEX, glName); gl = lua_touserdata(L, -1); lua_pop(L, 1); + if (gl && gl->parent) parent = gl->parent; - pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); - win = winFangAdd(NULL, 0, 0, w, h, title, name); + win = winFangAdd(parent, 25, 25, w, h, title, name); eina_clist_add_head(&gl->winFangs, &win->node); lua_pushlightuserdata(L, win); @@ -285,15 +292,6 @@ static int closeWindow(lua_State *L) winFangDel(win); } - if (logDom >= 0) - { - eina_log_domain_unregister(logDom); - logDom = -1; - } - - // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed. - elm_shutdown(); - return 0; } @@ -313,6 +311,7 @@ int luaopen_GuiLua(lua_State *L) { int skang; +printf("**********************require GuiLua\n"); // In theory this function only ever gets called once. logDom = loggingStartup("GuiLua", logDom); @@ -362,7 +361,7 @@ PD("GuiLua 3"); return 1; } -GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) +GuiLua *GuiLuaDo(int argc, char **argv, Evas_Object *parent) { GuiLua *result; lua_State *L; @@ -409,6 +408,14 @@ GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) PE("Error running - skang.loopWindow()"); lua_pop(L, closeWindow(L)); lua_close(L); + if (logDom >= 0) + { + eina_log_domain_unregister(logDom); + logDom = -1; + } + + // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed. + elm_shutdown(); } } else diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h index fd766e6..c0fa9c7 100644 --- a/src/GuiLua/GuiLua.h +++ b/src/GuiLua/GuiLua.h @@ -1,9 +1,3 @@ -#include "SledjHamr.h" -#include "LumbrJack.h" -#include "Runnr.h" -#include "winFang.h" - - #define WIDTH (300) #define HEIGHT (300) @@ -16,7 +10,7 @@ typedef struct _GuiLua { lua_State *L; - winFang *parent; // Our parent window, if it exists. + Evas_Object *parent; // Our parent window, if it exists. Eina_Clist winFangs; // The windows we might open. Eina_Clist node; @@ -24,4 +18,4 @@ typedef struct _GuiLua Evas_Smart_Cb on_del; } GuiLua; -GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent); +GuiLua *GuiLuaDo(int argc, char **argv, Evas_Object *parent); diff --git a/src/GuiLua/skang.c b/src/GuiLua/skang.c index c15108b..a0dca5c 100644 --- a/src/GuiLua/skang.c +++ b/src/GuiLua/skang.c @@ -1,3 +1,7 @@ +#include "SledjHamr.h" +#include "LumbrJack.h" +#include "Runnr.h" +#include "winFang.h" #include "GuiLua.h" diff --git a/src/GuiLua/test.lua b/src/GuiLua/test.lua index 705f7ad..aa7235a 100644 --- a/src/GuiLua/test.lua +++ b/src/GuiLua/test.lua @@ -4,9 +4,10 @@ do -- Only I'm not gonna indent this. local skang = require 'skang' local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[ - local win = skang.window(500, 500, "G'day planet.", 'testWindow') + local win = skang.window(200, 100, "G'day planet.", 'testWindow') skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} - win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translat 'quit' into the Lua 'skang.quit()'? + win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'? + skang.thingasm{win, 'ffuncer', 'Calls ffunc', types = 'widget', widget='"button", "ffunc()", 10, 40, 100, 30', action='test.ffunc(3, 4)'} ]]) print('code') diff --git a/src/GuiLua/test.skang b/src/GuiLua/test.skang index 337b75f..e3b303b 100644 --- a/src/GuiLua/test.skang +++ b/src/GuiLua/test.skang @@ -4,7 +4,7 @@ -- There's an implied local test = require 'test' -- This is a bit more verbose than I wanted. lol -local win = skang.window(512, 512, "G'day planet.", 'testWindow') +local win = skang.window(200, 100, "G'day planet.", 'testWindow') skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'? diff --git a/src/GuiLua/test_c.c b/src/GuiLua/test_c.c index 5328bda..6421d24 100644 --- a/src/GuiLua/test_c.c +++ b/src/GuiLua/test_c.c @@ -10,6 +10,10 @@ http://lua-users.org/lists/lua-l/2008-01/msg00671.html */ +#include "SledjHamr.h" +#include "LumbrJack.h" +#include "Runnr.h" +#include "winFang.h" #include "GuiLua.h" -- cgit v1.1