diff options
author | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
commit | c963d75dfdeec11f82e79e727062fbf89afa2c04 (patch) | |
tree | 895633dbf641110be46f117c29890c49b3ffc0bd /libraries/edje/src/examples/edje-signals-messages.c | |
parent | Adding the new extantz viewer and grid manager. (diff) | |
download | SledjHamr-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/edje-signals-messages.c')
-rw-r--r-- | libraries/edje/src/examples/edje-signals-messages.c | 112 |
1 files changed, 68 insertions, 44 deletions
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 | ||
30 | static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png"; | 30 | static const char commands[] = \ |
31 | static const char *edje_file_path = \ | ||
32 | PACKAGE_EXAMPLES_DIR "/signals-messages.edj"; | ||
33 | |||
34 | static Ecore_Evas *ee; | ||
35 | static Evas_Object *edje_obj; | ||
36 | static Eina_Bool right_rect_show = EINA_TRUE; | ||
37 | |||
38 | static 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 | ||
36 | static Eina_Bool right_rect_show = EINA_TRUE; | ||
37 | |||
43 | static void | 38 | static 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 | ||
73 | static void | 78 | static void |
@@ -85,7 +90,7 @@ _sig_print(const char *emission, | |||
85 | } | 90 | } |
86 | 91 | ||
87 | static void | 92 | static 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 */ |
97 | static void | 102 | static 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 | ||
135 | int | 140 | int |
136 | main(void) | 141 | main(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 | |||
217 | error: | ||
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 | ||
224 | error_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 | } | ||