Eail configure fixed
[platform/core/uifw/eail.git] / explorer / src / eail-explorer-ui.c
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 /**
21  * @file eail-explorer-ui.c
22  *
23  * @brief EAIL Explorer UI implementation
24  */
25
26 #define _GNU_SOURCE
27 #include "string.h"
28 #include "eail-explorer-ui.h"
29 #include "eail-explorer-tr.h"
30 #include "eail-browser.h"
31 #include <stdio.h>
32
33 /** @brief action_cb_struct Struct for action callbacks */
34 action_cb_struct *acs = NULL;
35
36 /**
37  * @brief cleanup
38  *
39  * Cleans memory by free action cb struct
40  */
41 void free_memory()
42 {
43         if(acs)
44         {
45                 eina_list_free(acs->list);
46                 free(acs);
47                 acs = NULL;
48         }
49 }
50
51 /**
52  * @brief Refreshes explorer layout
53  *
54  * Use elm_toolbar_item_selected_set() twice to refresh layout
55  *
56  * @param toolbar Toolbar object
57  *
58  * @return
59  */
60 void refresh_layout(Evas_Object *toolbar)
61 {
62         Elm_Object_Item *tb_item = elm_toolbar_first_item_get(toolbar);
63         if(tb_item)
64         {
65                 elm_toolbar_item_selected_set(tb_item, EINA_FALSE);
66                 elm_toolbar_item_selected_set(tb_item, EINA_TRUE);
67         }
68         else
69         {
70                 tb_item = elm_toolbar_first_item_get(toolbar);
71                 elm_toolbar_item_selected_set(tb_item, EINA_TRUE);
72         }
73 }
74
75 /**
76  * @brief checks whether an object is part of EAIL-Explorer
77  *
78  * Check is performed by getting the role and name from AtkObject
79  *
80  * @param obj AtkObject which is checked
81  *
82  * @return true when the object is part of EAIL-Explorer, false otherwise
83  */
84 Eina_Bool _is_part_of_eail_explorer(AtkObject *obj)
85 {
86         if(!obj || ATK_ROLE_APPLICATION == atk_object_get_role(obj))
87                 return EINA_FALSE;
88
89         AtkObject *atk_window = obj;
90         while(ATK_ROLE_WINDOW != atk_object_get_role(atk_window))
91                 atk_window = atk_object_get_parent(atk_window);
92
93         const char *name = atk_object_get_name(atk_window);
94         if(name && !strcmp(name, EAIL_EXPLORER))
95                 return EINA_TRUE;
96
97         return EINA_FALSE;
98 }
99
100 void _print_desc_on_entry(void *data, Evas_Object *obj, void *event_info)
101 {
102         action_cb_struct *acs = (action_cb_struct*)data;
103         if(!acs->atk_obj)
104         {
105                 return;
106         }
107         Evas_Object *entry = eina_list_nth(acs->list, 1);
108         Elm_Object_Item *it = (Elm_Object_Item*)event_info;
109         int i = 0;
110         const Eina_List *list = elm_list_items_get(eina_list_nth(acs->list, 0));
111         const Eina_List *l;
112         void *list_data;
113         EINA_LIST_FOREACH(list, l, list_data)
114         {
115                 if(list_data == it)
116                 {
117                         const char *desc = atk_action_get_description(ATK_ACTION(acs->atk_obj), i);
118                         elm_entry_entry_set(entry, desc);
119                         return;
120                 }
121                 ++i;
122         }
123 }
124
125 void _fill_action_list(void *data)
126 {
127         action_cb_struct *acs = (action_cb_struct*)data;
128         if(!acs->atk_obj)
129         {
130                 return;
131         }
132         Evas_Object *list = eina_list_nth(acs->list, 0);
133         AtkObject *obj = acs->atk_obj;
134         int counter = atk_action_get_n_actions(ATK_ACTION(obj));
135         elm_list_clear(list);
136         int i;
137         for(i = 0; i < counter; ++i)
138         {
139                 const char *desc = atk_action_get_description(ATK_ACTION(obj), i);
140                 if(!desc)
141                 {
142                         elm_list_item_append(list, atk_action_get_name(ATK_ACTION(obj), i), NULL, NULL, _print_desc_on_entry, acs);
143                 }
144                 else
145                 {
146                         char *action_name_with_desc = NULL;
147                         if(asprintf(&action_name_with_desc, "%s [%s]", atk_action_get_name(ATK_ACTION(obj), i), desc) < 0)
148                         {
149                                 EINA_LOG_ERR(ERR_MEMORY);
150                                 elm_list_item_append(list, atk_action_get_name(ATK_ACTION(obj), i), NULL, NULL, _print_desc_on_entry, acs);
151                         }
152                         else
153                         {
154                                 elm_list_item_append(list, action_name_with_desc, NULL, NULL, _print_desc_on_entry, acs);
155                                 free(action_name_with_desc);
156                         }
157                 }
158         }
159         elm_list_go(list);
160 }
161
162 /**
163  * @brief Callback function for Button click in Action Layout
164  *
165  * The callback is called when the Action label for button is clicked.
166  * The callback performs the action selected in the given action list.
167  *
168  * @param data Data passed to callback, action_cb_struct
169  * @param obj UNUSED
170  * @param event_info UNUSED
171  *
172  * @return
173  */
174 void _action_cb(void *data, Evas_Object *obj, void *event_info)
175 {
176         action_cb_struct *acs = (action_cb_struct*)data;
177         if(!acs->atk_obj)
178         {
179                 return;
180         }
181         Evas_Object *eo = eina_list_nth(acs->list, 0);
182         Elm_Object_Item *it = elm_list_selected_item_get(eo);
183         if(!it)
184         {
185                 return;
186         }
187         int i = 0;
188         const Eina_List *list = elm_list_items_get(eo);
189         const Eina_List *l;
190         void *list_data;
191         EINA_LIST_FOREACH(list, l, list_data)
192         {
193                 if(list_data == it)
194                 {
195                         atk_action_do_action(ATK_ACTION(acs->atk_obj), i);
196                         expand_browser(acs->atk_obj);
197                         return;
198                 }
199                 ++i;
200         }
201 }
202
203 void _set_action_desc(void *data, Evas_Object *obj, void *event_info)
204 {
205         action_cb_struct *acs = (action_cb_struct*)data;
206         if(!acs->atk_obj)
207         {
208                 return;
209         }
210         Evas_Object *eo = eina_list_nth(acs->list, 0);
211         Elm_Object_Item *it = elm_list_selected_item_get(eo);
212         if(!it)
213         {
214                 return;
215         }
216         Evas_Object *entry = eina_list_nth(acs->list, 1);
217         const char *desc = elm_entry_entry_get(entry);
218         if(!desc || !strcmp(desc, ""))
219         {
220                 return;
221         }
222         const Eina_List *list = elm_list_items_get(eina_list_nth(acs->list, 0));
223         const Eina_List *l;
224         void *list_data;
225         int i = 0;
226         EINA_LIST_FOREACH(list, l, list_data)
227         {
228                 if(list_data == it)
229                 {
230                         atk_action_set_description(ATK_ACTION(acs->atk_obj), i, desc);
231                         _fill_action_list(acs);
232                         return;
233                 }
234                 ++i;
235         }
236 }
237
238 /**
239  * @brief Prints all avaiable actions for given AtkObject.
240  *
241  * Function prints all avaiable actions for given Accessible Object
242  * and register callback for click on button.
243  *
244  * @param eo Actions Layout object
245  * @param obj AtkObject which currently has focus
246  * @param parent Main Layout Object
247  */
248 void print_actions(Evas_Object *eo, AtkObject *obj, Evas_Object *parent)
249 {
250         if(!acs)
251         {
252                 acs = (action_cb_struct*)malloc(sizeof(action_cb_struct));
253         }
254         else
255         {
256                 eina_list_free(acs->list);
257         }
258
259         char *c = NULL;
260         int actions_counter = atk_action_get_n_actions(ATK_ACTION(obj));
261         Evas_Object *action_list = elm_object_part_content_get(eo, "elm.editor.name.list");
262         Evas_Object *entry = elm_object_part_content_get(eo, "elm.editor.name.entry");
263         elm_entry_entry_set(entry, NULL);
264         if (asprintf(&c,"%d", actions_counter) < 0 )
265                 EINA_LOG_ERR(ERR_ACTION);
266         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label1"), c);
267         acs->atk_obj = obj;
268         acs->list = NULL;
269         acs->list = eina_list_append(acs->list, action_list);
270         acs->list = eina_list_append(acs->list, entry);
271         _fill_action_list(acs);
272
273         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button"), "clicked", _action_cb);
274         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button"), "clicked", _action_cb, acs);
275         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button2"), "clicked", _set_action_desc);
276         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button2"), "clicked", _set_action_desc, acs);
277
278         elm_object_part_content_set(parent, "elm.layout", eo);
279         evas_object_show(eo);
280         free(c);
281 }
282
283 /**
284  * @brief prepares Action interface view
285  *
286  * Function prepares action Layout by adding all
287  * the used objects to layout and setting object labels
288  *
289  * @param parent Evas_Object wich represent Parent Layout
290  *
291  * @return Evas_Object representing Action Layout
292  */
293 Evas_Object* prepare_layout_action(Evas_Object *parent)
294 {
295         Evas_Object *eo = elm_layout_add(parent);
296         elm_layout_file_set(eo, EDJ_PATH_ACT, "explorer/action");
297
298         Evas_Object *lb1, *separator, *button, *list, *entry, *button2;
299
300         lb1 = elm_label_add(eo);
301         list = elm_list_add(eo);
302         elm_list_multi_select_set(list, EINA_FALSE);
303         separator = elm_separator_add(eo);
304         button = elm_button_add(eo);
305         button2 = elm_button_add(eo);
306         entry = elm_entry_add(eo);
307         elm_entry_single_line_set(entry, EINA_TRUE);
308         elm_entry_scrollable_set(entry, EINA_TRUE);
309         elm_object_part_text_set(entry, "guide", ACTION_DESC);
310         elm_object_text_set(button, DO_ACTION);
311         elm_object_text_set(button2, SET);
312         elm_separator_horizontal_set(separator, EINA_FALSE);
313         elm_object_part_content_set(eo, "elm.editor.name.label1", lb1);
314         elm_object_part_content_set(eo, "elm.editor.name.list", list);
315         elm_object_part_content_set(eo, "elm.editor.name.button", button);
316         elm_object_part_content_set(eo, "elm.separator.1", separator);
317         elm_object_part_content_set(eo, "elm.editor.name.entry", entry);
318         elm_object_part_content_set(eo, "elm.editor.name.button2", button2);
319
320         evas_object_color_set(separator, 1, 1, 1, 255);
321         elm_object_part_text_set(eo, "text1", NUM_OF_ACTIONS);
322         elm_object_part_text_set(eo, "text2", ACC_DESC);
323         elm_object_part_text_set(eo, "text3", SET_DESC);
324         elm_label_slide_duration_set(lb1, 3);
325         elm_object_style_set(lb1, "slide_bounce");
326
327         return eo;
328 }
329
330 /**
331  * @brief callback for resize event
332  *
333  * Callback called when resize button on component layout is clicked,
334  * resize on focused object is performed with paramenters received from
335  * data parameter
336  *
337  * @param data action_cb_struct which has values from entries in layout
338  * @param obj UNUSED
339  * @param event_info UNUSED
340  */
341 void _component_resize_cb(void *data, Evas_Object *obj, void *event_info)
342 {
343         int width, height;
344         char *size;
345
346         action_cb_struct *acs = (action_cb_struct*)data;
347         Evas_Object *eo1 = eina_list_nth(acs->list, 0);
348         Evas_Object *eo2 = eina_list_nth(acs->list, 1);
349         Evas_Object *lab = eina_list_nth(acs->list, 6);
350
351         atk_component_set_size(ATK_COMPONENT(acs->atk_obj), atoi(elm_entry_entry_get(eo1)), atoi(elm_entry_entry_get(eo2)));
352
353         atk_component_get_size(ATK_COMPONENT(acs->atk_obj), &width, &height);
354
355         if(asprintf(&size, "%s: %d, %s: %d", WIDTH, width, HEIGHT, height) < 0)
356         {
357                 elm_object_text_set(lab, "Error");
358         }
359         else
360         {
361                 elm_object_text_set(lab, size);
362         }
363
364         free(size);
365 }
366
367 /**
368  * @brief callback for change position event
369  *
370  * Callback called when change position button on component layout is clicked,
371  * position change on focued object is prerformed with parameters received from
372  * data parameter.
373  *
374  * @param data action_cb_struct which has values from entries in layout
375  * @param obj UNUSED
376  * @param event_info UNUSED
377  */
378 void _component_change_position_cb(void *data, Evas_Object *obj, void *event_info)
379 {
380         int s_x, s_y;
381         int w_x, w_y;
382         char *s_position;
383         char *w_position;
384
385         action_cb_struct *acs = (action_cb_struct*)data;
386         Evas_Object *eo1 = eina_list_nth(acs->list, 2);
387         Evas_Object *eo2 = eina_list_nth(acs->list, 3);
388         Evas_Object *lab = eina_list_nth(acs->list, 4);
389         Evas_Object *lab1 = eina_list_nth(acs->list, 5);
390
391         atk_component_set_position(ATK_COMPONENT(acs->atk_obj), atoi(elm_entry_entry_get(eo1)), atoi(elm_entry_entry_get(eo2)), ATK_XY_WINDOW);
392
393         atk_component_get_position(ATK_COMPONENT(acs->atk_obj), &s_x, &s_y, ATK_XY_SCREEN);
394         atk_component_get_position(ATK_COMPONENT(acs->atk_obj), &w_x, &w_y, ATK_XY_WINDOW);
395
396         if(asprintf(&s_position, "X: %d, Y: %d", s_x, s_y) < 0)
397         {
398                 EINA_LOG_ERR(ERR_MEMORY);
399                 elm_object_text_set(lab, "-");
400         }
401         else
402         {
403                 elm_object_text_set(lab, s_position);
404         }
405         if(asprintf(&w_position, "X: %d, Y: %d", w_x, w_y) < 0)
406         {
407                 EINA_LOG_ERR(ERR_MEMORY);
408                 elm_object_text_set(lab1, "-");
409         }
410         else
411         {
412                 elm_object_text_set(lab1, w_position);
413         }
414
415         free(s_position);
416         free(w_position);
417 }
418
419 /**
420  * @brief prints Component layout
421  *
422  * Main function to print layout component, called when click on component
423  * label in toolbar is clicked, that function fills all entries and labels
424  * in that layout, register callbacks on objects
425  *
426  * @param eo Component Layout object
427  * @param obj AtkObject which has focus
428  * @param parent Main Layout object
429  */
430 void print_component(Evas_Object *eo, AtkObject *obj, Evas_Object *parent)
431 {
432         if(!acs)
433         {
434                 acs = (action_cb_struct*)malloc(sizeof(action_cb_struct));
435         }
436         else
437         {
438                 eina_list_free(acs->list);
439         }
440
441         int s_x, s_y;
442         int w_x, w_y;
443         int atk_mdi_zorder;
444         int width, height;
445         double atk_alpha;
446         AtkLayer atk_layer;
447         char *s_position = NULL;
448         char *w_position = NULL;
449         char *size = NULL;
450         char *layer = NULL;
451         char *mdi_zorder = NULL;
452         char *alpha = NULL;
453         char *width_char = WIDTH;
454         char *height_char = HEIGHT;
455         acs->list = NULL;
456
457         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.button"), RESIZE);
458         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.button1"), CHANGE_POS);
459
460         atk_component_get_position(ATK_COMPONENT(obj), &s_x, &s_y, ATK_XY_SCREEN);
461         atk_component_get_position(ATK_COMPONENT(obj), &w_x, &w_y, ATK_XY_WINDOW);
462         atk_component_get_size(ATK_COMPONENT(obj), &width, &height);
463         atk_layer = atk_component_get_layer(ATK_COMPONENT(obj));
464         atk_mdi_zorder = atk_component_get_mdi_zorder(ATK_COMPONENT(obj));
465         atk_alpha = atk_component_get_alpha(ATK_COMPONENT(obj));
466
467         if (asprintf(&s_position,"X: %d, Y: %d", s_x, s_y) < 0)
468                 EINA_LOG_ERR(ERR_SET_POSITION);
469         if (asprintf(&w_position,"X: %d, Y: %d", w_x, w_y) < 0)
470                 EINA_LOG_ERR(ERR_SET_POSITION);
471         if (asprintf(&size, "%s: %d, %s: %d", width_char, width, height_char, height) < 0)
472                 EINA_LOG_ERR(ERR_SET_POSITION);
473         if (asprintf(&layer, "%d",  atk_layer) < 0)
474                 EINA_LOG_ERR(ERR_ATK_LAYER);
475         if (asprintf(&mdi_zorder, "%i", atk_mdi_zorder) < 0)
476                 EINA_LOG_ERR(ERR_MDI_ZORDER);
477         if (asprintf(&alpha, "%g", atk_alpha) < 0)
478                 EINA_LOG_ERR(ERR_ATK_ALPHA);
479         acs->atk_obj = obj;
480         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry1"));
481         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry2"));
482         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry3"));
483         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry4"));
484         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.label1"));
485         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.label2"));
486         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.label3"));
487
488         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label1"), s_position);
489         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label2"), w_position);
490         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label3"), size);
491         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label4"), layer);
492         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label5"), mdi_zorder);
493         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label6"), alpha);
494
495         elm_entry_entry_set(elm_object_part_content_get(eo, "elm.editor.name.entry1"), NULL);
496         elm_entry_entry_set(elm_object_part_content_get(eo, "elm.editor.name.entry2"), NULL);
497         elm_entry_entry_set(elm_object_part_content_get(eo, "elm.editor.name.entry3"), NULL);
498         elm_entry_entry_set(elm_object_part_content_get(eo, "elm.editor.name.entry4"), NULL);
499
500         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button"), "clicked", _component_resize_cb);
501         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button1"), "clicked", _component_change_position_cb);
502
503         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button"), "clicked", _component_resize_cb, acs);
504         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button1"), "clicked", _component_change_position_cb, acs);
505
506         elm_object_part_content_set(parent, "elm.layout", eo);
507         evas_object_show(eo);
508         free(s_position);
509         free(w_position);
510         free(size);
511         free(layer);
512         free(mdi_zorder);
513         free(alpha);
514 }
515
516 /**
517  * @brief prepares Component interface view
518  *
519  * Function prepares Component Layout by adding all
520  * the used objects to layout and setting object labels
521  *
522  * @param parent Parent Layout object
523  *
524  * @return Evas_Object representing component layout
525  */
526 Evas_Object* prepare_layout_component(Evas_Object *parent)
527 {
528         Evas_Object *eo = elm_layout_add(parent);
529         elm_layout_file_set(eo, EDJ_PATH_CMP, "explorer/component");
530
531         Evas_Object *lb1, *lb2, *lb3, *lb4, *lb5, *lb6;
532         Evas_Object *e1, *e2, *e3, *e4, *separator;
533         Evas_Object *button, *button1;
534         Evas_Object *box1, *box2, *box3, *box4;
535
536         lb1 = elm_label_add(eo);
537         lb2 = elm_label_add(eo);
538         lb3 = elm_label_add(eo);
539         lb4 = elm_label_add(eo);
540         lb5 = elm_label_add(eo);
541         lb6 = elm_label_add(eo);
542
543         box1 = elm_box_add(eo);
544         box2 = elm_box_add(eo);
545         box3 = elm_box_add(eo);
546         box4 = elm_box_add(eo);
547
548         e1 = elm_entry_add(eo);
549         e2 = elm_entry_add(eo);
550         e3 = elm_entry_add(eo);
551         e4  = elm_entry_add(eo);
552
553         button = elm_button_add(eo);
554         button1 = elm_button_add(eo);
555
556         separator = elm_separator_add(eo);
557
558         elm_separator_horizontal_set(separator, EINA_FALSE);
559
560         evas_object_size_hint_weight_set(e1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
561         evas_object_size_hint_align_set(e1, EVAS_HINT_FILL, EVAS_HINT_FILL);
562         elm_entry_line_wrap_set(e1, EINA_TRUE);
563         elm_entry_scrollable_set(e1, EINA_TRUE);
564         elm_box_pack_end(box1, e1);
565
566         evas_object_size_hint_weight_set(e2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
567         evas_object_size_hint_align_set(e2, EVAS_HINT_FILL, EVAS_HINT_FILL);
568         elm_entry_line_wrap_set(e2, EINA_TRUE);
569         elm_entry_scrollable_set(e2, EINA_TRUE);
570         elm_box_pack_end(box2, e2);
571
572         evas_object_size_hint_weight_set(e3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
573         evas_object_size_hint_align_set(e3, EVAS_HINT_FILL, EVAS_HINT_FILL);
574         elm_entry_line_wrap_set(e3, EINA_TRUE);
575         elm_entry_scrollable_set(e3, EINA_TRUE);
576         elm_box_pack_end(box3, e3);
577
578         evas_object_size_hint_weight_set(e4, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
579         evas_object_size_hint_align_set(e4, EVAS_HINT_FILL, EVAS_HINT_FILL);
580         elm_entry_line_wrap_set(e4, EINA_TRUE);
581         elm_entry_scrollable_set(e4, EINA_TRUE);
582         elm_box_pack_end(box4, e4);
583
584
585         elm_object_part_content_set(eo, "elm.editor.name.label1", lb1);
586         elm_object_part_content_set(eo, "elm.editor.name.label2", lb2);
587         elm_object_part_content_set(eo, "elm.editor.name.label3", lb3);
588         elm_object_part_content_set(eo, "elm.editor.name.label4", lb4);
589         elm_object_part_content_set(eo, "elm.editor.name.label5", lb5);
590         elm_object_part_content_set(eo, "elm.editor.name.label6", lb6);
591
592         elm_object_part_content_set(eo, "elm.editor.name.entry1", e1);
593         elm_object_part_content_set(eo, "elm.editor.name.entry2", e2);
594         elm_object_part_content_set(eo, "elm.editor.name.entry3", e3);
595         elm_object_part_content_set(eo, "elm.editor.name.entry4", e4);
596
597         elm_object_part_content_set(eo, "elm.editor.name.box1", box1);
598         elm_object_part_content_set(eo, "elm.editor.name.box2", box2);
599         elm_object_part_content_set(eo, "elm.editor.name.box3", box3);
600         elm_object_part_content_set(eo, "elm.editor.name.box4", box4);
601
602         elm_object_part_content_set(eo, "elm.editor.name.button", button);
603         elm_object_part_content_set(eo, "elm.editor.name.button1", button1);
604
605         elm_object_part_content_set(eo, "elm.separator.1", separator);
606
607         elm_object_part_text_set(e1, "guide", ENTER_VAL);
608         elm_object_part_text_set(e2, "guide", ENTER_VAL);
609         elm_object_part_text_set(e3, "guide", ENTER_VAL);
610         elm_object_part_text_set(e4, "guide", ENTER_VAL);
611
612         evas_object_color_set(separator, 1, 1, 1, 255);
613
614         elm_object_part_text_set(eo, "text1", POS_ON_SCREEN);
615         elm_object_part_text_set(eo, "text2", POS_IN_WIN);
616         elm_object_part_text_set(eo, "text3", SIZE);
617         elm_object_part_text_set(eo, "text4", LAYER);
618         elm_object_part_text_set(eo, "text5", MDI_ZORDER);
619         elm_object_part_text_set(eo, "text6", ALPHA);
620         elm_object_part_text_set(eo, "text7", SET_SIZE);
621         elm_object_part_text_set(eo, "text8", WIDTH);
622         elm_object_part_text_set(eo, "text9", HEIGHT);
623         elm_object_part_text_set(eo, "text10", CHANGE_POS);
624         elm_object_part_text_set(eo, "text11", X);
625         elm_object_part_text_set(eo, "text12", Y);
626
627         return eo;
628 }
629
630 /**
631  * @brief callback for set atk object name
632  *
633  * That callback function is called when "Set name" button
634  * on object layout is clicked, it set Accessible Name for
635  * focused object.
636  *
637  * @param data action_cb_struct which contains value from entry
638  * @param obj UNUSED
639  * @param event_info UNUSED
640  */
641 void _set_name_obj_cb(void *data, Evas_Object *obj, void *event_info)
642 {
643         action_cb_struct *acs = (action_cb_struct*)data;
644         if(!acs->atk_obj)
645         {
646                 return;
647         }
648         Evas_Object *e1 = eina_list_nth(acs->list, 0);
649         Evas_Object *e2 = eina_list_nth(acs->list, 1);
650         const char *text = elm_entry_entry_get(e2);
651         if(text == NULL)
652         {
653                 text = "";
654         }
655         atk_object_set_name(acs->atk_obj, text);
656         elm_object_text_set(e1, atk_object_get_name(acs->atk_obj));
657         selected_item_update();
658 }
659
660 /**
661  * @brief callback for set atk object description
662  *
663  * That callback function is called when "Set description" button
664  * on object layout is clicked, it set Accessible Description for
665  * focused object.
666  *
667  * @param data action_cb_struct which contains value from entry
668  * @param obj UNUSED
669  * @param event_info UNUSED
670  */
671 void _set_desc_obj_cb(void *data, Evas_Object *obj, void *event_info)
672 {
673         action_cb_struct *acs = (action_cb_struct*)data;
674         if(!acs->atk_obj)
675         {
676                 return;
677         }
678         Evas_Object *e1 = eina_list_nth(acs->list, 2);
679         Evas_Object *e2 = eina_list_nth(acs->list, 3);
680         const char *text = elm_entry_entry_get(e2);
681         if(text == NULL)
682         {
683                 text = "";
684         }
685         atk_object_set_description(acs->atk_obj, text);
686         elm_object_text_set(e1, atk_object_get_description(acs->atk_obj));
687 }
688
689 /**
690  * @brief prints Object layout
691  *
692  * Main function to print object layout, called when click object label
693  * in toolbar is clicked or when focus is changed to new object,
694  * that function fills all entries and labels in that layout,
695  * register callbacks on objects
696  *
697  * @param eo Object Layout object
698  * @param obj AtkObject which has focus
699  * @param parent Main Layout object
700  */
701 void print_object(Evas_Object *eo, AtkObject *obj, Evas_Object *parent)
702 {
703         if(!acs)
704         {
705                 acs = (action_cb_struct*)malloc(sizeof(action_cb_struct));
706         }
707         else
708         {
709                 eina_list_free(acs->list);
710         }
711
712         AtkObject *parent_obj;
713         AtkRole role;
714         AtkRelationSet *relationSet;
715         AtkStateSet *stateSet;
716         Evas_Object *btn1, *btn2;
717
718         parent_obj = atk_object_get_parent(obj);
719         role = atk_object_get_role(obj);
720         relationSet = atk_object_ref_relation_set(obj);
721         stateSet = atk_object_ref_state_set(obj);
722
723         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label1"), g_type_name(G_TYPE_FROM_INSTANCE(obj)));
724         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label2"), atk_object_get_name(obj));
725         elm_entry_entry_set(elm_object_part_content_get(eo, "elm.editor.name.entry1"), NULL);
726
727         if(parent_obj)
728         {
729                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label3"), g_type_name(G_TYPE_FROM_INSTANCE(parent_obj)));
730                 const char *parent_name = atk_object_get_name(parent_obj);
731                 if(parent_name)
732                 {
733                         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label4"), atk_object_get_name(parent_obj));
734                 }
735                 else
736                 {
737                         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label4"), NO_NAME);
738                 }
739                 if(atk_object_get_index_in_parent(obj) == -1)
740                 {
741                         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label5"), INDEX_ERR);
742                 }
743                 else
744                 {
745                         char *c = NULL;
746                         if (asprintf(&c,"%d", atk_object_get_index_in_parent(obj)) < 0)
747                                 EINA_LOG_ERR(ERR_OBJECT_INDEX);
748                         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label5"), c);
749                         free(c);
750                 }
751         }
752         else
753         {
754                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label3"), NO_PAR);
755                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label4"), NO_PAR);
756                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label5"), NO_PAR);
757         }
758         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label6"), atk_role_get_name(role));
759         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label7"), atk_object_get_description(obj));
760         elm_entry_entry_set(elm_object_part_content_get(eo, "elm.editor.name.entry2"), NULL);
761         char *c = NULL;
762         if (asprintf(&c,"%d", atk_object_get_n_accessible_children(obj)) < 0)
763                 EINA_LOG_ERR(ERR_CHILD_COUNT);
764         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label9"),c);
765         free(c);
766         if (atk_relation_set_get_n_relations(relationSet) != 0 )
767                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label9"), EXISTS);
768         else
769                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label9"), NOT_EXISTS);
770
771         if (atk_state_set_is_empty(stateSet))
772         {
773                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label10"), NO_STATES);
774         }
775         else
776         {
777                 char *states = NULL;
778                 AtkStateType i;
779                 for (i = ATK_STATE_INVALID; i <= ATK_STATE_LAST_DEFINED; i++) {
780                         if (atk_state_set_contains_state(stateSet, i)){
781                                 const char *state = atk_state_type_get_name(i);
782                                 if(!states)
783                                 {
784                                         if(asprintf(&states, "%s", state) < 0)
785                                                 EINA_LOG_ERR(ERR_WRITE_STATES);
786                                 }
787                                 else
788                                 {
789                                         char *temp = NULL;
790                                         if(asprintf(&temp, "%s, %s", states, state) < 0)
791                                                 EINA_LOG_ERR(ERR_WRITE_STATES);
792                                         free(states);
793                                         states = temp;
794                                 }
795                         }
796                 }
797                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label10"), states);
798                 free(states);
799         }
800
801         g_object_unref(stateSet);
802
803         btn1 = elm_object_part_content_get(eo, "elm.editor.name.button1");
804         btn2 = elm_object_part_content_get(eo, "elm.editor.name.button2");
805         acs->list = NULL;
806         acs->atk_obj = obj;
807         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.label2"));
808         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry1"));
809         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.label7"));
810         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry2"));
811
812         evas_object_smart_callback_add(btn1, "clicked", _set_name_obj_cb, acs);
813
814         evas_object_smart_callback_add(btn2, "clicked", _set_desc_obj_cb, acs);
815
816         elm_object_part_content_set(parent, "elm.layout", eo);
817         evas_object_show(eo);
818 }
819
820 /**
821  * @brief prepares Object interface view
822  *
823  * Function prepares Object Layout by adding all
824  * the used objects to layout and setting object labels
825  *
826  * @param parent Parent Layout object
827  *
828  * @return Evas_Object representing Object layout
829  */
830 Evas_Object* prepare_layout_object(Evas_Object *parent)
831 {
832         Evas_Object *eo = elm_layout_add(parent);
833         elm_layout_file_set(eo, EDJ_PATH_OBJ, "explorer/object");
834
835         Evas_Object *lb1, *lb2, *lb3, *lb4, *lb5, *lb6, *lb7, *lb8, *lb9, *lb10;
836         Evas_Object *e3, *e9;
837         Evas_Object *separator, *btn1, *btn2;
838         Evas_Object *box1, *box2;
839
840         lb1 = elm_label_add(eo);
841         lb2 = elm_label_add(eo);
842         lb3 = elm_label_add(eo);
843         lb4 = elm_label_add(eo);
844         lb5 = elm_label_add(eo);
845         lb6 = elm_label_add(eo);
846         lb7 = elm_label_add(eo);
847         lb8 = elm_label_add(eo);
848         lb9 = elm_label_add(eo);
849         lb10 = elm_label_add(eo);
850
851         btn1 = elm_button_add(eo);
852         btn2 = elm_button_add(eo);
853
854         box1 = elm_box_add(eo);
855         box2 = elm_box_add(eo);
856
857         separator = elm_separator_add(eo);
858         elm_separator_horizontal_set(separator, EINA_FALSE);
859
860         e3 = elm_entry_add(eo);
861         e9 = elm_entry_add(eo);
862
863         evas_object_size_hint_weight_set(e3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
864         evas_object_size_hint_align_set(e3, EVAS_HINT_FILL, EVAS_HINT_FILL);
865         elm_entry_line_wrap_set(e3, EINA_TRUE);
866         elm_entry_scrollable_set(e3, EINA_TRUE);
867         elm_box_pack_end(box1, e3);
868
869         evas_object_size_hint_weight_set(e9, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
870         evas_object_size_hint_align_set(e9, EVAS_HINT_FILL, EVAS_HINT_FILL);
871         elm_entry_line_wrap_set(e9, EINA_TRUE);
872         elm_entry_scrollable_set(e9, EINA_TRUE);
873         elm_box_pack_end(box2, e9);
874
875         elm_object_part_content_set(eo, "elm.editor.name.box1", box1);
876         elm_object_part_content_set(eo, "elm.editor.name.box2", box2);
877         elm_object_part_content_set(eo, "elm.editor.name.label1", lb1);
878         elm_object_part_content_set(eo, "elm.editor.name.label2", lb2);
879         elm_object_part_content_set(eo, "elm.editor.name.label3", lb3);
880         elm_object_part_content_set(eo, "elm.editor.name.label4", lb4);
881         elm_object_part_content_set(eo, "elm.editor.name.label5", lb5);
882         elm_object_part_content_set(eo, "elm.editor.name.label6", lb6);
883         elm_object_part_content_set(eo, "elm.editor.name.label7", lb7);
884         elm_object_part_content_set(eo, "elm.editor.name.label8", lb8);
885         elm_object_part_content_set(eo, "elm.editor.name.label9", lb9);
886         elm_object_part_content_set(eo, "elm.editor.name.label10", lb10);
887
888         elm_object_part_content_set(eo, "elm.editor.name.entry1", e3);
889         elm_object_part_content_set(eo, "elm.editor.name.entry2", e9);
890
891         elm_object_part_content_set(eo, "elm.editor.name.button1", btn1);
892         elm_object_part_content_set(eo, "elm.editor.name.button2", btn2);
893
894         elm_object_part_content_set(eo, "elm.separator.1", separator);
895
896         elm_entry_editable_set(e3, EINA_TRUE);
897         elm_entry_editable_set(e9, EINA_TRUE);
898
899         elm_entry_single_line_set(e3, EINA_TRUE);
900         elm_entry_single_line_set(e9, EINA_TRUE);
901
902         elm_object_part_text_set(e3, "guide", ENTER_NAME);
903         elm_object_part_text_set(e9, "guide", ENTER_DESC);
904
905         elm_object_part_text_set(eo, "text1", ACC_TYPE);
906         elm_object_part_text_set(eo, "text2", ACC_NAME);
907         elm_object_part_text_set(eo, "text3", ACC_NAME_TO_SET);
908         elm_object_part_text_set(eo, "text4", PAR_ACC_TYPE);
909         elm_object_part_text_set(eo, "text5", PAR_ACC_NAME);
910         elm_object_part_text_set(eo, "text6", INDEX_IN_PAR);
911         elm_object_part_text_set(eo, "text8", ACC_DESC);
912         elm_object_part_text_set(eo, "text9", ACC_DESC_TO_SET);
913         elm_object_part_text_set(eo, "text7", ACC_ROLE);
914         elm_object_part_text_set(eo, "text10", NUM_OF_CHILDREN);
915         elm_object_part_text_set(eo, "text11", NUM_OF_RELATIONS);
916         elm_object_part_text_set(eo, "text12", ACC_STATES);
917
918         elm_label_slide_duration_set(lb1, 3);
919         elm_label_slide_duration_set(lb2, 3);
920         elm_label_slide_duration_set(lb3, 3);
921         elm_label_slide_duration_set(lb4, 3);
922         elm_label_slide_duration_set(lb5, 3);
923         elm_label_slide_duration_set(lb6, 3);
924         elm_label_slide_duration_set(lb7, 3);
925         elm_label_slide_duration_set(lb8, 3);
926         elm_label_slide_duration_set(lb9, 3);
927         elm_label_slide_duration_set(lb10, 3);
928
929         elm_object_style_set(lb1, "slide_bounce");
930         elm_object_style_set(lb2, "slide_bounce");
931         elm_object_style_set(lb3, "slide_bounce");
932         elm_object_style_set(lb4, "slide_bounce");
933         elm_object_style_set(lb5, "slide_bounce");
934         elm_object_style_set(lb6, "slide_bounce");
935         elm_object_style_set(lb7, "slide_bounce");
936         elm_object_style_set(lb8, "slide_bounce");
937         elm_object_style_set(lb9, "slide_bounce");
938         elm_object_style_set(lb10, "slide_bounce");
939
940         elm_label_line_wrap_set(lb10, ELM_WRAP_WORD);
941
942         evas_object_color_set(separator, 1, 1, 1, 255);
943         elm_object_part_text_set(btn1, "default", SET_NAME);
944         elm_object_part_text_set(btn2, "default", SET_DESC);
945
946         return eo;
947 }
948
949 /**
950  * @brief changes a row's description in a table
951  *
952  * Interface table allow to set description for row,
953  * that function take description from entry after
954  * "Set description" and set Accessible row description
955  *
956  * @param data action cb struct which contains entry field from layout and atk object
957  * @param obj Layout object
958  * @param event_info UNUSED
959  */
960 void _table_change_row_desc(void *data, Evas_Object *obj, void *event_info)
961 {
962         action_cb_struct *acs = (action_cb_struct*)data;
963         if(!acs->atk_obj)
964         {
965                 return;
966         }
967         Evas_Object *eo = eina_list_nth(acs->list, 0);
968         int int_row_n = atk_table_get_n_rows(ATK_TABLE(acs->atk_obj));
969         int i;
970         for(i = 0; i < int_row_n; ++i)
971         {
972                 if(atk_table_is_row_selected(ATK_TABLE(acs->atk_obj), i))
973                 {
974                         atk_table_set_row_description(ATK_TABLE(acs->atk_obj), i, elm_entry_entry_get(eo));
975                 }
976         }
977 }
978
979 /**
980  * @brief changes a column's description in a table
981  *
982  * Interface table allow to set description for column,
983  * that function take description from entry after
984  * "Set description" and set Accessible column description
985  *
986  * @param data action cb struct which contains entry field from layout and atk object
987  * @param obj Layout object
988  * @param event_info UNUSED
989  */
990 void _table_change_col_desc(void *data, Evas_Object *obj, void *event_info)
991 {
992         action_cb_struct *acs = (action_cb_struct*)data;
993         if(!acs->atk_obj)
994         {
995                 return;
996         }
997         Evas_Object *eo = eina_list_nth(acs->list, 1);
998         int int_col_n = atk_table_get_n_columns(ATK_TABLE(acs->atk_obj));
999         int i;
1000         for(i = 0; i < int_col_n; ++i)
1001         {
1002                 if(atk_table_is_column_selected(ATK_TABLE(acs->atk_obj), i))
1003                 {
1004                         atk_table_set_column_description(ATK_TABLE(acs->atk_obj), i, elm_entry_entry_get(eo));
1005                 }
1006         }
1007 }
1008
1009 /**
1010  * @brief selects next column in a table
1011  *
1012  * That callback is called when "Next column" button is selected in
1013  * table layout, it add selection to next column.
1014  *
1015  * @param data action cb struct which contains given table object
1016  * @param obj UNUSED
1017  * @param event_info UNUSED
1018  */
1019 void _table_next_col(void *data, Evas_Object *obj, void *event_info)
1020 {
1021         action_cb_struct *acs = (action_cb_struct*)data;
1022         if(!acs->atk_obj)
1023         {
1024                 return;
1025         }
1026         int int_col_n = atk_table_get_n_columns(ATK_TABLE(acs->atk_obj));
1027         int i;
1028         for(i = 0; i < int_col_n - 1; ++i)
1029         {
1030                 if(atk_table_is_column_selected(ATK_TABLE(acs->atk_obj), i))
1031                 {
1032                         atk_table_add_column_selection(ATK_TABLE(acs->atk_obj), i + 1);
1033                         return;
1034                 }
1035         }
1036         atk_table_add_column_selection(ATK_TABLE(acs->atk_obj), 0);
1037 }
1038
1039 /**
1040  * @brief selects previous column in a table
1041  *
1042  * That callback is called when "Previous column" button is selected in
1043  * table layout, it add selection to previous column.
1044  *
1045  * @param data action cb struct which contains given table object
1046  * @param obj UNUSED
1047  * @param event_info UNUSED
1048  */
1049 void _table_prev_col(void *data, Evas_Object *obj, void *event_info)
1050 {
1051         action_cb_struct *acs = (action_cb_struct*)data;
1052         if(!acs->atk_obj)
1053         {
1054                 return;
1055         }
1056         int int_col_n = atk_table_get_n_columns(ATK_TABLE(acs->atk_obj));
1057         int i;
1058         for(i = 1; i < int_col_n; ++i)
1059         {
1060                 if(atk_table_is_column_selected(ATK_TABLE(acs->atk_obj), i))
1061                 {
1062                         atk_table_add_column_selection(ATK_TABLE(acs->atk_obj), i - 1);
1063                         return;
1064                 }
1065         }
1066         atk_table_add_column_selection(ATK_TABLE(acs->atk_obj), int_col_n - 1);
1067 }
1068
1069 /**
1070  * @brief selects next row in a table
1071  *
1072  * That callback is called when "Next row" button is selected in
1073  * table layout, it add selection to next row.
1074  *
1075  * @param data action cb struct which contains given table object
1076  * @param obj UNUSED
1077  * @param event_info UNUSED
1078  */
1079 void _table_next_row(void *data, Evas_Object *obj, void *event_info)
1080 {
1081         action_cb_struct *acs = (action_cb_struct*)data;
1082         if(!acs->atk_obj)
1083         {
1084                 return;
1085         }
1086         int int_row_n = atk_table_get_n_rows(ATK_TABLE(acs->atk_obj));
1087         int i;
1088         for(i = 1; i < int_row_n; ++i)
1089         {
1090                 if(atk_table_is_row_selected(ATK_TABLE(acs->atk_obj), i))
1091                 {
1092                         atk_table_add_row_selection(ATK_TABLE(acs->atk_obj), i - 1);
1093                         return;
1094                 }
1095         }
1096         atk_table_add_row_selection(ATK_TABLE(acs->atk_obj), int_row_n - 1);
1097 }
1098
1099 /**
1100  * @brief selects previous row in a table
1101  *
1102  * That callback is called when "Previous row" button is selected in
1103  * table layout, it add selection to previous row.
1104  *
1105  * @param data action cb struct which contains given table object
1106  * @param obj UNUSED
1107  * @param event_info UNUSED
1108  */
1109 void _table_prev_row(void *data, Evas_Object *obj, void *event_info)
1110 {
1111         action_cb_struct *acs = (action_cb_struct*)data;
1112         if(!acs->atk_obj)
1113         {
1114                 return;
1115         }
1116         int int_row_n = atk_table_get_n_rows(ATK_TABLE(acs->atk_obj));
1117         int i;
1118         for(i = 1; i < int_row_n; ++i)
1119         {
1120                 if(atk_table_is_row_selected(ATK_TABLE(acs->atk_obj), i))
1121                 {
1122                         atk_table_add_row_selection(ATK_TABLE(acs->atk_obj), i - 1);
1123                         return;
1124                 }
1125         }
1126         atk_table_add_row_selection(ATK_TABLE(acs->atk_obj), int_row_n - 1);
1127 }
1128
1129 /**
1130  * @brief prints Table layout
1131  *
1132  * Main function to print table layout, called when click on table
1133  * label in toolbar is clicked, that function fills all entries and labels
1134  * in that layout, register callbacks on objects
1135  *
1136  * @param eo Table Layout object
1137  * @param obj AtkObject which has focus
1138  * @param parent Main Layout object
1139  */
1140 void print_table(Evas_Object *eo, AtkObject *obj, Evas_Object *tb, Evas_Object *parent)
1141 {
1142         if(!acs)
1143         {
1144                 acs = (action_cb_struct*)malloc(sizeof(action_cb_struct));
1145         }
1146         else
1147         {
1148                 eina_list_free(acs->list);
1149         }
1150
1151         char *rows_n = NULL;
1152         char *cols_n = NULL;
1153
1154         int int_row_n = atk_table_get_n_rows(ATK_TABLE(obj));
1155         int int_col_n = atk_table_get_n_columns(ATK_TABLE(obj));
1156
1157         if (asprintf(&rows_n, "%d", int_row_n) < 0)
1158                 EINA_LOG_ERR(ERR_ROW);
1159         if (asprintf(&cols_n, "%d", int_col_n) < 0)
1160                 EINA_LOG_ERR(ERR_COLUMN);
1161
1162         const char *sel_col_desc = NULL;
1163         const char *sel_row_desc = NULL;
1164         acs->list = NULL;
1165
1166         int i;
1167         for(i = 0; i < int_row_n; ++i)
1168         {
1169                 if(atk_table_is_row_selected(ATK_TABLE(obj), i))
1170                 {
1171                         sel_row_desc = atk_table_get_row_description(ATK_TABLE(obj), i);
1172                 }
1173         }
1174         for(i = 0; i < int_col_n; ++i)
1175         {
1176                 if(atk_table_is_column_selected(ATK_TABLE(obj), i))
1177                 {
1178                         sel_col_desc = atk_table_get_column_description(ATK_TABLE(obj), i);
1179                 }
1180         }
1181
1182         acs->atk_obj = obj;
1183         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry1"));
1184         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry2"));
1185
1186         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button1"), "clicked", _table_change_row_desc);
1187         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button2"), "clicked", _table_change_col_desc);
1188         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button3"), "clicked", _table_next_col);
1189         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button4"), "clicked", _table_prev_col);
1190         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button5"), "clicked", _table_next_row);
1191         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button6"), "clicked", _table_prev_row);
1192
1193         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button1"), "clicked", _table_change_row_desc, acs);
1194         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button2"), "clicked", _table_change_col_desc, acs);
1195         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button3"), "clicked", _table_next_col, acs);
1196         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button4"), "clicked", _table_prev_col, acs);
1197         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button5"), "clicked", _table_next_row, acs);
1198         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button6"), "clicked", _table_prev_row, acs);
1199
1200         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label1"), cols_n);
1201         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label2"), rows_n);
1202         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label3"), sel_row_desc);
1203         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label4"), sel_col_desc);
1204
1205         elm_object_part_content_set(parent, "elm.layout", eo);
1206         evas_object_show(eo);
1207         free(rows_n);
1208         free(cols_n);
1209 }
1210
1211 /**
1212  * @brief prepares Table interface view
1213  *
1214  * Function prepares table Layout by adding all
1215  * the used objects to layout and setting object labels
1216  *
1217  * @param parent Parent Layout object
1218  *
1219  * @return Evas_Object representing table layout
1220  */
1221 Evas_Object* prepare_layout_table(Evas_Object *parent)
1222 {
1223         Evas_Object *eo = elm_layout_add(parent);
1224         elm_layout_file_set(eo, EDJ_PATH_TBL, "explorer/table");
1225
1226         Evas_Object *separator;
1227         Evas_Object *lb1, *lb2, *lb3, *lb4, *e1, *e2;
1228         Evas_Object *button1, *button2, *button3, *button4, *button5, *button6;
1229         Evas_Object *box1, *box2;
1230
1231         lb1 = elm_label_add(eo);
1232         lb2 = elm_label_add(eo);
1233         lb3 = elm_label_add(eo);
1234         lb4 = elm_label_add(eo);
1235
1236         box1 = elm_box_add(eo);
1237         box2 = elm_box_add(eo);
1238
1239         e1 = elm_entry_add(eo);
1240         e2 = elm_entry_add(eo);
1241
1242         button1 = elm_button_add(eo);
1243         button2 = elm_button_add(eo);
1244         button3 = elm_button_add(eo);
1245         button4 = elm_button_add(eo);
1246         button5 = elm_button_add(eo);
1247         button6 = elm_button_add(eo);
1248
1249         separator = elm_separator_add(eo);
1250         elm_separator_horizontal_set(separator, EINA_FALSE);
1251
1252         evas_object_size_hint_weight_set(e1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1253         evas_object_size_hint_align_set(e1, EVAS_HINT_FILL, EVAS_HINT_FILL);
1254         elm_entry_scrollable_set(e1, EINA_TRUE);
1255         elm_entry_line_wrap_set(e1, EINA_TRUE);
1256         elm_box_pack_end(box1, e1);
1257
1258         evas_object_size_hint_weight_set(e2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1259         evas_object_size_hint_align_set(e2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1260         elm_entry_scrollable_set(e2, EINA_TRUE);
1261         elm_entry_line_wrap_set(e2, EINA_TRUE);
1262         elm_box_pack_end(box2, e2);
1263
1264         elm_object_part_content_set(eo, "elm.editor.name.label1", lb1);
1265         elm_object_part_content_set(eo, "elm.editor.name.label2", lb2);
1266         elm_object_part_content_set(eo, "elm.editor.name.label3", lb3);
1267         elm_object_part_content_set(eo, "elm.editor.name.label4", lb4);
1268
1269         elm_object_part_content_set(eo, "elm.editor.name.entry1", e1);
1270         elm_object_part_content_set(eo, "elm.editor.name.entry2", e2);
1271
1272         elm_object_part_content_set(eo, "elm.editor.name.box1", box1);
1273         elm_object_part_content_set(eo, "elm.editor.name.box2", box2);
1274
1275         elm_object_part_content_set(eo, "elm.editor.name.button1", button1);
1276         elm_object_part_content_set(eo, "elm.editor.name.button2", button2);
1277         elm_object_part_content_set(eo, "elm.editor.name.button3", button3);
1278         elm_object_part_content_set(eo, "elm.editor.name.button4", button4);
1279         elm_object_part_content_set(eo, "elm.editor.name.button5", button5);
1280         elm_object_part_content_set(eo, "elm.editor.name.button6", button6);
1281
1282         elm_object_part_content_set(eo, "elm.separator.1", separator);
1283         evas_object_color_set(separator, 1, 1, 1, 255);
1284
1285         elm_label_slide_duration_set(lb1, 3);
1286         elm_label_slide_duration_set(lb2, 3);
1287         elm_label_slide_duration_set(lb3, 3);
1288         elm_label_slide_duration_set(lb4, 3);
1289
1290         elm_object_style_set(lb1, "slide_bounce");
1291         elm_object_style_set(lb2, "slide_bounce");
1292         elm_object_style_set(lb3, "slide_bounce");
1293         elm_object_style_set(lb4, "slide_bounce");
1294
1295         elm_entry_editable_set(e1, EINA_TRUE);
1296         elm_entry_editable_set(e2, EINA_TRUE);
1297
1298         elm_entry_single_line_set(e1, EINA_TRUE);
1299         elm_entry_single_line_set(e2, EINA_TRUE);
1300
1301         elm_object_part_text_set(e1, "guide", ENTER_DESC);
1302         elm_object_part_text_set(e2, "guide", ENTER_DESC);
1303
1304         elm_object_text_set(button1, SET_DESC);
1305         elm_object_text_set(button2, SET_DESC);
1306         elm_object_text_set(button3, NEXT_COL);
1307         elm_object_text_set(button4, PREV_COL);
1308         elm_object_text_set(button5, NEXT_ROW);
1309         elm_object_text_set(button6, PREV_ROW);
1310
1311         elm_object_part_text_set(eo, "text1", NUM_OF_ROWS);
1312         elm_object_part_text_set(eo, "text2", NUM_OF_COLS);
1313         elm_object_part_text_set(eo, "text3", SEL_ROW_DESC);
1314         elm_object_part_text_set(eo, "text4", SEL_COL_DESC);
1315         elm_object_part_text_set(eo, "text5", SET_SEL_ROW_DESC);
1316         elm_object_part_text_set(eo, "text6", SET_SEL_COL_DESC);
1317         elm_object_part_text_set(eo, "text7", SEL_NEXT_COL);
1318         elm_object_part_text_set(eo, "text8", SEL_PREV_COL);
1319         elm_object_part_text_set(eo, "text9", SEL_NEXT_ROW);
1320         elm_object_part_text_set(eo, "text10", SEL_PREV_ROW);
1321
1322         return eo;
1323 }
1324
1325 /**
1326  * @brief selects the first element
1327  *
1328  * Callback called when "select first child" button on Selection Layout is clicked,
1329  * it perform selection for the first object in object set.
1330  *
1331  * @param data action_cb_stuct, which contains object with avaiable selection interface
1332  * @param obj UNUSED
1333  * @param event_info UNUSED
1334  */
1335 void _select_first_selection(void *data, Evas_Object *obj, void *event_info)
1336 {
1337         action_cb_struct *acs = (action_cb_struct*)data;
1338         atk_selection_add_selection(ATK_SELECTION(acs->atk_obj), 0);
1339 }
1340
1341 /**
1342  * @brief selects the last element
1343  *
1344  * Callback called when "select last child" button on Selection Layout is clicked,
1345  * it perform selection for the last object in object set.
1346  *
1347  * @param data data action_cb_stuct, which contains object with avaiable selection interface
1348  * @param obj UNUSED
1349  * @param event_info UNUSED
1350  */
1351 void _select_last_selection(void *data, Evas_Object *obj, void *event_info)
1352 {
1353         action_cb_struct *acs = (action_cb_struct*)data;
1354         int counter = atk_object_get_n_accessible_children(acs->atk_obj);
1355         atk_selection_add_selection(ATK_SELECTION(acs->atk_obj), counter - 1);
1356 }
1357
1358 /**
1359  * @brief selects the next element
1360  *
1361  * Callback called when "select next child" button on Selection Layout is clicked,
1362  * it perform selection for the next object in object set.
1363  *
1364  * @param data data action_cb_stuct, which contains object with avaiable selection interface
1365  * @param obj UNUSED
1366  * @param event_info UNUSED
1367  */
1368 void _select_next_selection(void *data, Evas_Object *obj, void *event_info)
1369 {
1370         action_cb_struct *acs = (action_cb_struct*)data;
1371         int i;
1372         int counter = atk_object_get_n_accessible_children(acs->atk_obj);
1373         for(i = 0; i < counter - 1; ++i)
1374         {
1375                 if(atk_selection_is_child_selected(ATK_SELECTION(acs->atk_obj), i))
1376                 {
1377                         atk_selection_add_selection(ATK_SELECTION(acs->atk_obj), i + 1);
1378                         return;
1379                 }
1380         }
1381         atk_selection_add_selection(ATK_SELECTION(acs->atk_obj), 0);
1382 }
1383
1384 /**
1385  * @brief selects the previous element
1386  *
1387  * Callback called when "select previous child" button on Selection Layout is clicked,
1388  * it perform selection for the previous object in object set.
1389  *
1390  * @param data data action_cb_stuct, which contains object with avaiable selection interface
1391  * @param obj UNUSED
1392  * @param event_info UNUSED
1393  */
1394 void _select_prev_selection(void *data, Evas_Object *obj, void *event_info)
1395 {
1396         action_cb_struct *acs = (action_cb_struct*)data;
1397         int i;
1398         int counter = atk_object_get_n_accessible_children(acs->atk_obj);
1399         for(i = 1; i < counter; ++i)
1400         {
1401                 if(atk_selection_is_child_selected(ATK_SELECTION(acs->atk_obj), i))
1402                 {
1403                         atk_selection_add_selection(ATK_SELECTION(acs->atk_obj), i - 1);
1404                         return;
1405                 }
1406         }
1407         atk_selection_add_selection(ATK_SELECTION(acs->atk_obj), counter - 1);
1408 }
1409
1410 /**
1411  * @brief clears the selection
1412  *
1413  * Callback called when "clear selection" button on Selection Layout is clicked,
1414  * it perform selection clean for all objects in object set.
1415  *
1416  * @param data action_cb_stuct, which contains object with avaiable selection interface
1417  * @param obj UNUSED
1418  * @param event_info UNUSED
1419  */
1420 void _clear_selection(void *data, Evas_Object *obj, void *event_info)
1421 {
1422         action_cb_struct *acs = (action_cb_struct*)data;
1423         atk_selection_clear_selection(ATK_SELECTION(acs->atk_obj));
1424 }
1425
1426 /**
1427  * @brief selects all the elements
1428  *
1429  * Callback called when "select all children" button on Selection Layout is clicked,
1430  * it perform selection for the all objects in object set.
1431  *
1432  * @param data action_cb_stuct, which contains object with avaiable selection interface
1433  * @param obj UNUSED
1434  * @param event_info UNUSED
1435  */
1436 void _all_selection(void *data, Evas_Object *obj, void *event_info)
1437 {
1438         action_cb_struct *acs = (action_cb_struct*)data;
1439         atk_selection_select_all_selection(ATK_SELECTION(acs->atk_obj));
1440 }
1441
1442 /**
1443  * @brief prints the Selection layout
1444  *
1445  * Main function to print selection layout, called when click on selection
1446  * label in toolbar is clicked, that function fills all entries and labels
1447  * in that layout, register callbacks on objects
1448  *
1449  * @param eo Selection Layout object
1450  * @param obj AtkObject which has focus
1451  * @param parent Main Layout object
1452  */
1453 void print_selection(Evas_Object *eo, AtkObject *obj, Evas_Object *parent)
1454 {
1455         if(!acs)
1456         {
1457                 acs = (action_cb_struct*)malloc(sizeof(action_cb_struct));
1458         }
1459         else
1460         {
1461                 eina_list_free(acs->list);
1462         }
1463
1464         acs->atk_obj = obj;
1465         acs->list = NULL;
1466
1467         char *children = NULL;
1468         Evas_Object *lb1 = elm_object_part_content_get(eo, "elm.selection.name.label1");
1469         if (asprintf(&children,"%d", atk_selection_get_selection_count(ATK_SELECTION(obj))) < 0 )
1470                 EINA_LOG_ERR(ERR_SELECTION);
1471         elm_object_text_set(lb1, children);
1472
1473         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.selection.name.button1"), "clicked", _select_first_selection);
1474         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.selection.name.button2"), "clicked", _select_last_selection);
1475         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.selection.name.button3"), "clicked", _select_next_selection);
1476         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.selection.name.button4"), "clicked", _select_prev_selection);
1477         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.selection.name.button5"), "clicked", _clear_selection);
1478         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.selection.name.button6"), "clicked", _all_selection);
1479
1480         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.selection.name.button1"), "clicked", _select_first_selection, acs);
1481         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.selection.name.button2"), "clicked", _select_last_selection, acs);
1482         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.selection.name.button3"), "clicked", _select_next_selection, acs);
1483         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.selection.name.button4"), "clicked", _select_prev_selection, acs);
1484         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.selection.name.button5"), "clicked", _clear_selection, acs);
1485         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.selection.name.button6"), "clicked", _all_selection, acs);
1486
1487
1488         elm_object_part_content_set(parent, "elm.layout", eo);
1489         evas_object_show(eo);
1490         free(children);
1491 }
1492
1493 /**
1494  * @brief prepares Selection interface view
1495  *
1496  * Function prepares Selection Layout by adding all
1497  * the used objects to layout and setting object labels
1498  *
1499  * @param parent Parent Layout object
1500  *
1501  * @return Evas_Object representing Selection layout
1502  */
1503 Evas_Object* prepare_layout_selection(Evas_Object *parent)
1504 {
1505         Evas_Object *eo = elm_layout_add(parent);
1506         elm_layout_file_set(eo, EDJ_PATH_SEL, "explorer/selection");
1507         Evas_Object *lb1, *separator, *button1, *button2, *button3;
1508         Evas_Object *button4, *button5, *button6;
1509
1510         lb1 = elm_label_add(eo);
1511         button1 = elm_button_add(eo);
1512         button2 = elm_button_add(eo);
1513         button3 = elm_button_add(eo);
1514         button4 = elm_button_add(eo);
1515         button5 = elm_button_add(eo);
1516         button6 = elm_button_add(eo);
1517
1518         elm_object_text_set(button1, SEL);
1519         elm_object_text_set(button2, SEL);
1520         elm_object_text_set(button3, SEL);
1521         elm_object_text_set(button4, SEL);
1522         elm_object_text_set(button5, SEL);
1523         elm_object_text_set(button6, SEL);
1524
1525         separator = elm_separator_add(eo);
1526         elm_separator_horizontal_set(separator, EINA_FALSE);
1527
1528         elm_object_part_content_set(eo, "elm.selection.name.label1", lb1);
1529         elm_object_part_content_set(eo, "elm.selection.name.button1", button1);
1530         elm_object_part_content_set(eo, "elm.selection.name.button2", button2);
1531         elm_object_part_content_set(eo, "elm.selection.name.button3", button3);
1532         elm_object_part_content_set(eo, "elm.selection.name.button4", button4);
1533         elm_object_part_content_set(eo, "elm.selection.name.button5", button5);
1534         elm_object_part_content_set(eo, "elm.selection.name.button6", button6);
1535         elm_object_part_content_set(eo, "elm.separator.1", separator);
1536
1537         evas_object_color_set(separator, 1, 1, 1, 255);
1538
1539         elm_label_slide_duration_set(lb1, 3);
1540         elm_object_style_set(lb1, "slide_bounce");
1541
1542
1543         elm_object_part_text_set(eo, "text1", NUM_OF_SEL_CHLD);
1544         elm_object_part_text_set(eo, "text2", SEL_FIRST_CHILD);
1545         elm_object_part_text_set(eo, "text3", SEL_LAST_CHILD);
1546         elm_object_part_text_set(eo, "text4", SEL_NEXT_CHILD);
1547         elm_object_part_text_set(eo, "text5", SEL_PREV_CHILD);
1548         elm_object_part_text_set(eo, "text6", CLEAR_SEL);
1549         elm_object_part_text_set(eo, "text7", SEL_ALL_CHILDREN);
1550
1551         return eo;
1552 }
1553
1554 /**
1555  * @brief change image description
1556  *
1557  * Callback called when set image description button is clicked.
1558  *
1559  * @param data action_cb_stuct, which contains object with avaiable image interface
1560  * @param obj UNUSED
1561  * @param event_info UNUSED
1562  */
1563 void _set_desc_img_cb(void *data, Evas_Object *obj, void *event_info)
1564 {
1565         action_cb_struct *acs = (action_cb_struct*)data;
1566         if(!acs->atk_obj)
1567         {
1568                 return;
1569         }
1570
1571         Evas_Object *entry = eina_list_nth(acs->list, 0);
1572         Evas_Object *label = eina_list_nth(acs->list, 1);
1573
1574         if(atk_image_set_image_description(ATK_IMAGE(acs->atk_obj), elm_entry_entry_get(entry)))
1575                 elm_object_text_set(label, atk_image_get_image_description(ATK_IMAGE(acs->atk_obj)));
1576         else
1577                 EINA_LOG_ERR(ERR_DESCRIPTION);
1578 }
1579
1580 /**
1581  * @brief prints the Image layout
1582  *
1583  * Main function to print image layout, called when click on image
1584  * label in toolbar is clicked, that function fills all entries and labels
1585  * in that layout, register callbacks on objects
1586  *
1587  * @param eo Image Layout object
1588  * @param obj AtkObject which has focus
1589  * @param parent Main Layout object
1590  */
1591 void print_image(Evas_Object *eo, AtkObject *obj, Evas_Object *tb, Evas_Object *parent)
1592 {
1593         if(!acs)
1594         {
1595                 acs = (action_cb_struct*)malloc(sizeof(action_cb_struct));
1596         }
1597         else
1598         {
1599                 eina_list_free(acs->list);
1600         }
1601
1602         acs->list = NULL;
1603
1604         acs->atk_obj = obj;
1605         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry1"));
1606         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.label1"));
1607
1608         const char *description = atk_image_get_image_description(ATK_IMAGE(obj));
1609         if(description)
1610         {
1611                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label1"), description);
1612         }
1613         else
1614         {
1615                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label1"), NO_DESC);
1616         }
1617
1618         int x, y;
1619         atk_image_get_image_position(ATK_IMAGE(obj), &x, &y, ATK_XY_WINDOW);
1620         char *position = NULL;
1621         if (asprintf(&position,"X: %d Y: %d", x, y) < 0)
1622                 EINA_LOG_ERR(ERR_GET_POSITION);
1623         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label2"), position);
1624
1625         atk_image_get_image_size(ATK_IMAGE(obj), &x, &y);
1626         char *size = NULL;
1627         if (asprintf(&size, "Width: %d Height: %d", x, y) < 0)
1628                 EINA_LOG_ERR(ERR_GET_POSITION);
1629         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label3"), size);
1630
1631         const char *locale = atk_image_get_image_locale(ATK_IMAGE(obj));
1632         if(!locale)
1633         {
1634                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label4"), NO_LOCALE);
1635         }
1636         else
1637         {
1638                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label4"), locale);
1639         }
1640
1641         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button1"), "clicked", _set_desc_img_cb);
1642         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button1"), "clicked", _set_desc_img_cb, acs);
1643
1644         elm_entry_entry_set(elm_object_part_content_get(eo, "elm.editor.name.entry1"), NULL);
1645
1646         elm_object_part_content_set(parent, "elm.layout", eo);
1647         evas_object_show(eo);
1648         free(position);
1649         free(size);
1650 }
1651
1652 /**
1653  * @brief prepares Image interface view
1654  *
1655  * Function prepares Image Layout by adding all
1656  * the used objects to layout and setting object labels
1657  *
1658  * @param parent Parent Layout object
1659  *
1660  * @return Evas_Object representing Image layout
1661  */
1662 Evas_Object* prepare_layout_image(Evas_Object *parent)
1663 {
1664         Evas_Object *eo = elm_layout_add(parent);
1665
1666         elm_layout_file_set(eo, EDJ_PATH_IMG, "explorer/image");
1667         Evas_Object *lb1, *lb2, *lb3, *lb4, *separator;
1668         Evas_Object *entry, *bt;
1669
1670         lb1 = elm_label_add(eo);
1671         lb2 = elm_label_add(eo);
1672         lb3 = elm_label_add(eo);
1673         lb4 = elm_label_add(eo);
1674
1675         entry = elm_entry_add(eo);
1676
1677         bt = elm_button_add(eo);
1678
1679         separator = elm_separator_add(eo);
1680         elm_separator_horizontal_set(separator, EINA_FALSE);
1681
1682         elm_object_part_content_set(eo, "elm.editor.name.label1", lb1);
1683         elm_object_part_content_set(eo, "elm.editor.name.label2", lb2);
1684         elm_object_part_content_set(eo, "elm.editor.name.label3", lb3);
1685         elm_object_part_content_set(eo, "elm.editor.name.label4", lb4);
1686         elm_object_part_content_set(eo, "elm.separator.1", separator);
1687         elm_object_part_content_set(eo, "elm.editor.name.entry1", entry);
1688         elm_object_part_content_set(eo, "elm.editor.name.button1", bt);
1689
1690         elm_label_slide_duration_set(lb1, 3);
1691         elm_label_slide_duration_set(lb2, 3);
1692         elm_label_slide_duration_set(lb3, 3);
1693         elm_label_slide_duration_set(lb4, 3);
1694
1695         elm_object_style_set(lb1, "slide_bounce");
1696         elm_object_style_set(lb2, "slide_bounce");
1697         elm_object_style_set(lb3, "slide_bounce");
1698         elm_object_style_set(lb4, "slide_bounce");
1699
1700         evas_object_color_set(separator, 1, 1, 1, 255);
1701
1702         elm_object_part_text_set(eo, "text1", IMG_DESC);
1703         elm_object_part_text_set(eo, "text2", SET_IMG_DESC);
1704         elm_object_part_text_set(eo, "text3", IMG_POS);
1705         elm_object_part_text_set(eo, "text4", IMG_SIZE);
1706         elm_object_part_text_set(eo, "text5", IMG_LOCALE);
1707
1708         elm_entry_editable_set(entry, EINA_TRUE);
1709
1710         elm_entry_single_line_set(entry, EINA_TRUE);
1711
1712         elm_entry_scrollable_set(entry, EINA_TRUE);
1713
1714         elm_object_part_text_set(entry, "guide", ENTER_DESC);
1715
1716         elm_object_part_text_set(bt, "default", SET_DESC);
1717
1718         return eo;
1719 }
1720
1721 /**
1722  * @brief prints gvalue
1723  *
1724  * That function print string from GValue object
1725  *
1726  * @param val GValue object 
1727  *
1728  * @return GValue transformated to string
1729  */
1730 char* gvalue_pprint(GValue *val)
1731 {
1732         char *buffer = NULL;
1733
1734         if(G_VALUE_HOLDS_UINT(val)) {
1735                 if (asprintf(&buffer, "%d", g_value_get_uint(val)) < 0)
1736                         EINA_LOG_ERR(ERR_PRINT_GVALUE);
1737         }
1738         else if(G_VALUE_HOLDS_INT(val)) {
1739                 if (asprintf(&buffer, "%d", g_value_get_int(val)) < 0)
1740                         EINA_LOG_ERR(ERR_PRINT_GVALUE);
1741         }
1742         else if(G_VALUE_HOLDS_DOUBLE(val)) {
1743                 if (asprintf(&buffer, "%g", g_value_get_double(val)) < 0)
1744                         EINA_LOG_ERR(ERR_PRINT_GVALUE);
1745         }
1746         return buffer;
1747 }
1748
1749 /**
1750  * @brief callback for set new value event
1751  *
1752  * Callback which allows to set new value in object which has interface value,
1753  * called when "set value" button in value interface is clicked
1754  *
1755  * @param data action_cb_stuct, which contains object with avaiable value interface
1756  * @param obj UNUSED
1757  * @param event_info UNUSED
1758  */
1759 void _value_set_new_value_cb(void *data, Evas_Object *obj, void *event_info)
1760 {
1761         action_cb_struct *acs = (action_cb_struct*)data;
1762
1763         if(!acs->atk_obj)
1764         {
1765                 return;
1766         }
1767
1768         char *curr_value = NULL;
1769
1770         Evas_Object *entry = eina_list_nth(acs->list, 0);
1771         Evas_Object *label1 = eina_list_nth(acs->list, 1);
1772
1773         GValue gvalue = G_VALUE_INIT;
1774         GValue curr_value_temp = G_VALUE_INIT;
1775
1776         const char *name = g_type_name(G_TYPE_FROM_INSTANCE(acs->atk_obj));
1777
1778         if(!strcmp(name, "EailActionSlider"))
1779         {
1780                 g_value_init (&gvalue, G_TYPE_UINT);
1781                 g_value_set_uint(&gvalue, atoi(elm_entry_entry_get(entry)));
1782         }
1783         else if(!strcmp(name, "EailColorselector") || !strcmp(name, "EailClock") || !strcmp(name, "EailDatetime")
1784         || !strcmp(name, "EailCalendar"))
1785         {
1786                 g_value_init (&gvalue, G_TYPE_INT);
1787                 g_value_set_int(&gvalue, atoi(elm_entry_entry_get(entry)));
1788         }
1789         else
1790         {
1791                 g_value_init (&gvalue, G_TYPE_DOUBLE);
1792                 g_value_set_double(&gvalue, atof(elm_entry_entry_get(entry)));
1793         }
1794
1795         if(atk_value_set_current_value(ATK_VALUE(acs->atk_obj), &gvalue))
1796         {
1797                 atk_value_get_current_value(ATK_VALUE(acs->atk_obj), &curr_value_temp);
1798
1799                 curr_value = gvalue_pprint(&curr_value_temp);
1800
1801                 elm_object_text_set(label1, curr_value);
1802         }
1803         else
1804         {
1805                 elm_object_text_set(label1, FAIL_OCC);
1806         }
1807         free(curr_value);
1808 }
1809
1810 /**
1811  * @brief prints value layout
1812  *
1813  * Main function to print Value layout, called when click on selection
1814  * label in toolbar is clicked, that function fills all entries and labels
1815  * in that layout, register callbacks on objects
1816  *
1817  * @param eo Selection Layout object
1818  * @param obj AtkObject which has focus
1819  * @param parent Main Layout object
1820  */
1821 void print_value(Evas_Object *eo, AtkObject *obj, Evas_Object *toolbar, Evas_Object *parent)
1822 {
1823         GValue curr_value_temp = G_VALUE_INIT;
1824         GValue max_value_temp = G_VALUE_INIT;
1825         GValue min_value_temp = G_VALUE_INIT;
1826         GValue min_inc_temp = G_VALUE_INIT;
1827
1828         g_value_init (&curr_value_temp, G_TYPE_DOUBLE);
1829         g_value_init (&max_value_temp, G_TYPE_DOUBLE);
1830         g_value_init (&min_value_temp, G_TYPE_DOUBLE);
1831         g_value_init (&min_inc_temp, G_TYPE_DOUBLE);
1832
1833         char *curr_value = NULL;
1834         char *max_value = NULL;
1835         char *min_value = NULL;
1836         char *min_inc = NULL;
1837
1838         if(!acs)
1839         {
1840                 acs = (action_cb_struct*)malloc(sizeof(action_cb_struct));
1841         }
1842         else
1843         {
1844                 eina_list_free(acs->list);
1845         }
1846
1847         acs->list = NULL;
1848
1849         acs->atk_obj = obj;
1850         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.entry1"));
1851         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.label1"));
1852
1853         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button"), "clicked", _value_set_new_value_cb);
1854
1855         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button"), "clicked", _value_set_new_value_cb, acs);
1856
1857         atk_value_get_current_value(ATK_VALUE(obj), &curr_value_temp);
1858         atk_value_get_maximum_value(ATK_VALUE(obj), &max_value_temp);
1859         atk_value_get_minimum_value(ATK_VALUE(obj), &min_value_temp);
1860         atk_value_get_minimum_increment(ATK_VALUE(obj), &min_inc_temp);
1861
1862         curr_value = gvalue_pprint(&curr_value_temp);
1863         max_value = gvalue_pprint(&max_value_temp);
1864         min_value = gvalue_pprint(&min_value_temp);
1865         min_inc = gvalue_pprint(&min_inc_temp);
1866
1867         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label1"), curr_value);
1868         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label2"), max_value);
1869         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label3"), min_value);
1870         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label4"), min_inc);
1871
1872         free(curr_value);
1873         free(max_value);
1874         free(min_value);
1875         free(min_inc);
1876
1877         elm_entry_entry_set(elm_object_part_content_get(eo, "elm.editor.name.entry1"), NULL);
1878
1879         elm_object_part_content_set(parent, "elm.layout", eo);
1880         evas_object_show(eo);
1881 }
1882
1883 /**
1884  * @brief prepares Value interface view
1885  *
1886  * Function prepares Value Layout by adding all
1887  * the used objects to layout and setting object labels
1888  *
1889  * @param parent Parent Layout object
1890  *
1891  * @return Evas_Object representing Value layout
1892  */
1893 Evas_Object* prepare_layout_value(Evas_Object *parent)
1894 {
1895         Evas_Object *eo = elm_layout_add(parent);
1896
1897         elm_layout_file_set(eo, EDJ_PATH_VAL, "explorer/value");
1898
1899         Evas_Object *lb1, *lb2, *lb3, *lb4, *e1, *button, *separator, *box1;
1900
1901         lb1 = elm_label_add(eo);
1902         lb2 = elm_label_add(eo);
1903         lb3 = elm_label_add(eo);
1904         lb4 = elm_label_add(eo);
1905         box1 = elm_box_add(eo);
1906         e1 = elm_entry_add(eo);
1907         button = elm_button_add(eo);
1908         separator = elm_separator_add(eo);
1909         elm_separator_horizontal_set(separator, EINA_FALSE);
1910
1911         evas_object_size_hint_weight_set(e1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1912         evas_object_size_hint_align_set(e1, EVAS_HINT_FILL, EVAS_HINT_FILL);
1913         elm_entry_scrollable_set(e1, EINA_TRUE);
1914         elm_entry_line_wrap_set(e1, EINA_TRUE);
1915         elm_box_pack_end(box1, e1);
1916
1917         elm_object_part_content_set(eo, "elm.editor.name.box1", box1);
1918         elm_object_part_content_set(eo, "elm.editor.name.label1", lb1);
1919         elm_object_part_content_set(eo, "elm.editor.name.label2", lb2);
1920         elm_object_part_content_set(eo, "elm.editor.name.label3", lb3);
1921         elm_object_part_content_set(eo, "elm.editor.name.label4", lb4);
1922         elm_object_part_content_set(eo, "elm.editor.name.entry1", e1);
1923         elm_object_part_content_set(eo, "elm.separator.1", separator);
1924         elm_object_part_content_set(eo, "elm.editor.name.button", button);
1925         elm_object_text_set(button, SET_VAL);
1926
1927         elm_entry_editable_set(e1, EINA_TRUE);
1928         elm_entry_single_line_set(e1, EINA_TRUE);
1929         elm_object_part_text_set(e1, "guide", ENTER_VAL);
1930
1931         elm_label_slide_duration_set(lb1, 3);
1932         elm_label_slide_duration_set(lb2, 3);
1933         elm_label_slide_duration_set(lb3, 3);
1934         elm_label_slide_duration_set(lb4, 3);
1935
1936         elm_object_style_set(lb1, "slide_bounce");
1937         elm_object_style_set(lb2, "slide_bounce");
1938         elm_object_style_set(lb3, "slide_bounce");
1939         elm_object_style_set(lb4, "slide_bounce");
1940
1941         elm_object_part_text_set(eo, "text1", CURR_VAL);
1942         elm_object_part_text_set(eo, "text2", MAX_VAL);
1943         elm_object_part_text_set(eo, "text3", MIN_VAL);
1944         elm_object_part_text_set(eo, "text4", MIN_INC);
1945         elm_object_part_text_set(eo, "text5", SET_VAL);
1946
1947         evas_object_color_set(separator, 1, 1, 1, 255);
1948
1949         return eo;
1950 }
1951
1952 /**
1953  * @brief gets character at offset position
1954  *
1955  * That callback is called when spinner value in text layout is changed
1956  *
1957  * @param data action_cb_stuct, which contains object with avaiable text interface
1958  * @param obj UNUSED
1959  * @param event_info UNUSED
1960  */
1961 void _text_get_char_at_offset(void *data, Evas_Object *obj, void *event_info)
1962 {
1963         action_cb_struct *acs = (action_cb_struct*)data;
1964         if(!acs->atk_obj)
1965         {
1966                 return;
1967         }
1968         Evas_Object *eo, *eo1, *eo2;
1969         eo1 = eina_list_nth(acs->list, 0);
1970         eo2 = eina_list_nth(acs->list, 1);
1971         eo = eina_list_nth(acs->list, 4);
1972
1973         char *value = NULL;
1974         gchar *full_text = atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1);
1975         if(full_text && strlen(full_text) > (int)elm_spinner_value_get(eo2))
1976         {
1977                 if (asprintf(&value,"%c", atk_text_get_character_at_offset(ATK_TEXT(acs->atk_obj), (int)elm_spinner_value_get(eo2))) < 0)
1978                         EINA_LOG_ERR(ERR_GET_CHAR_OFFSET);
1979         }
1980         g_free(full_text);
1981
1982         if(!sizeof(value))
1983         {
1984                 return;
1985         }
1986         elm_object_text_set(eo1, value);
1987         free(value);
1988
1989         if(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
1990         {
1991                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)) - 1);
1992                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)) - 1);
1993         }
1994         else
1995         {
1996                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, 0);
1997                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, 0);
1998         }
1999 }
2000
2001 /**
2002  * @brief selects text
2003  *
2004  * Callback called when button for select text in text layout is clicked
2005  *
2006  * @param data param data action_cb_stuct, which contains object with avaiable text interface
2007  * @param obj UNUSED
2008  * @param event_info UNUSED
2009  */
2010 void _text_add_selection(void *data, Evas_Object *obj, void *event_info)
2011 {
2012         action_cb_struct *acs = (action_cb_struct*)data;
2013         char *selected_regions;
2014
2015         if(!acs->atk_obj)
2016         {
2017                 return;
2018         }
2019         Evas_Object *eo1, *eo2, *lab, *eo;
2020         eo1 = eina_list_nth(acs->list, 2);
2021         eo2 = eina_list_nth(acs->list, 3);
2022         lab = eina_list_nth(acs->list, 5);
2023         eo = eina_list_nth(acs->list, 4);
2024
2025         if(!atk_text_remove_selection(ATK_TEXT(acs->atk_obj), 0))
2026         {
2027                 if(!(int)elm_spinner_value_get(eo1) && !(int)elm_spinner_value_get(eo2))
2028                 {
2029                         elm_check_state_set(elm_object_part_content_get(eo, "elm.editor.name.button"), EINA_FALSE);
2030                         return;
2031                 }
2032                 else if((int)elm_spinner_value_get(eo1) > (int)elm_spinner_value_get(eo2))
2033                 {
2034                         elm_check_state_set(elm_object_part_content_get(eo, "elm.editor.name.button"), EINA_FALSE);
2035                         return;
2036                 }
2037                 else if((int)elm_spinner_value_get(eo1) == (int)elm_spinner_value_get(eo2))
2038                 {
2039                         elm_check_state_set(elm_object_part_content_get(eo, "elm.editor.name.button"), EINA_FALSE);
2040                         return;
2041                 }
2042                 atk_text_add_selection(ATK_TEXT(acs->atk_obj), (int)elm_spinner_value_get(eo1), (int)elm_spinner_value_get(eo2));
2043
2044                 if(asprintf(&selected_regions, "%d", atk_text_get_n_selections(ATK_TEXT(acs->atk_obj))) < 0)
2045                 {
2046                         EINA_LOG_ERR(ERR_MEMORY);
2047                         elm_object_text_set(lab, FAIL_OCC);
2048                 }
2049                 else
2050                 {
2051                         elm_object_part_text_set(obj, NULL, UNSET);
2052                         elm_object_text_set(lab, selected_regions);
2053                 }
2054         }
2055         else
2056         {
2057                 if(asprintf(&selected_regions, "%d", atk_text_get_n_selections(ATK_TEXT(acs->atk_obj))) < 0)
2058                 {
2059                         EINA_LOG_ERR(ERR_MEMORY);
2060                 }
2061                 else
2062                 {
2063                         elm_object_text_set(lab, selected_regions);
2064                         elm_object_part_text_set(obj, NULL, SET);
2065                 }
2066         }
2067
2068         if(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
2069         {
2070                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2071                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2072         }
2073         else
2074         {
2075                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, 0);
2076                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, 0);
2077         }
2078
2079         free(selected_regions);
2080 }
2081
2082 /**
2083  * @brief prints the Text layout
2084  *
2085  * Main function to print selection layout, called when click on text
2086  * label in toolbar is clicked, that function fills all entries and labels
2087  * in that layout, register callbacks on objects
2088  *
2089  * @param eo Text Layout object
2090  * @param obj AtkObject which has focus
2091  * @param parent Main Layout object
2092  */
2093 void print_text(Evas_Object *eo, AtkObject *obj, Evas_Object *parent)
2094 {
2095
2096         char *caret_value = NULL;
2097         char *counter = NULL;
2098         char *selected_regions = NULL;
2099
2100         if(!acs)
2101         {
2102                 acs = (action_cb_struct*)malloc(sizeof(action_cb_struct));
2103         }
2104         else
2105         {
2106                 eina_list_free(acs->list);
2107         }
2108
2109         acs->list = NULL;
2110
2111         acs->atk_obj = obj;
2112         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.label2"));
2113         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.spinner"));
2114         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.spinner1"));
2115         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.spinner2"));
2116         acs->list = eina_list_append(acs->list, eo);
2117         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.label5"));
2118
2119         if(atk_text_get_text(ATK_TEXT(obj), 0, -1))
2120         {
2121                 elm_object_disabled_set(elm_object_part_content_get(eo, "elm.editor.name.button"), EINA_FALSE);
2122                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner"), 0, strlen(atk_text_get_text(ATK_TEXT(obj), 0, -1)) - 1);
2123                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, strlen(atk_text_get_text(ATK_TEXT(obj), 0, -1)));
2124                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, strlen(atk_text_get_text(ATK_TEXT(obj), 0, -1)));
2125         }
2126         else
2127         {
2128                 elm_object_disabled_set(elm_object_part_content_get(eo, "elm.editor.name.button"), EINA_TRUE);
2129                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner"), 0, 0);
2130                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, 0);
2131                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, 0);
2132         }
2133
2134         elm_spinner_value_set(elm_object_part_content_get(eo, "elm.editor.name.spinner"), 0);
2135         elm_spinner_value_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0);
2136         elm_spinner_value_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0);
2137
2138         elm_entry_entry_set(elm_object_part_content_get(eo, "elm.editor.name.label1"), atk_text_get_text(ATK_TEXT(obj), 0, -1));
2139
2140         if (asprintf(&caret_value, "%d", atk_text_get_caret_offset(ATK_TEXT(obj))) < 0)
2141                 EINA_LOG_ERR(ERR_GET_CHAR_OFFSET);
2142
2143         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label3"), caret_value);
2144
2145         if (asprintf(&counter, "%d", atk_text_get_character_count(ATK_TEXT(obj))) < 0)
2146                 EINA_LOG_ERR(ERR_CHAR_COUNT);
2147
2148         elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label4"), counter);
2149
2150         if (asprintf(&selected_regions, "%d", atk_text_get_n_selections(ATK_TEXT(obj))) < 0)
2151                 EINA_LOG_ERR(ERR_N_SELECTIONS);
2152
2153         if(atk_text_get_n_selections(ATK_TEXT(obj)) == -1)
2154         {
2155                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label5"), FAIL_OCC);
2156                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.button"), SET);
2157                 elm_check_state_set(elm_object_part_content_get(eo, "elm.editor.name.button"), EINA_FALSE);
2158                 elm_object_disabled_set(elm_object_part_content_get(eo, "elm.editor.name.button"), EINA_TRUE);
2159         }
2160         else if(atk_text_get_n_selections(ATK_TEXT(obj)) > 0)
2161         {
2162                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label5"), selected_regions);
2163                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.button"), UNSET);
2164                 elm_check_state_set(elm_object_part_content_get(eo, "elm.editor.name.button"), EINA_TRUE);
2165         }
2166         else
2167         {
2168                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.label5"), selected_regions);
2169                 elm_object_text_set(elm_object_part_content_get(eo, "elm.editor.name.button"), SET);
2170                 elm_check_state_set(elm_object_part_content_get(eo, "elm.editor.name.button"), EINA_FALSE);
2171         }
2172
2173
2174         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button"), "changed", _text_add_selection);
2175         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.spinner"), "changed", _text_get_char_at_offset);
2176
2177         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button"), "changed", _text_add_selection, acs);
2178         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.spinner"), "changed", _text_get_char_at_offset, acs);
2179
2180         elm_object_part_content_set(parent, "elm.layout", eo);
2181         evas_object_show(eo);
2182         free(caret_value);
2183         free(counter);
2184         free(selected_regions);
2185 }
2186 /**
2187  * @brief prepares Text interface view
2188  *
2189  * Function prepares text Layout by adding all
2190  * the used objects to layout and setting object labels
2191  *
2192  * @param parent Parent Layout object
2193  *
2194  * @return Evas_Object representing text layout
2195  */
2196 Evas_Object* prepare_layout_text(Evas_Object *parent)
2197 {
2198         Evas_Object *eo = elm_layout_add(parent);
2199
2200         elm_layout_file_set(eo, EDJ_PATH_TXT, "explorer/text");
2201
2202         Evas_Object *e1, *lb1, *lb2, *lb3, *lb4, *separator, *spinner, *spinner1, *spinner2, *box;
2203         Evas_Object *selection_check;
2204
2205         box = elm_box_add(eo);
2206         e1 = elm_entry_add(eo);
2207         lb1 = elm_label_add(eo);
2208         lb2 = elm_label_add(eo);
2209         lb3 = elm_label_add(eo);
2210         lb4 = elm_label_add(eo);
2211         spinner = elm_spinner_add(eo);
2212         spinner1 = elm_spinner_add(eo);
2213         spinner2 = elm_spinner_add(eo);
2214         separator = elm_separator_add(eo);
2215         selection_check = elm_check_add(eo);
2216
2217         evas_object_size_hint_weight_set(e1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2218         evas_object_size_hint_align_set(e1, EVAS_HINT_FILL, EVAS_HINT_FILL);
2219         elm_entry_scrollable_set(e1, EINA_TRUE);
2220         elm_entry_line_wrap_set(e1, EINA_TRUE);
2221         elm_box_pack_end(box, e1);
2222
2223         elm_separator_horizontal_set(separator, EINA_FALSE);
2224         elm_object_part_content_set(eo, "elm.editor.name.box1", box);
2225         elm_object_part_content_set(eo, "elm.editor.name.label1", e1);
2226         elm_object_part_content_set(eo, "elm.editor.name.label2", lb1);
2227         elm_object_part_content_set(eo, "elm.editor.name.label3", lb2);
2228         elm_object_part_content_set(eo, "elm.editor.name.label4", lb3);
2229         elm_object_part_content_set(eo, "elm.editor.name.label5", lb4);
2230         elm_object_part_content_set(eo, "elm.editor.name.spinner", spinner);
2231         elm_object_part_content_set(eo, "elm.editor.name.spinner1", spinner1);
2232         elm_object_part_content_set(eo, "elm.editor.name.spinner2", spinner2);
2233         elm_object_part_content_set(eo, "elm.editor.name.button", selection_check);
2234         elm_object_part_content_set(eo, "elm.editor.name.separator", separator);
2235
2236         elm_entry_editable_set(e1, EINA_FALSE);
2237         elm_object_part_text_set(e1, "guide", ENTER_VAL);
2238
2239         elm_label_slide_duration_set(lb1, 3);
2240         elm_label_slide_duration_set(lb2, 3);
2241         elm_label_slide_duration_set(lb3, 3);
2242         elm_label_slide_duration_set(lb4, 3);
2243
2244         elm_object_style_set(lb1, "slide_bounce");
2245         elm_object_style_set(lb2, "slide_bounce");
2246         elm_object_style_set(lb3, "slide_bounce");
2247         elm_object_style_set(lb4, "slide_bounce");
2248
2249         evas_object_color_set(separator, 1, 1, 1, 255);
2250
2251         elm_object_part_text_set(eo, "text1", TEXT_VAL);
2252         elm_object_part_text_set(eo, "text2", CHAR_AT_OFFSET);
2253         elm_object_part_text_set(eo, "text3", CARET_OFFSET);
2254         elm_object_part_text_set(eo, "text4", CHAR_COUNT);
2255         elm_object_part_text_set(eo, "text5", NUM_OF_SEL_REGIONS);
2256         elm_object_part_text_set(eo, "text6", OFFSET);
2257         elm_object_part_text_set(eo, "text7", START_OFFSET);
2258         elm_object_part_text_set(eo, "text8", END_OFFSET);
2259         elm_object_part_text_set(eo, "text9", SET_SEL);
2260         elm_object_part_text_set(eo, "text10", USAGE);
2261
2262         return eo;
2263 }
2264
2265 /**
2266  * @brief set text
2267  *
2268  * Called when set text button in Editable text layout is clicked.
2269  * Allows to set text for labels, entries and all other object which implements that interface.
2270  *
2271  * @param data action_cb_stuct, which contains object with avaiable editable text interface
2272  * @param obj UNUSED
2273  * @param event_info UNUSED
2274  */
2275 void _text_set_cb(void *data, Evas_Object *obj, void *event_info)
2276 {
2277         action_cb_struct *acs = (action_cb_struct*)data;
2278         if(!acs->atk_obj)
2279         {
2280                 return;
2281         }
2282
2283         Evas_Object *eo1, *eo;
2284         eo1 = eina_list_nth(acs->list, 0);
2285         eo = eina_list_nth(acs->list, 3);
2286
2287         atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(acs->atk_obj), elm_entry_entry_get(eo1));
2288
2289         if(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
2290         {
2291                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2292                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2293         }
2294         else
2295         {
2296                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, 0);
2297                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, 0);
2298         }
2299 }
2300
2301 /**
2302  * @brief copy text
2303  *
2304  * Called when copy text button in Editable text layout is clicked.
2305  * Allows to copy text in labels, entries and all other object which implements that interface.
2306  *
2307  * @param data action_cb_stuct, which contains object with avaiable text interface
2308  * @param obj UNUSED
2309  * @param event_info UNUSED
2310  */
2311 void _text_copy_cb(void *data, Evas_Object *obj, void *event_info)
2312 {
2313         action_cb_struct *acs = (action_cb_struct*)data;
2314         if(!acs->atk_obj)
2315         {
2316                 return;
2317         }
2318
2319         Evas_Object *spin, *spin1, *eo;
2320         spin = eina_list_nth(acs->list, 1);
2321         spin1 = eina_list_nth(acs->list, 2);
2322         eo = eina_list_nth(acs->list, 3);
2323
2324         if(!atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
2325                 return;
2326
2327         if((int)elm_spinner_value_get(spin) > strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)))
2328                 return;
2329
2330         if((int)elm_spinner_value_get(spin) > (int)elm_spinner_value_get(spin1))
2331                 return;
2332
2333         atk_editable_text_copy_text(ATK_EDITABLE_TEXT(acs->atk_obj),(int)elm_spinner_value_get(spin), (int)elm_spinner_value_get(spin1));
2334
2335         if(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
2336         {
2337                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2338                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2339         }
2340         else
2341         {
2342                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, 0);
2343                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, 0);
2344         }
2345 }
2346
2347 /**
2348  * @brief paste text
2349  *
2350  * Called when paste text button in Editable text layout is clicked.
2351  * Allows to paste text for entries and all other object which implements that interface.
2352  *
2353  * @param data action_cb_stuct, which contains object with avaiable text interface
2354  * @param obj UNUSED
2355  * @param event_info UNUSED
2356  */
2357 void _text_paste_cb(void *data, Evas_Object *obj, void *event_info)
2358 {
2359         action_cb_struct *acs = (action_cb_struct*)data;
2360         if(!acs->atk_obj)
2361         {
2362                 return;
2363         }
2364
2365         Evas_Object *spin, *eo;
2366         spin = eina_list_nth(acs->list, 1);
2367         eo = eina_list_nth(acs->list, 3);
2368
2369         if(!atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
2370         {
2371                 atk_editable_text_paste_text(ATK_EDITABLE_TEXT(acs->atk_obj), 0);
2372                 elm_entry_entry_set(eina_list_nth(acs->list, 0), atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1));
2373                 return;
2374         }
2375
2376         if((int)elm_spinner_value_get(spin) >= strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)))
2377         {
2378                 atk_editable_text_paste_text(ATK_EDITABLE_TEXT(acs->atk_obj), strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2379                 elm_entry_entry_set(eina_list_nth(acs->list, 0), atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1));
2380                 return;
2381         }
2382
2383         atk_editable_text_paste_text(ATK_EDITABLE_TEXT(acs->atk_obj),(int)elm_spinner_value_get(spin));
2384
2385
2386         elm_entry_entry_set(eina_list_nth(acs->list, 0), atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1));
2387
2388         if(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
2389         {
2390                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2391                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2392         }
2393         else
2394         {
2395                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, 0);
2396                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, 0);
2397         }
2398 }
2399
2400 /**
2401  * @brief cut text
2402  *
2403  * Called when cut text button in Editable text layout is clicked.
2404  * Allows to cut text for entries and all other object which implements that interface.
2405  *
2406  * @param data action_cb_stuct, which contains object with avaiable text interface
2407  * @param obj UNUSED
2408  * @param event_info UNUSED
2409  */
2410 void _text_cut_cb(void *data, Evas_Object *obj, void *event_info)
2411 {
2412         action_cb_struct *acs = (action_cb_struct*)data;
2413         if(!acs->atk_obj)
2414         {
2415                 return;
2416         }
2417
2418         Evas_Object *spin, *spin1, *eo;
2419         spin = eina_list_nth(acs->list, 1);
2420         spin1 = eina_list_nth(acs->list, 2);
2421         eo = eina_list_nth(acs->list, 3);
2422
2423         if(!atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
2424                 return;
2425
2426         if((int)elm_spinner_value_get(spin) > (int)elm_spinner_value_get(spin1))
2427                 return;
2428
2429         else if((int)elm_spinner_value_get(spin) > strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)) ||
2430                 (int)elm_spinner_value_get(spin1) > strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)))
2431                         return;
2432
2433         atk_editable_text_cut_text(ATK_EDITABLE_TEXT(acs->atk_obj), (int)elm_spinner_value_get(spin), (int)elm_spinner_value_get(spin1));
2434         elm_entry_entry_set(eina_list_nth(acs->list, 0), atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1));
2435
2436         if(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
2437         {
2438                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2439                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2440         }
2441         else
2442         {
2443                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, 0);
2444                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, 0);
2445         }
2446 }
2447
2448 /**
2449  * @brief prints the Editable Text layout
2450  *
2451  * Main function to print selection layout, called when click on editable text
2452  * label in toolbar is clicked, that function fills all entries and labels
2453  * in that layout, register callbacks on objects
2454  *
2455  * @param eo Editable Text Layout object
2456  * @param obj AtkObject which has focus
2457  * @param parent Main Layout object
2458  */
2459 void print_edit_text(Evas_Object *eo, AtkObject *obj, Evas_Object *parent)
2460 {
2461
2462         if(!acs)
2463         {
2464                 acs = (action_cb_struct*)malloc(sizeof(action_cb_struct));
2465         }
2466         else
2467         {
2468                 eina_list_free(acs->list);
2469         }
2470
2471         acs->list = NULL;
2472
2473         acs->atk_obj = obj;
2474         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.e1"));
2475         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.spinner1"));
2476         acs->list = eina_list_append(acs->list, elm_object_part_content_get(eo, "elm.editor.name.spinner2"));
2477         acs->list = eina_list_append(acs->list, eo);
2478
2479         if(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1))
2480         {
2481                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2482                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, strlen(atk_text_get_text(ATK_TEXT(acs->atk_obj), 0, -1)));
2483         }
2484         else
2485         {
2486                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner1"), 0, 0);
2487                 elm_spinner_min_max_set(elm_object_part_content_get(eo, "elm.editor.name.spinner2"), 0, 0);
2488         }
2489
2490         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button"), "clicked", _text_set_cb);
2491         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button1"), "clicked", _text_copy_cb);
2492         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button2"), "clicked", _text_paste_cb);
2493         evas_object_smart_callback_del(elm_object_part_content_get(eo, "elm.editor.name.button3"), "clicked", _text_cut_cb);
2494
2495         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button"), "clicked", _text_set_cb, acs);
2496         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button1"), "clicked", _text_copy_cb, acs);
2497         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button2"), "clicked", _text_paste_cb, acs);
2498         evas_object_smart_callback_add(elm_object_part_content_get(eo, "elm.editor.name.button3"), "clicked", _text_cut_cb, acs);
2499
2500         elm_object_part_content_set(parent, "elm.layout", eo);
2501         evas_object_show(eo);
2502 }
2503
2504 /**
2505  * @brief prepares Editable Text interface view
2506  *
2507  * Function prepares Editable Text Layout by adding all
2508  * the used objects to layout and setting object labels
2509  *
2510  * @param parent Parent Layout object
2511  *
2512  * @return Evas_Object representing Editable Text layout
2513  */
2514 Evas_Object* prepare_layout_edit_text(Evas_Object *parent)
2515 {
2516         Evas_Object *eo = elm_layout_add(parent);
2517
2518         elm_layout_file_set(eo, EDJ_PATH_ETXT, "explorer/editable_text");
2519
2520         Evas_Object *e1, *separator, *spinner1, *spinner2, *box;
2521         Evas_Object *set_text_button, *copy_text_button, *paste_text_button;
2522         Evas_Object *cut_text_button;
2523
2524         box = elm_box_add(eo);
2525         e1 = elm_entry_add(eo);
2526         spinner1 = elm_spinner_add(eo);
2527         spinner2 = elm_spinner_add(eo);
2528         separator = elm_separator_add(eo);
2529         set_text_button = elm_button_add(eo);
2530         copy_text_button = elm_button_add(eo);
2531         paste_text_button = elm_button_add(eo);
2532         cut_text_button = elm_button_add(eo);
2533
2534         evas_object_size_hint_weight_set(e1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2535         evas_object_size_hint_align_set(e1, EVAS_HINT_FILL, EVAS_HINT_FILL);
2536         elm_entry_single_line_set(e1, EINA_TRUE);
2537         elm_entry_scrollable_set(e1, EINA_TRUE);
2538         elm_entry_line_wrap_set(e1, EINA_TRUE);
2539         elm_box_pack_end(box, e1);
2540
2541         elm_object_part_text_set(e1, "guide", ENTER_TXT);
2542
2543         elm_separator_horizontal_set(separator, EINA_FALSE);
2544         elm_object_part_content_set(eo, "elm.editor.name.box1", box);
2545         elm_object_part_content_set(eo, "elm.editor.name.e1", e1);
2546         elm_object_part_content_set(eo, "elm.editor.name.spinner1", spinner1);
2547         elm_object_part_content_set(eo, "elm.editor.name.spinner2", spinner2);
2548         elm_object_part_content_set(eo, "elm.editor.name.button", set_text_button);
2549         elm_object_part_content_set(eo, "elm.editor.name.button1", copy_text_button);
2550         elm_object_part_content_set(eo, "elm.editor.name.button2", paste_text_button);
2551         elm_object_part_content_set(eo, "elm.editor.name.button3", cut_text_button);
2552         elm_object_part_content_set(eo, "elm.editor.name.separator", separator);
2553
2554         elm_object_text_set(set_text_button, SET);
2555         elm_object_text_set(copy_text_button, COPY);
2556         elm_object_text_set(paste_text_button, PASTE);
2557         elm_object_text_set(cut_text_button, CUT);
2558
2559         evas_object_color_set(separator, 1, 1, 1, 255);
2560
2561         elm_object_part_text_set(eo, "text1", SET_TEXT);
2562         elm_object_part_text_set(eo, "text2", COPY);
2563         elm_object_part_text_set(eo, "text3", COPY_TEXT_DESCRIPTION);
2564         elm_object_part_text_set(eo, "text4", PASTE_TEXT);
2565         elm_object_part_text_set(eo, "text5", CUT_TEXT);
2566         elm_object_part_text_set(eo, "text6", START_POINT);
2567         elm_object_part_text_set(eo, "text7", END_POINT);
2568
2569         return eo;
2570 }