atspi: add i18n support for name and description 53/66753/3
authorLukasz Stanislawski <l.stanislaws@samsung.com>
Thu, 30 Jul 2015 11:14:20 +0000 (13:14 +0200)
committerPrasoon Singh <prasoon.16@samsung.com>
Wed, 11 May 2016 12:24:27 +0000 (17:54 +0530)
Add new API to set atspi translation domain for name and description properties.
If translation domain is not set name and a description strings
will be used in its literal form.

@tizen_feature

Change-Id: I87dc3ac486289438f44ecfd4a5906be02f69f939

src/lib/elm_interface_atspi_accessible.eo
src/lib/elm_widget.c
src/lib/elm_widget.eo
src/lib/elm_widget.h
src/lib/elm_widget_item.eo
src/tests/elm_test_atspi.c

index 993d447..613e735 100644 (file)
@@ -199,6 +199,8 @@ mixin Elm_Interface_Atspi_Accessible ()
    implements {
       @virtual .relationship_append;
       @virtual .relationship_remove;
+      @virtual .translation_domain.get;
+      @virtual .translation_domain.set;
    }
    //////////
 }
index fab3e37..ae74d4b 100644 (file)
@@ -4575,6 +4575,11 @@ _elm_widget_item_eo_base_destructor(Eo *eo_item, Elm_Widget_Item_Data *item)
    if (item->atspi_custom_relations)
      elm_atspi_relation_set_free(&item->atspi_custom_relations);
 
+   //TIZEN_ONLY(20150731) : add i18n support for name and description
+   if (item->atspi_translation_domain)
+     eina_stringshare_del(item->atspi_translation_domain);
+   ///
+
    EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
 
    eo_do_super(eo_item, ELM_WIDGET_ITEM_CLASS, eo_destructor());
@@ -5867,6 +5872,11 @@ _elm_widget_eo_base_destructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
      eina_stringshare_del(sd->name);
    ///
 
+   //TIZEN_ONLY(20150731) : add i18n support for name and description
+   if (sd->atspi_translation_domain)
+     eina_stringshare_del(sd->atspi_translation_domain);
+   ///
+
    eo_do_super(obj, ELM_WIDGET_CLASS, eo_destructor());
    sd->on_destroy = EINA_FALSE;
 
@@ -5983,7 +5993,16 @@ _elm_widget_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Wid
    const char *ret;
    //TIZEN_ONLY(20150717) add widget name setter
    if (_pd->name)
-     return strdup(_pd->name);
+     {
+#ifdef HAVE_GETTEXT
+        if (_pd->atspi_translation_domain)
+          return strdup(dgettext(_pd->atspi_translation_domain, _pd->name));
+        else
+          return strdup(_pd->name);
+#else
+        return strdup(_pd->name);
+#endif
+     }
    ///
 
    ret = elm_object_text_get(obj);
@@ -6006,13 +6025,22 @@ EOLIAN char*
 _elm_widget_item_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd EINA_UNUSED)
 {
    if (_pd->name)
-     return strdup(_pd->name);
+     {
+#ifdef HAVE_GETTEXT
+        if (_pd->atspi_translation_domain)
+          return strdup(dgettext(_pd->atspi_translation_domain, _pd->name));
+        else
+          return strdup(_pd->name);
+#else
+        return strdup(_pd->name);
+#endif
+     }
+   ///
 
    return NULL;
 }
 ///
 
-//TIZEN_ONLY(20160329): widget: sort accessible children spatially (d940068e1f7cc5cfc6208245a1fb0e92f1a813d4)
 static int _sort_vertically(const void *data1, const void *data2)
 {
    Evas_Coord y1, y2;
@@ -6367,5 +6395,31 @@ _elm_widget_item_elm_interface_atspi_accessible_relationship_remove(Eo *obj EINA
 }
 ///////////////////////////////////
 
+//TIZEN_ONLY(20150731) : add i18n support for name and description
+EOLIAN static void
+_elm_widget_elm_interface_atspi_accessible_translation_domain_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd, const char *domain)
+{
+   eina_stringshare_replace(&_pd->atspi_translation_domain, domain);
+}
+
+EOLIAN static const char*
+_elm_widget_elm_interface_atspi_accessible_translation_domain_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
+{
+   return _pd->atspi_translation_domain;
+}
+
+EOLIAN static void
+_elm_widget_item_elm_interface_atspi_accessible_translation_domain_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd, const char *domain)
+{
+   eina_stringshare_replace(&_pd->atspi_translation_domain, domain);
+}
+
+EOLIAN static const char*
+_elm_widget_item_elm_interface_atspi_accessible_translation_domain_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd)
+{
+   return _pd->atspi_translation_domain;
+}
+///
+
 #include "elm_widget_item.eo.c"
 #include "elm_widget.eo.c"
