[access] export some APIs which would improve application side flexibility.
authorShinwoo Kim <kimcinoo.efl@gmail.com>
Thu, 10 Jan 2013 12:00:05 +0000 (12:00 +0000)
committerShinwoo Kim <kimcinoo.efl@gmail.com>
Thu, 10 Jan 2013 12:00:05 +0000 (12:00 +0000)
  + elm_access_object_item_register();
  + elm_access_object_item_unregister();
  + elm_access_object_item_access_get();

SVN revision: 82561

legacy/elementary/src/lib/elm_access.c
legacy/elementary/src/lib/elm_access.h
legacy/elementary/src/lib/elm_gengrid.c
legacy/elementary/src/lib/elm_genlist.c

index 73e8dae..d4d52ef 100644 (file)
@@ -419,7 +419,7 @@ _elm_access_object_get(const Evas_Object *obj)
 EAPI void
 _elm_access_object_hilight(Evas_Object *obj)
 {
-   Evas_Object *o, *parent_obj;
+   Evas_Object *o;
    Evas_Coord x, y, w, h;
 
    o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
@@ -447,11 +447,7 @@ _elm_access_object_hilight(Evas_Object *obj)
      }
    evas_object_data_set(o, "_elm_access_target", obj);
 
-   parent_obj = obj;
-   if (!elm_widget_is(obj))
-      parent_obj = evas_object_data_get(obj, "_elm_access_parent");
-
-   elm_widget_theme_object_set(parent_obj, o, "access", "base", "default");
+   elm_widget_theme_object_set(obj, o, "access", "base", "default");
 
    evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
                                   _access_obj_hilight_del_cb, NULL);
@@ -518,109 +514,100 @@ _content_move(void *data, Evas *e __UNUSED__, Evas_Object *obj,
    evas_object_move(accessobj, x, y);
 }
 
-static char *
-_part_access_info_cb(void *data, Evas_Object *obj)
-{
-   Evas_Object *eobj = data;
-   if (!eobj) return NULL;
-
-   const char *part = evas_object_data_get(obj, "_elm_access_part");
-   const char *txt = edje_object_part_text_get(eobj, part);
-   if (txt) return strdup(txt);
-   return NULL;
-}
-
-static void
-_access_obj_del(void *data __UNUSED__, Evas *e __UNUSED__,
-                Evas_Object *obj, void *event_info __UNUSED__)
-{
-   char *part = evas_object_data_get(obj, "_elm_access_part");
-   evas_object_data_del(obj, "_elm_access_part");
-   if (part) free(part);
-}
-
-EAPI Evas_Object *
-_elm_access_edje_object_part_object_register(Evas_Object* obj,
-                                             const Evas_Object *eobj,
-                                             const char* part)
+static Evas_Object *
+_access_object_register(Evas_Object *obj, Evas_Object *parent)
 {
    Evas_Object *ao;
-   Evas_Object *po = (Evas_Object *)edje_object_part_object_get(eobj, part);
-   Evas_Coord x, y, w, h;
    Elm_Access_Info *ac;
+   Evas_Coord x, y, w, h;
 
-   if (!obj || !po) return NULL;
+   if (!obj) return NULL;
 
-   // check previous access object
-   ao = evas_object_data_get(po, "_part_access_obj");
-   if (ao)
-     _elm_access_edje_object_part_object_unregister(obj, eobj, part);
-
-   // create access object
-   ao = _elm_access_add(obj);
+   /* create access object */
+   ao = _elm_access_add(parent);
    if (!ao) return NULL;
 
-   evas_object_event_callback_add(po, EVAS_CALLBACK_RESIZE,
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
                                   _content_resize, ao);
-   evas_object_event_callback_add(po, EVAS_CALLBACK_MOVE,
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
                                   _content_move, ao);
 
-   evas_object_geometry_get(po, &x, &y, &w, &h);
+   evas_object_geometry_get(obj, &x, &y, &w, &h);
    evas_object_move(ao, x, y);
    evas_object_resize(ao, w, h);
    evas_object_show(ao);
 
-   // register access object
-   _elm_access_object_register(ao, po);
-   _elm_access_text_set(_elm_access_object_get(ao),
-                        ELM_ACCESS_TYPE, evas_object_type_get(po));
-   evas_object_data_set(ao, "_elm_access_part", strdup(part));
-   evas_object_event_callback_add(ao, EVAS_CALLBACK_DEL,
-                                  _access_obj_del, NULL);
-   _elm_access_callback_set(_elm_access_object_get(ao),
-                            ELM_ACCESS_INFO,
-                            _part_access_info_cb, eobj);
-
-   // set access object
-   evas_object_data_set(po, "_part_access_obj", ao);
+   /* register access object */
+   _elm_access_object_register(ao, obj);
+
+   /* set access object */
+   evas_object_data_set(obj, "_part_access_obj", ao);
 
    /* set owner part object */
    ac = evas_object_data_get(ao, "_elm_access");
-   ac->part_object = po;
+   ac->part_object = obj;
 
    return ao;
 }
 
