elementary - added elm_object_item_translatable_part_text_set() elm_object_item_trans...
authorChunEon Park <chuneon.park@samsung.com>
Fri, 29 Mar 2013 10:16:00 +0000 (19:16 +0900)
committerSungho Kwak <sungho1.kwak@samsung.com>
Tue, 2 Apr 2013 09:44:55 +0000 (18:44 +0900)
elementary - move elm_object_translatable_set()/get() from elm_general.h to elm_object.h
elemenatry - replace elm_object_domain_translatable_text_part_set()/text_part_get() with elm_object_domain_transltable_part_text_set(), part_text_get()
elementary - removed duplicated logic from translatable_part_text_set()/get().

author ChunEon Park <hermet@hermet.pe.kr> 2013-02-12 10:38:33 (GMT)
committer ChunEon Park <hermet@hermet.pe.kr> 2013-02-12 10:38:33 (GMT)
commit 9dbff2d9d513968eb55f61af8865b5f5610cd028 (patch)

author ChunEon Park <hermet@hermet.pe.kr> 2013-02-12 10:42:12 (GMT)
committer ChunEon Park <hermet@hermet.pe.kr> 2013-02-12 10:42:12 (GMT)
commit 470e2b450ca2d397c595073ff55fec73007fd9ea (patch)

author ChunEon Park <hermet@hermet.pe.kr> 2013-02-12 11:43:39 (GMT)
committer ChunEon Park <hermet@hermet.pe.kr> 2013-02-12 11:43:39 (GMT)
commit 5cd0d3a7d175db33ec84827f0bb59dc95d13b5e3 (patch)

author ChunEon Park <hermet@hermet.pe.kr> 2013-02-12 13:00:37 (GMT)
committer ChunEon Park <hermet@hermet.pe.kr> 2013-02-12 13:00:37 (GMT)
commit f1f8bfe8c25c47c675cdc4e06e675e165ec6337f (patch)

Change-Id: Ifdd39322808e747b337f84769ca59a90f4de2442

src/lib/elm_deprecated.h
src/lib/elm_general.h
src/lib/elm_main.c
src/lib/elm_object.h
src/lib/elm_object_item.h
src/lib/elm_widget.c
src/lib/elm_widget.h

