2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <Elementary.h>
28 #include <Ecore_Evas.h>
35 #include <livebox-errno.h>
36 #include <livebox-service.h>
38 #include "script_port.h"
40 #define TEXT_CLASS "tizen"
41 #define BASE_WIDTH 720.0f
43 #define PUBLIC __attribute__((visibility("default")))
79 Eina_List *access_chain;
82 static inline double scale_get(void)
86 ecore_x_window_size_get(0, &width, &height);
87 return (double)width / BASE_WIDTH;
90 static inline Evas_Object *find_edje(struct info *handle, const char *id)
94 struct obj_info *obj_info;
96 EINA_LIST_FOREACH(handle->obj_list, l, edje) {
97 obj_info = evas_object_data_get(edje, "obj_info");
99 ErrPrint("Object info is not valid\n");
108 } else if (!obj_info->id) {
112 if (!strcmp(obj_info->id, id))
116 DbgPrint("EDJE[%s] is not found\n", id);
120 static inline void rebuild_focus_chain(Evas_Object *obj)
122 struct obj_info *obj_info;
126 obj_info = evas_object_data_get(obj, "obj_info");
128 ErrPrint("Object info is not available\n");
132 elm_object_focus_custom_chain_unset(obj);
134 DbgPrint("Rebuild focus chain begin\n");
135 EINA_LIST_FOREACH(obj_info->access_chain, l, ao) {
136 DbgPrint("Append %p\n", ao);
137 elm_object_focus_custom_chain_append(obj, ao, NULL);
139 DbgPrint("Rebuild focus chain done\n");
142 PUBLIC const char *script_magic_id(void)
147 PUBLIC int script_update_color(void *h, Evas *e, const char *id, const char *part, const char *rgba)
149 struct info *handle = h;
151 int r[3], g[3], b[3], a[3];
154 edje = find_edje(handle, id);
156 return LB_STATUS_ERROR_NOT_EXIST;
158 ret = sscanf(rgba, "%d %d %d %d %d %d %d %d %d %d %d %d",
159 r, g, b, a, /* OBJECT */
160 r + 1, g + 1, b + 1, a + 1, /* OUTLINE */
161 r + 2, g + 2, b + 2, a + 2); /* SHADOW */
163 DbgPrint("id[%s] part[%s] rgba[%s]\n", id, part, rgba);
164 return LB_STATUS_ERROR_INVALID;
167 ret = edje_object_color_class_set(elm_layout_edje_get(edje), part,
168 r[0], g[0], b[0], a[0], /* OBJECT */
169 r[1], g[1], b[1], a[1], /* OUTLINE */
170 r[2], g[2], b[2], a[2]); /* SHADOW */
172 DbgPrint("EDJE[%s] color class is %s changed", id, ret == EINA_TRUE ? "successfully" : "not");
173 return LB_STATUS_SUCCESS;
176 PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part, const char *text)
178 struct obj_info *obj_info;
179 struct info *handle = h;
183 edje = find_edje(handle, id);
185 ErrPrint("Failed to find EDJE\n");
186 return LB_STATUS_ERROR_NOT_EXIST;
189 obj_info = evas_object_data_get(edje, "obj_info");
191 ErrPrint("Object info is not available\n");
192 return LB_STATUS_ERROR_FAULT;
195 elm_object_part_text_set(edje, part, text);
197 to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
201 ao = evas_object_data_get(to, "ao");
203 /* Update Access Info */
204 elm_access_info_set(ao, ELM_ACCESS_INFO, text);
205 DbgPrint("[%s] Update access info: (%s)\n", part, text);
207 ao = elm_access_object_register(to, edje);
209 ErrPrint("Failed to add access object\n");
212 utf8 = elm_entry_markup_to_utf8(text);
214 DbgPrint("[%s] Text is converted to [%s]\n", part, utf8);
215 elm_access_info_set(ao, ELM_ACCESS_INFO, utf8);
218 DbgPrint("[%s] Unable to convert text to utf8: [%s]\n", part, text);
219 elm_access_info_set(ao, ELM_ACCESS_INFO, text);
222 obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
223 evas_object_data_set(to, "ao", ao);
224 elm_object_focus_custom_chain_append(edje, ao, NULL);
228 ErrPrint("Unable to get text part[%s]\n", part);
231 return LB_STATUS_SUCCESS;
234 static void parse_aspect(struct image_option *img_opt, const char *value, int len)
236 while (len > 0 && *value == ' ') {
244 img_opt->aspect = !strncasecmp(value, "true", 4);
245 DbgPrint("Parsed ASPECT: %d (%s)\n", img_opt->aspect, value);
248 static void parse_orient(struct image_option *img_opt, const char *value, int len)
250 while (len > 0 && *value == ' ') {
258 img_opt->orient = !strncasecmp(value, "true", 4);
259 DbgPrint("Parsed ORIENT: %d (%s)\n", img_opt->aspect, value);
262 static void parse_size(struct image_option *img_opt, const char *value, int len)
268 while (len > 0 && *value == ' ') {
273 buf = strndup(value, len);
275 ErrPrint("Heap: %s\n", strerror(errno));
279 if (sscanf(buf, "%dx%d", &width, &height) == 2) {
280 img_opt->width = width;
281 img_opt->height = height;
282 DbgPrint("Parsed size : %dx%d (%s)\n", width, height, buf);
284 DbgPrint("Invalid size tag[%s]\n", buf);
290 static void parse_fill(struct image_option *img_opt, const char *value, int len)
292 while (len > 0 && *value == ' ') {
297 if (!strncasecmp(value, "in-size", len))
298 img_opt->fill = FILL_IN_SIZE;
299 else if (!strncasecmp(value, "over-size", len))
300 img_opt->fill = FILL_OVER_SIZE;
302 img_opt->fill = FILL_DISABLE;
304 DbgPrint("Parsed FILL: %d (%s)\n", img_opt->fill, value);
307 static inline void parse_image_option(const char *option, struct image_option *img_opt)
314 void (*handler)(struct image_option *img_opt, const char *value, int len);
317 .cmd = "aspect", /* Keep the aspect ratio */
318 .handler = parse_aspect,
321 .cmd = "orient", /* Keep the orientation value: for the rotated images */
322 .handler = parse_orient,
325 .cmd = "fill", /* Fill the image to its container */
326 .handler = parse_fill, /* Value: in-size, over-size, disable(default) */
330 .handler = parse_size,
344 if (!option || !*option)
350 * GCC 4.7 warnings uninitialized idx and tag value.
351 * But it will be initialized by the state machine. :(
352 * Anyway, I just reset idx and tag for reducing the GCC4.7 complains.
359 for (ptr = option; state != STATE_END; ptr++) {
374 cmd = cmd_list[tag].cmd;
380 } else if (*ptr == '\0') {
385 if (cmd[idx] == '\0' && (*ptr == ' ' || *ptr == '\t' || *ptr == '=')) {
390 state = STATE_IGNORE;
393 } else if (*ptr == '\0') {
395 } else if (cmd[idx] == *ptr) {
401 if (tag == sizeof(cmd_list) / sizeof(cmd_list[0])) {
405 cmd = cmd_list[tag].cmd;
411 if (*ptr == ';' || *ptr == '\0') {
412 cmd_list[tag].handler(img_opt, value + 1, idx);
413 state = *ptr ? STATE_START : STATE_END;
421 else if (*ptr == '\0')
430 PUBLIC int script_update_access(void *_h, Evas *e, const char *id, const char *part, const char *text, const char *option)
432 struct info *handle = _h;
434 struct obj_info *obj_info;
437 edje = find_edje(handle, id);
439 ErrPrint("No such object: %s\n", id);
440 return LB_STATUS_ERROR_NOT_EXIST;
443 obj_info = evas_object_data_get(edje, "obj_info");
445 ErrPrint("Object info is not available\n");
446 return LB_STATUS_ERROR_FAULT;
449 to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
453 ao = evas_object_data_get(to, "ao");
455 DbgPrint("[%s] Update access object (%s)\n", part, text);
456 elm_access_info_set(ao, ELM_ACCESS_INFO, text);
458 ao = elm_access_object_register(to, edje);
460 ErrPrint("Unable to register access object\n");
462 elm_access_info_set(ao, ELM_ACCESS_INFO, text);
463 obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
464 evas_object_data_set(to, "ao", ao);
465 elm_object_focus_custom_chain_append(edje, ao, NULL);
466 DbgPrint("[%s] Register access info: (%s)\n", part, text);
470 ErrPrint("[%s] is not exists\n", part);
473 return LB_STATUS_SUCCESS;
476 PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *part, const char *path, const char *option)
478 struct info *handle = _h;
483 struct obj_info *obj_info;
485 struct image_option img_opt = {
488 .fill = FILL_DISABLE,
493 edje = find_edje(handle, id);
495 ErrPrint("No such object: %s\n", id);
496 return LB_STATUS_ERROR_NOT_EXIST;
499 obj_info = evas_object_data_get(edje, "obj_info");
501 ErrPrint("Object info is not available\n");
502 return LB_STATUS_ERROR_FAULT;
505 img = elm_object_part_content_unset(edje, part);
511 EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) {
512 if (child->obj != img)
515 obj_info->children = eina_list_remove(obj_info->children, child);
521 DbgPrint("delete object %s %p\n", part, img);
522 ao = evas_object_data_del(img, "ao");
524 elm_access_object_unregister(ao);
525 obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
526 DbgPrint("Successfully unregistered\n");
528 evas_object_del(img);
530 rebuild_focus_chain(edje);
533 if (!path || !strlen(path) || access(path, R_OK) != 0) {
534 DbgPrint("SKIP - Path: [%s]\n", path);
535 return LB_STATUS_SUCCESS;
538 child = malloc(sizeof(*child));
540 ErrPrint("Heap: %s\n", strerror(errno));
541 return LB_STATUS_ERROR_MEMORY;
544 child->part = strdup(part);
546 ErrPrint("Heap: %s\n", strerror(errno));
548 return LB_STATUS_ERROR_MEMORY;
551 img = evas_object_image_add(e);
553 ErrPrint("Failed to add an image object\n");
556 return LB_STATUS_ERROR_FAULT;
559 evas_object_image_preload(img, EINA_FALSE);
560 parse_image_option(option, &img_opt);
561 evas_object_image_load_orientation_set(img, img_opt.orient);
563 evas_object_image_file_set(img, path, NULL);
564 err = evas_object_image_load_error_get(img);
565 if (err != EVAS_LOAD_ERROR_NONE) {
566 ErrPrint("Load error: %s\n", evas_load_error_str(err));
567 evas_object_del(img);
570 return LB_STATUS_ERROR_IO;
573 evas_object_image_size_get(img, &w, &h);
574 if (img_opt.aspect) {
575 if (img_opt.fill == FILL_OVER_SIZE) {
579 if (img_opt.width >= 0 && img_opt.height >= 0) {
580 part_w = img_opt.width * scale_get();
581 part_h = img_opt.height * scale_get();
585 edje_object_part_geometry_get(elm_layout_edje_get(edje), part, NULL, NULL, &part_w, &part_h);
587 DbgPrint("Original %dx%d (part: %dx%d)\n", w, h, part_w, part_h);
589 if (part_w > w || part_h > h) {
593 fw = (double)part_w / (double)w;
594 fh = (double)part_h / (double)h;
604 DbgPrint("Size: %dx%d\n", w, h);
606 evas_object_image_load_size_set(img, w, h);
607 evas_object_image_load_region_set(img, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h);
608 evas_object_image_fill_set(img, 0, 0, part_w, part_h);
609 evas_object_image_reload(img);
611 evas_object_image_fill_set(img, 0, 0, w, h);
612 evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
613 evas_object_size_hint_aspect_set(img, EVAS_ASPECT_CONTROL_BOTH, w, h);
616 if (img_opt.width >= 0 && img_opt.height >= 0) {
619 DbgPrint("Using given image size: %dx%d\n", w, h);
622 evas_object_image_fill_set(img, 0, 0, w, h);
623 evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
624 evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
629 * object will be shown by below statement automatically
631 DbgPrint("%s part swallow image %p (%dx%d)\n", part, img, w, h);
633 elm_object_part_content_set(edje, part, img);
634 obj_info->children = eina_list_append(obj_info->children, child);
638 * This object is not registered as an access object.
639 * So the developer should add it to access list manually, using DESC_ACCESS block.
641 return LB_STATUS_SUCCESS;
644 static void script_signal_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
646 struct info *handle = data;
658 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
659 edje_object_part_geometry_get(elm_layout_edje_get(obj), source, &px, &py, &pw, &ph);
663 sx = (double)px / (double)w;
664 ex = (double)(px + pw) / (double)w;
669 sy = (double)py / (double)h;
670 ey = (double)(py + ph) / (double)h;
673 DbgPrint("Signal emit: source[%s], emission[%s]\n", source, emission);
674 script_signal_emit(handle->e, source, emission, sx, sy, ex, ey);
677 static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info)
679 struct info *handle = _info;
680 struct obj_info *obj_info;
684 handle->obj_list = eina_list_remove(handle->obj_list, obj);
686 obj_info = evas_object_data_del(obj, "obj_info");
688 ErrPrint("Object info is not valid\n");
692 DbgPrint("delete object %s %p\n", obj_info->id, obj);
694 elm_object_signal_callback_del(obj, "*", "*", script_signal_cb);
696 elm_object_focus_custom_chain_unset(obj);
698 EINA_LIST_FREE(obj_info->children, child) {
699 DbgPrint("delete object %s %p\n", child->part, child->obj);
702 ao = evas_object_data_del(child->obj, "ao");
704 obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
705 elm_access_object_unregister(ao);
707 evas_object_del(child->obj);
713 EINA_LIST_FREE(obj_info->access_chain, ao) {
714 elm_access_object_unregister(ao);
722 LB_ACCESS_HIGHLIGHT 0
723 LB_ACCESS_HIGHLIGHT_NEXT 1
724 LB_ACCESS_HIGHLIGHT_PREV 2
726 LB_ACCESS_VALUE_CHANGE 4
729 PUBLIC int script_feed_event(void *h, Evas *e, int event_type, int x, int y, double timestamp)
731 struct info *handle = h;
733 struct obj_info *obj_info;
734 int ret = LB_STATUS_SUCCESS;
736 DbgPrint("event: %d, x: %d, y: %d\n", event_type, x, y);
738 edje = find_edje(handle, NULL); /*!< Get the base layout */
740 ErrPrint("Base layout is not exist\n");
741 return LB_STATUS_ERROR_NOT_EXIST;
744 obj_info = evas_object_data_get(edje, "obj_info");
746 ErrPrint("Object info is not valid\n");
747 return LB_STATUS_ERROR_INVALID;
750 if (event_type & LB_SCRIPT_ACCESS_EVENT) {
751 Elm_Access_Action_Info *info;
752 Elm_Access_Action_Type action;
754 info = malloc(sizeof(*info));
756 ErrPrint("Error: %s\n", strerror(errno));
757 return LB_STATUS_ERROR_MEMORY;
761 const Eina_List *chain;
762 chain = elm_object_focus_custom_chain_get(edje);
763 DbgPrint("Focus chain : %d\n", eina_list_count(chain));
766 switch (event_type) {
767 case LB_SCRIPT_ACCESS_HIGHLIGHT: /*!< LB_ACCESS_HIGHLIGHT */
768 action = ELM_ACCESS_ACTION_HIGHLIGHT;
771 ret = elm_access_action(edje, action, info);
772 DbgPrint("ACCESS_HIGHLIGHT: %dx%d returns %d\n", x, y, ret);
773 if (ret == EINA_FALSE)
774 ret = LB_ACCESS_STATUS_ERROR;
776 ret = LB_ACCESS_STATUS_DONE;
778 case LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT: /*!< LB_ACCESS_HIGHLIGHT_NEXT */
779 action = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
780 info->highlight_cycle = EINA_FALSE;
781 ret = elm_access_action(edje, action, info);
782 DbgPrint("ACCESS_HIGHLIGHT_NEXT, returns %d\n", ret);
783 if (ret == EINA_FALSE)
784 ret = LB_ACCESS_STATUS_LAST;
786 ret = LB_ACCESS_STATUS_DONE;
788 case LB_SCRIPT_ACCESS_HIGHLIGHT_PREV: /*!< LB_ACCESS_HIGHLIGHT_PREV */
789 action = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
790 info->highlight_cycle = EINA_FALSE;
791 ret = elm_access_action(edje, action, info);
792 DbgPrint("ACCESS_HIGHLIGHT_PREV, returns %d\n", ret);
793 if (ret == EINA_FALSE)
794 ret = LB_ACCESS_STATUS_FIRST;
796 ret = LB_ACCESS_STATUS_DONE;
798 case LB_SCRIPT_ACCESS_ACTIVATE: /*!< LB_ACCESS_ACTIVATE */
799 action = ELM_ACCESS_ACTION_ACTIVATE;
800 ret = elm_access_action(edje, action, info);
801 DbgPrint("ACCESS_HIGHLIGHT_ACTIVATE, returns %d\n", ret);
802 if (ret == EINA_FALSE)
803 ret = LB_ACCESS_STATUS_ERROR;
805 ret = LB_ACCESS_STATUS_DONE;
807 case LB_SCRIPT_ACCESS_VALUE_CHANGE: /*!< LB_ACCESS_VALUE_CHANGE */
808 action = ELM_ACCESS_ACTION_VALUE_CHANGE;
809 ret = elm_access_action(edje, action, info);
810 DbgPrint("ACCESS_HIGHLIGHT_VALUE_CHANGE, returns %d\n", ret);
811 if (ret == EINA_FALSE)
812 ret = LB_ACCESS_STATUS_ERROR;
814 ret = LB_ACCESS_STATUS_DONE;
816 case LB_SCRIPT_ACCESS_SCROLL: /*!< LB_ACCESS_SCROLL */
817 action = ELM_ACCESS_ACTION_SCROLL;
818 ret = elm_access_action(edje, action, info);
819 DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret);
820 if (ret == EINA_FALSE)
821 ret = LB_ACCESS_STATUS_ERROR;
823 ret = LB_ACCESS_STATUS_DONE;
825 case LB_SCRIPT_ACCESS_UNHIGHLIGHT:
826 action = ELM_ACCESS_ACTION_UNHIGHLIGHT;
827 ret = elm_access_action(edje, action, info);
828 DbgPrint("ACCESS_UNHIGHLIGHT, returns %d\n", ret);
829 if (ret == EINA_FALSE)
830 ret = LB_ACCESS_STATUS_ERROR;
832 ret = LB_ACCESS_STATUS_DONE;
835 DbgPrint("Invalid event\n");
836 ret = LB_ACCESS_STATUS_ERROR;
840 } else if (event_type & LB_SCRIPT_MOUSE_EVENT) {
841 switch (event_type) {
842 case LB_SCRIPT_MOUSE_DOWN:
843 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
844 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
846 case LB_SCRIPT_MOUSE_MOVE:
847 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
849 case LB_SCRIPT_MOUSE_UP:
850 evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
851 evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
853 case LB_SCRIPT_MOUSE_IN:
854 evas_event_feed_mouse_in(e, timestamp, NULL);
856 case LB_SCRIPT_MOUSE_OUT:
857 evas_event_feed_mouse_out(e, timestamp, NULL);
860 return LB_STATUS_ERROR_INVALID;
862 } else if (event_type & LB_SCRIPT_KEY_EVENT) {
863 DbgPrint("Key event is not implemented\n");
864 return LB_STATUS_ERROR_NOT_IMPLEMENTED;
870 PUBLIC int script_update_script(void *h, Evas *e, const char *src_id, const char *target_id, const char *part, const char *path, const char *group)
872 struct info *handle = h;
875 struct obj_info *obj_info;
878 DbgPrint("src_id[%s] target_id[%s] part[%s] path[%s] group[%s]\n", src_id, target_id, part, path, group);
880 edje = find_edje(handle, src_id);
882 ErrPrint("Edje is not exists\n");
883 return LB_STATUS_ERROR_NOT_EXIST;
886 obj_info = evas_object_data_get(edje, "obj_info");
888 ErrPrint("Object info is not valid\n");
889 return LB_STATUS_ERROR_INVALID;
892 obj = elm_object_part_content_unset(edje, part);
897 EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) {
898 if (child->obj != obj)
901 obj_info->children = eina_list_remove(obj_info->children, child);
908 DbgPrint("delete object %s %p\n", part, obj);
911 * This will call the edje_del_cb.
912 * It will delete all access objects
914 evas_object_del(obj);
917 if (!path || !strlen(path) || access(path, R_OK) != 0) {
918 DbgPrint("SKIP - Path: [%s]\n", path);
919 return LB_STATUS_SUCCESS;
922 obj = elm_layout_add(edje);
924 ErrPrint("Failed to add a new edje object\n");
925 return LB_STATUS_ERROR_FAULT;
928 if (!elm_layout_file_set(obj, path, group)) {
932 err = edje_object_load_error_get(elm_layout_edje_get(obj));
933 errmsg = edje_load_error_str(err);
934 ErrPrint("Could not load %s from %s: %s\n", group, path, errmsg);
935 evas_object_del(obj);
936 return LB_STATUS_ERROR_IO;
939 evas_object_show(obj);
941 obj_info = calloc(1, sizeof(*obj_info));
943 ErrPrint("Failed to add a obj_info\n");
944 evas_object_del(obj);
945 return LB_STATUS_ERROR_MEMORY;
948 obj_info->id = strdup(target_id);
950 ErrPrint("Failed to add a obj_info\n");
952 evas_object_del(obj);
953 return LB_STATUS_ERROR_MEMORY;
956 child = malloc(sizeof(*child));
958 ErrPrint("Error: %s\n", strerror(errno));
961 evas_object_del(obj);
962 return LB_STATUS_ERROR_MEMORY;
965 child->part = strdup(part);
967 ErrPrint("Error: %s\n", strerror(errno));
971 evas_object_del(obj);
972 return LB_STATUS_ERROR_MEMORY;
977 evas_object_data_set(obj, "obj_info", obj_info);
978 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, edje_del_cb, handle);
979 elm_object_signal_callback_add(obj, "*", "*", script_signal_cb, handle);
980 handle->obj_list = eina_list_append(handle->obj_list, obj);
982 DbgPrint("%s part swallow edje %p\n", part, obj);
983 elm_object_part_content_set(edje, part, obj);
984 obj_info = evas_object_data_get(edje, "obj_info");
985 obj_info->children = eina_list_append(obj_info->children, child);
986 return LB_STATUS_SUCCESS;
989 PUBLIC int script_update_signal(void *h, Evas *e, const char *id, const char *part, const char *signal)
991 struct info *handle = h;
994 DbgPrint("id[%s], part[%s], signal[%s]\n", id, part, signal);
996 edje = find_edje(handle, id);
998 return LB_STATUS_ERROR_NOT_EXIST;
1000 elm_object_signal_emit(edje, signal, part);
1001 return LB_STATUS_SUCCESS;
1004 PUBLIC int script_update_drag(void *h, Evas *e, const char *id, const char *part, double x, double y)
1006 struct info *handle = h;
1009 DbgPrint("id[%s], part[%s], %lfx%lf\n", id, part, x, y);
1011 edje = find_edje(handle, id);
1013 return LB_STATUS_ERROR_NOT_EXIST;
1015 edje_object_part_drag_value_set(elm_layout_edje_get(edje), part, x, y);
1016 return LB_STATUS_SUCCESS;
1019 PUBLIC int script_update_size(void *han, Evas *e, const char *id, int w, int h)
1021 struct info *handle = han;
1024 edje = find_edje(handle, id);
1026 return LB_STATUS_ERROR_NOT_EXIST;
1033 DbgPrint("Resize object to %dx%d\n", w, h);
1034 evas_object_resize(edje, w, h);
1035 return LB_STATUS_SUCCESS;
1038 PUBLIC int script_update_category(void *h, Evas *e, const char *id, const char *category)
1040 struct info *handle = h;
1042 DbgPrint("id[%s], category[%s]\n", id, category);
1044 if (handle->category) {
1045 free(handle->category);
1046 handle->category = NULL;
1050 return LB_STATUS_SUCCESS;
1052 handle->category = strdup(category);
1053 if (!handle->category) {
1054 ErrPrint("Error: %s\n", strerror(errno));
1055 return LB_STATUS_ERROR_MEMORY;
1058 return LB_STATUS_SUCCESS;
1061 PUBLIC void *script_create(const char *file, const char *group)
1063 struct info *handle;
1065 DbgPrint("file[%s], group[%s]\n", file, group);
1067 handle = calloc(1, sizeof(*handle));
1069 ErrPrint("Error: %s\n", strerror(errno));
1073 handle->file = strdup(file);
1074 if (!handle->file) {
1075 ErrPrint("Error: %s\n", strerror(errno));
1080 handle->group = strdup(group);
1081 if (!handle->group) {
1082 ErrPrint("Error: %s\n", strerror(errno));
1091 PUBLIC int script_destroy(void *_handle)
1093 struct info *handle;
1098 edje = eina_list_nth(handle->obj_list, 0);
1100 evas_object_del(edje);
1102 free(handle->category);
1104 free(handle->group);
1106 return LB_STATUS_SUCCESS;
1109 PUBLIC int script_load(void *_handle, Evas *e, int w, int h)
1111 struct info *handle;
1113 struct obj_info *obj_info;
1117 obj_info = calloc(1, sizeof(*obj_info));
1119 ErrPrint("Heap: %s\n", strerror(errno));
1120 return LB_STATUS_ERROR_MEMORY;
1123 obj_info->win = evas_object_rectangle_add(e);
1124 if (!obj_info->win) {
1126 return LB_STATUS_ERROR_FAULT;
1129 edje = elm_layout_add(obj_info->win);
1131 ErrPrint("Failed to create an edje object\n");
1132 evas_object_del(obj_info->win);
1134 return LB_STATUS_ERROR_FAULT;
1137 DbgPrint("Load edje: %s - %s\n", handle->file, handle->group);
1138 if (!elm_layout_file_set(edje, handle->file, handle->group)) {
1142 err = edje_object_load_error_get(elm_layout_edje_get(edje));
1143 errmsg = edje_load_error_str(err);
1144 ErrPrint("Could not load %s from %s: %s\n", handle->group, handle->file, errmsg);
1145 evas_object_del(edje);
1146 evas_object_del(obj_info->win);
1148 return LB_STATUS_ERROR_IO;
1155 elm_object_signal_callback_add(edje, "*", "*", script_signal_cb, handle);
1156 evas_object_event_callback_add(edje, EVAS_CALLBACK_DEL, edje_del_cb, handle);
1157 evas_object_size_hint_weight_set(edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1158 evas_object_size_hint_fill_set(edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
1159 evas_object_resize(edje, handle->w, handle->h);
1160 evas_object_show(edje);
1161 evas_object_data_set(edje, "obj_info", obj_info);
1163 handle->obj_list = eina_list_append(handle->obj_list, edje);
1164 return LB_STATUS_SUCCESS;
1167 PUBLIC int script_unload(void *_handle, Evas *e)
1169 struct info *handle;
1174 DbgPrint("Unload edje: %s - %s\n", handle->file, handle->group);
1175 edje = eina_list_nth(handle->obj_list, 0);
1177 evas_object_del(edje);
1179 return LB_STATUS_SUCCESS;
1182 static void access_cb(keynode_t *node, void *user_data)
1187 if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &state) != 0) {
1188 ErrPrint("Idle lock state is not valid\n");
1189 state = 0; /* DISABLED */
1192 state = vconf_keynode_get_bool(node);
1195 elm_config_access_set(state);
1198 PUBLIC int script_init(void)
1205 /* ecore is already initialized */
1207 elm_config_scale_set(scale_get());
1209 ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, access_cb, NULL);
1211 ErrPrint("Failed to access cb\n");
1213 access_cb(NULL, NULL);
1214 return LB_STATUS_SUCCESS;
1217 PUBLIC int script_fini(void)
1219 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, access_cb);
1221 return LB_STATUS_SUCCESS;