18
#ifndef PACKAGE_DATA_DIR
19
#define PACKAGE_DATA_DIR "."
23
#include <Ecore_Evas.h>
31
static int lang_idx = 0;
32
static const char *lang[] = {
39
_on_delete(Ecore_Evas *ee EINA_UNUSED)
41
ecore_main_loop_quit();
45
_on_text_change(void *data EINA_UNUSED, Evas_Object *obj, const char *part)
47
char *str = edje_object_part_text_unescaped_get(obj, part);
48
printf("text: %s\n", str);
53
_on_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o, void *event_info EINA_UNUSED)
55
static char envbuf[20];
57
lang_idx = (lang_idx + 1) % (sizeof (lang) / sizeof (lang[0]));
58
fprintf(stderr, "Setting lang of this edje object to '%s'\n", lang[lang_idx]);
67
env = getenv("LANGUAGE");
68
if (env) env = strdup(env);
69
snprintf(envbuf, sizeof(envbuf), "LANGUAGE=%s", lang[lang_idx]);
72
edje_object_language_set(o, lang[lang_idx]);
74
snprintf(envbuf, sizeof(envbuf), "LANGUAGE=%s", env ? env : "");
80
_on_mouse_down_text(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info EINA_UNUSED)
82
static char *env_lang_str = NULL;
85
lang_idx = (lang_idx + 1) % (sizeof (lang)/ sizeof (lang[0]));
86
fprintf(stderr, "Setting lang to '%s'\n", lang[lang_idx]);
87
s = malloc(10 + strlen(lang[lang_idx]));
90
strcpy(s, "LANGUAGE=");
91
strcpy(s + 9, lang[lang_idx]);
93
if (env_lang_str) free(env_lang_str);
96
edje_language_set(lang[lang_idx]);
99
main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
101
const char *edje_file = PACKAGE_DATA_DIR"/text.edj";
105
Evas_Object *edje_obj;
106
Evas_Object *edje_obj_one;
107
Evas_Object *edje_obj_two;
108
Evas_Object *edje_obj_three;
110
if (!ecore_evas_init())
114
goto shutdown_ecore_evas;
118
ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
119
if (!ee) goto shutdown_edje;
121
ecore_evas_callback_delete_request_set(ee, _on_delete);
122
ecore_evas_title_set(ee, "Edje Text Example");
124
evas = ecore_evas_get(ee);
126
bg = evas_object_rectangle_add(evas);
127
evas_object_color_set(bg, 255, 255, 255, 255);
128
evas_object_move(bg, 0, 0);
129
evas_object_resize(bg, WIDTH, HEIGHT);
130
evas_object_show(bg);
131
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
133
edje_obj = edje_object_add(evas);
134
edje_object_file_set(edje_obj, edje_file, "example_group");
135
evas_object_move(edje_obj, 0, 20);
136
evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
137
evas_object_show(edje_obj);
138
putenv("LANGUAGE=en_IN");
139
edje_object_language_set(edje_obj, "en_IN");
140
edje_object_text_change_cb_set(edje_obj, _on_text_change, NULL);
141
edje_object_part_text_set(edje_obj, "part_two", "<b>Click here");
142
edje_object_part_text_select_allow_set(edje_obj, "part_two", EINA_TRUE);
143
edje_object_part_text_select_all(edje_obj, "part_two");
144
printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two"));
145
edje_object_part_text_select_none(edje_obj, "part_two");
146
printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two"));
147
evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, NULL);
149
edje_obj_one = edje_object_add(evas);
150
edje_object_file_set(edje_obj_one, edje_file, "example_group1");
151
evas_object_move(edje_obj_one, 0, 50);
152
evas_object_resize(edje_obj_one, WIDTH - 40, HEIGHT - 40);
153
evas_object_show(edje_obj_one);
154
edje_object_language_set(edje_obj_one, "en_IN");
155
edje_object_text_change_cb_set(edje_obj_one, _on_text_change, NULL);
156
edje_object_part_text_set(edje_obj_one, "part_two", "<b>Click here");
157
edje_object_part_text_select_allow_set(edje_obj_one, "part_two", EINA_TRUE);
158
edje_object_part_text_select_all(edje_obj_one, "part_two");
159
printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj_one, "part_two"));
160
edje_object_part_text_select_none(edje_obj_one, "part_two");
161
printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj_one, "part_two"));
162
evas_object_event_callback_add(edje_obj_one, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, NULL);
165
edje_obj_two = edje_object_add(evas);
166
edje_object_file_set(edje_obj_two, edje_file, "example_group2");
167
evas_object_move(edje_obj_two, 0, 250);
168
evas_object_resize(edje_obj_two, WIDTH - 40, HEIGHT - 40);
169
evas_object_show(edje_obj_two);
170
edje_language_set("en_IN");
171
edje_object_text_change_cb_set(edje_obj_two, _on_text_change, NULL);
172
edje_object_part_text_set(edje_obj_two, "part_two", "<b>Click here");
173
edje_object_part_text_select_allow_set(edje_obj_two, "part_two", EINA_TRUE);
174
edje_object_part_text_select_all(edje_obj_two, "part_two");
175
printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj_two, "part_two"));
176
edje_object_part_text_select_none(edje_obj_two, "part_two");
177
printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj_two, "part_two"));
178
evas_object_event_callback_add(edje_obj_two, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down_text, NULL);
180
edje_obj_three = edje_object_add(evas);
181
edje_object_file_set(edje_obj_three, edje_file, "example_group3");
182
evas_object_move(edje_obj_three, 0, 350);
183
evas_object_resize(edje_obj_three, WIDTH - 40, HEIGHT - 40);
184
evas_object_show(edje_obj_three);
185
edje_object_text_change_cb_set(edje_obj_three, _on_text_change, NULL);
186
edje_object_part_text_set(edje_obj_three, "part_two", "<b>Click here");
187
edje_object_part_text_select_allow_set(edje_obj_three, "part_two", EINA_TRUE);
188
edje_object_part_text_select_all(edje_obj_three, "part_two");
189
printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj_three, "part_two"));
190
edje_object_part_text_select_none(edje_obj_three, "part_two");
191
printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj_three, "part_two"));
192
evas_object_event_callback_add(edje_obj_three, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down_text, NULL);
196
ecore_main_loop_begin();
199
ecore_evas_shutdown();
207
ecore_evas_shutdown();