index a664a0e..922e9db 100644 (file)
@@ -487,3 +487,49 @@ EINA_DEPRECATED EAPI void                        elm_label_slide_set(Evas_Object
  * @ingroup Label
  */
 EINA_DEPRECATED EAPI Eina_Bool                   elm_label_slide_get(const Evas_Object *obj);
+
+/**
+ * Set the text for an object's part, marking it as translatable.
+ *
+ * The string to set as @p text must be the original one. Do not pass the
+ * return of @c gettext() here. Elementary will translate the string
+ * internally and set it on the object using elm_object_part_text_set(),
+ * also storing the original string so that it can be automatically
+ * translated when the language is changed with elm_language_set().
+ *
+ * The @p domain will be stored along to find the translation in the
+ * correct catalog. It can be NULL, in which case it will use whatever
+ * domain was set by the application with @c textdomain(). This is useful
+ * in case you are building a library on top of Elementary that will have
+ * its own translatable strings, that should not be mixed with those of
+ * programs using the library.
+ *
+ * @param obj The object containing the text part
+ * @param part The name of the part to set
+ * @param domain The translation domain to use
+ * @param text The original, non-translated text to set
+ *
+ * @deprecated Use elm_object_domain_translatable_part_text_set() instead.
+ *
+ * @ingroup General
+ */
+EINA_DEPRECATED EAPI void      elm_object_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text);
+
+/**
+ * Gets the original string set as translatable for an object
+ *
+ * When setting translated strings, the function elm_object_part_text_get()
+ * will return the translation returned by @c gettext(). To get the
+ * original string use this function.
+ *
+ * @param obj The object
+ * @param part The name of the part that was set
+ *
+ * @return The original, untranslated string
+ *
+ * @deprecated Use elm_object_translatable_part_text_get() instead.
+ *
+ * @ingroup General
+ */
+EINA_DEPRECATED EAPI const char *elm_object_translatable_text_part_get(const Evas_Object *obj, const char *part);
+
index d2b5c9b..7b89a7b 100644 (file)
@@ -331,52 +331,5 @@ EAPI int       elm_policy_get(unsigned int policy);
 EAPI void      elm_language_set(const char *lang);
 
 /**
- * Set the text for an objects' part, marking it as translatable.
- *
- * The string to set as @p text must be the original one. Do not pass the
- * return of @c gettext() here. Elementary will translate the string
- * internally and set it on the object using elm_object_part_text_set(),
- * also storing the original string so that it can be automatically
- * translated when the language is changed with elm_language_set().
- *
- * The @p domain will be stored along to find the translation in the
- * correct catalog. It can be NULL, in which case it will use whatever
- * domain was set by the application with @c textdomain(). This is useful
- * in case you are building a library on top of Elementary that will have
- * its own translatable strings, that should not be mixed with those of
- * programs using the library.
- *
- * @param obj The object containing the text part
- * @param part The name of the part to set
- * @param domain The translation domain to use
- * @param text The original, non-translated text to set
- *
- * @ingroup General
- */
-EAPI void      elm_object_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text);
-
-#define elm_object_domain_translatable_text_set(obj, domain, text) elm_object_domain_translatable_text_part_set((obj), NULL, (domain), (text))
-
-#define elm_object_translatable_text_set(obj, text)                elm_object_domain_translatable_text_part_set((obj), NULL, NULL, (text))
-
-/**
- * Gets the original string set as translatable for an object
- *
- * When setting translated strings, the function elm_object_part_text_get()
- * will return the translation returned by @c gettext(). To get the
- * original string use this function.
- *
- * @param obj The object
- * @param part The name of the part that was set
- *
- * @return The original, untranslated string
- *
- * @ingroup General
- */
-EAPI const char *elm_object_translatable_text_part_get(const Evas_Object *obj, const char *part);
-
-#define elm_object_translatable_text_get(obj) elm_object_translatable_text_part_get((obj), NULL)
-
-/**
  * @}
  */
index 2f9a3a3..8668a64 100644 (file)
@@ -966,17 +966,29 @@ elm_object_part_text_get(const Evas_Object *obj, const char *part)
 }
 
 EAPI void
-elm_object_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text)
+elm_object_domain_translatable_part_text_set(Evas_Object *obj, const char *part, const char *domain, const char *text)
 {
    EINA_SAFETY_ON_NULL_RETURN(obj);
-   elm_widget_domain_translatable_text_part_set(obj, part, domain, text);
+   elm_widget_domain_translatable_part_text_set(obj, part, domain, text);
 }
 
 EAPI const char *
-elm_object_translatable_text_part_get(const Evas_Object *obj, const char *part)
+elm_object_translatable_part_text_get(const Evas_Object *obj, const char *part)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
-   return elm_widget_translatable_text_part_get(obj, part);
+   return elm_widget_translatable_part_text_get(obj, part);
+}
+
+EINA_DEPRECATED EAPI void
+elm_object_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text)
+{
+   elm_object_domain_translatable_part_text_set(obj, part, domain, text);
+}
+
+EINA_DEPRECATED EAPI const char *
+elm_object_translatable_text_part_get(const Evas_Object *obj, const char *part)
+{
+   return elm_object_translatable_part_text_get(obj, part);
 }
 
 EAPI void
@@ -1422,6 +1434,18 @@ elm_object_item_part_text_get(const Elm_Object_Item *it, const char *part)
 }
 
 EAPI void
