diff options
Diffstat (limited to '')
-rwxr-xr-x | src/purkle/build.lua | 22 | ||||
-rw-r--r-- | src/purkle/purkle.c | 82 |
2 files changed, 104 insertions, 0 deletions
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 @@ | |||
1 | #!/usr/bin/env lua | ||
2 | |||
3 | local dir = ... | ||
4 | |||
5 | if 'nil' == type(dir) then | ||
6 | local build, err = loadfile('../../build.lua') | ||
7 | if build then | ||
8 | setfenv(build, getfenv(2)) | ||
9 | build(2) | ||
10 | else | ||
11 | print("ERROR - " .. err) | ||
12 | end | ||
13 | dir = workingDir | ||
14 | end | ||
15 | |||
16 | CFLAGS = CFLAGS .. ' -I../GuiLua' | ||
17 | LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS | ||
18 | libs = libs .. ' -lGuiLua -lwinFang -lRunnr' | ||
19 | |||
20 | removeFiles(dir, {lib_d .. '/purkle.so'}) | ||
21 | |||
22 | 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 @@ | |||
1 | //#include "LumbrJack.h" | ||
2 | #include "GuiLua.h" | ||
3 | #include "Runnr.h" | ||
4 | #include "winFang.h" | ||
5 | |||
6 | |||
7 | // TODO - This is to work around a bug in Elm entry, remove it when the bug is fixed. | ||
8 | // The bug is that editable entry widgets cause the app to hang on exit. | ||
9 | static void _on_entry_del(void *data, Evas_Object *obj, void *event_info) | ||
10 | { | ||
11 | // winFang *me = data; | ||
12 | |||
13 | elm_entry_editable_set(obj, EINA_FALSE); | ||
14 | } | ||
15 | |||
16 | static winFang *purkleAdd(winFang *parent, int w, int h) | ||
17 | { | ||
18 | winFang *me; | ||
19 | Widget *wid; | ||
20 | Evas_Object *en; | ||
21 | |||
22 | me = winFangAdd(parent, 30, 520, w, h, "chatter box", "purkle"); | ||
23 | |||
24 | en = eo_add(ELM_OBJ_ENTRY_CLASS, me->win, | ||
25 | elm_obj_entry_scrollable_set(EINA_TRUE), | ||
26 | elm_obj_entry_editable_set(EINA_FALSE), | ||
27 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), | ||
28 | evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), | ||
29 | evas_obj_visibility_set(EINA_TRUE) | ||
30 | ); | ||
31 | elm_object_text_set(en, "History is shown here"); | ||
32 | elm_box_pack_end(me->box, en); | ||
33 | eo_unref(en); | ||
34 | |||
35 | wid = widgetAdd(me, ELM_OBJ_ENTRY_CLASS, me->win, ""); | ||
36 | wid->on_del = _on_entry_del; | ||
37 | eo_do(wid->obj, | ||
38 | elm_obj_entry_scrollable_set(EINA_TRUE), | ||
39 | elm_obj_entry_editable_set(EINA_TRUE) | ||
40 | ); | ||
41 | elm_box_pack_end(me->box, wid->obj); | ||
42 | |||
43 | evas_object_show(me->box); | ||
44 | |||
45 | return me; | ||
46 | } | ||
47 | |||
48 | static const char *ourName = "purkle"; | ||
49 | int skang, _M; | ||
50 | |||
51 | int luaopen_purkle(lua_State *L) | ||
52 | { | ||
53 | GuiLua *gl; | ||
54 | winFang *parent = NULL; | ||
55 | |||
56 | |||
57 | // local skang = require 'skang' | ||
58 | lua_getglobal(L, "require"); | ||
59 | lua_pushstring(L, SKANG); | ||
60 | lua_call(L, 1, 1); | ||
61 | lua_setfield(L, LUA_REGISTRYINDEX, SKANG); | ||
62 | lua_getfield(L, LUA_REGISTRYINDEX, SKANG); | ||
63 | skang = lua_gettop(L); | ||
64 | |||
65 | // local _M = skang.moduleBegin('test_c', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', nil, false) | ||
66 | push_lua(L, "@ ( $ ~ $ $ $ ~ ! )", skang, MODULEBEGIN, ourName, "Copyright 2014 David Seikel", "0.1", "2014-05-08 07:18:00", 0, 1); | ||
67 | lua_setfield(L, LUA_REGISTRYINDEX, ourName); | ||
68 | lua_getfield(L, LUA_REGISTRYINDEX, ourName); | ||
69 | _M = lua_gettop(L); | ||
70 | |||
71 | lua_getfield(L, LUA_REGISTRYINDEX, glName); | ||
72 | gl = lua_touserdata(L, -1); | ||
73 | lua_pop(L, 1); | ||
74 | if (gl && gl->parent) parent = gl->parent; | ||
75 | |||
76 | purkleAdd(parent, 300, 400); | ||
77 | |||
78 | push_lua(L, "@ ( = )", skang, MODULEEND, _M, 0); | ||
79 | |||
80 | // Return _M, the table itself, not the index. | ||
81 | return 1; | ||
82 | } | ||