index dfee0d9..a53c698 100644 (file)
@@ -790,6 +790,10 @@ abstract Elm.Widget (Evas.Object_Smart, Elm_Interface_Atspi_Accessible, Elm_Inte
       Elm_Interface_Atspi_Accessible.relationship_append;
       Elm_Interface_Atspi_Accessible.relationship_remove;
       //
+      //TIZEN_ONLY(20150731) : add i18n support for name and description
+      Elm_Interface_Atspi_Accessible.translation_domain.set;
+      Elm_Interface_Atspi_Accessible.translation_domain.get;
+      ///
       Elm_Interface_Atspi_Component.focus_grab;
       //TIZEN_ONLY(20160329): atspi: implement HighlightGrab and HighlightClear methods (29e253e2f7ef3c632ac3a64c489bf569df407f30)
       Elm_Interface_Atspi_Component.highlight_grab;
index e0f383a..db81481 100644 (file)
@@ -420,6 +420,9 @@ typedef struct _Elm_Widget_Smart_Data
    //TIZEN_ONLY(20150709) add relations atpi
    Elm_Atspi_Relation_Set       atspi_custom_relations; /**< Developer-defined accessiblity relations */
    ///////////////////////////////////
+   //TIZEN_ONLY(20150731) : add i18n support for name and description
+   const char                   *atspi_translation_domain;
+   ///
 
    /* this is a hook to be set on-the-fly on widgets. this is code
     * handling the request of showing a specific region from an inner
@@ -648,6 +651,9 @@ struct _Elm_Widget_Item_Data
    Elm_Atspi_Relation_Set        atspi_custom_relations; /**< Developer-defined accessiblity relations */
    ///////////////////////////////////
    const char                    *name;
+   //TIZEN_ONLY(20150731) : add i18n support for name and description
+   const char                    *atspi_translation_domain;
+   ///
 
    Eina_Bool                      disabled : 1;
    Eina_Bool                      on_deletion : 1;
index 392c698..e5cea05 100644 (file)
@@ -539,6 +539,10 @@ class Elm.Widget_Item(Eo.Base, Elm_Interface_Atspi_Accessible,
            Elm_Interface_Atspi_Accessible.relationship_append;
            Elm_Interface_Atspi_Accessible.relationship_remove;
            //
+           //TIZEN_ONLY(20150731) : add i18n support for name and description
+           Elm_Interface_Atspi_Accessible.translation_domain.set;
+           Elm_Interface_Atspi_Accessible.translation_domain.get;
+           ///
            Elm_Interface_Atspi_Component.extents.get;
            Elm_Interface_Atspi_Component.extents.set;
            Elm_Interface_Atspi_Component.alpha.get;
index 972dffd..12e0e53 100644 (file)
@@ -312,7 +312,6 @@ START_TEST (elm_atspi_children_and_parent2)
 }
 END_TEST
 
-<<<<<<< HEAD
 /* Initial value of translation domain should be NULL */
 START_TEST (elm_atspi_translation_domain_get)
 {
@@ -356,37 +355,19 @@ START_TEST (elm_atspi_relationship_append)
    elm_init(0, NULL);
    generate_app();
 
-=======
-START_TEST (elm_atspi_elm_widget_custom_relations)
-{
->>>>>>> 876f95b... atspi: add new APIs for setting atspi relationship.
    Elm_Atspi_Relation_Set set;
    Elm_Atspi_Relation *rel, *rel_to, *rel_from;
    Eina_List *l;
 
-<<<<<<< HEAD
    eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_bg));
    eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM, g_win));
    eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
 
-=======
-   elm_init(0, NULL);
-   generate_app2();
-
-   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
-   ck_assert(set == NULL);
-
-   eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_lbl));
-   eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM, g_win));
-
-   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
->>>>>>> 876f95b... atspi: add new APIs for setting atspi relationship.
    ck_assert(set != NULL);
    ck_assert(eina_list_count(set) >= 2);
 
    rel_to = rel_from = NULL;
    EINA_LIST_FOREACH(set, l, rel)
