Remove unused variables
[platform/framework/web/livebox-edje.git] / src / script_port.c
index 934361a..e401356 100644 (file)
@@ -82,8 +82,10 @@ struct info {
        int is_mouse_down;
 
        Evas *e;
+       Evas_Object *parent;
 
        Eina_List *obj_list;
+       Eina_List *access_chain;
 };
 
 struct child {
@@ -95,7 +97,6 @@ struct obj_info {
        char *id;
        Eina_List *children;
        Evas_Object *parent;
-       Eina_List *access_chain;
 };
 
 static struct {
@@ -142,26 +143,6 @@ static inline Evas_Object *find_edje(struct info *handle, const char *id)
        return NULL;
 }
 
-static inline void rebuild_focus_chain(Evas_Object *obj)
-{
-       struct obj_info *obj_info;
-       Evas_Object *ao;
-       Eina_List *l;
-
-       obj_info = evas_object_data_get(obj, "obj_info");
-       if (!obj_info) {
-               ErrPrint("Object info is not available\n");
-               return;
-       }
-
-       elm_object_focus_custom_chain_unset(obj);
-
-       EINA_LIST_FOREACH(obj_info->access_chain, l, ao) {
-               DbgPrint("Append %p\n", ao);
-               elm_object_focus_custom_chain_append(obj, ao, NULL);
-       }
-}
-
 PUBLIC const char *script_magic_id(void)
 {
        return "edje";
@@ -242,12 +223,25 @@ static void activate_cb(void *data, Evas_Object *part_obj, Elm_Object_Item *item
        evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, (timestamp + 0.03f) * 1000, NULL);
 }
 
+static void access_del_cb(void *_info, Evas *e, Evas_Object *ao, void *event_info)
+{
+       struct info *handle = _info;
+       Evas_Object *edje_part;
+
+       edje_part = evas_object_data_del(ao, "edje,part");
+       (void)evas_object_data_del(ao, "edje");
+       (void)evas_object_data_del(edje_part, "ao");
+
+       handle->access_chain = eina_list_remove(handle->access_chain, edje_part);
+       DbgPrint("AO(%p) is removed from local access chain\n", ao);
+}
+
 PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part, const char *text)
 {
        struct obj_info *obj_info;
        struct info *handle = h;
        Evas_Object *edje;
-       Evas_Object *to;
+       Evas_Object *edje_part;
 
        edje = find_edje(handle, id);
        if (!edje) {
@@ -263,33 +257,42 @@ PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part
 
        elm_object_part_text_set(edje, part, text ? text : "");
 
-       to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
-       if (to) {
+       edje_part = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+       if (edje_part) {
                Evas_Object *ao;
                char *utf8;
 
-               ao = evas_object_data_get(to, "ao");
+               ao = evas_object_data_get(edje_part, "ao");
                if (!ao) {
-                       ao = elm_access_object_register(to, edje);
+                       ao = elm_access_object_register(edje_part, handle->parent);
                        if (!ao) {
-                               ErrPrint("Unable to add ao: %s\n", part);
+                               ErrPrint("Unable to register an access object(%s)\n", part);
                                goto out;
                        }
-                       obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
-                       evas_object_data_set(to, "ao", ao);
+                       handle->access_chain = eina_list_append(handle->access_chain, edje_part);
+                       evas_object_data_set(edje_part, "ao", ao);
                        evas_object_data_set(ao, "edje", edje);
+                       evas_object_data_set(ao, "edje,part", edje_part);
                        elm_access_activate_cb_set(ao, activate_cb, NULL);
-                       elm_object_focus_custom_chain_append(edje, ao, NULL);
+                       elm_object_focus_custom_chain_append(handle->parent, ao, NULL);
+                       evas_object_event_callback_add(ao, EVAS_CALLBACK_DEL, access_del_cb, handle);
+
+                       DbgPrint("[%s] Register access info: (%s) to, %p\n", part, text, handle->parent);
                }
 
                if (!text || !strlen(text)) {
-                       obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                       evas_object_data_del(to, "ao");
-                       evas_object_data_del(ao, "edje");
+                       /*
+                       handle->access_chain = eina_list_remove(handle->access_chain, edje_part);
+                       (void)evas_object_data_del(edje_part, "ao");
+                       (void)evas_object_data_del(ao, "edje");
+                       */
+                       /*!
+                        * \note
+                        * Delete callback will be called
+                        */
+                       DbgPrint("[%s] Remove access object(%p)\n", part, ao);
                        elm_access_object_unregister(ao);
-                       DbgPrint("[%s] Remove access object\n", part);
 
-                       rebuild_focus_chain(edje);
                        goto out;
                }
 
@@ -297,13 +300,18 @@ PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part
                if ((!utf8 || !strlen(utf8))) {
                        free(utf8);
 
-                       obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                       evas_object_data_del(to, "ao");
-                       evas_object_data_del(ao, "edje");
+                       /*
+                       handle->access_chain = eina_list_remove(handle->access_chain, edje_part);
+                       (void)evas_object_data_del(edje_part, "ao");
+                       (void)evas_object_data_del(ao, "edje");
+                       */
+                       /*!
+                        * \note
+                        * Delete callback will be called
+                        */
+                       DbgPrint("[%s] Remove access object(%p)\n", part, ao);
                        elm_access_object_unregister(ao);
-                       DbgPrint("[%s] Remove access object\n", part);
 
-                       rebuild_focus_chain(edje);
                        goto out;
                }
 
@@ -545,7 +553,7 @@ PUBLIC int script_update_access(void *_h, Evas *e, const char *id, const char *p
        struct info *handle = _h;
        Evas_Object *edje;
        struct obj_info *obj_info;
-       Evas_Object *to;
+       Evas_Object *edje_part;
 
        edje = find_edje(handle, id);
        if (!edje) {
@@ -559,35 +567,42 @@ PUBLIC int script_update_access(void *_h, Evas *e, const char *id, const char *p
                return LB_STATUS_ERROR_FAULT;
        }
 
-       to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
-       if (to) {
+       edje_part = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+       if (edje_part) {
                Evas_Object *ao;
 
-               ao = evas_object_data_get(to, "ao");
+               ao = evas_object_data_get(edje_part, "ao");
                if (ao) {
                        if (text && strlen(text)) {
                                elm_access_info_set(ao, ELM_ACCESS_INFO, text);
+                               DbgPrint("Access info is updated: [%s]\n", text);
                        } else {
-                               obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                               evas_object_data_del(to, "ao");
-                               evas_object_data_del(ao, "edje");
+                               /*
+                               handle->access_chain = eina_list_remove(handle->access_chain, edje_part);
+                               (void)evas_object_data_del(edje_part, "ao");
+                               (void)evas_object_data_del(ao, "edje");
+                               */
+                               /*!
+                                * \note
+                                * Delete clalback will be called
+                                */
+                               DbgPrint("[%s] Remove access object(%p)\n", part, ao);
                                elm_access_object_unregister(ao);
-                               DbgPrint("Successfully unregistered\n");
-
-                               rebuild_focus_chain(edje);
                        }
                } else if (text && strlen(text)) {
-                       ao = elm_access_object_register(to, edje);
+                       ao = elm_access_object_register(edje_part, handle->parent);
                        if (!ao) {
-                               ErrPrint("Unable to register access object\n");
+                               ErrPrint("Unable to register an access object(%s)\n", part);
                        } else {
                                elm_access_info_set(ao, ELM_ACCESS_INFO, text);
-                               obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
-                               evas_object_data_set(to, "ao", ao);
-                               elm_object_focus_custom_chain_append(edje, ao, NULL);
-                               DbgPrint("[%s] Register access info: (%s)\n", part, text);
+                               handle->access_chain = eina_list_append(handle->access_chain, edje_part);
+                               evas_object_data_set(edje_part, "ao", ao);
                                evas_object_data_set(ao, "edje", edje);
+                               evas_object_data_set(ao, "edje,part", edje_part);
+                               elm_object_focus_custom_chain_append(handle->parent, ao, NULL);
                                elm_access_activate_cb_set(ao, activate_cb, NULL);
+                               evas_object_event_callback_add(ao, EVAS_CALLBACK_DEL, access_del_cb, handle);
+                               DbgPrint("[%s] Register access info: (%s) to, %p\n", part, text, handle->parent);
                        }
                }
        } else {
@@ -626,19 +641,19 @@ PUBLIC int script_operate_access(void *_h, Evas *e, const char *id, const char *
        /* OPERATION is defined in liblivebox package */
        if (!strcasecmp(operation, "set,hl")) {
                if (part) {
-                       Evas_Object *to;
+                       Evas_Object *edje_part;
                        Evas_Coord x;
                        Evas_Coord y;
                        Evas_Coord w;
                        Evas_Coord h;
 
-                       to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
-                       if (!to) {
+                       edje_part = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+                       if (!edje_part) {
                                ErrPrint("Invalid part: %s\n", part);
                                goto out;
                        }
 
-                       evas_object_geometry_get(to, &x, &y, &w, &h);
+                       evas_object_geometry_get(edje_part, &x, &y, &w, &h);
 
                        action_info.x = x + w / 2;
                        action_info.y = x + h / 2;
@@ -713,7 +728,6 @@ PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *pa
        if (img) {
                Eina_List *l;
                Eina_List *n;
-               Evas_Object *ao;
 
                EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) {
                        if (child->obj != img) {
@@ -727,16 +741,7 @@ PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *pa
                }
 
                DbgPrint("delete object %s %p\n", part, img);
-               ao = evas_object_data_del(img, "ao");
-               if (ao) {
-                       obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                       evas_object_data_del(ao, "edje");
-                       elm_access_object_unregister(ao);
-                       DbgPrint("Successfully unregistered\n");
-               }
                evas_object_del(img);
-
-               rebuild_focus_chain(edje);
        }
 
        if (!path || !strlen(path) || access(path, R_OK) != 0) {
@@ -1052,7 +1057,6 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info
        struct obj_info *obj_info;
        struct obj_info *parent_obj_info;
        struct child *child;
-       Evas_Object *ao;
 
        handle->obj_list = eina_list_remove(handle->obj_list, obj);
 
@@ -1091,28 +1095,44 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info
 
        elm_object_signal_callback_del(obj, "*", "*", script_signal_cb);
 
-       elm_object_focus_custom_chain_unset(obj);
-
        EINA_LIST_FREE(obj_info->children, child) {
                DbgPrint("delete object %s %p\n", child->part, child->obj);
                if (child->obj) {
-                       Evas_Object *ao;
-                       ao = evas_object_data_del(child->obj, "ao");
-                       if (ao) {
-                               obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                               evas_object_data_del(ao, "edje");
-                               elm_access_object_unregister(ao);
-                       }
                        evas_object_del(child->obj);
                }
                free(child->part);
                free(child);
        }
 
-       EINA_LIST_FREE(obj_info->access_chain, ao) {
-               evas_object_data_del(ao, "edje");
-               elm_access_object_unregister(ao);
+#if 0
+       Eina_List *l;
+       Eina_List *n;
+       Evas_Object *ao;
+       Evas_Object *edje_part;
+       Evas_Object *edje;
+       EINA_LIST_FOREACH_SAFE(handle->access_chain, l, n, edje_part) {
+               ao = evas_object_data_get(edje_part, "ao");
+               if (ao) {
+                       edje = evas_object_data_get(ao, "edje");
+               } else {
+                       ErrPrint("edje_part has no ao\n");
+                       continue;
+               }
+
+               if (edje == obj) {
+                       /*!
+                       handle->access_chain = eina_list_remove(handle->access_chain, edje_part);
+                       (void)evas_object_data_del(edje_part, "ao");
+                       (void)evas_object_data_del(ao, "edje");
+                       */
+                       /*!
+                        * Delete callback will be called
+                        */
+                       DbgPrint("Remove access object(%p)\n", ao);
+                       elm_access_object_unregister(ao);
+               }
        }
+#endif
 
        free(obj_info->id);
        free(obj_info);
@@ -1449,6 +1469,7 @@ PUBLIC int script_update_script(void *h, Evas *e, const char *src_id, const char
 
        obj_info = evas_object_data_get(edje, "obj_info");
        obj_info->children = eina_list_append(obj_info->children, child);
+
        return LB_STATUS_SUCCESS;
 }
 
@@ -1623,6 +1644,7 @@ PUBLIC int script_load(void *_handle, Evas *e, int w, int h)
        handle->e = e;
        handle->w = w;
        handle->h = h;
+       handle->parent = edje;
 
        elm_object_signal_callback_add(edje, "*", "*", script_signal_cb, handle);
        evas_object_event_callback_add(edje, EVAS_CALLBACK_DEL, edje_del_cb, handle);