From 6617c76a5e8c902abab5e54c462e552f4ac285e1 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 8 May 2014 07:32:36 +1000 Subject: And now purkle is it's own skang module. --- extantz.sh | 2 +- src/GuiLua/GuiLua.c | 2 +- src/GuiLua/GuiLua.h | 2 ++ src/extantz/build.lua | 4 +-- src/extantz/extantz.c | 7 +++-- src/extantz/extantz.h | 1 - src/extantz/purkle.c | 43 --------------------------- src/purkle/build.lua | 22 ++++++++++++++ src/purkle/purkle.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 114 insertions(+), 51 deletions(-) delete mode 100644 src/extantz/purkle.c create mode 100755 src/purkle/build.lua create mode 100644 src/purkle/purkle.c diff --git a/extantz.sh b/extantz.sh index 8149926..95b1daa 100755 --- a/extantz.sh +++ b/extantz.sh @@ -3,5 +3,5 @@ wd=$(pwd) export LUA_PATH="$wd/lib/?.lua;$wd/src/GuiLua/?.lua" -export LUA_CPATH="$wd/lib/lib?.so;$wd/src/GuiLua/?.so" +export LUA_CPATH="$wd/lib/lib?.so;$wd/lib/?.so;$wd/src/GuiLua/?.so" ./extantz diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index cfcc9d8..dbd3f95 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c @@ -144,7 +144,7 @@ and ordinary elementary widgets. Proper introspection can come later. static int logDom; // Our logging domain. -static const char *glName = "ourGuiLua"; +const char *glName = "ourGuiLua"; /* Sooo, how to do this - widget has to be a light userdata diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h index 2a4a3f0..75c0b38 100644 --- a/src/GuiLua/GuiLua.h +++ b/src/GuiLua/GuiLua.h @@ -27,6 +27,8 @@ typedef struct _GuiLua Evas_Smart_Cb on_del; } GuiLua; +extern const char *glName; + GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent); void GuiLuaDel(GuiLua *gl); diff --git a/src/extantz/build.lua b/src/extantz/build.lua index d15be35..1591e8a 100755 --- a/src/extantz/build.lua +++ b/src/extantz/build.lua @@ -18,11 +18,11 @@ LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux' libs = libs .. ' -lIrrlicht -lGL -lbz2 -lGuiLua -lwinFang -lRunnr' removeFiles(dir, {'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', '../../media/extantz.edj'}) -removeFiles(dir, {'../../extantz', 'camera.o', 'purkle.o', 'files.o', 'scenri.o', 'woMan.o'}) +removeFiles(dir, {'../../extantz', 'camera.o', 'files.o', 'scenri.o', 'woMan.o'}) runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' extantz.edc ../../media/extantz.edj') runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS) runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS) runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS) CFLAGS = CFLAGS .. ' -Wl,-export-dynamic' -compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'camera', 'Evas_3D_demo', 'purkle', 'files', 'scenri', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o') +compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'camera', 'Evas_3D_demo', 'files', 'scenri', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o') diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index b8536e9..590770d 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c @@ -515,11 +515,12 @@ EAPI_MAIN int elm_main(int argc, char **argv) makeMainMenu(&ourGlobals); // overlay_add(&ourGlobals); - woMan_add(&ourGlobals); - purkleAdd(&ourGlobals); - ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL}; GuiLuaDo(5, args, ourGlobals.mainWindow); + woMan_add(&ourGlobals); + args[2] = "purkle"; + GuiLuaDo(3, args, ourGlobals.mainWindow); + ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); #if USE_PHYSICS world = ephysicsAdd(&ourGlobals); diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index c6e3393..684b53d 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h @@ -258,7 +258,6 @@ Eina_Bool animateCamera(Scene_Data *scene); winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool save); void filesShow(winFang *me, Evas_Smart_Cb func, void *data); -winFang *purkleAdd(globals *ourGlobals); winFang *woMan_add(globals *ourGlobals); diff --git a/src/extantz/purkle.c b/src/extantz/purkle.c deleted file mode 100644 index 590a84e..0000000 --- a/src/extantz/purkle.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "extantz.h" - - -// TODO - This is to work around a bug in Elm entry, remove it when the bug is fixed. -// The bug is that editable entry widgets cause the app to hang on exit. -static void _on_entry_del(void *data, Evas_Object *obj, void *event_info) -{ -// winFang *me = data; - - elm_entry_editable_set(obj, EINA_FALSE); -} - -winFang *purkleAdd(globals *ourGlobals) -{ - winFang *me; - Widget *wid; - Evas_Object *en; - - me = winFangAdd(ourGlobals->mainWindow, 30, 520, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "chatter box", "purkle"); - - en = eo_add(ELM_OBJ_ENTRY_CLASS, me->win, - elm_obj_entry_scrollable_set(EINA_TRUE), - elm_obj_entry_editable_set(EINA_FALSE), - evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), - evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), - evas_obj_visibility_set(EINA_TRUE) - ); - elm_object_text_set(en, "History is shown here"); - elm_box_pack_end(me->box, en); - eo_unref(en); - - wid = widgetAdd(me, ELM_OBJ_ENTRY_CLASS, me->win, ""); - wid->on_del = _on_entry_del; - eo_do(wid->obj, - elm_obj_entry_scrollable_set(EINA_TRUE), - elm_obj_entry_editable_set(EINA_TRUE) - ); - elm_box_pack_end(me->box, wid->obj); - - evas_object_show(me->box); - - return me; -} diff --git a/src/purkle/build.lua b/src/purkle/build.lua new file mode 100755 index 0000000..32ff522 --- /dev/null +++ b/src/purkle/build.lua @@ -0,0 +1,22 @@ +#!/usr/bin/env lua + +local dir = ... + +if 'nil' == type(dir) then + local build, err = loadfile('../../build.lua') + if build then + setfenv(build, getfenv(2)) + build(2) + else + print("ERROR - " .. err) + end + dir = workingDir +end + +CFLAGS = CFLAGS .. ' -I../GuiLua' +LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS +libs = libs .. ' -lGuiLua -lwinFang -lRunnr' + +removeFiles(dir, {lib_d .. '/purkle.so'}) + +runCommand('C modules', dir, 'gcc ' .. CFLAGS .. ' -fPIC -shared -o ' .. lib_d .. '/purkle.so purkle.c') diff --git a/src/purkle/purkle.c b/src/purkle/purkle.c new file mode 100644 index 0000000..971ad37 --- /dev/null +++ b/src/purkle/purkle.c @@ -0,0 +1,82 @@ +//#include "LumbrJack.h" +#include "GuiLua.h" +#include "Runnr.h" +#include "winFang.h" + + +// TODO - This is to work around a bug in Elm entry, remove it when the bug is fixed. +// The bug is that editable entry widgets cause the app to hang on exit. +static void _on_entry_del(void *data, Evas_Object *obj, void *event_info) +{ +// winFang *me = data; + + elm_entry_editable_set(obj, EINA_FALSE); +} + +static winFang *purkleAdd(winFang *parent, int w, int h) +{ + winFang *me; + Widget *wid; + Evas_Object *en; + + me = winFangAdd(parent, 30, 520, w, h, "chatter box", "purkle"); + + en = eo_add(ELM_OBJ_ENTRY_CLASS, me->win, + elm_obj_entry_scrollable_set(EINA_TRUE), + elm_obj_entry_editable_set(EINA_FALSE), + evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), + evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), + evas_obj_visibility_set(EINA_TRUE) + ); + elm_object_text_set(en, "History is shown here"); + elm_box_pack_end(me->box, en); + eo_unref(en); + + wid = widgetAdd(me, ELM_OBJ_ENTRY_CLASS, me->win, ""); + wid->on_del = _on_entry_del; + eo_do(wid->obj, + elm_obj_entry_scrollable_set(EINA_TRUE), + elm_obj_entry_editable_set(EINA_TRUE) + ); + elm_box_pack_end(me->box, wid->obj); + + evas_object_show(me->box); + + return me; +} + +static const char *ourName = "purkle"; +int skang, _M; + +int luaopen_purkle(lua_State *L) +{ + GuiLua *gl; + winFang *parent = NULL; + + +// local skang = require 'skang' + lua_getglobal(L, "require"); + lua_pushstring(L, SKANG); + lua_call(L, 1, 1); + lua_setfield(L, LUA_REGISTRYINDEX, SKANG); + lua_getfield(L, LUA_REGISTRYINDEX, SKANG); + skang = lua_gettop(L); + +// local _M = skang.moduleBegin('test_c', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', nil, false) + push_lua(L, "@ ( $ ~ $ $ $ ~ ! )", skang, MODULEBEGIN, ourName, "Copyright 2014 David Seikel", "0.1", "2014-05-08 07:18:00", 0, 1); + lua_setfield(L, LUA_REGISTRYINDEX, ourName); + lua_getfield(L, LUA_REGISTRYINDEX, ourName); + _M = lua_gettop(L); + + lua_getfield(L, LUA_REGISTRYINDEX, glName); + gl = lua_touserdata(L, -1); + lua_pop(L, 1); + if (gl && gl->parent) parent = gl->parent; + + purkleAdd(parent, 300, 400); + + push_lua(L, "@ ( = )", skang, MODULEEND, _M, 0); + + // Return _M, the table itself, not the index. + return 1; +} -- cgit v1.1