-<<<<<<< HEAD
    {
       if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
         rel_to = rel;
@@ -447,30 +428,11 @@ START_TEST (elm_atspi_relationship_remove)
    eo_do(g_btn, elm_interface_atspi_accessible_relationship_remove(ELM_ATSPI_RELATION_FLOWS_TO, g_bg));
    eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
 
-=======
-     {
-        if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
-          rel_to = rel;
-        if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
-          rel_from = rel;
-     }
-
-   ck_assert(rel_to != NULL);
-   ck_assert(rel_from != NULL);
-   ck_assert(eina_list_data_find(rel_to->objects, g_lbl) != NULL);
-   ck_assert(eina_list_data_find(rel_from->objects, g_win) != NULL);
-
-   elm_atspi_relation_set_free(&set);
-
-   eo_do(g_btn, elm_interface_atspi_accessible_relationship_remove(ELM_ATSPI_RELATION_FLOWS_TO, g_lbl));
-   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
->>>>>>> 876f95b... atspi: add new APIs for setting atspi relationship.
    ck_assert(set != NULL);
    ck_assert(eina_list_count(set) >= 1);
 
    rel_to = rel_from = NULL;
    EINA_LIST_FOREACH(set, l, rel)
-<<<<<<< HEAD
    {
       if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
         rel_to = rel;
@@ -554,7 +516,52 @@ START_TEST (elm_atspi_relationships_clear)
    }
 
    elm_atspi_relation_set_free(set);
-=======
+   elm_shutdown();
+}
+END_TEST
+
+START_TEST (elm_atspi_elm_widget_custom_relations)
+{
+   Elm_Atspi_Relation_Set set;
+   Elm_Atspi_Relation *rel, *rel_to, *rel_from;
+   Eina_List *l;
+
+   elm_init(0, NULL);
+   generate_app2();
+
+   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
+   ck_assert(set == NULL);
+
+   eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_TO, g_lbl));
+   eo_do(g_btn, elm_interface_atspi_accessible_relationship_append(ELM_ATSPI_RELATION_FLOWS_FROM, g_win));
+
+   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
+   ck_assert(set != NULL);
+   ck_assert(eina_list_count(set) >= 2);
+
+   rel_to = rel_from = NULL;
+   EINA_LIST_FOREACH(set, l, rel)
+     {
+        if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
+          rel_to = rel;
+        if (rel->type == ELM_ATSPI_RELATION_FLOWS_FROM)
+          rel_from = rel;
+     }
+
+   ck_assert(rel_to != NULL);
+   ck_assert(rel_from != NULL);
+   ck_assert(eina_list_data_find(rel_to->objects, g_lbl) != NULL);
+   ck_assert(eina_list_data_find(rel_from->objects, g_win) != NULL);
+
+   elm_atspi_relation_set_free(&set);
+
+   eo_do(g_btn, elm_interface_atspi_accessible_relationship_remove(ELM_ATSPI_RELATION_FLOWS_TO, g_lbl));
+   eo_do(g_btn, set = elm_interface_atspi_accessible_relation_set_get());
+   ck_assert(set != NULL);
+   ck_assert(eina_list_count(set) >= 1);
+
+   rel_to = rel_from = NULL;
+   EINA_LIST_FOREACH(set, l, rel)
      {
         if (rel->type == ELM_ATSPI_RELATION_FLOWS_TO)
           ck_assert(EINA_FALSE);
@@ -562,11 +569,37 @@ START_TEST (elm_atspi_relationships_clear)
 
    elm_atspi_relation_set_free(&set);
 
->>>>>>> 876f95b... atspi: add new APIs for setting atspi relationship.
    elm_shutdown();
 }
 END_TEST
 
+//TIZEN_ONLY(20150731) : add i18n support for name and description
+START_TEST (elm_atspi_elm_widget_translation_domain)
+{
+   elm_init(0, NULL);
+   generate_app();
+   const char *domain;
+
+   // Initially domain shuld not be set
+   eo_do(g_btn, domain = elm_interface_atspi_accessible_translation_domain_get());
+   ck_assert(domain == NULL);
+
+   eo_do(g_btn, elm_interface_atspi_accessible_translation_domain_set("Test domain"));
+
+   eo_do(g_btn, domain = elm_interface_atspi_accessible_translation_domain_get());
+   ck_assert(domain != NULL);
+   ck_assert_str_eq(domain, "Test domain");
+
+   eo_do(g_btn, elm_interface_atspi_accessible_translation_domain_set(NULL));
+
+   eo_do(g_btn, domain = elm_interface_atspi_accessible_translation_domain_get());
+   ck_assert(domain == NULL);
+
+   elm_shutdown();
+}
+END_TEST
+///
+
 void elm_test_atspi(TCase *tc)
 {
    tcase_add_test(tc, elm_atspi_app_obj_name_get);
@@ -580,13 +613,13 @@ void elm_test_atspi(TCase *tc)
    tcase_add_test(tc, elm_atspi_description_get);
    tcase_add_test(tc, elm_atspi_children_and_parent);
    tcase_add_test(tc, elm_atspi_children_and_parent2);
-<<<<<<< HEAD
    tcase_add_test(tc, elm_atspi_translation_domain_get);
    tcase_add_test(tc, elm_atspi_translation_domain_set);
    tcase_add_test(tc, elm_atspi_relationship_append);
    tcase_add_test(tc, elm_atspi_relationship_remove);
    tcase_add_test(tc, elm_atspi_relationships_clear);
-=======
    tcase_add_test(tc, elm_atspi_elm_widget_custom_relations);
->>>>>>> 876f95b... atspi: add new APIs for setting atspi relationship.
+   //TIZEN_ONLY(20150731) : add i18n support for name and description
+   tcase_add_test(tc, elm_atspi_elm_widget_translation_domain);
+   ///
 }