1 //Compile with:
2 // edje_cc animations2.edc && gcc -o animations2 animations2.c `pkg-config --libs --cflags ecore ecore-evas edje evas`
3
4 #ifdef HAVE_CONFIG_H
5 #include "config.h"
6 #else
7 #define PACKAGE_EXAMPLES_DIR "."
8 #define EINA_UNUSED
9 #endif
10
11 #ifndef PACKAGE_DATA_DIR
12 #define PACKAGE_DATA_DIR "."
13 #endif
14
15 #include <Ecore.h>
16 #include <Ecore_Evas.h>
17 #include <Edje.h>
18 #include <stdio.h>
19
20 #define WIDTH (700)
21 #define HEIGHT (700)
22
23 static void
_on_delete(Ecore_Evas * ee EINA_UNUSED)24 _on_delete(Ecore_Evas *ee EINA_UNUSED)
25 {
26 ecore_main_loop_quit();
27 }
28
29 int
main(int argc EINA_UNUSED,char ** argv EINA_UNUSED)30 main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
31 {
32 const char *edje_file = PACKAGE_DATA_DIR"/animations2.edj";
33 Evas *evas;
34 Ecore_Evas *ee;
35 Evas_Object *edje_obj;
36 Evas_Object *bg;
37
38 if (!ecore_evas_init()) return EXIT_FAILURE;
39
40 if (!edje_init()) goto shutdown_ecore_evas;
41
42 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
43
44 if (!ee) goto shutdown_edje;
45
46 ecore_evas_callback_delete_request_set(ee, _on_delete);
47 ecore_evas_title_set(ee, "Animations");
48
49 evas = ecore_evas_get(ee);
50
51 bg = evas_object_rectangle_add(evas);
52 evas_object_color_set(bg, 255, 255, 255, 255);
53 evas_object_move(bg, 0, 0);
54 evas_object_resize(bg, WIDTH, HEIGHT);
55 evas_object_show(bg);
56
57 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
58 evas_object_focus_set(bg, EINA_TRUE);
59
60 edje_obj = edje_object_add(evas);
61
62 fprintf(stderr, "loading edje file; %s\n", edje_file);
63
64 if (!edje_object_file_set(edje_obj, edje_file, "animation_group"))
65 {
66 int err = edje_object_load_error_get(edje_obj);
67 const char *errmsg = edje_load_error_str(err);
68 fprintf(stderr, "Could not load the edje file - reason:%s\n", errmsg);
69 goto shutdown_edje;
70 }
71
72 evas_object_resize(edje_obj, 700, 700);
73 evas_object_move(edje_obj, 50, 50);
74 evas_object_show(edje_obj);
75
76 ecore_evas_show(ee);
77
78 ecore_main_loop_begin();
79
80 ecore_evas_free(ee);
81 edje_shutdown();
82 ecore_evas_shutdown();
83
84 return EXIT_SUCCESS;
85
86 shutdown_edje: edje_shutdown();
87
88 shutdown_ecore_evas: ecore_evas_shutdown();
89
90 return EXIT_FAILURE;
91 }
92