-EAPI void
-_elm_access_edje_object_part_object_unregister(Evas_Object* obj,
-                                               const Evas_Object *eobj,
-                                               const char* part)
+static void
+_access_object_unregister(Evas_Object *obj)
 {
    Evas_Object *ao;
-   Evas_Object *po = (Evas_Object *)edje_object_part_object_get(eobj, part);
 
-   if (!obj || !po) return;
+   if (!obj) return;
 
-   ao = evas_object_data_get(po, "_part_access_obj");
+   ao = evas_object_data_get(obj, "_part_access_obj");
    if (!ao) return;
 
-   evas_object_data_del(po, "_part_access_obj");
+   evas_object_data_del(obj, "_part_access_obj");
 
-   // delete callbacks
-   evas_object_event_callback_del_full(po, EVAS_CALLBACK_RESIZE,
+   /* delete callbacks */
+   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
                                        _content_resize, ao);
-   evas_object_event_callback_del_full(po, EVAS_CALLBACK_MOVE,
+   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
                                        _content_move, ao);
 
-   evas_object_event_callback_del_full(po, EVAS_CALLBACK_MOUSE_IN,
-                                      _access_obj_mouse_in_cb, ao);
-   evas_object_event_callback_del_full(po, EVAS_CALLBACK_MOUSE_OUT,
-                                      _access_obj_mouse_out_cb, ao);
-   evas_object_event_callback_del_full(po, EVAS_CALLBACK_DEL,
-                                       _access_obj_del_cb, ao);
+   /* unregister access object */
+   _elm_access_object_unregister(ao, obj);
+
    evas_object_del(ao);
 }
 
