aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/examples
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-04-22 09:19:23 +1000
committerDavid Walter Seikel2012-04-22 09:19:23 +1000
commitc963d75dfdeec11f82e79e727062fbf89afa2c04 (patch)
tree895633dbf641110be46f117c29890c49b3ffc0bd /libraries/edje/src/examples
parentAdding the new extantz viewer and grid manager. (diff)
downloadSledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.zip
SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.gz
SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.bz2
SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.xz
Update EFL to latest beta.
Diffstat (limited to 'libraries/edje/src/examples')
-rw-r--r--libraries/edje/src/examples/Makefile.am38
-rw-r--r--libraries/edje/src/examples/Makefile.in45
-rw-r--r--libraries/edje/src/examples/edje-animations.c125
-rw-r--r--libraries/edje/src/examples/edje-basic.c107
-rw-r--r--libraries/edje/src/examples/edje-box.c185
-rw-r--r--libraries/edje/src/examples/edje-box2.c187
-rw-r--r--libraries/edje/src/examples/edje-color-class.c140
-rw-r--r--libraries/edje/src/examples/edje-drag.c175
-rw-r--r--libraries/edje/src/examples/edje-perspective.c132
-rw-r--r--libraries/edje/src/examples/edje-signals-messages.c112
-rw-r--r--libraries/edje/src/examples/edje-swallow.c73
-rw-r--r--libraries/edje/src/examples/edje-table.c101
-rw-r--r--libraries/edje/src/examples/edje-text.c65
-rw-r--r--libraries/edje/src/examples/sigtest.c110
14 files changed, 1063 insertions, 532 deletions
diff --git a/libraries/edje/src/examples/Makefile.am b/libraries/edje/src/examples/Makefile.am
index 579f148..e3893cd 100644
--- a/libraries/edje/src/examples/Makefile.am
+++ b/libraries/edje/src/examples/Makefile.am
@@ -1,5 +1,10 @@
1MAINTAINERCLEANFILES = Makefile.in 1MAINTAINERCLEANFILES = Makefile.in
2 2
3EDJE_CC = @edje_cc@
4EDJE_CC_FLAGS_VERBOSE_0 =
5EDJE_CC_FLAGS_VERBOSE_1 = -v
6EDJE_CC_FLAGS = $(EDJE_CC_FLAGS_$(V)) -id $(srcdir) -fd $(srcdir)
7
3examplesdir = $(datadir)/$(PACKAGE)/examples 8examplesdir = $(datadir)/$(PACKAGE)/examples
4 9
5if ENABLE_MULTISENSE 10if ENABLE_MULTISENSE
@@ -24,7 +29,8 @@ EDCS = \
24 $(MULTISENSE_EDC_FILE) 29 $(MULTISENSE_EDC_FILE)
25 30
26.edc.edj: 31.edc.edj:
27 $(edje_cc) -v -fd $(srcdir) -id $(srcdir) $(SND_DIR) $< $(builddir)/$(@F) 32 $(EDJE_CC) $(EDJE_CC_FLAGS) $(SND_DIR) $< $(builddir)/$(@F)
33
28 34
29EDJS = $(EDCS:%.edc=%.edj) 35EDJS = $(EDCS:%.edc=%.edj)
30 36
@@ -53,31 +59,33 @@ EXTRA_DIST = $(files_DATA)
53if BUILD_EXAMPLES 59if BUILD_EXAMPLES
54 60
55AM_CPPFLAGS = \ 61AM_CPPFLAGS = \
56 -I. \ 62-I. \
57 -I$(top_srcdir)/src/lib \ 63-I$(top_srcdir)/src/lib \
58 -I$(top_srcdir)/src/lib/include \ 64-I$(top_srcdir)/src/lib/include \
59 -DPACKAGE_BIN_DIR=\"$(bindir)\" \ 65-DPACKAGE_BIN_DIR=\"$(bindir)\" \
60 -DPACKAGE_LIB_DIR=\"$(libdir)\" \ 66-DPACKAGE_LIB_DIR=\"$(libdir)\" \
61 -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ 67-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \
62 -DPACKAGE_EXAMPLES_DIR=\"$(datadir)/$(PACKAGE)/examples\" \ 68@EDJE_CFLAGS@
63 @EDJE_CFLAGS@
64 69
65files_DATA += $(EDJS) 70files_DATA += $(EDJS)
66 71
67examples_PROGRAMS = \ 72examples_PROGRAMS = \
73 edje-animations \
68 edje-basic \ 74 edje-basic \
69 edje-swallow \
70 edje-text \
71 edje-table \
72 edje-box \ 75 edje-box \
73 edje-box2 \ 76 edje-box2 \
74 edje-drag\
75 edje-signals-messages \
76 edje-color-class \ 77 edje-color-class \
78 edje-drag\
77 edje-perspective \ 79 edje-perspective \
78 edje-animations \ 80 edje-signals-messages \
81 edje-swallow \
82 edje-table \
83 edje-text \
79 sigtest 84 sigtest
80 85
81LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_LIBS@ 86LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_LIBS@
82 87
83endif 88endif
89
90clean-local:
91 rm -f *.edj
diff --git a/libraries/edje/src/examples/Makefile.in b/libraries/edje/src/examples/Makefile.in
index 7f867e0..de47940 100644
--- a/libraries/edje/src/examples/Makefile.in
+++ b/libraries/edje/src/examples/Makefile.in
@@ -36,14 +36,15 @@ POST_UNINSTALL = :
36build_triplet = @build@ 36build_triplet = @build@
37host_triplet = @host@ 37host_triplet = @host@
38@BUILD_EXAMPLES_TRUE@am__append_1 = $(EDJS) 38@BUILD_EXAMPLES_TRUE@am__append_1 = $(EDJS)
39@BUILD_EXAMPLES_TRUE@examples_PROGRAMS = edje-basic$(EXEEXT) \ 39@BUILD_EXAMPLES_TRUE@examples_PROGRAMS = edje-animations$(EXEEXT) \
40@BUILD_EXAMPLES_TRUE@ edje-swallow$(EXEEXT) edje-text$(EXEEXT) \ 40@BUILD_EXAMPLES_TRUE@ edje-basic$(EXEEXT) edje-box$(EXEEXT) \
41@BUILD_EXAMPLES_TRUE@ edje-table$(EXEEXT) edje-box$(EXEEXT) \ 41@BUILD_EXAMPLES_TRUE@ edje-box2$(EXEEXT) \
42@BUILD_EXAMPLES_TRUE@ edje-box2$(EXEEXT) edje-drag$(EXEEXT) \
43@BUILD_EXAMPLES_TRUE@ edje-signals-messages$(EXEEXT) \
44@BUILD_EXAMPLES_TRUE@ edje-color-class$(EXEEXT) \ 42@BUILD_EXAMPLES_TRUE@ edje-color-class$(EXEEXT) \
43@BUILD_EXAMPLES_TRUE@ edje-drag$(EXEEXT) \
45@BUILD_EXAMPLES_TRUE@ edje-perspective$(EXEEXT) \ 44@BUILD_EXAMPLES_TRUE@ edje-perspective$(EXEEXT) \
46@BUILD_EXAMPLES_TRUE@ edje-animations$(EXEEXT) sigtest$(EXEEXT) 45@BUILD_EXAMPLES_TRUE@ edje-signals-messages$(EXEEXT) \
46@BUILD_EXAMPLES_TRUE@ edje-swallow$(EXEEXT) edje-table$(EXEEXT) \
47@BUILD_EXAMPLES_TRUE@ edje-text$(EXEEXT) sigtest$(EXEEXT)
47subdir = src/examples 48subdir = src/examples
48DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 49DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
49ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 50ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -279,6 +280,8 @@ PACKAGE_URL = @PACKAGE_URL@
279PACKAGE_VERSION = @PACKAGE_VERSION@ 280PACKAGE_VERSION = @PACKAGE_VERSION@
280PATH_SEPARATOR = @PATH_SEPARATOR@ 281PATH_SEPARATOR = @PATH_SEPARATOR@
281PKG_CONFIG = @PKG_CONFIG@ 282PKG_CONFIG = @PKG_CONFIG@
283PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
284PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
282PYTHON = @PYTHON@ 285PYTHON = @PYTHON@
283PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ 286PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
284PYTHON_PLATFORM = @PYTHON_PLATFORM@ 287PYTHON_PLATFORM = @PYTHON_PLATFORM@
@@ -366,6 +369,10 @@ top_srcdir = @top_srcdir@
366version_info = @version_info@ 369version_info = @version_info@
367vimdir = @vimdir@ 370vimdir = @vimdir@
368MAINTAINERCLEANFILES = Makefile.in 371MAINTAINERCLEANFILES = Makefile.in
372EDJE_CC = @edje_cc@
373EDJE_CC_FLAGS_VERBOSE_0 =
374EDJE_CC_FLAGS_VERBOSE_1 = -v
375EDJE_CC_FLAGS = $(EDJE_CC_FLAGS_$(V)) -id $(srcdir) -fd $(srcdir)
369examplesdir = $(datadir)/$(PACKAGE)/examples 376examplesdir = $(datadir)/$(PACKAGE)/examples
370@ENABLE_MULTISENSE_TRUE@MULTISENSE_EDC_FILE = multisense.edc 377@ENABLE_MULTISENSE_TRUE@MULTISENSE_EDC_FILE = multisense.edc
371@ENABLE_MULTISENSE_TRUE@SND_DIR = -sd $(srcdir) 378@ENABLE_MULTISENSE_TRUE@SND_DIR = -sd $(srcdir)
@@ -394,14 +401,13 @@ files_DATA = $(EDCS) bubble.png red.png test.png Vera.ttf edje-basic.c \
394 edje-perspective.c edje-animations.c sigtest.c $(am__append_1) 401 edje-perspective.c edje-animations.c sigtest.c $(am__append_1)
395EXTRA_DIST = $(files_DATA) 402EXTRA_DIST = $(files_DATA)
396@BUILD_EXAMPLES_TRUE@AM_CPPFLAGS = \ 403@BUILD_EXAMPLES_TRUE@AM_CPPFLAGS = \
397@BUILD_EXAMPLES_TRUE@ -I. \ 404@BUILD_EXAMPLES_TRUE@-I. \
398@BUILD_EXAMPLES_TRUE@ -I$(top_srcdir)/src/lib \ 405@BUILD_EXAMPLES_TRUE@-I$(top_srcdir)/src/lib \
399@BUILD_EXAMPLES_TRUE@ -I$(top_srcdir)/src/lib/include \ 406@BUILD_EXAMPLES_TRUE@-I$(top_srcdir)/src/lib/include \
400@BUILD_EXAMPLES_TRUE@ -DPACKAGE_BIN_DIR=\"$(bindir)\" \ 407@BUILD_EXAMPLES_TRUE@-DPACKAGE_BIN_DIR=\"$(bindir)\" \
401@BUILD_EXAMPLES_TRUE@ -DPACKAGE_LIB_DIR=\"$(libdir)\" \ 408@BUILD_EXAMPLES_TRUE@-DPACKAGE_LIB_DIR=\"$(libdir)\" \
402@BUILD_EXAMPLES_TRUE@ -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ 409@BUILD_EXAMPLES_TRUE@-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \
403@BUILD_EXAMPLES_TRUE@ -DPACKAGE_EXAMPLES_DIR=\"$(datadir)/$(PACKAGE)/examples\" \ 410@BUILD_EXAMPLES_TRUE@@EDJE_CFLAGS@
404@BUILD_EXAMPLES_TRUE@ @EDJE_CFLAGS@
405 411
406@BUILD_EXAMPLES_TRUE@LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_LIBS@ 412@BUILD_EXAMPLES_TRUE@LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_LIBS@
407all: all-am 413all: all-am
@@ -705,7 +711,7 @@ maintainer-clean-generic:
705clean: clean-am 711clean: clean-am
706 712
707clean-am: clean-examplesPROGRAMS clean-generic clean-libtool \ 713clean-am: clean-examplesPROGRAMS clean-generic clean-libtool \
708 mostlyclean-am 714 clean-local mostlyclean-am
709 715
710distclean: distclean-am 716distclean: distclean-am
711 -rm -rf ./$(DEPDIR) 717 -rm -rf ./$(DEPDIR)
@@ -776,8 +782,8 @@ uninstall-am: uninstall-examplesPROGRAMS uninstall-filesDATA
776.MAKE: install-am install-strip 782.MAKE: install-am install-strip
777 783
778.PHONY: CTAGS GTAGS all all-am check check-am clean \ 784.PHONY: CTAGS GTAGS all all-am check check-am clean \
779 clean-examplesPROGRAMS clean-generic clean-libtool ctags \ 785 clean-examplesPROGRAMS clean-generic clean-libtool clean-local \
780 distclean distclean-compile distclean-generic \ 786 ctags distclean distclean-compile distclean-generic \
781 distclean-libtool distclean-tags distdir dvi dvi-am html \ 787 distclean-libtool distclean-tags distdir dvi dvi-am html \
782 html-am info info-am install install-am install-data \ 788 html-am info info-am install install-am install-data \
783 install-data-am install-dvi install-dvi-am \ 789 install-data-am install-dvi install-dvi-am \
@@ -793,7 +799,10 @@ uninstall-am: uninstall-examplesPROGRAMS uninstall-filesDATA
793 799
794 800
795.edc.edj: 801.edc.edj:
796 $(edje_cc) -v -fd $(srcdir) -id $(srcdir) $(SND_DIR) $< $(builddir)/$(@F) 802 $(EDJE_CC) $(EDJE_CC_FLAGS) $(SND_DIR) $< $(builddir)/$(@F)
803
804clean-local:
805 rm -f *.edj
797 806
798# Tell versions [3.59,3.63) of GNU make to not export all variables. 807# Tell versions [3.59,3.63) of GNU make to not export all variables.
799# Otherwise a system limit (for SysV at least) may be exceeded. 808# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/libraries/edje/src/examples/edje-animations.c b/libraries/edje/src/examples/edje-animations.c
index 9363471..15f2ee0 100644
--- a/libraries/edje/src/examples/edje-animations.c
+++ b/libraries/edje/src/examples/edje-animations.c
@@ -10,10 +10,9 @@
10 */ 10 */
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13#include "config.h" 13# include "config.h"
14#else 14#else
15#define PACKAGE_EXAMPLES_DIR "." 15# define __UNUSED__
16#define __UNUSED__
17#endif 16#endif
18 17
19#include <Ecore.h> 18#include <Ecore.h>
@@ -23,34 +22,59 @@
23#define WIDTH (400) 22#define WIDTH (400)
24#define HEIGHT (300) 23#define HEIGHT (300)
25 24
26static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/animations.edj"; 25static const char commands[] = \
27static Ecore_Evas *ee; 26 "commands are:\n"
28static Evas_Object *bg, *edje_obj; 27 "\t+ - increase frametime\n"
29static double frametime = 1.0/30.0; /* default value */ 28 "\t- - decrease frametime\n"
29 "\t= - status of the animation\n"
30 "\ts - pause\n"
31 "\tp - play\n"
32 "\tf - freeze one object\n"
33 "\tF - freeze all objects\n"
34 "\tt - thaw one object\n"
35 "\tT - thaw all objects\n"
36 "\ta - start animation of one object\n"
37 "\tA - stop animation of one object\n"
38 "\tEsc - exit\n"
39 "\th - print help\n";
40
41static double frametime = 1.0 / 30.0; /* default value */
30 42
31static void 43static void
32_on_delete_cb(Ecore_Evas *ee) 44_on_delete_cb(Ecore_Evas *ee __UNUSED__)
33{ 45{
34 ecore_main_loop_quit(); 46 ecore_main_loop_quit();
35} 47}
36 48
37static void 49static void
38_canvas_resize_cb(Ecore_Evas *ee) 50_on_canvas_resize(Ecore_Evas *ee)
39{ 51{
40 int w, h; 52 Evas_Object *bg;
41 53 Evas_Object *edje_obj;
42 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 54 int w;
43 evas_object_resize(bg, w, h); 55 int h;
44 evas_object_resize(edje_obj, w, h); 56
57 bg = ecore_evas_data_get(ee, "background");
58 edje_obj = ecore_evas_data_get(ee, "edje_obj");
59 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
60 evas_object_resize(bg, w, h);
61 evas_object_resize(edje_obj, w, h);
45} 62}
46 63
47static void 64static void
48_on_key_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info) 65_on_key_down(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
49{ 66{
50 Evas_Event_Key_Down *ev = event_info; 67 Evas_Event_Key_Down *ev;
51 double ft; 68 double ft;
69
70 ev = (Evas_Event_Key_Down *)event_info;
52 71
53 if (!strcmp(ev->key, "plus")) 72 if (!strcmp(ev->keyname, "h"))
73 {
74 fprintf(stdout, commands);
75 return;
76 }
77 else if (!strcmp(ev->key, "plus"))
54 { 78 {
55 frametime *= 2.0; 79 frametime *= 2.0;
56 fprintf(stdout, "Increasing frametime to: %f\n", frametime); 80 fprintf(stdout, "Increasing frametime to: %f\n", frametime);
@@ -109,24 +133,52 @@ _on_key_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
109 edje_object_animation_set(obj, EINA_FALSE); 133 edje_object_animation_set(obj, EINA_FALSE);
110 fprintf(stdout, "Stopping the animation in the Edje object\n"); 134 fprintf(stdout, "Stopping the animation in the Edje object\n");
111 } 135 }
136 else if (!strcmp(ev->keyname, "Escape"))
137 ecore_main_loop_quit();
138 else
139 {
140 printf("unhandled key: %s\n", ev->keyname);
141 fprintf(stdout, commands);
142 }
112} 143}
113 144
114int 145int
115main(int argc, char *argv[]) 146main(int argc __UNUSED__, char *argv[])
116{ 147{
117 Evas *evas; 148 char edje_file_path[PATH_MAX];
118 149 const char *edje_file = "animations.edj";
119 ecore_evas_init(); 150 Ecore_Evas *ee;
120 edje_init(); 151 Evas *evas;
152 Evas_Object *bg;
153 Evas_Object *edje_obj;
154 Eina_Prefix *pfx;
155
156 if (!ecore_evas_init())
157 return EXIT_FAILURE;
158
159 if (!edje_init())
160 goto shutdown_ecore_evas;
161
162 pfx = eina_prefix_new(argv[0], main,
163 "EDJE_EXAMPLES",
164 "edje/examples",
165 edje_file,
166 PACKAGE_BIN_DIR,
167 PACKAGE_LIB_DIR,
168 PACKAGE_DATA_DIR,
169 PACKAGE_DATA_DIR);
170 if (!pfx)
171 goto shutdown_edje;
121 172
122 /* this will give you a window with an Evas canvas under the first 173 /* this will give you a window with an Evas canvas under the first
123 * engine available */ 174 * engine available */
124 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 175 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
176 if (!ee)
177 goto free_prefix;
125 178
126 ecore_evas_callback_delete_request_set(ee, _on_delete_cb); 179 ecore_evas_callback_delete_request_set(ee, _on_delete_cb);
127 ecore_evas_callback_resize_set(ee, _canvas_resize_cb); 180 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
128 ecore_evas_title_set(ee, "Edje Animations Example"); 181 ecore_evas_title_set(ee, "Edje Animations Example");
129 ecore_evas_show(ee);
130 182
131 evas = ecore_evas_get(ee); 183 evas = ecore_evas_get(ee);
132 184
@@ -135,22 +187,41 @@ main(int argc, char *argv[])
135 evas_object_move(bg, 0, 0); /* at canvas' origin */ 187 evas_object_move(bg, 0, 0); /* at canvas' origin */
136 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ 188 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
137 evas_object_show(bg); 189 evas_object_show(bg);
190 ecore_evas_data_set(ee, "background", bg);
138 191
139 edje_obj = edje_object_add(evas); 192 edje_obj = edje_object_add(evas);
140 193
194 snprintf(edje_file_path, sizeof(edje_file_path),
195 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
141 edje_object_file_set(edje_obj, edje_file_path, "animations_group"); 196 edje_object_file_set(edje_obj, edje_file_path, "animations_group");
142 evas_object_move(edje_obj, 0, 0); 197 evas_object_move(edje_obj, 0, 0);
143 evas_object_resize(edje_obj, WIDTH, HEIGHT); 198 evas_object_resize(edje_obj, WIDTH, HEIGHT);
144 evas_object_show(edje_obj); 199 evas_object_show(edje_obj);
200 ecore_evas_data_set(ee, "edje_obj", edje_obj);
145 201
146 evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_KEY_DOWN, 202 evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_KEY_DOWN,
147 _on_key_down_cb, NULL); 203 _on_key_down, NULL);
148 evas_object_focus_set(edje_obj, EINA_TRUE); 204 evas_object_focus_set(edje_obj, EINA_TRUE);
149 205
206 fprintf(stdout, commands);
207
208 ecore_evas_show(ee);
209
150 ecore_main_loop_begin(); 210 ecore_main_loop_begin();
151 211
212 eina_prefix_free(pfx);
152 ecore_evas_free(ee); 213 ecore_evas_free(ee);
153 ecore_evas_shutdown(); 214 ecore_evas_shutdown();
154 edje_shutdown(); 215 edje_shutdown();
155 return 0; 216
217 return EXIT_SUCCESS;
218
219 free_prefix:
220 eina_prefix_free(pfx);
221 shutdown_edje:
222 edje_shutdown();
223 shutdown_ecore_evas:
224 ecore_evas_shutdown();
225
226 return EXIT_FAILURE;
156} 227}
diff --git a/libraries/edje/src/examples/edje-basic.c b/libraries/edje/src/examples/edje-basic.c
index 2a7a862..8a85312 100644
--- a/libraries/edje/src/examples/edje-basic.c
+++ b/libraries/edje/src/examples/edje-basic.c
@@ -11,47 +11,46 @@
11 */ 11 */
12 12
13#ifdef HAVE_CONFIG_H 13#ifdef HAVE_CONFIG_H
14#include "config.h" 14# include "config.h"
15#else 15#else
16#define PACKAGE_EXAMPLES_DIR "." 16# define __UNUSED__
17#define __UNUSED__
18#endif 17#endif
19 18
19#include <stdio.h>
20
21#include <Eina.h>
20#include <Ecore.h> 22#include <Ecore.h>
21#include <Ecore_Evas.h> 23#include <Ecore_Evas.h>
22#include <Edje.h> 24#include <Edje.h>
23#include <stdio.h>
24 25
25#define WIDTH (300) 26#define WIDTH (300)
26#define HEIGHT (300) 27#define HEIGHT (300)
27 28
28static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
29static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/basic.edj";
30
31static Ecore_Evas *ee;
32static Evas_Object *edje_obj;
33
34static const char commands[] = \ 29static const char commands[] = \
35 "commands are:\n" 30 "commands are:\n"
36 "\ts - change Edje's global scaling factor\n" 31 "\ts - change Edje's global scaling factor\n"
37 "\tr - change center rectangle's scaling factor\n" 32 "\tr - change center rectangle's scaling factor\n"
33 "\tEsc - exit\n"
38 "\th - print help\n"; 34 "\th - print help\n";
39 35
40static void 36static void
41_on_keydown(void *data __UNUSED__, 37_on_keydown(void *data,
42 Evas *evas __UNUSED__, 38 Evas *evas __UNUSED__,
43 Evas_Object *o __UNUSED__, 39 Evas_Object *o __UNUSED__,
44 void *einfo) 40 void *einfo)
45{ 41{
46 Evas_Event_Key_Down *ev = einfo; 42 Evas_Event_Key_Down *ev;
43 Evas_Object *edje_obj;
44
45 ev = (Evas_Event_Key_Down *)einfo;
46 edje_obj = (Evas_Object *)data;
47 47
48 if (strcmp(ev->keyname, "h") == 0) /* print help */ 48 if (strcmp(ev->keyname, "h") == 0) /* print help */
49 { 49 {
50 fprintf(stdout, commands); 50 fprintf(stdout, commands);
51 return; 51 return;
52 } 52 }
53 53 else if (strcmp(ev->keyname, "s") == 0) /* global scaling factor */
54 if (strcmp(ev->keyname, "s") == 0) /* global scaling factor */
55 { 54 {
56 double scale = edje_scale_get(); 55 double scale = edje_scale_get();
57 56
@@ -66,8 +65,7 @@ _on_keydown(void *data __UNUSED__,
66 65
67 return; 66 return;
68 } 67 }
69 68 else if (strcmp(ev->keyname, "r") == 0) /* individual scaling factor */
70 if (strcmp(ev->keyname, "r") == 0) /* individual scaling factor */
71 { 69 {
72 double scale = edje_object_scale_get(edje_obj); 70 double scale = edje_object_scale_get(edje_obj);
73 71
@@ -84,6 +82,13 @@ _on_keydown(void *data __UNUSED__,
84 82
85 return; 83 return;
86 } 84 }
85 else if (!strcmp(ev->keyname, "Escape"))
86 ecore_main_loop_quit();
87 else
88 {
89 printf("unhandled key: %s\n", ev->keyname);
90 fprintf(stdout, commands);
91 }
87} 92}
88 93
89static void 94static void
@@ -93,27 +98,47 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
93} 98}
94 99
95int 100int
96main(void) 101main(int argc __UNUSED__, char *argv[])
97{ 102{
98 Evas_Object *border, *bg; 103 char border_img_path[PATH_MAX];
99 int x, y, w, h; 104 char edje_file_path[PATH_MAX];
100 Evas *evas; 105 const char *edje_file = "basic.edj";
106 Ecore_Evas *ee;
107 Evas *evas;
108 Evas_Object *bg;
109 Evas_Object *border;
110 Evas_Object *edje_obj;
111 Eina_Prefix *pfx;
112 int x;
113 int y;
114 int w;
115 int h;
101 116
102 if (!ecore_evas_init()) 117 if (!ecore_evas_init())
103 return EXIT_FAILURE; 118 return EXIT_FAILURE;
104 119
105 if (!edje_init()) 120 if (!edje_init())
106 return EXIT_FAILURE; 121 goto shutdown_ecore_evas;
122
123 pfx = eina_prefix_new(argv[0], main,
124 "EDJE_EXAMPLES",
125 "edje/examples",
126 edje_file,
127 PACKAGE_BIN_DIR,
128 PACKAGE_LIB_DIR,
129 PACKAGE_DATA_DIR,
130 PACKAGE_DATA_DIR);
131 if (!pfx)
132 goto shutdown_edje;
107 133
108 /* this will give you a window with an Evas canvas under the first 134 /* this will give you a window with an Evas canvas under the first
109 * engine available */ 135 * engine available */
110 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 136 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
111 if (!ee) 137 if (!ee)
112 goto error; 138 goto free_prefix;
113 139
114 ecore_evas_callback_delete_request_set(ee, _on_delete); 140 ecore_evas_callback_delete_request_set(ee, _on_delete);
115 ecore_evas_title_set(ee, "Edje Basics Example"); 141 ecore_evas_title_set(ee, "Edje Basics Example");
116 ecore_evas_show(ee);
117 142
118 evas = ecore_evas_get(ee); 143 evas = ecore_evas_get(ee);
119 144
@@ -125,11 +150,12 @@ main(void)
125 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); 150 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
126 151
127 evas_object_focus_set(bg, EINA_TRUE); 152 evas_object_focus_set(bg, EINA_TRUE);
128 evas_object_event_callback_add(
129 bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
130 153
131 edje_obj = edje_object_add(evas); 154 edje_obj = edje_object_add(evas);
132 155
156 snprintf(edje_file_path, sizeof(edje_file_path),
157 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
158 printf("%s\n", edje_file_path);
133 /* exercising Edje loading error, on purpose */ 159 /* exercising Edje loading error, on purpose */
134 if (!edje_object_file_set(edje_obj, edje_file_path, "unexistant_group")) 160 if (!edje_object_file_set(edje_obj, edje_file_path, "unexistant_group"))
135 { 161 {
@@ -147,7 +173,7 @@ main(void)
147 errmsg); 173 errmsg);
148 174
149 evas_object_del(edje_obj); 175 evas_object_del(edje_obj);
150 goto error_edj; 176 goto free_prefix;
151 } 177 }
152 178
153 fprintf(stdout, "Loaded Edje object bound to group 'example_group' from" 179 fprintf(stdout, "Loaded Edje object bound to group 'example_group' from"
@@ -157,6 +183,11 @@ main(void)
157 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40); 183 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
158 evas_object_show(edje_obj); 184 evas_object_show(edje_obj);
159 185
186 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, edje_obj);
187
188 snprintf(border_img_path, sizeof(border_img_path),
189 "%s/edje/examples/red.png", eina_prefix_data_get(pfx));
190
160 /* this is a border around the Edje object above, here just to 191 /* this is a border around the Edje object above, here just to
161 * emphasize its geometry */ 192 * emphasize its geometry */
162 border = evas_object_image_filled_add(evas); 193 border = evas_object_image_filled_add(evas);
@@ -203,24 +234,24 @@ main(void)
203 "y = %d, w = %d, h = %d\n", x, y, w, h); 234 "y = %d, w = %d, h = %d\n", x, y, w, h);
204 235
205 fprintf(stdout, commands); 236 fprintf(stdout, commands);
237
238 ecore_evas_show(ee);
239
206 ecore_main_loop_begin(); 240 ecore_main_loop_begin();
207 241
242 eina_prefix_free(pfx);
208 ecore_evas_free(ee); 243 ecore_evas_free(ee);
209 ecore_evas_shutdown(); 244 ecore_evas_shutdown();
210 edje_shutdown(); 245 edje_shutdown();
211 return 0;
212 246
213error: 247 return EXIT_SUCCESS;
214 fprintf(stderr, "You got to have at least one evas engine built"
215 " and linked up to ecore-evas for this example to run"
216 " properly.\n");
217 ecore_evas_shutdown();
218 return -1;
219
220error_edj:
221 fprintf(stderr, "Failed to load basic.edj!\n");
222 248
249 free_prefix:
250 eina_prefix_free(pfx);
251 shutdown_edje:
252 edje_shutdown();
253 shutdown_ecore_evas:
223 ecore_evas_shutdown(); 254 ecore_evas_shutdown();
224 return -2;
225}
226 255
256 return EXIT_FAILURE;
257}
diff --git a/libraries/edje/src/examples/edje-box.c b/libraries/edje/src/examples/edje-box.c
index 7fffba3..2b0cbda 100644
--- a/libraries/edje/src/examples/edje-box.c
+++ b/libraries/edje/src/examples/edje-box.c
@@ -10,10 +10,9 @@
10 */ 10 */
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13#include "config.h" 13# include "config.h"
14#else 14#else
15#define PACKAGE_EXAMPLES_DIR "." 15# define __UNUSED__
16#define __UNUSED__
17#endif 16#endif
18 17
19#include <Ecore.h> 18#include <Ecore.h>
@@ -28,13 +27,13 @@
28 27
29#define NRECTS 20 28#define NRECTS 20
30 29
31static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/box.edj"; 30static const char commands[] = \
32 31 "commands are:\n"
33struct _App { 32 "\ti - prepend rectangle\n"
34 Ecore_Evas *ee; 33 "\ta - append rectangle\n"
35 Evas_Object *edje; 34 "\tc - remove\n"
36 Evas_Object *bg; 35 "\tEsc - exit\n"
37}; 36 "\th - print help\n";
38 37
39static void 38static void
40_on_destroy(Ecore_Evas *ee __UNUSED__) 39_on_destroy(Ecore_Evas *ee __UNUSED__)
@@ -45,32 +44,41 @@ _on_destroy(Ecore_Evas *ee __UNUSED__)
45/* here just to keep our example's window size and background image's 44/* here just to keep our example's window size and background image's
46 * size in synchrony */ 45 * size in synchrony */
47static void 46static void
48_canvas_resize_cb(Ecore_Evas *ee) 47_on_canvas_resize(Ecore_Evas *ee)
49{ 48{
50 int w, h; 49 Evas_Object *bg;
51 struct _App *app = ecore_evas_data_get(ee, "app"); 50 Evas_Object *edje_obj;
51 int w;
52 int h;
52 53
54 bg = ecore_evas_data_get(ee, "background");
55 edje_obj = ecore_evas_data_get(ee, "edje_obj");
53 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 56 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
54 evas_object_resize(app->bg, w, h); 57 evas_object_resize(bg, w, h);
55 evas_object_resize(app->edje, w, h); 58 evas_object_resize(edje_obj, w, h);
56} 59}
57 60
58static void 61static void
59_rect_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info) 62_on_rect_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info)
60{ 63{
61 struct _App *app = data; 64 Ecore_Evas *ee;
62 Evas_Event_Mouse_Down *ev = event_info; 65 Evas_Event_Mouse_Down *ev;
66 Evas_Object *edje_obj;
67
68 ee = (Ecore_Evas *)data;
69 ev = (Evas_Event_Mouse_Down *)event_info;
70 edje_obj = ecore_evas_data_get(ee, "edje_obj");
63 71
64 if (ev->button == 1) 72 if (ev->button == 1)
65 { 73 {
66 printf("Removing rect %p under the mouse pointer.\n", o); 74 printf("Removing rect %p under the mouse pointer.\n", o);
67 edje_object_part_box_remove(app->edje, "example/box", o); 75 edje_object_part_box_remove(edje_obj, "example/box", o);
68 evas_object_del(o); 76 evas_object_del(o);
69 } 77 }
70 else if (ev->button == 3) 78 else if (ev->button == 3)
71 { 79 {
72 Evas_Object *rect; 80 Evas_Object *rect;
73 Eina_Bool r; 81 Eina_Bool r;
74 82
75 rect = evas_object_rectangle_add(e); 83 rect = evas_object_rectangle_add(e);
76 evas_object_color_set(rect, 0, 0, 255, 255); 84 evas_object_color_set(rect, 0, 0, 255, 255);
@@ -78,23 +86,32 @@ _rect_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info)
78 evas_object_show(rect); 86 evas_object_show(rect);
79 87
80 printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect); 88 printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect);
81 r = edje_object_part_box_insert_before(app->edje, "example/box", rect, o); 89 r = edje_object_part_box_insert_before(edje_obj, "example/box", rect, o);
82 if (!r) 90 if (!r)
83 printf("An error ocurred when appending rect %p to the box.\n", rect); 91 printf("An error ocurred when appending rect %p to the box.\n", rect);
84 92
85 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _rect_mouse_down, app); 93 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, NULL);
86 } 94 }
87} 95}
88 96
89static void 97static void
90_bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info) 98_on_bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
91{ 99{
92 struct _App *app = data; 100 Ecore_Evas *ee;
93 Evas_Event_Key_Down *ev = event_info; 101 Evas_Event_Key_Down *ev;
94 Evas_Object *rect; 102 Evas_Object *edje_obj;
95 Eina_Bool r; 103 Evas_Object *rect;
104 Eina_Bool r;
96 105
106 ee = (Ecore_Evas *)data;
107 ev = (Evas_Event_Key_Down *)event_info;
108 edje_obj = ecore_evas_data_get(ee, "edje_obj");
97 109
110 if (!strcmp(ev->keyname, "h"))
111 {
112 fprintf(stdout, commands);
113 return;
114 }
98 if (!strcmp(ev->keyname, "i")) 115 if (!strcmp(ev->keyname, "i"))
99 { 116 {
100 rect = evas_object_rectangle_add(e); 117 rect = evas_object_rectangle_add(e);
@@ -103,11 +120,11 @@ _bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
103 evas_object_show(rect); 120 evas_object_show(rect);
104 121
105 printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect); 122 printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect);
106 r = edje_object_part_box_insert_at(app->edje, "example/box", rect, 0); 123 r = edje_object_part_box_insert_at(edje_obj, "example/box", rect, 0);
107 if (!r) 124 if (!r)
108 printf("An error ocurred when appending rect %p to the box.\n", rect); 125 printf("An error ocurred when appending rect %p to the box.\n", rect);
109 126
110 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _rect_mouse_down, app); 127 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, NULL);
111 } 128 }
112 else if (!strcmp(ev->keyname, "a")) 129 else if (!strcmp(ev->keyname, "a"))
113 { 130 {
@@ -117,53 +134,82 @@ _bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
117 evas_object_show(rect); 134 evas_object_show(rect);
118 135
119 printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect); 136 printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect);
120 r = edje_object_part_box_append(app->edje, "example/box", rect); 137 r = edje_object_part_box_append(edje_obj, "example/box", rect);
121 if (!r) 138 if (!r)
122 printf("An error ocurred when appending rect %p to the box.\n", rect); 139 printf("An error ocurred when appending rect %p to the box.\n", rect);
123 140
124 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _rect_mouse_down, app); 141 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, NULL);
125 } 142 }
126 else if (!strcmp(ev->keyname, "c")) 143 else if (!strcmp(ev->keyname, "c"))
127 edje_object_part_box_remove_all(app->edje, "example/box", EINA_TRUE); 144 edje_object_part_box_remove_all(edje_obj, "example/box", EINA_TRUE);
145 else if (!strcmp(ev->keyname, "Escape"))
146 ecore_main_loop_quit();
147 else
148 {
149 printf("unhandled key: %s\n", ev->keyname);
150 fprintf(stdout, commands);
151 }
128} 152}
129 153
130int 154int
131main(void) 155main(int argc __UNUSED__, char *argv[])
132{ 156{
133 Evas *evas; 157 char edje_file_path[PATH_MAX];
134 struct _App app; 158 const char *edje_file = "box.edj";
135 int i; 159 Ecore_Evas *ee;
136 160 Evas *evas;
137 ecore_evas_init(); 161 Evas_Object *bg;
138 edje_init(); 162 Evas_Object *edje_obj;
163 Eina_Prefix *pfx;
164 int i;
165
166 if (!ecore_evas_init())
167 return EXIT_FAILURE;
168
169 if (!edje_init())
170 goto shutdown_ecore_evas;
171
172 pfx = eina_prefix_new(argv[0], main,
173 "EDJE_EXAMPLES",
174 "edje/examples",
175 edje_file,
176 PACKAGE_BIN_DIR,
177 PACKAGE_LIB_DIR,
178 PACKAGE_DATA_DIR,
179 PACKAGE_DATA_DIR);
180 if (!pfx)
181 goto shutdown_edje;
139 182
140 /* this will give you a window with an Evas canvas under the first 183 /* this will give you a window with an Evas canvas under the first
141 * engine available */ 184 * engine available */
142 app.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 185 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
143 186 if (!ee)
144 ecore_evas_callback_destroy_set(app.ee, _on_destroy); 187 goto free_prefix;
145 ecore_evas_callback_resize_set(app.ee, _canvas_resize_cb);
146 ecore_evas_title_set(app.ee, "Edje Box Example");
147 ecore_evas_show(app.ee);
148 188
149 ecore_evas_data_set(app.ee, "app", &app); 189 ecore_evas_callback_destroy_set(ee, _on_destroy);
190 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
191 ecore_evas_title_set(ee, "Edje Box Example");
150 192
151 evas = ecore_evas_get(app.ee); 193 evas = ecore_evas_get(ee);
152 194
153 app.bg = evas_object_rectangle_add(evas); 195 bg = evas_object_rectangle_add(evas);
154 evas_object_color_set(app.bg, 255, 255, 255, 255); 196 evas_object_color_set(bg, 255, 255, 255, 255);
155 evas_object_resize(app.bg, WIDTH, HEIGHT); 197 evas_object_resize(bg, WIDTH, HEIGHT);
156 evas_object_focus_set(app.bg, EINA_TRUE); 198 evas_object_focus_set(bg, EINA_TRUE);
157 evas_object_show(app.bg); 199 evas_object_show(bg);
200 ecore_evas_data_set(ee, "background", bg);
158 201
159 evas_object_event_callback_add(app.bg, EVAS_CALLBACK_KEY_DOWN, _bg_key_down, &app); 202 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, ee);
160 203
161 app.edje = edje_object_add(evas); 204 edje_obj = edje_object_add(evas);
162 205
163 edje_object_file_set(app.edje, edje_file_path, "example/group"); 206 snprintf(edje_file_path, sizeof(edje_file_path),
164 evas_object_move(app.edje, 0, 0); 207 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
165 evas_object_resize(app.edje, WIDTH, HEIGHT); 208 edje_object_file_set(edje_obj, edje_file_path, "example/group");
166 evas_object_show(app.edje); 209 evas_object_move(edje_obj, 0, 0);
210 evas_object_resize(edje_obj, WIDTH, HEIGHT);
211 evas_object_show(edje_obj);
212 ecore_evas_data_set(ee, "edje_obj", edje_obj);
167 213
168 for (i = 0; i < NRECTS; i++) 214 for (i = 0; i < NRECTS; i++)
169 { 215 {
@@ -173,19 +219,34 @@ main(void)
173 rect = evas_object_rectangle_add(evas); 219 rect = evas_object_rectangle_add(evas);
174 evas_object_color_set(rect, red, 0, 0, 255); 220 evas_object_color_set(rect, red, 0, 0, 255);
175 evas_object_resize(rect, RECTW, RECTH); 221 evas_object_resize(rect, RECTW, RECTH);
176 r = edje_object_part_box_append(app.edje, "example/box", rect); 222 r = edje_object_part_box_append(edje_obj, "example/box", rect);
177 if (!r) 223 if (!r)
178 printf("An error ocurred when appending rect #%d to the box.\n", i); 224 printf("An error ocurred when appending rect #%d to the box.\n", i);
179 evas_object_show(rect); 225 evas_object_show(rect);
180 226
181 evas_object_event_callback_add( 227 evas_object_event_callback_add(
182 rect, EVAS_CALLBACK_MOUSE_DOWN, _rect_mouse_down, &app); 228 rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, ee);
183 } 229 }
184 230
231 fprintf(stdout, commands);
232
233 ecore_evas_show(ee);
234
185 ecore_main_loop_begin(); 235 ecore_main_loop_begin();
186 236
187 ecore_evas_free(app.ee); 237 eina_prefix_free(pfx);
238 ecore_evas_free(ee);
188 ecore_evas_shutdown(); 239 ecore_evas_shutdown();
189 edje_shutdown(); 240 edje_shutdown();
190 return 0; 241
242 return EXIT_SUCCESS;
243
244 free_prefix:
245 eina_prefix_free(pfx);
246 shutdown_edje:
247 edje_shutdown();
248 shutdown_ecore_evas:
249 ecore_evas_shutdown();
250
251 return EXIT_FAILURE;
191} 252}
diff --git a/libraries/edje/src/examples/edje-box2.c b/libraries/edje/src/examples/edje-box2.c
index b3f4e40..81f1a90 100644
--- a/libraries/edje/src/examples/edje-box2.c
+++ b/libraries/edje/src/examples/edje-box2.c
@@ -10,40 +10,35 @@
10 */ 10 */
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13#include "config.h" 13# include "config.h"
14#else 14#else
15#define PACKAGE_EXAMPLES_DIR "." 15# define __UNUSED__
16#define __UNUSED__
17#endif 16#endif
18 17
19#include <Ecore.h>
20#include <Evas.h>
21#include <Ecore_Evas.h>
22#include <Edje.h>
23
24#include <stdlib.h> 18#include <stdlib.h>
25#include <stdio.h> 19#include <stdio.h>
26#include <string.h> 20#include <string.h>
27 21
28static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/box.edj"; 22#include <Ecore.h>
29 23#include <Evas.h>
30struct _App { 24#include <Ecore_Evas.h>
31 Ecore_Evas *ee; 25#include <Edje.h>
32 Evas *evas;
33 Evas_Object *bg;
34 Evas_Object *box;
35};
36 26
37static struct _App app; 27static const char commands[] = \
28 "commands are:\n"
29 "\tShift - remove box\n"
30 "\tCtrl - insert box\n"
31 "\tEsc - exit\n"
32 "\th - print help\n";
38 33
39static void 34static void
40custom_layout(Evas_Object *o, Evas_Object_Box_Data *p, void *data) 35custom_layout(Evas_Object *o, Evas_Object_Box_Data *p, void *data __UNUSED__)
41{ 36{
37 Evas_Object_Box_Option *opt;
38 Eina_List *l;
42 int x, y, w, h; 39 int x, y, w, h;
43 int xx, yy, ww, hh; 40 int xx, yy, ww, hh;
44 int count; 41 int count;
45 Eina_List *l;
46 Evas_Object_Box_Option *opt;
47 42
48 evas_object_geometry_get(o, &x, &y, &w, &h); 43 evas_object_geometry_get(o, &x, &y, &w, &h);
49 count = eina_list_count(p->children); 44 count = eina_list_count(p->children);
@@ -76,129 +71,177 @@ new_greenie_block(Evas *e)
76} 71}
77 72
78static void 73static void
79on_keydown(void *data, Evas *evas, Evas_Object *o, void *einfo) 74on_keydown(void *data, Evas *evas, Evas_Object *o __UNUSED__, void *einfo)
80{ 75{
81 struct _App *app = data; 76 Evas_Event_Key_Down *ev;
82 Evas_Event_Key_Down *ev = einfo; 77 Evas_Object *edje_obj;
83 const Evas_Modifier *mods; 78 const Evas_Modifier *mods;
84 79
80 ev = (Evas_Event_Key_Down *)einfo;
81 edje_obj = (Evas_Object *)data;
82
85 mods = evas_key_modifier_get(evas); 83 mods = evas_key_modifier_get(evas);
84 if (!strcmp(ev->keyname, "h"))
85 {
86 fprintf(stdout, commands);
87 return;
88 }
86 if (evas_key_modifier_is_set(mods, "Shift")) 89 if (evas_key_modifier_is_set(mods, "Shift"))
87 { 90 {
88 int pos; 91 int pos;
89 Evas_Object *obj = NULL; 92 Evas_Object *obj = NULL;
90 pos = atoi(ev->keyname); 93 pos = atoi(ev->keyname);
91 obj = edje_object_part_box_remove_at(app->box, "example/box", pos); 94 obj = edje_object_part_box_remove_at(edje_obj, "example/box", pos);
92 if (obj) 95 if (obj)
93 evas_object_del(obj); 96 evas_object_del(obj);
94 return; 97 return;
95 } 98 }
96 if (evas_key_modifier_is_set(mods, "Control")) 99 if (evas_key_modifier_is_set(mods, "Control"))
97 { 100 {
98 Evas_Object *o; 101 Evas_Object *obj;
99 int pos; 102 int pos;
100 pos = atoi(ev->keyname); 103 pos = atoi(ev->keyname);
101 o = new_greenie_block(app->evas); 104 obj = new_greenie_block(evas);
102 if (!edje_object_part_box_insert_at(app->box, "example/box", o, pos)) 105 if (!edje_object_part_box_insert_at(edje_obj, "example/box", obj, pos))
103 edje_object_part_box_append(app->box, "example/box", o); 106 edje_object_part_box_append(edje_obj, "example/box", obj);
104 return; 107 return;
105 } 108 }
106 if (strcmp(ev->keyname, "Escape") == 0) 109 if (!strcmp(ev->keyname, "Escape"))
107 ecore_main_loop_quit(); 110 ecore_main_loop_quit();
108} 111}
109 112
110static Evas_Object * 113static Evas_Object *
111box_new(Evas *evas, const char *name, int x, int y, int w, int h) 114box_new(Ecore_Evas *ee, const char *edje_file_path, const char *name, int x, int y, int w, int h)
112{ 115{
113 Evas_Object *o; 116 Evas_Object *edje_obj;
114 117
115 o = edje_object_add(evas); 118 edje_obj = edje_object_add(ecore_evas_get(ee));
116 evas_object_move(o, x, y); 119 evas_object_move(edje_obj, x, y);
117 evas_object_resize(o, w, h); 120 evas_object_resize(edje_obj, w, h);
118 if (!edje_object_file_set(o, edje_file_path, "example/group2")) 121 if (!edje_object_file_set(edje_obj, edje_file_path, "example/group2"))
119 { 122 {
120 printf("error: could not load file object.\n"); 123 printf("error: could not load file object.\n");
121 } 124 }
122 evas_object_show(o); 125 evas_object_show(edje_obj);
123 126 evas_object_name_set(edje_obj, name);
124 evas_object_name_set(o, name); 127 ecore_evas_data_set(ee, "edje_obj", edje_obj);
125 128
126 return o; 129 return edje_obj;
127} 130}
128 131
129static void 132static void
130on_resize(Ecore_Evas *ee) 133on_resize(Ecore_Evas *ee)
131{ 134{
132 int w, h; 135 Evas_Object *bg;
133 136 Evas_Object *edje_obj;
134 evas_output_viewport_get(app.evas, NULL, NULL, &w, &h); 137 int w;
135 evas_object_resize(app.bg, w, h); 138 int h;
136 evas_object_resize(app.box, w, h); 139
140 bg = ecore_evas_data_get(ee, "background");
141 edje_obj = ecore_evas_data_get(ee, "edje_obj");
142 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
143 evas_object_resize(bg, w, h);
144 evas_object_resize(edje_obj, w, h);
137} 145}
138 146
139static void 147static void
140on_destroy(Ecore_Evas *ee) 148on_destroy(Ecore_Evas *ee __UNUSED__)
141{ 149{
142 ecore_main_loop_quit(); 150 ecore_main_loop_quit();
143} 151}
144 152
145int 153int
146main(int argc, char *argv[]) 154main(int argc __UNUSED__, char *argv[])
147{ 155{
148 Ecore_Evas *ee; 156 char edje_file_path[PATH_MAX];
149 int w, h, i; 157 const char *edje_file = "box.edj";
158 Ecore_Evas *ee;
159 Evas *evas;
160 Evas_Object *bg;
161 Evas_Object *edje_obj;
150 Evas_Object *last; 162 Evas_Object *last;
151 Evas_Object *o; 163 Evas_Object *o;
152 164 Eina_Prefix *pfx;
153 evas_init(); 165 int w;
154 ecore_init(); 166 int h;
155 ecore_evas_init(); 167 int i;
156 edje_init(); 168
157 169 if (!ecore_evas_init())
170 return EXIT_FAILURE;
171
172 if (!edje_init())
173 goto shutdown_ecore_evas;
174
175 pfx = eina_prefix_new(argv[0], main,
176 "EDJE_EXAMPLES",
177 "edje/examples",
178 edje_file,
179 PACKAGE_BIN_DIR,
180 PACKAGE_LIB_DIR,
181 PACKAGE_DATA_DIR,
182 PACKAGE_DATA_DIR);
183 if (!pfx)
184 goto shutdown_edje;
185
186 /* this will give you a window with an Evas canvas under the first
187 * engine available */
158 ee = ecore_evas_new(NULL, 0, 0, 640, 480, NULL); 188 ee = ecore_evas_new(NULL, 0, 0, 640, 480, NULL);
159 ecore_evas_show(ee); 189 if (!ee)
160 190 goto free_prefix;
161 app.ee = ee;
162 app.evas = ecore_evas_get(ee);
163 191
164 ecore_evas_callback_resize_set(ee, on_resize); 192 ecore_evas_callback_resize_set(ee, on_resize);
165 ecore_evas_callback_destroy_set(ee, on_destroy); 193 ecore_evas_callback_destroy_set(ee, on_destroy);
194 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
166 195
167 evas_output_viewport_get(app.evas, NULL, NULL, &w, &h); 196 evas = ecore_evas_get(ee);
168 197
169 app.bg = evas_object_rectangle_add(app.evas); 198 bg = evas_object_rectangle_add(evas);
170 evas_object_resize(app.bg, w, h); 199 evas_object_resize(bg, w, h);
171 evas_object_show(app.bg); 200 evas_object_show(bg);
172 evas_object_focus_set(app.bg, 1); 201 evas_object_focus_set(bg, 1);
173 evas_object_event_callback_add( 202 ecore_evas_data_set(ee, "background", bg);
174 app.bg, EVAS_CALLBACK_KEY_DOWN, on_keydown, &app);
175 203
176 edje_box_layout_register("custom_layout", custom_layout, NULL, NULL, NULL, NULL); 204 edje_box_layout_register("custom_layout", custom_layout, NULL, NULL, NULL, NULL);
177 205
178 app.box = box_new(app.evas, "box", 0, 0, w, h); 206 snprintf(edje_file_path, sizeof(edje_file_path),
207 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
208 edje_obj = box_new(ee, edje_file_path, "box", 0, 0, w, h);
209 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, on_keydown, edje_obj);
179 210
180 for (i = 1; i <= 5; i++) 211 for (i = 1; i <= 5; i++)
181 { 212 {
182 o = last = evas_object_rectangle_add(app.evas); 213 o = last = evas_object_rectangle_add(evas);
183 evas_object_size_hint_min_set(o, 50, 50); 214 evas_object_size_hint_min_set(o, 50, 50);
184 evas_object_resize(o, 50, 50); 215 evas_object_resize(o, 50, 50);
185 evas_object_color_set(o, 255, 0, 0, 128); 216 evas_object_color_set(o, 255, 0, 0, 128);
186 evas_object_show(o); 217 evas_object_show(o);
187 218
188 if (!edje_object_part_box_append(app.box, "example/box", o)) 219 if (!edje_object_part_box_append(edje_obj, "example/box", o))
189 { 220 {
190 fprintf(stderr, "error appending child object!\n"); 221 fprintf(stderr, "error appending child object!\n");
191 return 1; 222 return 1;
192 } 223 }
193 } 224 }
194 225
226 fprintf(stdout, commands);
227
228 ecore_evas_show(ee);
229
195 ecore_main_loop_begin(); 230 ecore_main_loop_begin();
196 231
197 edje_shutdown(); 232 eina_prefix_free(pfx);
233 ecore_evas_free(ee);
198 ecore_evas_shutdown(); 234 ecore_evas_shutdown();
199 ecore_shutdown(); 235 edje_shutdown();
200 evas_shutdown(); 236
237 return EXIT_SUCCESS;
201 238
239 free_prefix:
240 eina_prefix_free(pfx);
241 shutdown_edje:
242 edje_shutdown();
243 shutdown_ecore_evas:
244 ecore_evas_shutdown();
202 245
203 return 0; 246 return EXIT_FAILURE;
204} 247}
diff --git a/libraries/edje/src/examples/edje-color-class.c b/libraries/edje/src/examples/edje-color-class.c
index 9ac8653..8d073d0 100644
--- a/libraries/edje/src/examples/edje-color-class.c
+++ b/libraries/edje/src/examples/edje-color-class.c
@@ -10,10 +10,9 @@
10 */ 10 */
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13#include "config.h" 13# include "config.h"
14#else 14#else
15#define PACKAGE_EXAMPLES_DIR "." 15# define __UNUSED__
16#define __UNUSED__
17#endif 16#endif
18 17
19#include <Ecore.h> 18#include <Ecore.h>
@@ -23,13 +22,11 @@
23#define WIDTH (400) 22#define WIDTH (400)
24#define HEIGHT (400) 23#define HEIGHT (400)
25 24
26static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/color-class.edj";
27
28typedef int color[4]; /* rgba */ 25typedef int color[4]; /* rgba */
29 26
30static Ecore_Evas *ee, *ee2; 27static Ecore_Evas *ee1, *ee2;
31static Evas *evas, *evas2; 28static Evas *evas1, *evas2;
32static Evas_Object *bg, *edje_obj, *bg2, *edje_obj2; 29static Evas_Object *bg1, *edje_obj1, *bg2, *edje_obj2;
33static const char *selected_class; 30static const char *selected_class;
34 31
35static color colors_init_data[] = 32static color colors_init_data[] =
@@ -96,21 +93,23 @@ _color_classes_print(void)
96} 93}
97 94
98static void 95static void
99_on_destroy(Ecore_Evas *ee) 96_on_destroy(Ecore_Evas *ee __UNUSED__)
100{ 97{
101 ecore_main_loop_quit(); 98 ecore_main_loop_quit();
102} 99}
103 100
104static void 101static void
105_on_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) 102_on_mouse_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
106{ 103{
107 Evas_Event_Mouse_Down *ev = event_info; 104 Evas_Event_Mouse_Down *ev = event_info;
108 105
109 if (ev->button == 1) 106 if (ev->button == 1)
110 if (obj == edje_obj) 107 {
111 edje_color_class_del(selected_class); 108 if (obj == edje_obj1)
112 else 109 edje_color_class_del(selected_class);
113 edje_object_color_class_del(edje_obj2, selected_class); 110 else
111 edje_object_color_class_del(edje_obj2, selected_class);
112 }
114} 113}
115 114
116/* here just to keep our example's window size 115/* here just to keep our example's window size
@@ -122,10 +121,10 @@ _canvas_resize_cb(Ecore_Evas *_ee)
122 121
123 ecore_evas_geometry_get(_ee, NULL, NULL, &w, &h); 122 ecore_evas_geometry_get(_ee, NULL, NULL, &w, &h);
124 123
125 if (_ee == ee) 124 if (_ee == ee1)
126 { 125 {
127 evas_object_resize(bg, w, h); 126 evas_object_resize(bg1, w, h);
128 evas_object_resize(edje_obj, w, h); 127 evas_object_resize(edje_obj1, w, h);
129 } 128 }
130 else 129 else
131 { 130 {
@@ -135,8 +134,8 @@ _canvas_resize_cb(Ecore_Evas *_ee)
135} 134}
136 135
137static void 136static void
138_color_class_callback_delete(void *data, Evas *evas, Evas_Object *obj, 137_color_class_callback_delete(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
139 const char *emission, void *source) 138 const char *emission, void *source __UNUSED__)
140{ 139{
141 if (!strcmp(data, "process")) 140 if (!strcmp(data, "process"))
142 fprintf(stdout, "Color class: %s deleted on process level\n", emission); 141 fprintf(stdout, "Color class: %s deleted on process level\n", emission);
@@ -144,32 +143,34 @@ _color_class_callback_delete(void *data, Evas *evas, Evas_Object *obj,
144 fprintf(stdout, "Color class: %s deleted on object level\n", emission); 143 fprintf(stdout, "Color class: %s deleted on object level\n", emission);
145} 144}
146 145
147static void 146static int
148_create_windows(void) 147_create_windows(const char *edje_file_path)
149{ 148{
150 /* this will give you a window with an Evas canvas under the first 149 /* this will give you a window with an Evas canvas under the first
151 * engine available */ 150 * engine available */
152 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 151 ee1 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
152 if (!ee1)
153 return 0;
153 ee2 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 154 ee2 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
155 if (!ee2)
156 return 0;
154 157
155 ecore_evas_callback_destroy_set(ee, _on_destroy); 158 ecore_evas_callback_destroy_set(ee1, _on_destroy);
156 ecore_evas_callback_resize_set(ee, _canvas_resize_cb); 159 ecore_evas_callback_resize_set(ee1, _canvas_resize_cb);
157 ecore_evas_title_set(ee, "Edje Color Class Example"); 160 ecore_evas_title_set(ee1, "Edje Color Class Example");
158 ecore_evas_show(ee);
159 161
160 ecore_evas_callback_destroy_set(ee2, _on_destroy); 162 ecore_evas_callback_destroy_set(ee2, _on_destroy);
161 ecore_evas_callback_resize_set(ee2, _canvas_resize_cb); 163 ecore_evas_callback_resize_set(ee2, _canvas_resize_cb);
162 ecore_evas_title_set(ee2, "Edje Object Color Class Example"); 164 ecore_evas_title_set(ee2, "Edje Object Color Class Example");
163 ecore_evas_show(ee2);
164 165
165 evas = ecore_evas_get(ee); 166 evas1 = ecore_evas_get(ee1);
166 evas2 = ecore_evas_get(ee2); 167 evas2 = ecore_evas_get(ee2);
167 168
168 bg = evas_object_rectangle_add(evas); 169 bg1 = evas_object_rectangle_add(evas1);
169 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ 170 evas_object_color_set(bg1, 255, 255, 255, 255); /* white bg */
170 evas_object_move(bg, 0, 0); /* at canvas' origin */ 171 evas_object_move(bg1, 0, 0); /* at canvas' origin */
171 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ 172 evas_object_resize(bg1, WIDTH, HEIGHT); /* covers full canvas */
172 evas_object_show(bg); 173 evas_object_show(bg1);
173 174
174 bg2 = evas_object_rectangle_add(evas2); 175 bg2 = evas_object_rectangle_add(evas2);
175 evas_object_color_set(bg2, 255, 255, 255, 255); /* white bg */ 176 evas_object_color_set(bg2, 255, 255, 255, 255); /* white bg */
@@ -177,18 +178,18 @@ _create_windows(void)
177 evas_object_resize(bg2, WIDTH, HEIGHT); /* covers full canvas */ 178 evas_object_resize(bg2, WIDTH, HEIGHT); /* covers full canvas */
178 evas_object_show(bg2); 179 evas_object_show(bg2);
179 180
180 edje_obj = edje_object_add(evas); 181 edje_obj1 = edje_object_add(evas1);
181 evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_MOUSE_DOWN, 182 evas_object_event_callback_add(edje_obj1, EVAS_CALLBACK_MOUSE_DOWN,
182 _on_mouse_down, NULL); 183 _on_mouse_down, NULL);
183 184
184 edje_object_file_set(edje_obj, edje_file_path, "example_color_class"); 185 edje_object_file_set(edje_obj1, edje_file_path, "example_color_class");
185 evas_object_move(edje_obj, 0, 0); /* at canvas' origin */ 186 evas_object_move(edje_obj1, 0, 0); /* at canvas' origin */
186 evas_object_resize(edje_obj, WIDTH, HEIGHT); 187 evas_object_resize(edje_obj1, WIDTH, HEIGHT);
187 edje_object_part_text_set(edje_obj, "part_four", "EDJE EXAMPLE"); 188 edje_object_part_text_set(edje_obj1, "part_four", "EDJE EXAMPLE");
188 edje_object_signal_callback_add(edje_obj, "color_class,del", "*", 189 edje_object_signal_callback_add(edje_obj1, "color_class,del", "*",
189 (Edje_Signal_Cb) _color_class_callback_delete, 190 (Edje_Signal_Cb) _color_class_callback_delete,
190 "process"); 191 "process");
191 evas_object_show(edje_obj); 192 evas_object_show(edje_obj1);
192 193
193 edje_obj2 = edje_object_add(evas2); 194 edje_obj2 = edje_object_add(evas2);
194 evas_object_event_callback_add(edje_obj2, EVAS_CALLBACK_MOUSE_DOWN, 195 evas_object_event_callback_add(edje_obj2, EVAS_CALLBACK_MOUSE_DOWN,
@@ -202,13 +203,18 @@ _create_windows(void)
202 (Edje_Signal_Cb) _color_class_callback_delete, 203 (Edje_Signal_Cb) _color_class_callback_delete,
203 "object"); 204 "object");
204 evas_object_show(edje_obj2); 205 evas_object_show(edje_obj2);
206
207 return 1;
205} 208}
206 209
207int 210int
208main(int argc, char *argv[]) 211main(int argc, char *argv[])
209{ 212{
210 color c1, c2, c3; 213 char edje_file_path[PATH_MAX];
211 int i; 214 const char *edje_file = "color-class.edj";
215 Eina_Prefix *pfx;
216 color c1, c2, c3;
217 int i;
212 218
213 if (argc != 5) 219 if (argc != 5)
214 { 220 {
@@ -218,7 +224,7 @@ main(int argc, char *argv[])
218 for (i = 0; i < 8; i++) 224 for (i = 0; i < 8; i++)
219 fprintf(stderr, "%s\n", color_names[i]); 225 fprintf(stderr, "%s\n", color_names[i]);
220 226
221 return 1; 227 return EXIT_FAILURE;
222 } 228 }
223 229
224 selected_class = argv[1]; 230 selected_class = argv[1];
@@ -227,13 +233,30 @@ main(int argc, char *argv[])
227 _get_color_from_name(argv[4], &c3))) 233 _get_color_from_name(argv[4], &c3)))
228 { 234 {
229 fprintf(stderr, "Color not available!\n"); 235 fprintf(stderr, "Color not available!\n");
230 return 2; 236 return EXIT_FAILURE;
231 } 237 }
232 238
233 ecore_evas_init(); 239 if (!ecore_evas_init())
234 edje_init(); 240 return EXIT_FAILURE;
241
242 if (!edje_init())
243 goto shutdown_ecore_evas;
244
245 pfx = eina_prefix_new(argv[0], main,
246 "EDJE_EXAMPLES",
247 "edje/examples",
248 edje_file,
249 PACKAGE_BIN_DIR,
250 PACKAGE_LIB_DIR,
251 PACKAGE_DATA_DIR,
252 PACKAGE_DATA_DIR);
253 if (!pfx)
254 goto shutdown_edje;
235 255
236 _create_windows(); 256 snprintf(edje_file_path, sizeof(edje_file_path),
257 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
258 if (!_create_windows(edje_file_path))
259 goto free_prefix;
237 260
238 edje_color_class_set(argv[1], /* class name */ 261 edje_color_class_set(argv[1], /* class name */
239 c1[0], c1[1], c1[2], c1[3], /* Object color */ 262 c1[0], c1[1], c1[2], c1[3], /* Object color */
@@ -248,10 +271,25 @@ main(int argc, char *argv[])
248 39, 90, 187, 255); /* Text shadow */ 271 39, 90, 187, 255); /* Text shadow */
249 272
250 _color_classes_print(); 273 _color_classes_print();
274
275 ecore_evas_show(ee1);
276 ecore_evas_show(ee2);
277
251 ecore_main_loop_begin(); 278 ecore_main_loop_begin();
252 ecore_evas_free(ee); 279
253 ecore_evas_free(ee2); 280 eina_prefix_free(pfx);
281 ecore_evas_free(ee1);
254 ecore_evas_shutdown(); 282 ecore_evas_shutdown();
255 edje_shutdown(); 283 edje_shutdown();
256 return 0; 284
285 return EXIT_SUCCESS;
286
287 free_prefix:
288 eina_prefix_free(pfx);
289 shutdown_edje:
290 edje_shutdown();
291 shutdown_ecore_evas:
292 ecore_evas_shutdown();
293
294 return EXIT_FAILURE;
257} 295}
diff --git a/libraries/edje/src/examples/edje-drag.c b/libraries/edje/src/examples/edje-drag.c
index 78e2e72..bb61b68 100644
--- a/libraries/edje/src/examples/edje-drag.c
+++ b/libraries/edje/src/examples/edje-drag.c
@@ -10,10 +10,9 @@
10 */ 10 */
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13#include "config.h" 13# include "config.h"
14#else 14#else
15#define PACKAGE_EXAMPLES_DIR "." 15# define __UNUSED__
16#define __UNUSED__
17#endif 16#endif
18 17
19#include <Ecore.h> 18#include <Ecore.h>
@@ -28,15 +27,17 @@
28 27
29#define NRECTS 20 28#define NRECTS 20
30 29
31static const char *PARTNAME = "example/knob"; 30static const char commands[] = \
32 31 "commands are:\n"
33static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/drag.edj"; 32 "\tDdown - set drag step to 1\n"
33 "\tUp - set drag step to -1\n"
34 "\tm - set drag value to 0.5\n"
35 "\tPrior - set drag page to -1\n"
36 "\tNext - set drag page to -1\n"
37 "\tEsc - exit\n"
38 "\th - print help\n";
34 39
35struct _App { 40static const char *PARTNAME = "example/knob";
36 Ecore_Evas *ee;
37 Evas_Object *edje;
38 Evas_Object *bg;
39};
40 41
41static void 42static void
42_on_destroy(Ecore_Evas *ee __UNUSED__) 43_on_destroy(Ecore_Evas *ee __UNUSED__)
@@ -47,111 +48,163 @@ _on_destroy(Ecore_Evas *ee __UNUSED__)
47/* here just to keep our example's window size and background image's 48/* here just to keep our example's window size and background image's
48 * size in synchrony */ 49 * size in synchrony */
49static void 50static void
50_canvas_resize_cb(Ecore_Evas *ee) 51_on_canvas_resize(Ecore_Evas *ee)
51{ 52{
52 int w, h; 53 Evas_Object *bg;
53 struct _App *app = ecore_evas_data_get(ee, "app"); 54 Evas_Object *edje_obj;
55 int w;
56 int h;
57
58 bg = ecore_evas_data_get(ee, "background");
59 edje_obj = ecore_evas_data_get(ee, "edje_obj");
54 60
55 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 61 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
56 evas_object_resize(app->bg, w, h); 62 evas_object_resize(bg, w, h);
57 evas_object_resize(app->edje, w, h); 63 evas_object_resize(edje_obj, w, h);
58} 64}
59 65
60static void 66static void
61_bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info) 67_on_bg_key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
62{ 68{
63 struct _App *app = data; 69 Ecore_Evas *ee;
64 Evas_Event_Key_Down *ev = event_info; 70 Evas_Event_Key_Down *ev;
65 Evas_Object *rect; 71 Evas_Object *edje_obj;
66 Eina_Bool r;
67 72
73 ee = (Ecore_Evas *)data;
74 ev = (Evas_Event_Key_Down *)event_info;
75 edje_obj = ecore_evas_data_get(ee, "edje_obj");
68 76
69 if (!strcmp(ev->keyname, "Down")) 77 if (!strcmp(ev->keyname, "h"))
70 { 78 {
71 edje_object_part_drag_step(app->edje, PARTNAME, 0, 1.0); 79 fprintf(stdout, commands);
80 return;
81 }
82 else if (!strcmp(ev->keyname, "Down"))
83 {
84 edje_object_part_drag_step(edje_obj, PARTNAME, 0, 1.0);
72 } 85 }
73 else if (!strcmp(ev->keyname, "Up")) 86 else if (!strcmp(ev->keyname, "Up"))
74 { 87 {
75 edje_object_part_drag_step(app->edje, PARTNAME, 0, -1.0); 88 edje_object_part_drag_step(edje_obj, PARTNAME, 0, -1.0);
76 } 89 }
77 else if (!strcmp(ev->keyname, "m")) 90 else if (!strcmp(ev->keyname, "m"))
78 { 91 {
79 edje_object_part_drag_value_set(app->edje, PARTNAME, 0.0, 0.5); 92 edje_object_part_drag_value_set(edje_obj, PARTNAME, 0.0, 0.5);
80 } 93 }
81 else if (!strcmp(ev->keyname, "Prior")) 94 else if (!strcmp(ev->keyname, "Prior"))
82 { 95 {
83 edje_object_part_drag_page(app->edje, PARTNAME, 0.0, -1.0); 96 edje_object_part_drag_page(edje_obj, PARTNAME, 0.0, -1.0);
84 } 97 }
85 else if (!strcmp(ev->keyname, "Next")) 98 else if (!strcmp(ev->keyname, "Next"))
86 { 99 {
87 edje_object_part_drag_page(app->edje, PARTNAME, 0.0, 1.0); 100 edje_object_part_drag_page(edje_obj, PARTNAME, 0.0, 1.0);
88 } 101 }
89 else if (!strcmp(ev->keyname, "Escape")) 102 else if (!strcmp(ev->keyname, "Escape"))
90 ecore_main_loop_quit(); 103 ecore_main_loop_quit();
91 else 104 else
92 printf("unhandled key: %s\n", ev->keyname); 105 {
106 printf("unhandled key: %s\n", ev->keyname);
107 fprintf(stdout, commands);
108 }
93} 109}
94 110
95static void 111static void
96_knob_moved_cb(void *data, Evas_Object *o, const char *emission, const char *source) 112_on_knob_moved(void *data __UNUSED__, Evas_Object *o, const char *emission __UNUSED__, const char *source __UNUSED__)
97{ 113{
98 double val; 114 double val;
115
99 edje_object_part_drag_value_get(o, PARTNAME, NULL, &val); 116 edje_object_part_drag_value_get(o, PARTNAME, NULL, &val);
100 printf("value changed to: %0.3f\n", val); 117 printf("value changed to: %0.3f\n", val);
101} 118}
102 119
103int 120int
104main(void) 121main(int argc __UNUSED__, char *argv[])
105{ 122{
106 Evas *evas; 123 char edje_file_path[PATH_MAX];
107 struct _App app; 124 const char *edje_file = "drag.edj";
108 int i; 125 Ecore_Evas *ee;
109 126 Evas *evas;
110 ecore_evas_init(); 127 Evas_Object *bg;
111 edje_init(); 128 Evas_Object *edje_obj;
129 Eina_Prefix *pfx;
130
131 if (!ecore_evas_init())
132 return EXIT_FAILURE;
133
134 if (!edje_init())
135 goto shutdown_ecore_evas;
136
137 pfx = eina_prefix_new(argv[0], main,
138 "EDJE_EXAMPLES",
139 "edje/examples",
140 edje_file,
141 PACKAGE_BIN_DIR,
142 PACKAGE_LIB_DIR,
143 PACKAGE_DATA_DIR,
144 PACKAGE_DATA_DIR);
145 if (!pfx)
146 goto shutdown_edje;
112 147
113 /* this will give you a window with an Evas canvas under the first 148 /* this will give you a window with an Evas canvas under the first
114 * engine available */ 149 * engine available */
115 app.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 150 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
116 151 if (!ee)
117 ecore_evas_callback_destroy_set(app.ee, _on_destroy); 152 goto free_prefix;
118 ecore_evas_callback_resize_set(app.ee, _canvas_resize_cb);
119 ecore_evas_title_set(app.ee, "Edje Box Example");
120 ecore_evas_show(app.ee);
121 153
122 ecore_evas_data_set(app.ee, "app", &app); 154 ecore_evas_callback_destroy_set(ee, _on_destroy);
155 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
156 ecore_evas_title_set(ee, "Edje Box Example");
123 157
124 evas = ecore_evas_get(app.ee); 158 evas = ecore_evas_get(ee);
125 159
126 app.bg = evas_object_rectangle_add(evas); 160 bg = evas_object_rectangle_add(evas);
127 evas_object_color_set(app.bg, 255, 255, 255, 255); 161 evas_object_color_set(bg, 255, 255, 255, 255);
128 evas_object_resize(app.bg, WIDTH, HEIGHT); 162 evas_object_resize(bg, WIDTH, HEIGHT);
129 evas_object_focus_set(app.bg, EINA_TRUE); 163 evas_object_focus_set(bg, EINA_TRUE);
130 evas_object_show(app.bg); 164 evas_object_show(bg);
165 ecore_evas_data_set(ee, "background", bg);
131 166
132 evas_object_event_callback_add(app.bg, EVAS_CALLBACK_KEY_DOWN, _bg_key_down, &app); 167 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, ee);
133 168
134 app.edje = edje_object_add(evas); 169 edje_obj = edje_object_add(evas);
135 170
136 edje_object_file_set(app.edje, edje_file_path, "example/group"); 171 snprintf(edje_file_path, sizeof(edje_file_path),
137 evas_object_move(app.edje, 0, 0); 172 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
138 evas_object_resize(app.edje, WIDTH, HEIGHT); 173 edje_object_file_set(edje_obj, edje_file_path, "example/group");
139 evas_object_show(app.edje); 174 evas_object_move(edje_obj, 0, 0);
175 evas_object_resize(edje_obj, WIDTH, HEIGHT);
176 evas_object_show(edje_obj);
177 ecore_evas_data_set(ee, "edje_obj", edje_obj);
140 178
141 edje_object_part_drag_size_set(app.edje, PARTNAME, 1.0, 0.4); 179 edje_object_part_drag_size_set(edje_obj, PARTNAME, 1.0, 0.4);
142 180
143 if (!edje_object_part_drag_step_set(app.edje, PARTNAME, 0.0, 0.1)) 181 if (!edje_object_part_drag_step_set(edje_obj, PARTNAME, 0.0, 0.1))
144 printf("error when setting drag step size.\n"); 182 printf("error when setting drag step size.\n");
145 183
146 if (!edje_object_part_drag_page_set(app.edje, PARTNAME, 0.0, 0.3)) 184 if (!edje_object_part_drag_page_set(edje_obj, PARTNAME, 0.0, 0.3))
147 printf("error when setting drag page step size.\n"); 185 printf("error when setting drag page step size.\n");
148 186
149 edje_object_signal_callback_add(app.edje, "drag", PARTNAME, _knob_moved_cb, &app); 187 edje_object_signal_callback_add(edje_obj, "drag", PARTNAME, _on_knob_moved, NULL);
188
189 fprintf(stdout, commands);
190
191 ecore_evas_show(ee);
150 192
151 ecore_main_loop_begin(); 193 ecore_main_loop_begin();
152 194
153 ecore_evas_free(app.ee); 195 eina_prefix_free(pfx);
196 ecore_evas_free(ee);
154 ecore_evas_shutdown(); 197 ecore_evas_shutdown();
155 edje_shutdown(); 198 edje_shutdown();
156 return 0; 199
200 return EXIT_SUCCESS;
201
202 free_prefix:
203 eina_prefix_free(pfx);
204 shutdown_edje:
205 edje_shutdown();
206 shutdown_ecore_evas:
207 ecore_evas_shutdown();
208
209 return EXIT_FAILURE;
157} 210}
diff --git a/libraries/edje/src/examples/edje-perspective.c b/libraries/edje/src/examples/edje-perspective.c
index 5220b74..1037043 100644
--- a/libraries/edje/src/examples/edje-perspective.c
+++ b/libraries/edje/src/examples/edje-perspective.c
@@ -10,10 +10,9 @@
10 */ 10 */
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13#include "config.h" 13# include "config.h"
14#else 14#else
15#define PACKAGE_EXAMPLES_DIR "." 15# define __UNUSED__
16#define __UNUSED__
17#endif 16#endif
18 17
19#include <Ecore.h> 18#include <Ecore.h>
@@ -23,11 +22,21 @@
23#define WIDTH 480 22#define WIDTH 480
24#define HEIGHT 320 23#define HEIGHT 320
25 24
26static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/perspective.edj"; 25static const char commands[] = \
26 "commands are:\n"
27 "\tDown - move part down\n"
28 "\tUp - move part up\n"
29 "\tLeft - move part left\n"
30 "\tRight - move part right\n"
31 "\tPrior - move part up-left\n"
32 "\tNext - move part down-right\n"
33 "\tInsert - increase focal\n"
34 "\tSuppr - decrease focal\n"
35 "\tEsc - exit\n"
36 "\th - print help\n";
27 37
28struct _App { 38struct _App {
29 Ecore_Evas *ee; 39 Evas_Object *edje_obj;
30 Evas_Object *edje;
31 Evas_Object *bg; 40 Evas_Object *bg;
32 Edje_Perspective *ps; 41 Edje_Perspective *ps;
33 Eina_Bool animating; 42 Eina_Bool animating;
@@ -44,14 +53,14 @@ _on_destroy(Ecore_Evas *ee __UNUSED__)
44/* here just to keep our example's window size and background image's 53/* here just to keep our example's window size and background image's
45 * size in synchrony */ 54 * size in synchrony */
46static void 55static void
47_canvas_resize_cb(Ecore_Evas *ee) 56_on_canvas_resize(Ecore_Evas *ee)
48{ 57{
49 int w, h; 58 int w, h;
50 struct _App *app = ecore_evas_data_get(ee, "app"); 59 struct _App *app = ecore_evas_data_get(ee, "app");
51 60
52 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 61 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
53 evas_object_resize(app->bg, w, h); 62 evas_object_resize(app->bg, w, h);
54 evas_object_resize(app->edje, w, h); 63 evas_object_resize(app->edje_obj, w, h);
55} 64}
56 65
57static void 66static void
@@ -74,20 +83,24 @@ _part_move(struct _App *app, int dx, int dy)
74 app->y = 0; 83 app->y = 0;
75 84
76 snprintf(emission, sizeof(emission), "move,%d,%d", app->x, app->y); 85 snprintf(emission, sizeof(emission), "move,%d,%d", app->x, app->y);
77 edje_object_signal_emit(app->edje, emission, ""); 86 edje_object_signal_emit(app->edje_obj, emission, "");
78 app->animating = EINA_TRUE; 87 app->animating = EINA_TRUE;
79} 88}
80 89
81 90
82static void 91static void
83_bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info) 92_on_bg_key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
84{ 93{
85 struct _App *app = data; 94 struct _App *app = data;
86 Evas_Event_Key_Down *ev = event_info; 95 Evas_Event_Key_Down *ev = event_info;
87 96
88 97 if (!strcmp(ev->keyname, "h"))
98 {
99 fprintf(stdout, commands);
100 return;
101 }
89 // just moving the part and text 102 // just moving the part and text
90 if (!strcmp(ev->keyname, "Down")) 103 else if (!strcmp(ev->keyname, "Down"))
91 { 104 {
92 _part_move(app, 0, 1); 105 _part_move(app, 0, 1);
93 } 106 }
@@ -116,7 +129,7 @@ _bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
116 { 129 {
117 app->focal += 5; 130 app->focal += 5;
118 edje_perspective_set(app->ps, 240, 160, 0, app->focal); 131 edje_perspective_set(app->ps, 240, 160, 0, app->focal);
119 edje_object_calc_force(app->edje); 132 edje_object_calc_force(app->edje_obj);
120 } 133 }
121 else if (!strcmp(ev->keyname, "KP_Subtract")) 134 else if (!strcmp(ev->keyname, "KP_Subtract"))
122 { 135 {
@@ -125,13 +138,16 @@ _bg_key_down(void *data, Evas *e, Evas_Object *o __UNUSED__, void *event_info)
125 app->focal = 5; 138 app->focal = 5;
126 139
127 edje_perspective_set(app->ps, 240, 160, 0, app->focal); 140 edje_perspective_set(app->ps, 240, 160, 0, app->focal);
128 edje_object_calc_force(app->edje); 141 edje_object_calc_force(app->edje_obj);
129 } 142 }
130 // exiting 143 // exiting
131 else if (!strcmp(ev->keyname, "Escape")) 144 else if (!strcmp(ev->keyname, "Escape"))
132 ecore_main_loop_quit(); 145 ecore_main_loop_quit();
133 else 146 else
134 printf("unhandled key: %s\n", ev->keyname); 147 {
148 printf("unhandled key: %s\n", ev->keyname);
149 fprintf(stdout, commands);
150 }
135} 151}
136 152
137static void 153static void
@@ -143,16 +159,33 @@ _animation_end_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __
143} 159}
144 160
145int 161int
146main(void) 162main(int argc __UNUSED__, char *argv[])
147{ 163{
148 Evas *evas; 164 char edje_file_path[PATH_MAX];
149 struct _App app; 165 const char *edje_file = "perspective.edj";
150 int i; 166 struct _App app;
151 167 Ecore_Evas *ee;
152 ecore_evas_init(); 168 Evas *evas;
153 edje_init(); 169 Eina_Prefix *pfx;
154 170
155 edje_frametime_set(((double)1) / 60); 171 if (!ecore_evas_init())
172 return EXIT_FAILURE;
173
174 if (!edje_init())
175 goto shutdown_ecore_evas;
176
177 pfx = eina_prefix_new(argv[0], main,
178 "EDJE_EXAMPLES",
179 "edje/examples",
180 edje_file,
181 PACKAGE_BIN_DIR,
182 PACKAGE_LIB_DIR,
183 PACKAGE_DATA_DIR,
184 PACKAGE_DATA_DIR);
185 if (!pfx)
186 goto shutdown_edje;
187
188 edje_frametime_set(1.0 / 60.0);
156 189
157 /* this will give you a window with an Evas canvas under the first 190 /* this will give you a window with an Evas canvas under the first
158 * engine available */ 191 * engine available */
@@ -160,16 +193,18 @@ main(void)
160 app.x = 0; 193 app.x = 0;
161 app.y = 0; 194 app.y = 0;
162 app.focal = 50; 195 app.focal = 50;
163 app.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
164 196
165 ecore_evas_callback_destroy_set(app.ee, _on_destroy); 197 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
166 ecore_evas_callback_resize_set(app.ee, _canvas_resize_cb); 198 if (!ee)
167 ecore_evas_title_set(app.ee, "Edje Box Example"); 199 goto free_prefix;
168 ecore_evas_show(app.ee); 200
201 ecore_evas_callback_destroy_set(ee, _on_destroy);
202 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
203 ecore_evas_title_set(ee, "Edje Box Example");
169 204
170 ecore_evas_data_set(app.ee, "app", &app); 205 ecore_evas_data_set(ee, "app", &app);
171 206
172 evas = ecore_evas_get(app.ee); 207 evas = ecore_evas_get(ee);
173 208
174 app.bg = evas_object_rectangle_add(evas); 209 app.bg = evas_object_rectangle_add(evas);
175 evas_object_color_set(app.bg, 255, 255, 255, 255); 210 evas_object_color_set(app.bg, 255, 255, 255, 255);
@@ -177,25 +212,42 @@ main(void)
177 evas_object_focus_set(app.bg, EINA_TRUE); 212 evas_object_focus_set(app.bg, EINA_TRUE);
178 evas_object_show(app.bg); 213 evas_object_show(app.bg);
179 214
180 evas_object_event_callback_add(app.bg, EVAS_CALLBACK_KEY_DOWN, _bg_key_down, &app); 215 evas_object_event_callback_add(app.bg, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, &app);
181 216
182 app.edje = edje_object_add(evas); 217 app.edje_obj = edje_object_add(evas);
183 218
184 edje_object_file_set(app.edje, edje_file_path, "example/group"); 219 snprintf(edje_file_path, sizeof(edje_file_path),
185 evas_object_move(app.edje, 0, 0); 220 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
186 evas_object_resize(app.edje, WIDTH, HEIGHT); 221 edje_object_file_set(app.edje_obj, edje_file_path, "example/group");
187 evas_object_show(app.edje); 222 evas_object_move(app.edje_obj, 0, 0);
223 evas_object_resize(app.edje_obj, WIDTH, HEIGHT);
224 evas_object_show(app.edje_obj);
188 225
189 edje_object_signal_callback_add(app.edje, "animation,end", "", _animation_end_cb, &app); 226 edje_object_signal_callback_add(app.edje_obj, "animation,end", "", _animation_end_cb, &app);
190 227
191 app.ps = edje_perspective_new(evas); 228 app.ps = edje_perspective_new(evas);
192 edje_perspective_set(app.ps, 240, 160, 0, app.focal); 229 edje_perspective_set(app.ps, 240, 160, 0, app.focal);
193 edje_perspective_global_set(app.ps, EINA_TRUE); 230 edje_perspective_global_set(app.ps, EINA_TRUE);
194 231
232 fprintf(stdout, commands);
233
234 ecore_evas_show(ee);
235
195 ecore_main_loop_begin(); 236 ecore_main_loop_begin();
196 237
197 ecore_evas_free(app.ee); 238 eina_prefix_free(pfx);
239 ecore_evas_free(ee);
198 ecore_evas_shutdown(); 240 ecore_evas_shutdown();
199 edje_shutdown(); 241 edje_shutdown();
200 return 0; 242
243 return EXIT_SUCCESS;
244
245 free_prefix:
246 eina_prefix_free(pfx);
247 shutdown_edje:
248 edje_shutdown();
249 shutdown_ecore_evas:
250 ecore_evas_shutdown();
251
252 return EXIT_FAILURE;
201} 253}
diff --git a/libraries/edje/src/examples/edje-signals-messages.c b/libraries/edje/src/examples/edje-signals-messages.c
index 2345738..4949415 100644
--- a/libraries/edje/src/examples/edje-signals-messages.c
+++ b/libraries/edje/src/examples/edje-signals-messages.c
@@ -27,34 +27,32 @@
27#define MSG_COLOR 1 27#define MSG_COLOR 1
28#define MSG_TEXT 2 28#define MSG_TEXT 2
29 29
30static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png"; 30static const char commands[] = \
31static const char *edje_file_path = \
32 PACKAGE_EXAMPLES_DIR "/signals-messages.edj";
33
34static Ecore_Evas *ee;
35static Evas_Object *edje_obj;
36static Eina_Bool right_rect_show = EINA_TRUE;
37
38static const char *commands = \
39 "commands are:\n" 31 "commands are:\n"
40 "\tt - toggle right rectangle's visibility\n" 32 "\tt - toggle right rectangle's visibility\n"
33 "\tEsc - exit\n"
41 "\th - print help\n"; 34 "\th - print help\n";
42 35
36static Eina_Bool right_rect_show = EINA_TRUE;
37
43static void 38static void
44_on_keydown(void *data __UNUSED__, 39_on_keydown(void *data,
45 Evas *evas __UNUSED__, 40 Evas *evas __UNUSED__,
46 Evas_Object *o __UNUSED__, 41 Evas_Object *o __UNUSED__,
47 void *einfo) 42 void *einfo)
48{ 43{
49 Evas_Event_Key_Down *ev = einfo; 44 Evas_Event_Key_Down *ev;
45 Evas_Object *edje_obj;
46
47 ev = (Evas_Event_Key_Down *)einfo;
48 edje_obj = (Evas_Object *)data;
50 49
51 if (strcmp(ev->keyname, "h") == 0) /* print help */ 50 if (!strcmp(ev->keyname, "h")) /* print help */
52 { 51 {
53 fprintf(stdout, commands); 52 fprintf(stdout, commands);
54 return; 53 return;
55 } 54 }
56 55 else if (!strcmp(ev->keyname, "t")) /* toggle right rectangle's visibility */
57 if (strcmp(ev->keyname, "t") == 0) /* toggle right rectangle's visibility */
58 { 56 {
59 char buf[1024]; 57 char buf[1024];
60 58
@@ -68,6 +66,13 @@ _on_keydown(void *data __UNUSED__,
68 66
69 return; 67 return;
70 } 68 }
69 else if (!strcmp(ev->keyname, "Escape"))
70 ecore_main_loop_quit();
71 else
72 {
73 printf("unhandled key: %s\n", ev->keyname);
74 fprintf(stdout, commands);
75 }
71} 76}
72 77
73static void 78static void
@@ -85,7 +90,7 @@ _sig_print(const char *emission,
85} 90}
86 91
87static void 92static void
88_mouse_wheel_cb(void *data __UNUSED__, 93_on_mouse_wheel(void *data __UNUSED__,
89 Evas_Object *obj __UNUSED__, 94 Evas_Object *obj __UNUSED__,
90 const char *emission, 95 const char *emission,
91 const char *source) 96 const char *source)
@@ -95,8 +100,8 @@ _mouse_wheel_cb(void *data __UNUSED__,
95 100
96/* mouse over signals */ 101/* mouse over signals */
97static void 102static void
98_mouse_over_cb(void *data __UNUSED__, 103_on_mouse_over(void *data __UNUSED__,
99 Evas_Object *obj __UNUSED__, 104 Evas_Object *edje_obj,
100 const char *emission, 105 const char *emission,
101 const char *source) 106 const char *source)
102{ 107{
@@ -133,28 +138,43 @@ _message_handle(void *data __UNUSED__,
133} 138}
134 139
135int 140int
136main(void) 141main(int argc __UNUSED__, char *argv[])
137{ 142{
138 Evas_Object *border, *bg; 143 char border_img_path[PATH_MAX];
139 Evas *evas; 144 char edje_file_path[PATH_MAX];
140 145 const char *edje_file = "signals-messages.edj";
141 srand(time(NULL)); 146 Ecore_Evas *ee;
147 Evas *evas;
148 Evas_Object *bg;
149 Evas_Object *edje_obj;
150 Evas_Object *border;
151 Eina_Prefix *pfx;
142 152
143 if (!ecore_evas_init()) 153 if (!ecore_evas_init())
144 return EXIT_FAILURE; 154 return EXIT_FAILURE;
145 155
146 if (!edje_init()) 156 if (!edje_init())
147 return EXIT_FAILURE; 157 goto shutdown_ecore_evas;
158
159 pfx = eina_prefix_new(argv[0], main,
160 "EDJE_EXAMPLES",
161 "edje/examples",
162 edje_file,
163 PACKAGE_BIN_DIR,
164 PACKAGE_LIB_DIR,
165 PACKAGE_DATA_DIR,
166 PACKAGE_DATA_DIR);
167 if (!pfx)
168 goto shutdown_edje;
148 169
149 /* this will give you a window with an Evas canvas under the first 170 /* this will give you a window with an Evas canvas under the first
150 * engine available */ 171 * engine available */
151 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 172 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
152 if (!ee) 173 if (!ee)
153 goto error; 174 goto free_prefix;
154 175
155 ecore_evas_callback_delete_request_set(ee, _on_delete); 176 ecore_evas_callback_delete_request_set(ee, _on_delete);
156 ecore_evas_title_set(ee, "Edje Basics Example"); 177 ecore_evas_title_set(ee, "Edje Basics Example");
157 ecore_evas_show(ee);
158 178
159 evas = ecore_evas_get(ee); 179 evas = ecore_evas_get(ee);
160 180
@@ -163,14 +183,13 @@ main(void)
163 evas_object_move(bg, 0, 0); /* at canvas' origin */ 183 evas_object_move(bg, 0, 0); /* at canvas' origin */
164 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ 184 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
165 evas_object_show(bg); 185 evas_object_show(bg);
166 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
167
168 evas_object_focus_set(bg, EINA_TRUE); 186 evas_object_focus_set(bg, EINA_TRUE);
169 evas_object_event_callback_add( 187 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
170 bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
171 188
172 edje_obj = edje_object_add(evas); 189 edje_obj = edje_object_add(evas);
173 190
191 snprintf(edje_file_path, sizeof(edje_file_path),
192 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
174 if (!edje_object_file_set(edje_obj, edje_file_path, "example_group")) 193 if (!edje_object_file_set(edje_obj, edje_file_path, "example_group"))
175 { 194 {
176 int err = edje_object_load_error_get(edje_obj); 195 int err = edje_object_load_error_get(edje_obj);
@@ -179,14 +198,14 @@ main(void)
179 "signals-messages.edj: %s\n", errmsg); 198 "signals-messages.edj: %s\n", errmsg);
180 199
181 evas_object_del(edje_obj); 200 evas_object_del(edje_obj);
182 goto error_edj; 201 goto free_prefix;
183 } 202 }
184 203
185 edje_object_signal_callback_add(edje_obj, "mouse,wheel,*", "part_left", 204 edje_object_signal_callback_add(edje_obj, "mouse,wheel,*", "part_left",
186 _mouse_wheel_cb, NULL); 205 _on_mouse_wheel, NULL);
187 206
188 edje_object_signal_callback_add(edje_obj, "mouse,over", "part_right", 207 edje_object_signal_callback_add(edje_obj, "mouse,over", "part_right",
189 _mouse_over_cb, NULL); 208 _on_mouse_over, NULL);
190 209
191 edje_object_message_handler_set(edje_obj, _message_handle, NULL); 210 edje_object_message_handler_set(edje_obj, _message_handle, NULL);
192 211
@@ -194,6 +213,11 @@ main(void)
194 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40); 213 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
195 evas_object_show(edje_obj); 214 evas_object_show(edje_obj);
196 215
216 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, edje_obj);
217
218 snprintf(border_img_path, sizeof(border_img_path),
219 "%s/edje/examples/red.png", eina_prefix_data_get(pfx));
220
197 /* this is a border around the Edje object above, here just to 221 /* this is a border around the Edje object above, here just to
198 * emphasize its geometry */ 222 * emphasize its geometry */
199 border = evas_object_image_filled_add(evas); 223 border = evas_object_image_filled_add(evas);
@@ -207,24 +231,24 @@ main(void)
207 evas_object_show(border); 231 evas_object_show(border);
208 232
209 fprintf(stdout, commands); 233 fprintf(stdout, commands);
234
235 ecore_evas_show(ee);
236
210 ecore_main_loop_begin(); 237 ecore_main_loop_begin();
211 238
239 eina_prefix_free(pfx);
212 ecore_evas_free(ee); 240 ecore_evas_free(ee);
213 ecore_evas_shutdown(); 241 ecore_evas_shutdown();
214 edje_shutdown(); 242 edje_shutdown();
215 return 0;
216
217error:
218 fprintf(stderr, "You got to have at least one Evas engine built"
219 " and linked up to ecore-evas for this example to run"
220 " properly.\n");
221 ecore_evas_shutdown();
222 return -1;
223 243
224error_edj: 244 return EXIT_SUCCESS;
225 fprintf(stderr, "Failed to load signals-messages.edj!\n");
226 245
246 free_prefix:
247 eina_prefix_free(pfx);
248 shutdown_edje:
249 edje_shutdown();
250 shutdown_ecore_evas:
227 ecore_evas_shutdown(); 251 ecore_evas_shutdown();
228 return -2;
229}
230 252
253 return EXIT_FAILURE;
254}
diff --git a/libraries/edje/src/examples/edje-swallow.c b/libraries/edje/src/examples/edje-swallow.c
index a1d30e2..ad79ca2 100644
--- a/libraries/edje/src/examples/edje-swallow.c
+++ b/libraries/edje/src/examples/edje-swallow.c
@@ -10,10 +10,9 @@
10 */ 10 */
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13#include "config.h" 13# include "config.h"
14#else 14#else
15#define PACKAGE_EXAMPLES_DIR "." 15# define __UNUSED__
16#define __UNUSED__
17#endif 16#endif
18 17
19#include <Ecore.h> 18#include <Ecore.h>
@@ -23,11 +22,6 @@
23#define WIDTH (300) 22#define WIDTH (300)
24#define HEIGHT (300) 23#define HEIGHT (300)
25 24
26static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/swallow.edj";
27
28static Ecore_Evas *ee;
29static Evas_Object *bg;
30
31static void 25static void
32_on_delete(Ecore_Evas *ee __UNUSED__) 26_on_delete(Ecore_Evas *ee __UNUSED__)
33{ 27{
@@ -37,31 +31,56 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
37/* here just to keep our example's window size and background image's 31/* here just to keep our example's window size and background image's
38 * size in synchrony */ 32 * size in synchrony */
39static void 33static void
40_canvas_resize_cb(Ecore_Evas *ee) 34_on_canvas_resize(Ecore_Evas *ee)
41{ 35{
42 int w, h; 36 Evas_Object *bg;
37 int w;
38 int h;
43 39
40 bg = ecore_evas_data_get(ee, "background");
44 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 41 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
45 evas_object_resize(bg, w, h); 42 evas_object_resize(bg, w, h);
46} 43}
47 44
48int 45int
49main(void) 46main(int argc __UNUSED__, char *argv[])
50{ 47{
51 Evas_Object *edje_obj, *rect, *obj; 48 char edje_file_path[PATH_MAX];
52 Evas *evas; 49 const char *edje_file = "swallow.edj";
53 50 Ecore_Evas *ee;
54 ecore_evas_init(); 51 Evas *evas;
55 edje_init(); 52 Evas_Object *bg;
53 Evas_Object *rect;
54 Evas_Object *obj;
55 Evas_Object *edje_obj;
56 Eina_Prefix *pfx;
57
58 if (!ecore_evas_init())
59 return EXIT_FAILURE;
60
61 if (!edje_init())
62 goto shutdown_ecore_evas;
63
64 pfx = eina_prefix_new(argv[0], main,
65 "EDJE_EXAMPLES",
66 "edje/examples",
67 edje_file,
68 PACKAGE_BIN_DIR,
69 PACKAGE_LIB_DIR,
70 PACKAGE_DATA_DIR,
71 PACKAGE_DATA_DIR);
72 if (!pfx)
73 goto shutdown_edje;
56 74
57 /* this will give you a window with an Evas canvas under the first 75 /* this will give you a window with an Evas canvas under the first
58 * engine available */ 76 * engine available */
59 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 77 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
78 if (!ee)
79 goto free_prefix;
60 80
61 ecore_evas_callback_delete_request_set(ee, _on_delete); 81 ecore_evas_callback_delete_request_set(ee, _on_delete);
62 ecore_evas_callback_resize_set(ee, _canvas_resize_cb); 82 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
63 ecore_evas_title_set(ee, "Edje Swallow Example"); 83 ecore_evas_title_set(ee, "Edje Swallow Example");
64 ecore_evas_show(ee);
65 84
66 evas = ecore_evas_get(ee); 85 evas = ecore_evas_get(ee);
67 86
@@ -70,9 +89,12 @@ main(void)
70 evas_object_move(bg, 0, 0); /* at canvas' origin */ 89 evas_object_move(bg, 0, 0); /* at canvas' origin */
71 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ 90 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
72 evas_object_show(bg); 91 evas_object_show(bg);
92 ecore_evas_data_set(ee, "background", bg);
73 93
74 edje_obj = edje_object_add(evas); 94 edje_obj = edje_object_add(evas);
75 95
96 snprintf(edje_file_path, sizeof(edje_file_path),
97 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
76 edje_object_file_set(edje_obj, edje_file_path, "example_group"); 98 edje_object_file_set(edje_obj, edje_file_path, "example_group");
77 evas_object_move(edje_obj, 20, 20); 99 evas_object_move(edje_obj, 20, 20);
78 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40); 100 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
@@ -86,10 +108,23 @@ main(void)
86 if(obj == rect) 108 if(obj == rect)
87 printf("Swallowing worked!\n"); 109 printf("Swallowing worked!\n");
88 110
111 ecore_evas_show(ee);
112
89 ecore_main_loop_begin(); 113 ecore_main_loop_begin();
90 114
115 eina_prefix_free(pfx);
91 ecore_evas_free(ee); 116 ecore_evas_free(ee);
92 ecore_evas_shutdown(); 117 ecore_evas_shutdown();
93 edje_shutdown(); 118 edje_shutdown();
94 return 0; 119
120 return EXIT_SUCCESS;
121
122 free_prefix:
123 eina_prefix_free(pfx);
124 shutdown_edje:
125 edje_shutdown();
126 shutdown_ecore_evas:
127 ecore_evas_shutdown();
128
129 return EXIT_FAILURE;
95} 130}
diff --git a/libraries/edje/src/examples/edje-table.c b/libraries/edje/src/examples/edje-table.c
index 3866d22..7780221 100644
--- a/libraries/edje/src/examples/edje-table.c
+++ b/libraries/edje/src/examples/edje-table.c
@@ -10,10 +10,9 @@
10 */ 10 */
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13#include "config.h" 13# include "config.h"
14#else 14#else
15#define PACKAGE_EXAMPLES_DIR "." 15# define __UNUSED__
16#define __UNUSED__
17#endif 16#endif
18 17
19#include <Ecore.h> 18#include <Ecore.h>
@@ -23,12 +22,6 @@
23#define WIDTH (400) 22#define WIDTH (400)
24#define HEIGHT (400) 23#define HEIGHT (400)
25 24
26static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/table.edj";
27
28static Ecore_Evas *ee;
29static Evas *evas;
30static Evas_Object *bg, *edje_obj, *rects[4];
31
32static void 25static void
33_on_delete(Ecore_Evas *ee __UNUSED__) 26_on_delete(Ecore_Evas *ee __UNUSED__)
34{ 27{
@@ -38,7 +31,7 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
38/* Try to get the number of columns and rows of the table 31/* Try to get the number of columns and rows of the table
39 * and print them. */ 32 * and print them. */
40static void 33static void
41_columns_rows_print(void) 34_columns_rows_print(Evas_Object *edje_obj)
42{ 35{
43 int cols, rows; 36 int cols, rows;
44 37
@@ -52,10 +45,18 @@ _columns_rows_print(void)
52/* here just to keep our example's window size and table items 45/* here just to keep our example's window size and table items
53 * size in synchrony. */ 46 * size in synchrony. */
54static void 47static void
55_canvas_resize_cb(Ecore_Evas *ee) 48_on_canvas_resize(Ecore_Evas *ee)
56{ 49{
57 int i, w, h; 50 Evas_Object *bg;
58 51 Evas_Object *edje_obj;
52 Evas_Object **rects;
53 int i;
54 int w;
55 int h;
56
57 bg = ecore_evas_data_get(ee, "background");
58 edje_obj = ecore_evas_data_get(ee, "edje_obj");
59 rects = ecore_evas_data_get(ee, "rects");
59 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 60 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
60 61
61 evas_object_resize(bg, w, h); 62 evas_object_resize(bg, w, h);
@@ -68,9 +69,13 @@ _canvas_resize_cb(Ecore_Evas *ee)
68/* Mouse button 1 = remove the clicked item 69/* Mouse button 1 = remove the clicked item
69 * any other button = remove all items. */ 70 * any other button = remove all items. */
70static void 71static void
71_on_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) 72_on_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
72{ 73{
73 Evas_Event_Mouse_Down *ev = event_info; 74 Evas_Event_Mouse_Down *ev;
75 Evas_Object *edje_obj;
76
77 ev = (Evas_Event_Mouse_Down *)event_info;
78 edje_obj = (Evas_Object *)data;
74 79
75 if (ev->button != 1) 80 if (ev->button != 1)
76 edje_object_part_table_clear(edje_obj, "table_part", EINA_TRUE); 81 edje_object_part_table_clear(edje_obj, "table_part", EINA_TRUE);
@@ -78,11 +83,11 @@ _on_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
78 fprintf(stderr, "Cannot remove the selected rectangle\n"); 83 fprintf(stderr, "Cannot remove the selected rectangle\n");
79 84
80 evas_object_del(obj); 85 evas_object_del(obj);
81 _columns_rows_print(); 86 _columns_rows_print(edje_obj);
82} 87}
83 88
84static void 89static void
85_rects_create(void) 90_rects_create(Evas *evas, Evas_Object **rects, Evas_Object *edje_obj)
86{ 91{
87 int i; 92 int i;
88 93
@@ -93,26 +98,48 @@ _rects_create(void)
93 evas_object_size_hint_weight_set(rects[i], 1.0, 1.0); 98 evas_object_size_hint_weight_set(rects[i], 1.0, 1.0);
94 evas_object_show(rects[i]); 99 evas_object_show(rects[i]);
95 evas_object_event_callback_add(rects[i], EVAS_CALLBACK_MOUSE_DOWN, 100 evas_object_event_callback_add(rects[i], EVAS_CALLBACK_MOUSE_DOWN,
96 _on_mouse_down, NULL); 101 _on_mouse_down, edje_obj);
97 } 102 }
98} 103}
99 104
100int 105int
101main(void) 106main(int argc __UNUSED__, char *argv[])
102{ 107{
103 int i; 108 char edje_file_path[PATH_MAX];
104 109 const char *edje_file = "table.edj";
105 ecore_evas_init(); 110 Ecore_Evas *ee;
106 edje_init(); 111 Evas *evas;
112 Evas_Object *bg;
113 Evas_Object *edje_obj;
114 Evas_Object *rects[4];
115 Eina_Prefix *pfx;
116
117 if (!ecore_evas_init())
118 return EXIT_FAILURE;
119
120 if (!edje_init())
121 goto shutdown_ecore_evas;
122
123 pfx = eina_prefix_new(argv[0], main,
124 "EDJE_EXAMPLES",
125 "edje/examples",
126 edje_file,
127 PACKAGE_BIN_DIR,
128 PACKAGE_LIB_DIR,
129 PACKAGE_DATA_DIR,
130 PACKAGE_DATA_DIR);
131 if (!pfx)
132 goto shutdown_edje;
107 133
108 /* this will give you a window with an Evas canvas under the first 134 /* this will give you a window with an Evas canvas under the first
109 * engine available */ 135 * engine available */
110 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 136 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
137 if (!ee)
138 goto free_prefix;
111 139
112 ecore_evas_callback_delete_request_set(ee, _on_delete); 140 ecore_evas_callback_delete_request_set(ee, _on_delete);
113 ecore_evas_callback_resize_set(ee, _canvas_resize_cb); 141 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
114 ecore_evas_title_set(ee, "Edje Table Example"); 142 ecore_evas_title_set(ee, "Edje Table Example");
115 ecore_evas_show(ee);
116 143
117 evas = ecore_evas_get(ee); 144 evas = ecore_evas_get(ee);
118 145
@@ -121,15 +148,20 @@ main(void)
121 evas_object_move(bg, 0, 0); /* at canvas' origin */ 148 evas_object_move(bg, 0, 0); /* at canvas' origin */
122 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ 149 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
123 evas_object_show(bg); 150 evas_object_show(bg);
151 ecore_evas_data_set(ee, "background", bg);
124 152
125 edje_obj = edje_object_add(evas); 153 edje_obj = edje_object_add(evas);
126 154
155 snprintf(edje_file_path, sizeof(edje_file_path),
156 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
127 edje_object_file_set(edje_obj, edje_file_path, "example_table"); 157 edje_object_file_set(edje_obj, edje_file_path, "example_table");
128 evas_object_move(edje_obj, 0, 0); /* at canvas' origin */ 158 evas_object_move(edje_obj, 0, 0); /* at canvas' origin */
129 evas_object_resize(edje_obj, WIDTH, HEIGHT); 159 evas_object_resize(edje_obj, WIDTH, HEIGHT);
130 evas_object_show(edje_obj); 160 evas_object_show(edje_obj);
161 ecore_evas_data_set(ee, "edje_obj", edje_obj);
131 162
132 _rects_create(); 163 _rects_create(evas, rects, edje_obj);
164 ecore_evas_data_set(ee, "rects", rects);
133 165
134 /* Colouring the rectangles */ 166 /* Colouring the rectangles */
135 evas_object_color_set(rects[0], 255, 0, 0, 255); 167 evas_object_color_set(rects[0], 255, 0, 0, 255);
@@ -154,12 +186,25 @@ main(void)
154 1, 1, 1, 1)) 186 1, 1, 1, 1))
155 fprintf(stderr, "Cannot add the rectangle 4 to table\n"); 187 fprintf(stderr, "Cannot add the rectangle 4 to table\n");
156 188
157 _columns_rows_print(); 189 _columns_rows_print(edje_obj);
190
191 ecore_evas_show(ee);
158 192
159 ecore_main_loop_begin(); 193 ecore_main_loop_begin();
160 194
195 eina_prefix_free(pfx);
161 ecore_evas_free(ee); 196 ecore_evas_free(ee);
162 ecore_evas_shutdown(); 197 ecore_evas_shutdown();
163 edje_shutdown(); 198 edje_shutdown();
164 return 0; 199
200 return EXIT_SUCCESS;
201
202 free_prefix:
203 eina_prefix_free(pfx);
204 shutdown_edje:
205 edje_shutdown();
206 shutdown_ecore_evas:
207 ecore_evas_shutdown();
208
209 return EXIT_FAILURE;
165} 210}
diff --git a/libraries/edje/src/examples/edje-text.c b/libraries/edje/src/examples/edje-text.c
index 0916509..5f801a2 100644
--- a/libraries/edje/src/examples/edje-text.c
+++ b/libraries/edje/src/examples/edje-text.c
@@ -10,10 +10,9 @@
10 */ 10 */
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13#include "config.h" 13# include "config.h"
14#else 14#else
15#define PACKAGE_EXAMPLES_DIR "." 15# define __UNUSED__
16#define __UNUSED__
17#endif 16#endif
18 17
19#include <Ecore.h> 18#include <Ecore.h>
@@ -23,11 +22,6 @@
23#define WIDTH (300) 22#define WIDTH (300)
24#define HEIGHT (300) 23#define HEIGHT (300)
25 24
26static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/text.edj";
27
28static Ecore_Evas *ee;
29static Evas_Object *bg;
30
31static void 25static void
32_on_delete(Ecore_Evas *ee __UNUSED__) 26_on_delete(Ecore_Evas *ee __UNUSED__)
33{ 27{
@@ -35,27 +29,47 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
35} 29}
36 30
37static void 31static void
38_cb(void *data, Evas_Object *obj, const char *part) 32_on_text_change(void *data __UNUSED__, Evas_Object *obj, const char *part)
39{ 33{
40 printf("text: %s\n", edje_object_part_text_unescaped_get(obj, part)); 34 printf("text: %s\n", edje_object_part_text_unescaped_get(obj, part));
41} 35}
42 36
43int 37int
44main(void) 38main(int argc __UNUSED__, char *argv[])
45{ 39{
46 Evas_Object *edje_obj, *rect, *obj; 40 char edje_file_path[PATH_MAX];
47 Evas *evas; 41 const char *edje_file = "text.edj";
48 42 Ecore_Evas *ee;
49 ecore_evas_init(); 43 Evas *evas;
50 edje_init(); 44 Evas_Object *bg;
45 Evas_Object *edje_obj;
46 Eina_Prefix *pfx;
47
48 if (!ecore_evas_init())
49 return EXIT_FAILURE;
50
51 if (!edje_init())
52 goto shutdown_ecore_evas;
53
54 pfx = eina_prefix_new(argv[0], main,
55 "EDJE_EXAMPLES",
56 "edje/examples",
57 edje_file,
58 PACKAGE_BIN_DIR,
59 PACKAGE_LIB_DIR,
60 PACKAGE_DATA_DIR,
61 PACKAGE_DATA_DIR);
62 if (!pfx)
63 goto shutdown_edje;
51 64
52 /* this will give you a window with an Evas canvas under the first 65 /* this will give you a window with an Evas canvas under the first
53 * engine available */ 66 * engine available */
54 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 67 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
68 if (!ee)
69 goto free_prefix;
55 70
56 ecore_evas_callback_delete_request_set(ee, _on_delete); 71 ecore_evas_callback_delete_request_set(ee, _on_delete);
57 ecore_evas_title_set(ee, "Edje text Example"); 72 ecore_evas_title_set(ee, "Edje text Example");
58 ecore_evas_show(ee);
59 73
60 evas = ecore_evas_get(ee); 74 evas = ecore_evas_get(ee);
61 75
@@ -68,12 +82,14 @@ main(void)
68 82
69 edje_obj = edje_object_add(evas); 83 edje_obj = edje_object_add(evas);
70 84
85 snprintf(edje_file_path, sizeof(edje_file_path),
86 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
71 edje_object_file_set(edje_obj, edje_file_path, "example_group"); 87 edje_object_file_set(edje_obj, edje_file_path, "example_group");
72 evas_object_move(edje_obj, 20, 20); 88 evas_object_move(edje_obj, 20, 20);
73 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40); 89 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
74 evas_object_show(edje_obj); 90 evas_object_show(edje_obj);
75 91
76 edje_object_text_change_cb_set(edje_obj, _cb, NULL); 92 edje_object_text_change_cb_set(edje_obj, _on_text_change, NULL);
77 edje_object_part_text_set(edje_obj, "part_one", "one"); 93 edje_object_part_text_set(edje_obj, "part_one", "one");
78 edje_object_part_text_set(edje_obj, "part_two", "<b>two"); 94 edje_object_part_text_set(edje_obj, "part_two", "<b>two");
79 95
@@ -83,10 +99,23 @@ main(void)
83 edje_object_part_text_select_none(edje_obj, "part_two"); 99 edje_object_part_text_select_none(edje_obj, "part_two");
84 printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two")); 100 printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two"));
85 101
102 ecore_evas_show(ee);
103
86 ecore_main_loop_begin(); 104 ecore_main_loop_begin();
87 105
106 eina_prefix_free(pfx);
88 ecore_evas_free(ee); 107 ecore_evas_free(ee);
89 ecore_evas_shutdown(); 108 ecore_evas_shutdown();
90 edje_shutdown(); 109 edje_shutdown();
91 return 0; 110
111 return EXIT_SUCCESS;
112
113 free_prefix:
114 eina_prefix_free(pfx);
115 shutdown_edje:
116 edje_shutdown();
117 shutdown_ecore_evas:
118 ecore_evas_shutdown();
119
120 return EXIT_FAILURE;
92} 121}
diff --git a/libraries/edje/src/examples/sigtest.c b/libraries/edje/src/examples/sigtest.c
index 6e4d85f..9538e13 100644
--- a/libraries/edje/src/examples/sigtest.c
+++ b/libraries/edje/src/examples/sigtest.c
@@ -13,35 +13,37 @@
13#define WIDTH (300) 13#define WIDTH (300)
14#define HEIGHT (300) 14#define HEIGHT (300)
15 15
16static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
17static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/sigtest.edj";
18
19static Ecore_Evas *ee;
20static Evas_Object *edje_obj;
21
22static const char commands[] = \ 16static const char commands[] = \
23 "commands are:\n" 17 "commands are:\n"
24 "\te - change te edje base\n" 18 "\te - change te edje base\n"
25 "\tl - change to lua base\n" 19 "\tl - change to lua base\n"
26 "\tm - send message\n" 20 "\tm - send message\n"
27 "\ts - send signal\n" 21 "\ts - send signal\n"
22 "\tEsc - exit\n"
28 "\th - print help\n"; 23 "\th - print help\n";
29 24
30static void 25static void
31_on_keydown(void *data __UNUSED__, 26_on_keydown(void *data,
32 Evas *evas __UNUSED__, 27 Evas *evas __UNUSED__,
33 Evas_Object *o __UNUSED__, 28 Evas_Object *o __UNUSED__,
34 void *einfo) 29 void *einfo)
35{ 30{
36 Evas_Event_Key_Down *ev = einfo; 31 Ecore_Evas *ee;
32 Evas_Event_Key_Down *ev;
33 Evas_Object *edje_obj;
34 char *edje_file_path;
35
36 ee = (Ecore_Evas *)data;
37 ev = (Evas_Event_Key_Down *)einfo;
38 edje_obj = ecore_evas_data_get(ee, "edje_obj");
39 edje_file_path = ecore_evas_data_get(ee, "file_path");
37 40
38 if (strcmp(ev->keyname, "h") == 0) 41 if (!strcmp(ev->keyname, "h"))
39 { 42 {
40 fprintf(stdout, commands); 43 fprintf(stdout, commands);
41 return; 44 return;
42 } 45 }
43 46 else if (!strcmp(ev->keyname, "e"))
44 if (strcmp(ev->keyname, "e") == 0)
45 { 47 {
46 if (!edje_object_file_set(edje_obj, edje_file_path, "plain/edje/group")) 48 if (!edje_object_file_set(edje_obj, edje_file_path, "plain/edje/group"))
47 { 49 {
@@ -55,8 +57,7 @@ _on_keydown(void *data __UNUSED__,
55 " file sigtest.edj with success!\n"); 57 " file sigtest.edj with success!\n");
56 return; 58 return;
57 } 59 }
58 60 else if (!strcmp(ev->keyname, "l"))
59 if (strcmp(ev->keyname, "l") == 0)
60 { 61 {
61 if (!edje_object_file_set(edje_obj, edje_file_path, "lua_base")) 62 if (!edje_object_file_set(edje_obj, edje_file_path, "lua_base"))
62 { 63 {
@@ -70,8 +71,7 @@ _on_keydown(void *data __UNUSED__,
70 " file sigtest.edj with success!\n"); 71 " file sigtest.edj with success!\n");
71 return; 72 return;
72 } 73 }
73 74 else if (!strcmp(ev->keyname, "m"))
74 if (strcmp(ev->keyname, "m") == 0)
75 { 75 {
76 Edje_Message_String *msg = malloc(sizeof(*msg)); 76 Edje_Message_String *msg = malloc(sizeof(*msg));
77 77
@@ -82,8 +82,7 @@ _on_keydown(void *data __UNUSED__,
82 fprintf(stdout, "C message sent\n"); 82 fprintf(stdout, "C message sent\n");
83 return; 83 return;
84 } 84 }
85 85 else if (!strcmp(ev->keyname, "s"))
86 if (strcmp(ev->keyname, "s") == 0)
87 { 86 {
88 fprintf(stdout, "\n"); 87 fprintf(stdout, "\n");
89 edje_object_signal_emit(edje_obj, "C signal 1", "Csource"); 88 edje_object_signal_emit(edje_obj, "C signal 1", "Csource");
@@ -91,10 +90,17 @@ _on_keydown(void *data __UNUSED__,
91 fprintf(stdout, "C signal sent\n"); 90 fprintf(stdout, "C signal sent\n");
92 return; 91 return;
93 } 92 }
93 else if (!strcmp(ev->keyname, "Escape"))
94 ecore_main_loop_quit();
95 else
96 {
97 printf("unhandled key: %s\n", ev->keyname);
98 fprintf(stdout, commands);
99 }
94} 100}
95 101
96static void 102static void
97_on_message(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg) 103_on_message(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Edje_Message_Type type, int id, void *msg)
98{ 104{
99 int i; 105 int i;
100 106
@@ -207,7 +213,7 @@ _on_message(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *
207} 213}
208 214
209static void 215static void
210_on_signal(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source) 216_on_signal(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *emission, const char *source)
211{ 217{
212 fprintf(stdout, "C::signal sig=|%s| src=|%s|\n", emission, source); 218 fprintf(stdout, "C::signal sig=|%s| src=|%s|\n", emission, source);
213} 219}
@@ -219,26 +225,43 @@ _on_delete(Ecore_Evas *ee __UNUSED__)
219} 225}
220 226
221int 227int
222main(void) 228main(int argc __UNUSED__, char *argv[])
223{ 229{
224 Evas_Object *border, *bg; 230 char border_img_path[PATH_MAX];
225 Evas *evas; 231 char edje_file_path[PATH_MAX];
232 const char *edje_file = "sigtest.edj";
233 Ecore_Evas *ee;
234 Evas *evas;
235 Evas_Object *bg;
236 Evas_Object *border;
237 Evas_Object *edje_obj;
238 Eina_Prefix *pfx;
226 239
227 if (!ecore_evas_init()) 240 if (!ecore_evas_init())
228 return EXIT_FAILURE; 241 return EXIT_FAILURE;
229 242
230 if (!edje_init()) 243 if (!edje_init())
231 return EXIT_FAILURE; 244 goto shutdown_ecore_evas;
245
246 pfx = eina_prefix_new(argv[0], main,
247 "EDJE_EXAMPLES",
248 "edje/examples",
249 edje_file,
250 PACKAGE_BIN_DIR,
251 PACKAGE_LIB_DIR,
252 PACKAGE_DATA_DIR,
253 PACKAGE_DATA_DIR);
254 if (!pfx)
255 goto shutdown_edje;
232 256
233 /* this will give you a window with an Evas canvas under the first 257 /* this will give you a window with an Evas canvas under the first
234 * engine available */ 258 * engine available */
235 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 259 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
236 if (!ee) 260 if (!ee)
237 goto error; 261 goto free_prefix;
238 262
239 ecore_evas_callback_delete_request_set(ee, _on_delete); 263 ecore_evas_callback_delete_request_set(ee, _on_delete);
240 ecore_evas_title_set(ee, "Signals and wessages tester"); 264 ecore_evas_title_set(ee, "Signals and wessages tester");
241 ecore_evas_show(ee);
242 265
243 evas = ecore_evas_get(ee); 266 evas = ecore_evas_get(ee);
244 267
@@ -250,14 +273,14 @@ main(void)
250 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); 273 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
251 274
252 evas_object_focus_set(bg, EINA_TRUE); 275 evas_object_focus_set(bg, EINA_TRUE);
253 evas_object_event_callback_add(
254 bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
255 276
256 edje_obj = edje_object_add(evas); 277 edje_obj = edje_object_add(evas);
257 278
258 edje_object_message_handler_set(edje_obj, _on_message, NULL); 279 edje_object_message_handler_set(edje_obj, _on_message, NULL);
259 edje_object_signal_callback_add(edje_obj, "*", "*", _on_signal, NULL); 280 edje_object_signal_callback_add(edje_obj, "*", "*", _on_signal, NULL);
260 281
282 snprintf(edje_file_path, sizeof(edje_file_path),
283 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
261 if (!edje_object_file_set(edje_obj, edje_file_path, "lua_base")) 284 if (!edje_object_file_set(edje_obj, edje_file_path, "lua_base"))
262 { 285 {
263 int err = edje_object_load_error_get(edje_obj); 286 int err = edje_object_load_error_get(edje_obj);
@@ -266,7 +289,7 @@ main(void)
266 errmsg); 289 errmsg);
267 290
268 evas_object_del(edje_obj); 291 evas_object_del(edje_obj);
269 goto error_edj; 292 goto free_prefix;
270 } 293 }
271 294
272 fprintf(stdout, "Loaded Edje object bound to group 'lua_base' from" 295 fprintf(stdout, "Loaded Edje object bound to group 'lua_base' from"
@@ -275,6 +298,13 @@ main(void)
275 evas_object_move(edje_obj, 20, 20); 298 evas_object_move(edje_obj, 20, 20);
276 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40); 299 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
277 evas_object_show(edje_obj); 300 evas_object_show(edje_obj);
301 ecore_evas_data_set(ee, "edje_obj", edje_obj);
302 ecore_evas_data_set(ee, "file_path", edje_file_path);
303
304 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, ee);
305
306 snprintf(border_img_path, sizeof(border_img_path),
307 "%s/edje/examples/red.png", eina_prefix_data_get(pfx));
278 308
279 /* this is a border around the Edje object above, here just to 309 /* this is a border around the Edje object above, here just to
280 * emphasize its geometry */ 310 * emphasize its geometry */
@@ -287,23 +317,25 @@ main(void)
287 evas_object_move(border, 20 - 2, 20 - 2); 317 evas_object_move(border, 20 - 2, 20 - 2);
288 evas_object_show(border); 318 evas_object_show(border);
289 319
320 fprintf(stdout, commands);
321
322 ecore_evas_show(ee);
323
290 ecore_main_loop_begin(); 324 ecore_main_loop_begin();
291 325
326 eina_prefix_free(pfx);
292 ecore_evas_free(ee); 327 ecore_evas_free(ee);
293 ecore_evas_shutdown(); 328 ecore_evas_shutdown();
294 edje_shutdown(); 329 edje_shutdown();
295 return 0;
296
297error:
298 fprintf(stderr, "You got to have at least one evas engine built"
299 " and linked up to ecore-evas for this example to run"
300 " properly.\n");
301 ecore_evas_shutdown();
302 return -1;
303 330
304error_edj: 331 return EXIT_SUCCESS;
305 fprintf(stderr, "Failed to load sigtest.edj!\n");
306 332
333 free_prefix:
334 eina_prefix_free(pfx);
335 shutdown_edje:
336 edje_shutdown();
337 shutdown_ecore_evas:
307 ecore_evas_shutdown(); 338 ecore_evas_shutdown();
308 return -2; 339
340 return EXIT_FAILURE;
309} 341}