+elm_object_item_domain_translatable_part_text_set(Elm_Object_Item *it, const char *part, const char *domain, const char *text)
+{
+   _elm_widget_item_domain_translatable_part_text_set((Elm_Widget_Item *)it, part, domain, text);
+}
+
+EAPI const char *
+elm_object_item_translatable_part_text_get(const Elm_Object_Item *it, const char *part)
+{
+   return _elm_widget_item_translatable_part_text_get((Elm_Widget_Item *)it, part);
+}
+
+EAPI void
 elm_object_access_info_set(Evas_Object *obj, const char *txt)
 {
    elm_widget_access_info_set(obj, txt);
index 17f207b..a997cc8 100644 (file)
@@ -29,6 +29,59 @@ EAPI const char                  *elm_object_part_text_get(const Evas_Object *ob
 #define elm_object_text_get(obj) elm_object_part_text_get((obj), NULL)
 
 /**
+ * Set the text for an object's part, marking it as translatable.
+ *
+ * The string to set as @p text must be the original one. Do not pass the
+ * return of @c gettext() here. Elementary will translate the string
+ * internally and set it on the object using elm_object_part_text_set(),
+ * also storing the original string so that it can be automatically
+ * translated when the language is changed with elm_language_set().
+ *
+ * The @p domain will be stored along to find the translation in the
+ * correct catalog. It can be NULL, in which case it will use whatever
+ * domain was set by the application with @c textdomain(). This is useful
+ * in case you are building a library on top of Elementary that will have
+ * its own translatable strings, that should not be mixed with those of
+ * programs using the library.
+ *
+ * @param obj The object containing the text part
+ * @param part The name of the part to set
+ * @param domain The translation domain to use
+ * @param text The original, non-translated text to set
+ *
+ * @since 1.8
+ *
+ * @ingroup General
+ */
+EAPI void      elm_object_domain_translatable_part_text_set(Evas_Object *obj, const char *part, const char *domain, const char *text);
+
+#define elm_object_domain_translatable_text_set(obj, domain, text) elm_object_domain_translatable_part_text_set((obj), NULL, (domain), (text))
+
+#define elm_object_translatable_text_set(obj, text)                elm_object_domain_translatable_part_text_set((obj), NULL, NULL, (text))
+
+/**
+ * Gets the original string set as translatable for an object
+ *
+ * When setting translated strings, the function elm_object_part_text_get()
+ * will return the translation returned by @c gettext(). To get the
+ * original string use this function.
+ *
+ * @param obj The object
+ * @param part The name of the part that was set
+ *
+ * @return The original, untranslated string
+ *
+ * @see elm_object_translatable_part_text_set()
+ *
+ * @since 1.8
+ *
+ * @ingroup General
+ */
+EAPI const char *elm_object_translatable_part_text_get(const Evas_Object *obj, const char *part);
+
+#define elm_object_translatable_text_get(obj) elm_object_translatable_part_text_get((obj), NULL)
+
+/**
  * Set the content on part of a given container widget
  *
  * @param obj The Elementary container widget
index bad0754..8ea325f 100644 (file)
@@ -115,6 +115,54 @@ EAPI const char                  *elm_object_item_part_text_get(const Elm_Object
 #define elm_object_item_text_get(it) elm_object_item_part_text_get((it), NULL)
 
 /**
+ * Set the text for an object item's part, marking it as translatable.
+ *
+ * The string to set as @p text must be the original one. Do not pass the
+ * return of @c gettext() here. Elementary will translate the string
+ * internally and set it on the object item using
+ * elm_object_item_part_text_set(), also storing the original string so that it
+ * can be automatically translated when the language is changed with
+ * elm_language_set(). The @p domain will be stored along to find the
+ * translation in the correct catalog. It can be NULL, in which case it will use
+ * whatever domain was set by the application with @c textdomain(). This is
+ * useful in case you are building a library on top of Elementary that will have
+ * its own translatable strings, that should not be mixed with those of programs
+ * using the library.
+ *
+ * @param it The object item containing the text part
+ * @param part The name of the part to set
+ * @param domain The translation domain to use
+ * @param text The original, non-translated text to set
+ *
+ * @ingroup General
+ * @since 1.8
+ */
+EAPI void      elm_object_item_domain_translatable_part_text_set(Elm_Object_Item *it, const char *part, const char *domain, const char *text);
+
+#define elm_object_item_domain_translatable_text_set(it, domain, text) elm_object_item_domain_translatable_part_text_set((it), NULL, (domain), (text))
+
+#define elm_object_item_translatable_text_set(it, text) elm_object_item_domain_translatable_part_text_set((it), NULL, NULL, (text))
+
+/**
+ * Gets the original string set as translatable for an object item.
+ *
+ * When setting translated strings, the function elm_object_item_part_text_get()
+ * will return the translation returned by @c gettext(). To get the original
+ * string use this function.
+ *
+ * @param it The object item.
+ * @param part The name of the part that was set
+ *
+ * @return The original, untranslated string
+ *
+ * @ingroup General
+ * @since 1.8
+ */
+EAPI const char *elm_object_item_translatable_part_text_get(const Elm_Object_Item *it, const char *part);
+
+#define elm_object_item_translatable_text_get(it) elm_object_item_translatable_part_text_get((it), NULL)
+
+/**
  * Set the text to read out when in accessibility mode
  *
  * @param it The object item which is to be described
index fc51be4..24980f8 100644 (file)
@@ -3247,35 +3247,32 @@ elm_widget_text_part_get(const Evas_Object *obj,
    return NULL;
 }
 
-EAPI void
-elm_widget_domain_translatable_text_part_set(Evas_Object *obj,
-                                             const char *part,
-                                             const char *domain,
-                                             const char *label)
+static Eina_Bool
+_translatable_part_text_set(Eina_List **translate_strings, const char *part, const char *domain, const char *label)
 {
    const char *str;
-   Eina_List *l;
+   Eina_List *t, *l;
    Elm_Translate_String_Data *ts = NULL;
-   API_ENTRY return;
 
+   t = *translate_strings;
    str = eina_stringshare_add(part);
-   EINA_LIST_FOREACH(sd->translate_strings, l, ts)
-     if (ts->id == str)
-       break;
-     else
-       ts = NULL;
+   EINA_LIST_FOREACH(t, l, ts)
+     {
+        if (ts->id == str) break;
+        else ts = NULL;
+     }
 
    if (!ts && !label)
      eina_stringshare_del(str);
    else if (!ts)
      {
         ts = malloc(sizeof(Elm_Translate_String_Data));
-        if (!ts) return;
+        if (!ts) return EINA_FALSE;
 
         ts->id = str;
         ts->domain = eina_stringshare_add(domain);
         ts->string = eina_stringshare_add(label);
-        sd->translate_strings = eina_list_append(sd->translate_strings, ts);
+        t = eina_list_append(t, ts);
      }
    else
      {
@@ -3286,8 +3283,7 @@ elm_widget_domain_translatable_text_part_set(Evas_Object *obj,
           }
         else
           {
-             sd->translate_strings = eina_list_remove_list(
-                 sd->translate_strings, l);
+             t = eina_list_remove_list(t, l);
              eina_stringshare_del(ts->id);
              eina_stringshare_del(ts->domain);
              eina_stringshare_del(ts->string);
@@ -3296,6 +3292,20 @@ elm_widget_domain_translatable_text_part_set(Evas_Object *obj,
         eina_stringshare_del(str);
      }
 
+   *translate_strings = t;
+   return EINA_TRUE;
+}
+
+EAPI void
+elm_widget_domain_translatable_part_text_set(Evas_Object *obj,
+                                             const char *part,
+                                             const char *domain,
+                                             const char *label)
+{
+   API_ENTRY return;
+
+   if (!_translatable_part_text_set(&sd->translate_strings, part, domain,
+                                    label)) return;
 #ifdef HAVE_GETTEXT
    if (label && label[0])
      label = dgettext(domain, label);
@@ -3303,26 +3313,33 @@ elm_widget_domain_translatable_text_part_set(Evas_Object *obj,
    elm_widget_text_part_set(obj, part, label);
 }
 
-EAPI const char *
-elm_widget_translatable_text_part_get(const Evas_Object *obj,
-                                      const char *part)
+static const char *
+_translatable_part_text_get(Eina_List *translate_strings, const char *part)
 {
-   const char *str, *ret = NULL;
-   Eina_List *l;
    Elm_Translate_String_Data *ts;
-   API_ENTRY return NULL;
+   const char*ret = NULL, *str;
+   Eina_List *l;
 
    str = eina_stringshare_add(part);
-   EINA_LIST_FOREACH(sd->translate_strings, l, ts)
+   EINA_LIST_FOREACH(translate_strings, l, ts)
      if (ts->id == str)
        {
           ret = ts->string;
           break;
        }
    eina_stringshare_del(str);
+
    return ret;
 }
 
+EAPI const char *
+elm_widget_translatable_part_text_get(const Evas_Object *obj,
+                                      const char *part)
+{
+   API_ENTRY return NULL;
+   return _translatable_part_text_get(sd->translate_strings, part);
+}
+
 EAPI void
 elm_widget_translate(Evas_Object *obj)
 {
@@ -3976,6 +3993,7 @@ _elm_widget_item_new(Evas_Object *widget,
 EAPI void
 _elm_widget_item_free(Elm_Widget_Item *item)
 {
+   Elm_Translate_String_Data *ts;
    Elm_Widget_Item_Signal_Data *wisd;
 
    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
@@ -3996,6 +4014,14 @@ _elm_widget_item_free(Elm_Widget_Item *item)
         free(wisd);
      }
 
+   EINA_LIST_FREE(item->translate_strings, ts)
+     {
+        eina_stringshare_del(ts->id);
+        eina_stringshare_del(ts->domain);
+        eina_stringshare_del(ts->string);
+        free(ts);
+     }
+
    EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
    free(item);
 }
@@ -4194,6 +4220,31 @@ _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
    item->disable_func = func;
 }
 
+EAPI void
+_elm_widget_item_domain_translatable_part_text_set(Elm_Widget_Item *item,
+                                                   const char *part,
+                                                   const char *domain,
+                                                   const char *label)
+{
+   ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+
+   if (!_translatable_part_text_set(&item->translate_strings, part, domain,
+                                    label)) return;
+#ifdef HAVE_GETTEXT
+   if (label && label[0])
+     label = dgettext(domain, label);
+#endif
+   _elm_widget_item_part_text_set(item, part, label);
+}
+
+EAPI const char *
+_elm_widget_item_translatable_part_text_get(const Elm_Widget_Item *item,
+                                            const char *part)
+{
+   ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
+   return _translatable_part_text_get(item->translate_strings, part);
+}
+
 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
 
 struct _Elm_Widget_Item_Tooltip
index 8f3d77f..1385755 100644 (file)
@@ -657,6 +657,7 @@ struct _Elm_Widget_Item
    Evas_Object                   *access_obj;
    const char                    *access_info;
    Eina_List                     *access_order;
+   Eina_List                     *translate_strings;
    Eina_List                     *signals;
 
    Eina_Bool                      disabled : 1;
@@ -798,8 +799,8 @@ EAPI Evas_Object     *elm_widget_newest_focus_order_get(const Evas_Object *obj,
 EAPI void             elm_widget_activate(Evas_Object *obj, Elm_Activate act);
 EAPI void             elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label);
 EAPI const char      *elm_widget_text_part_get(const Evas_Object *obj, const char *part);
-EAPI void             elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text);
-EAPI const char      *elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part);
+EAPI void             elm_widget_domain_translatable_part_text_set(Evas_Object *obj, const char *part, const char *domain, const char *text);
+EAPI const char      *elm_widget_translatable_part_text_get(const Evas_Object *obj, const char *part);
 EAPI void             elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content);
 EAPI Evas_Object     *elm_widget_content_part_get(const Evas_Object *obj, const char *part);
 EAPI Evas_Object     *elm_widget_content_part_unset(Evas_Object *obj, const char *part);
@@ -851,6 +852,9 @@ EAPI void             _elm_widget_item_disabled_set(Elm_Widget_Item *item, Eina_
 EAPI Eina_Bool        _elm_widget_item_disabled_get(const Elm_Widget_Item *item);
 EAPI void             _elm_widget_item_disable_hook_set(Elm_Widget_Item *item, Elm_Widget_Disable_Cb func);
 EAPI void             _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Del_Pre_Cb func);
+EAPI void             _elm_widget_item_domain_translatable_part_text_set(Elm_Widget_Item *item, const char *part, const char *domain, const char *label);
+EAPI const char *     _elm_widget_item_translatable_part_text_get(const Elm_Widget_Item *item, const char *part);
+EAPI void             _elm_widget_item_translate(Elm_Widget_Item *item);
 
 /**
  * Function to operate on a given widget's scrollabe children when necessary.