+EAPI Evas_Object *
+_elm_access_edje_object_part_object_register(Evas_Object* obj,
+                                             const Evas_Object *eobj,
+                                             const char* part)
+{
+   Evas_Object *ao, *po;
+
+   po = (Evas_Object *)edje_object_part_object_get(eobj, part);
+   if (!obj || !po) return NULL;
+
+   /* check previous access object */
+   ao = evas_object_data_get(po, "_part_access_obj");
+   if (ao)
+     _elm_access_edje_object_part_object_unregister(obj, eobj, part);
+
+   ao = _access_object_register(po, obj);
+
+   return ao;
+}
+
+//FIXME: unused obj should be removed from here and each widget.
+EAPI void
+_elm_access_edje_object_part_object_unregister(Evas_Object* obj __UNUSED__,
+                                               const Evas_Object *eobj,
+                                               const char* part)
+{
+   Evas_Object *po;
+
+   po = (Evas_Object *)edje_object_part_object_get(eobj, part);
+   if (!po) return;
+
+   _access_object_unregister(po);
+}
+
 EAPI void
 _elm_access_object_hilight_disable(Evas *e)
 {
@@ -686,7 +673,7 @@ _elm_access_widget_item_register(Elm_Widget_Item *item)
    Evas_Coord x, y, w, h;
    Elm_Access_Info *ac;
 
-   if (!item) return;
+   ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
 
    /* check previous access object */
    if (item->access_obj)
@@ -722,7 +709,9 @@ _elm_access_widget_item_unregister(Elm_Widget_Item *item)
 {
    Evas_Object *ho;
 
-   if (!item || !item->access_obj) return;
+   ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+
+   if (!item->access_obj) return;
 
    ho = item->view;
    evas_object_event_callback_del_full(ho, EVAS_CALLBACK_RESIZE,
@@ -805,59 +794,61 @@ static const Eo_Class_Description class_desc = {
      NULL
 };
 
-EAPI void
-elm_access_text_set(Evas_Object *obj, int type, const char *text)
+EAPI Evas_Object *
+elm_access_object_item_register(Elm_Object_Item *item)
 {
-   _elm_access_text_set(_elm_access_object_get(obj), type, text);
-}
+   Elm_Widget_Item *it;
 
-EAPI char *
-elm_access_text_get(Evas_Object *obj, int type)
-{
-   return _elm_access_text_get(_elm_access_object_get(obj), type, obj);
+   it = (Elm_Widget_Item *)item;
+
+   _elm_access_widget_item_register(it);
+
+   if (it) return it->access_obj;
+   return NULL;
 }
 
 EAPI void
-elm_access_object_register(Evas_Object *parent, Evas_Object *target)
+elm_access_object_item_unregister(Elm_Object_Item *item)
 {
-   Elm_Access_Info *ai;
+   _elm_access_widget_item_unregister((Elm_Widget_Item *)item);
+}
 
-   if (!parent || !target) return;
+EAPI Evas_Object *
+elm_access_object_item_access_get(Elm_Object_Item *item)
+{
+   if (!item) return NULL;
 
-   evas_object_event_callback_add(target, EVAS_CALLBACK_MOUSE_IN,
-                                  _access_obj_mouse_in_cb, target);
-   evas_object_event_callback_add(target, EVAS_CALLBACK_MOUSE_OUT,
-                                  _access_obj_mouse_out_cb, target);
-   evas_object_event_callback_add(target, EVAS_CALLBACK_DEL,
-                                  _access_obj_del_cb, target);
-   ai = calloc(1, sizeof(Elm_Access_Info));
-   evas_object_data_set(target, "_elm_access", ai);
+   return ((Elm_Widget_Item *)item)->access_obj;
+}
 
-   //TODO: evas_object_data_del(); parent should take care of children.
-   evas_object_data_set(target, "_elm_access_parent", parent);
+EAPI Evas_Object *
+elm_access_object_register(Evas_Object *obj, Evas_Object *parent)
+{
+   return _access_object_register(obj, parent);
 }
 
 EAPI void
 elm_access_object_unregister(Evas_Object *obj)
 {
-   Elm_Access_Info *ac;
+   _access_object_unregister(obj);
+}
 
-   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_IN,
-                                       _access_obj_mouse_in_cb, obj);
-   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_OUT,
-                                       _access_obj_mouse_out_cb, obj);
-   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
-                                       _access_obj_del_cb, obj);
+EAPI Evas_Object *
+elm_access_object_access_get(Evas_Object *obj)
+{
+   return evas_object_data_get(obj, "_part_access_obj");
+}
 
-   ac = evas_object_data_get(obj, "_elm_access");
-   evas_object_data_del(obj, "_elm_access");
-   if (ac)
-     {
-        _elm_access_clear(ac);
-        free(ac);
-     }
+EAPI void
+elm_access_text_set(Evas_Object *obj, int type, const char *text)
+{
+   _elm_access_text_set(_elm_access_object_get(obj), type, text);
+}
 
