aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/GuiLua.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-09 13:41:38 +1000
committerDavid Walter Seikel2014-04-09 13:41:38 +1000
commite4e750b9a749899f1eaa3b666381c39e9dc4bd7b (patch)
tree53559782b479e88b697a4b2ba4691ab269428367 /ClientHamr/GuiLua/GuiLua.c
parentMore notes! (diff)
downloadSledjHamr-e4e750b9a749899f1eaa3b666381c39e9dc4bd7b.zip
SledjHamr-e4e750b9a749899f1eaa3b666381c39e9dc4bd7b.tar.gz
SledjHamr-e4e750b9a749899f1eaa3b666381c39e9dc4bd7b.tar.bz2
SledjHamr-e4e750b9a749899f1eaa3b666381c39e9dc4bd7b.tar.xz
Make GuiLua an actual shared library, plus some minor clean ups.
Diffstat (limited to 'ClientHamr/GuiLua/GuiLua.c')
-rw-r--r--ClientHamr/GuiLua/GuiLua.c89
1 files changed, 9 insertions, 80 deletions
diff --git a/ClientHamr/GuiLua/GuiLua.c b/ClientHamr/GuiLua/GuiLua.c
index 47b46ca..47f63d5 100644
--- a/ClientHamr/GuiLua/GuiLua.c
+++ b/ClientHamr/GuiLua/GuiLua.c
@@ -2,10 +2,8 @@
2 2
3Provides the skang and widget Lua packages. 3Provides the skang and widget Lua packages.
4 4
5This should be a library in the end, but for now it's just an 5In the initial intended use case, several applications will be using
6application that is a test bed for what goes into the library. In the 6this all at once, with one central app hosting all the GUIs.
7initial intended use case, several applications will be using this all at
8once, with one central app hosting all the GUIs.
9 7
10Basically this should deal with "windows" and their contents. A 8Basically this should deal with "windows" and their contents. A
11"window" in this case is hosted in the central app as some sort of 9"window" in this case is hosted in the central app as some sort of
@@ -43,10 +41,7 @@ Lua scripts do -
43 Seems simplest. 41 Seems simplest.
44 42
45 Also - 43 Also -
46 Most of what is in here becomes a library for dynamic linking to C code.
47 Pretty much just leaving main(), though most of what is in there right now should become another function.
48 Some of this gets shared with LuaSL, since it came from there anyway. 44 Some of this gets shared with LuaSL, since it came from there anyway.
49 Perhaps GuiLua.so will work, and I don't have to think of another name. lol
50 45
51 Finally - 46 Finally -
52 Add a --gui command line option, that runs foo.skang. 47 Add a --gui command line option, that runs foo.skang.
@@ -144,68 +139,15 @@ and ordinary elementary widgets. Proper introspection can come later.
144 139
145 140
146 141
147#include <Eet.h> 142#include "GuiLua.h"
148#include <Ecore.h>
149#include <Ecore_Evas.h>
150#include <Edje.h>
151#include <stdio.h>
152#include <ctype.h>
153
154#include <lua.h>
155#include <luajit.h>
156#include <lualib.h>
157#include <lauxlib.h>
158
159typedef struct _globals globals;
160
161
162#define WIDTH (300)
163#define HEIGHT (300)
164
165#define PC(...) EINA_LOG_DOM_CRIT(ourGlobals->logDom, __VA_ARGS__)
166#define PE(...) EINA_LOG_DOM_ERR(ourGlobals->logDom, __VA_ARGS__)
167#define PW(...) EINA_LOG_DOM_WARN(ourGlobals->logDom, __VA_ARGS__)
168#define PD(...) EINA_LOG_DOM_DBG(ourGlobals->logDom, __VA_ARGS__)
169#define PI(...) EINA_LOG_DOM_INFO(ourGlobals->logDom, __VA_ARGS__)
170
171#define PCm(...) EINA_LOG_DOM_CRIT(ourGlobals.logDom, __VA_ARGS__)
172#define PEm(...) EINA_LOG_DOM_ERR(ourGlobals.logDom, __VA_ARGS__)
173#define PWm(...) EINA_LOG_DOM_WARN(ourGlobals.logDom, __VA_ARGS__)
174#define PDm(...) EINA_LOG_DOM_DBG(ourGlobals.logDom, __VA_ARGS__)
175#define PIm(...) EINA_LOG_DOM_INFO(ourGlobals.logDom, __VA_ARGS__)
176
177#define D() PD("DEBUG")
178
179// "01:03:52 01-01-1973\n\0"
180#define DATE_TIME_LEN 21
181
182
183#ifndef FALSE
184// NEVER change this
185typedef enum
186{
187 FALSE = 0,
188 TRUE = 1
189} boolean;
190#endif
191
192struct _globals
193{
194 Ecore_Evas *ee; // Our window.
195 Evas *canvas; // The canvas for drawing directly onto.
196 Evas_Object *bg; // Our background edje.
197 lua_State *L; // Our Lua state.
198 int eina, logDom, ecore_evas, edje;
199};
200
201 globals ourGlobals;
202 143
144globals ourGlobals;
203 145
204static const char *ourName = "widget"; 146static const char *ourName = "widget";
205int skang, _M; 147static int skang, _M;
148
206 149
207/* 150void dumpStack(lua_State *L, int i)
208static void dumpStack(lua_State *L, int i)
209{ 151{
210 int type = lua_type(L, i); 152 int type = lua_type(L, i);
211 153
@@ -224,15 +166,8 @@ static void dumpStack(lua_State *L, int i)
224 default : printf("Stack %d is unknown\n", i); break; 166 default : printf("Stack %d is unknown\n", i); break;
225 } 167 }
226} 168}
227*/
228
229
230 169
231char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); 170static char dateTime[DATE_TIME_LEN];
232
233# define DATE_TIME_LEN 21
234
235char dateTime[DATE_TIME_LEN];
236 171
237static void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args) 172static void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args)
238{ 173{
@@ -307,13 +242,11 @@ char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut)
307} 242}
308 243
309 244
310
311static void _on_delete(Ecore_Evas *ee /*__UNUSED__*/) 245static void _on_delete(Ecore_Evas *ee /*__UNUSED__*/)
312{ 246{
313 ecore_main_loop_quit(); 247 ecore_main_loop_quit();
314} 248}
315 249
316
317static int openWindow(lua_State *L) 250static int openWindow(lua_State *L)
318{ 251{
319 globals *ourGlobals; 252 globals *ourGlobals;
@@ -487,10 +420,8 @@ int luaopen_widget(lua_State *L)
487 return 1; 420 return 1;
488} 421}
489 422
490 423void GuiLuaDo(int argc, char **argv)
491int main(int argc, char **argv)
492{ 424{
493 int result = EXIT_FAILURE;
494 lua_Number i; 425 lua_Number i;
495 426
496 memset(&ourGlobals, 0, sizeof(globals)); 427 memset(&ourGlobals, 0, sizeof(globals));
@@ -532,6 +463,4 @@ int main(int argc, char **argv)
532 } 463 }
533 else 464 else
534 fprintf(stderr, "Failed to start Lua!\n"); 465 fprintf(stderr, "Failed to start Lua!\n");
535
536 return result;
537} 466}