aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/GuiLua
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-05 20:04:08 +1000
committerDavid Walter Seikel2014-05-05 20:04:08 +1000
commit969f1968f2f74f8f09c4788bc7f7b1c9655ad354 (patch)
tree90d1d572f57c03b65c105cdcc47e9b79640a617d /src/GuiLua
parentGuiLuaDo() now returns astructure, and has that structure in Lua's C registry... (diff)
downloadSledjHamr-969f1968f2f74f8f09c4788bc7f7b1c9655ad354.zip
SledjHamr-969f1968f2f74f8f09c4788bc7f7b1c9655ad354.tar.gz
SledjHamr-969f1968f2f74f8f09c4788bc7f7b1c9655ad354.tar.bz2
SledjHamr-969f1968f2f74f8f09c4788bc7f7b1c9655ad354.tar.xz
Call skang modules from extantz. Needs some clean up.
Diffstat (limited to 'src/GuiLua')
-rw-r--r--src/GuiLua/GuiLua.c33
-rw-r--r--src/GuiLua/GuiLua.h10
-rw-r--r--src/GuiLua/skang.c4
-rw-r--r--src/GuiLua/test.lua5
-rw-r--r--src/GuiLua/test.skang2
-rw-r--r--src/GuiLua/test_c.c4
6 files changed, 34 insertions, 24 deletions
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.
139*/ 139*/
140 140
141 141
142 142#include "SledjHamr.h"
143#include "LumbrJack.h"
144#include "Runnr.h"
145#include "winFang.h"
143#include "GuiLua.h" 146#include "GuiLua.h"
147//#include <stdio.h>
144 148
145 149
146static int logDom; // Our logging domain. 150static int logDom; // Our logging domain.
@@ -232,17 +236,20 @@ static int colour(lua_State *L)
232static int window(lua_State *L) 236static int window(lua_State *L)
233{ 237{
234 winFang *win = NULL; 238 winFang *win = NULL;
239 Evas_Object *parent = NULL;
235 char *name = "GuiLua"; 240 char *name = "GuiLua";
236 char *title = "GuiLua test harness"; 241 char *title = "GuiLua test harness";
237 int w = WIDTH, h = HEIGHT; 242 int w = WIDTH, h = HEIGHT;
238 GuiLua *gl; 243 GuiLua *gl;
239 244
245 pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name);
246
240 lua_getfield(L, LUA_REGISTRYINDEX, glName); 247 lua_getfield(L, LUA_REGISTRYINDEX, glName);
241 gl = lua_touserdata(L, -1); 248 gl = lua_touserdata(L, -1);
242 lua_pop(L, 1); 249 lua_pop(L, 1);
250 if (gl && gl->parent) parent = gl->parent;
243 251
244 pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); 252 win = winFangAdd(parent, 25, 25, w, h, title, name);
245 win = winFangAdd(NULL, 0, 0, w, h, title, name);
246 eina_clist_add_head(&gl->winFangs, &win->node); 253 eina_clist_add_head(&gl->winFangs, &win->node);
247 lua_pushlightuserdata(L, win); 254 lua_pushlightuserdata(L, win);
248 255
@@ -285,15 +292,6 @@ static int closeWindow(lua_State *L)
285 winFangDel(win); 292 winFangDel(win);
286 } 293 }
287 294
288 if (logDom >= 0)
289 {
290 eina_log_domain_unregister(logDom);
291 logDom = -1;
292 }
293
294 // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed.
295 elm_shutdown();
296
297 return 0; 295 return 0;
298} 296}
299 297
@@ -313,6 +311,7 @@ int luaopen_GuiLua(lua_State *L)
313{ 311{
314 int skang; 312 int skang;
315 313
314printf("**********************require GuiLua\n");
316 // In theory this function only ever gets called once. 315 // In theory this function only ever gets called once.
317 logDom = loggingStartup("GuiLua", logDom); 316 logDom = loggingStartup("GuiLua", logDom);
318 317
@@ -362,7 +361,7 @@ PD("GuiLua 3");
362 return 1; 361 return 1;
363} 362}
364 363
365GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) 364GuiLua *GuiLuaDo(int argc, char **argv, Evas_Object *parent)
366{ 365{
367 GuiLua *result; 366 GuiLua *result;
368 lua_State *L; 367 lua_State *L;
@@ -409,6 +408,14 @@ GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent)
409 PE("Error running - skang.loopWindow()"); 408 PE("Error running - skang.loopWindow()");
410 lua_pop(L, closeWindow(L)); 409 lua_pop(L, closeWindow(L));
411 lua_close(L); 410 lua_close(L);
411 if (logDom >= 0)
412 {
413 eina_log_domain_unregister(logDom);
414 logDom = -1;
415 }
416
417 // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed.
418 elm_shutdown();
412 } 419 }
413 } 420 }
414 else 421 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 @@
1#include "SledjHamr.h"
2#include "LumbrJack.h"
3#include "Runnr.h"
4#include "winFang.h"
5
6
7#define WIDTH (300) 1#define WIDTH (300)
8#define HEIGHT (300) 2#define HEIGHT (300)
9 3
@@ -16,7 +10,7 @@
16typedef struct _GuiLua 10typedef struct _GuiLua
17{ 11{
18 lua_State *L; 12 lua_State *L;
19 winFang *parent; // Our parent window, if it exists. 13 Evas_Object *parent; // Our parent window, if it exists.
20 Eina_Clist winFangs; // The windows we might open. 14 Eina_Clist winFangs; // The windows we might open.
21 15
22 Eina_Clist node; 16 Eina_Clist node;
@@ -24,4 +18,4 @@ typedef struct _GuiLua
24 Evas_Smart_Cb on_del; 18 Evas_Smart_Cb on_del;
25} GuiLua; 19} GuiLua;
26 20
27GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent); 21GuiLua *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 @@
1#include "SledjHamr.h"
2#include "LumbrJack.h"
3#include "Runnr.h"
4#include "winFang.h"
1#include "GuiLua.h" 5#include "GuiLua.h"
2 6
3 7
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.
4 4
5local skang = require 'skang' 5local skang = require 'skang'
6local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[ 6local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[
7 local win = skang.window(500, 500, "G'day planet.", 'testWindow') 7 local win = skang.window(200, 100, "G'day planet.", 'testWindow')
8 skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} 8 skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'}
9 win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translat 'quit' into the Lua 'skang.quit()'? 9 win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'?
10 skang.thingasm{win, 'ffuncer', 'Calls ffunc', types = 'widget', widget='"button", "ffunc()", 10, 40, 100, 30', action='test.ffunc(3, 4)'}
10]]) 11]])
11 12
12print('code') 13print('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 @@
4-- There's an implied local test = require 'test' 4-- There's an implied local test = require 'test'
5 5
6-- This is a bit more verbose than I wanted. lol 6-- This is a bit more verbose than I wanted. lol
7local win = skang.window(512, 512, "G'day planet.", 'testWindow') 7local win = skang.window(200, 100, "G'day planet.", 'testWindow')
8skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} 8skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'}
9win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'? 9win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'?
10 10
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
10*/ 10*/
11 11
12 12
13#include "SledjHamr.h"
14#include "LumbrJack.h"
15#include "Runnr.h"
16#include "winFang.h"
13#include "GuiLua.h" 17#include "GuiLua.h"
14 18
15 19