aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/examples/edje-swallow.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/edje/src/examples/edje-swallow.c')
-rw-r--r--libraries/edje/src/examples/edje-swallow.c73
1 files changed, 54 insertions, 19 deletions
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}