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-text.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 '')
-rw-r--r-- | libraries/edje/src/examples/edje-text.c | 65 |
1 files changed, 47 insertions, 18 deletions
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 | ||
26 | static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/text.edj"; | ||
27 | |||
28 | static Ecore_Evas *ee; | ||
29 | static Evas_Object *bg; | ||
30 | |||
31 | static void | 25 | static 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 | ||
37 | static void | 31 | static 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 | ||
43 | int | 37 | int |
44 | main(void) | 38 | main(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 | } |