aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-27 18:33:59 +1000
committerDavid Walter Seikel2014-04-27 18:33:59 +1000
commitb82d2d7e46ed5bc6202e8c7410807bd6ac0e173b (patch)
treefff74cc8492b6d937a68caf46d1d3baeb808f2d8 /src
parentCentralise the PACKAGE_* stuff, move our libraries to lib, and shuffle stuff ... (diff)
downloadSledjHamr-b82d2d7e46ed5bc6202e8c7410807bd6ac0e173b.zip
SledjHamr-b82d2d7e46ed5bc6202e8c7410807bd6ac0e173b.tar.gz
SledjHamr-b82d2d7e46ed5bc6202e8c7410807bd6ac0e173b.tar.bz2
SledjHamr-b82d2d7e46ed5bc6202e8c7410807bd6ac0e173b.tar.xz
Convert GuiLua to EO.
Diffstat (limited to 'src')
-rw-r--r--src/GuiLua/GuiLua.c41
-rw-r--r--src/GuiLua/GuiLua.h1
2 files changed, 31 insertions, 11 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c
index 8dbc2ff..06ad4d5 100644
--- a/src/GuiLua/GuiLua.c
+++ b/src/GuiLua/GuiLua.c
@@ -367,9 +367,10 @@ win.quitter.colour.r = 5 -> direct access to the table, well "direct" via Th
367 367
368struct _Widget 368struct _Widget
369{ 369{
370 char magic[8]; 370 char magic[8];
371 Evas_Object *obj; 371 Evas_Object *obj;
372 char *label, *look, *action, *help; 372 Eina_Clist node;
373 char *label, *look, *action, *help;
373 // foreground / background colour 374 // foreground / background colour
374 // thing 375 // thing
375 // types {} 376 // types {}
@@ -409,23 +410,32 @@ static int widget(lua_State *L)
409 pull_lua(L, 1, "$type $title %x %y %w %h", &type, &title, &x, &y, &w, &h); 410 pull_lua(L, 1, "$type $title %x %y %w %h", &type, &title, &x, &y, &w, &h);
410 411
411 // Poor mans introspection, until I write real introspection into EFL. 412 // Poor mans introspection, until I write real introspection into EFL.
413 // TODO - The alternative is to just lookup the ELM_*_CLASS in a hash table?
412 if (strcmp(type, "button") == 0) 414 if (strcmp(type, "button") == 0)
413 { 415 {
414 struct _Widget *wid; 416 struct _Widget *wid;
415 417
416 wid = calloc(1, sizeof(struct _Widget)); 418 wid = calloc(1, sizeof(struct _Widget));
417 strcpy(wid->magic, "Widget"); 419 strcpy(wid->magic, "Widget");
420 eina_clist_add_head(&ourGlobals->widgets, &wid->node);
418 wid->label = strdup(title); 421 wid->label = strdup(title);
419 wid->obj = elm_button_add(ourGlobals->win); 422
420 elm_object_text_set(wid->obj, title); 423 // These two lines are likely the only ones that will be different for the different sorts of widgets.
424 wid->obj = eo_add(ELM_OBJ_BUTTON_CLASS, ourGlobals->win);
421 evas_object_smart_callback_add(wid->obj, "clicked", _on_click, L); 425 evas_object_smart_callback_add(wid->obj, "clicked", _on_click, L);
422 evas_object_resize(wid->obj, w, h); 426
423 evas_object_move(wid->obj, x, y); 427 elm_object_part_text_set(wid->obj, NULL, wid->label);
424 evas_object_show(wid->obj); 428 eo_do(wid->obj,
425 evas_object_data_set(wid->obj, "Widget", wid); 429 evas_obj_size_set(w, h),
430 evas_obj_position_set(x, y),
431 evas_obj_visibility_set(EINA_TRUE),
432 eo_key_data_set("Widget", wid, NULL)
433 );
434
426 /* Evas_Object *bt isn't a real pointer it seems. At least Lua bitches about it - 435 /* Evas_Object *bt isn't a real pointer it seems. At least Lua bitches about it -
427 PANIC: unprotected error in call to Lua API (bad light userdata pointer) 436 PANIC: unprotected error in call to Lua API (bad light userdata pointer)
428 So we wrap it. 437 So we wrap the _Widget instead of the Evas_Object.
438 TODO - Might as well make _Widget a full userdata.
429 */ 439 */
430 lua_pushlightuserdata(L, (void *) wid); 440 lua_pushlightuserdata(L, (void *) wid);
431 return 1; 441 return 1;
@@ -476,6 +486,7 @@ static int window(lua_State *L)
476 486
477 if ((ourGlobals->win = elm_win_util_standard_add(name, title))) 487 if ((ourGlobals->win = elm_win_util_standard_add(name, title)))
478 { 488 {
489 eina_clist_init(&ourGlobals->widgets);
479 evas_object_smart_callback_add(ourGlobals->win, "delete,request", _on_done, ourGlobals); 490 evas_object_smart_callback_add(ourGlobals->win, "delete,request", _on_done, ourGlobals);
480 evas_object_resize(ourGlobals->win, w, h); 491 evas_object_resize(ourGlobals->win, w, h);
481 evas_object_move(ourGlobals->win, 0, 0); 492 evas_object_move(ourGlobals->win, 0, 0);
@@ -559,9 +570,17 @@ static int closeWindow(lua_State *L)
559 ourGlobals = lua_touserdata(L, -1); 570 ourGlobals = lua_touserdata(L, -1);
560 lua_pop(L, 1); 571 lua_pop(L, 1);
561 572
562 // Elm will delete our buttons to, and EO will bitch four times for each.
563 if (ourGlobals->win) 573 if (ourGlobals->win)
574 {
575 struct _Widget *wid;
576
577 // Elm will delete our widgets , but if we are using eo, we need to unref them.
578 EINA_CLIST_FOR_EACH_ENTRY(wid, &ourGlobals->widgets, struct _Widget, node)
579 {
580 eo_unref(wid->obj);
581 }
564 evas_object_del(ourGlobals->win); 582 evas_object_del(ourGlobals->win);
583 }
565 584
566 if (ourGlobals->logDom >= 0) 585 if (ourGlobals->logDom >= 0)
567 { 586 {
diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h
index 2dd77ba..d94c2ce 100644
--- a/src/GuiLua/GuiLua.h
+++ b/src/GuiLua/GuiLua.h
@@ -18,6 +18,7 @@ typedef struct _globals globals;
18struct _globals 18struct _globals
19{ 19{
20 Evas_Object *win; // Our Elm window. 20 Evas_Object *win; // Our Elm window.
21 Eina_Clist widgets; // Our windows widgets.
21 int logDom; // Our logging domain. 22 int logDom; // Our logging domain.
22 23
23//Ecore_Evas *ecore_evas; 24//Ecore_Evas *ecore_evas;