-   evas_object_data_del(obj, "_elm_access_parent");
+EAPI char *
+elm_access_text_get(Evas_Object *obj, int type)
+{
+   return _elm_access_text_get(_elm_access_object_get(obj), type, obj);
 }
 
 EAPI void
index cef6162..0009087 100644 (file)
@@ -22,25 +22,68 @@ typedef char *(*Elm_Access_Content_Cb)(void *data, Evas_Object *obj);
 typedef void (*Elm_Access_Activate_Cb)(void *data, Evas_Object *part_obj, Elm_Object_Item *item);
 
 /**
+ * @brief Register object item as an accessible object.
+ * @since 1.8
+ *
+ * @param item The elementary object item
+ *
+ * @ingroup Access
+ */
+EAPI Evas_Object * elm_access_object_item_register(Elm_Object_Item *item);
+
+/**
+ * @brief Unregister accessible object of the object item.
+ * @since 1.8
+ *
+ * @param item The elementary object item
+ *
+ * @ingroup Access
+ */
+EAPI void elm_access_object_item_unregister(Elm_Object_Item *item);
+
+/**
+ * @brief Get an accessible object of the object item.
+ * @since 1.8
+ *
+ * @param item The elementary object item
+ * @return Accessible object of the object item or NULL for any error
+ *
+ * @ingroup Access
+ */
+EAPI Evas_Object * elm_access_object_item_access_get(Elm_Object_Item *item);
+
+/**
  * @brief Register evas object as an accessible object.
  * @since 1.8
  *
- * @param parent Accessibility parent object. this should be one of widget.
- * @param target Evas object to register as an accessible object.
+ * @param obj The evas object to register as an accessible object.
+ * @param parent The elementary object which is used for creating
+ * accessible object.
  *
  * @ingroup Access
  */
-EAPI void elm_access_object_register(Evas_Object *parent, Evas_Object *target);
+EAPI Evas_Object * elm_access_object_register(Evas_Object *obj, Evas_Object *parent);
 
 /**
  * @brief Unregister accessible object.
  * @since 1.8
  *
- * @param obj Accessible object.
+ * @param obj The Evas object to unregister accessible object.
+ *
+ * @ingroup Access
+ */
+EAPI void elm_access_object_unregister(Evas_Object *obj);
+
+/**
+ * @brief Get an accessible object of the evas object.
+ * @since 1.8
+ *
+ * @param obj The evas object.
+ * @return Accessible object of the evas object or NULL for any error
  *
  * @ingroup Access
  */
-EAPI void elm_access_object_unregister(Evas_Object *target);
+EAPI Evas_Object * elm_access_object_access_get(Evas_Object *obj);
 
 /**
  * @brief Set text to give information for specific type.
index e243926..8d1457c 100644 (file)
@@ -735,6 +735,9 @@ _item_realize(Elm_Gen_Item *it)
    evas_object_size_hint_min_set(it->spacer, 2 * elm_config_scale_get(), 1);
    edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
 
+   /* access */
+   if (_elm_config->access_mode) _access_widget_item_register(it);
+
    if (it->itc->func.text_get)
      {
         const Eina_List *l;
@@ -852,10 +855,6 @@ _item_realize(Elm_Gen_Item *it)
 
    it->realized = EINA_TRUE;
    it->want_unrealize = EINA_FALSE;
-
-   // ACCESS
-   if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
-     _access_widget_item_register(it);
 }
 
 static Eina_Bool
index 86fba90..176da80 100644 (file)
@@ -1380,9 +1380,8 @@ _item_realize(Elm_Gen_Item *it,
           (VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
      }
 
-   // ACCESS
-   if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
-     _access_widget_item_register(it);
+   /* access */
+   if (_elm_config->access_mode) _access_widget_item_register(it);
 
    _item_order_update(EINA_INLIST_GET(it), in);