summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2013-04-23 17:11:28 +0900
committerChunEon Park <hermet@hermet.pe.kr>2013-04-23 17:11:28 +0900
commitaa7d8ad206f6a0d247475800cb5c6c32d80a6009 (patch)
tree901daff3a05858a17bbe4bc6403fff9ce23ae0c2
parent33e01102107bb7a4ae2934208912f3512fbc294e (diff)
downloadelementary-aa7d8ad206f6a0d247475800cb5c6c32d80a6009.tar.gz
elementary/widget item - and add elm_object_item_domain_part_text_translatable_set().
-rw-r--r--ChangeLog3
-rw-r--r--NEWS2
-rw-r--r--src/lib/elm_main.c6
-rw-r--r--src/lib/elm_object.h2
-rw-r--r--src/lib/elm_object_item.h28
-rw-r--r--src/lib/elm_widget.c34
-rw-r--r--src/lib/elm_widget.h1
7 files changed, 72 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 01233d33b..eaec38496 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1275,7 +1275,8 @@
2013-04-23 ChunEon Park
- * Added elm_object_domain_part_text_translatable_set().
+ * Added elm_object_domain_part_text_translatable_set(),
+ elm_object_item_domain_part_text_translatable_set().
2013-04-23 Jaehwan Kim
diff --git a/NEWS b/NEWS
index a2e8bee1b..c18294898 100644
--- a/NEWS
+++ b/NEWS
@@ -62,7 +62,7 @@ Additions:
* Add the API elm_scroller_single_direction_set/get.
* Add the feature for key events.
* Add elm_access_action(), elm_access_action_cb_set()
- * Add elm_object_domain_part_text_translatable_set()
+ * Add elm_object_domain_part_text_translatable_set(), elm_object_item_domain_part_text_translatable_set().
Improvements:
diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
index a055f28c1..28561b37d 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -1574,6 +1574,12 @@ elm_object_item_translatable_part_text_get(const Elm_Object_Item *it, const char
}
EAPI void
+elm_object_item_domain_part_text_translatable_set(Elm_Object_Item *it, const char *part, const char *domain, Eina_Bool translatable)
+{
+ _elm_widget_item_domain_part_text_translatable_set((Elm_Widget_Item *)it, part, domain, translatable);
+}
+
+EAPI void
elm_object_access_info_set(Evas_Object *obj, const char *txt)
{
elm_widget_access_info_set(obj, txt);
diff --git a/src/lib/elm_object.h b/src/lib/elm_object.h
index bc9c8861c..2e617c435 100644
--- a/src/lib/elm_object.h
+++ b/src/lib/elm_object.h
@@ -98,7 +98,7 @@ EAPI const char *elm_object_translatable_part_text_get(const Evas_Object *obj, c
* @param translatable @c EINA_TRUE, the part text will be translated
* internally. @c EINA_FALSE, otherwise.
*
- * @see elm_object_domain_part_text_translatable_set()
+ * @see elm_object_domain_translatable_part_text_set()
* @see elm_object_part_text_set()
* @see elm_policy()
*
diff --git a/src/lib/elm_object_item.h b/src/lib/elm_object_item.h
index ee7829203..a14649ed9 100644
--- a/src/lib/elm_object_item.h
+++ b/src/lib/elm_object_item.h
@@ -171,6 +171,34 @@ EAPI const char *elm_object_item_translatable_part_text_get(const Elm_Object_Ite
#define elm_object_item_translatable_text_get(it) elm_object_item_translatable_part_text_get((it), NULL)
+/**
+ * Mark the part text to be transltable or not.
+ *
+ * Once you mark the part text to be translatable, the text will be translated
+ * internally regardless of elm_object_item_part_text_set() and
+ * elm_object_item_domain_translatable_part_text_set(). In other case, if you
+ * set the Elementary policy that all text will be translatable in default, you
+ * can set the part text to not be translated by calling this API.
+ *
+ * @param it The object item containing the text part
+ * @param part The part name of the translatable text
+ * @param domain The translation domain to use
+ * @param translatable @c EINA_TRUE, the part text will be translated
+ * internally. @c EINA_FALSE, otherwise.
+ *
+ * @see elm_object_item_domain_translatable_part_text_set()
+ * @see elm_object_item_part_text_set()
+ * @see elm_policy()
+ *
+ * @since 1.8
+ *
+ * @ingroup General
+ */
+EAPI void elm_object_item_domain_part_text_translatable_set(Elm_Object_Item *it, const char *part, const char *domain, Eina_Bool translatable);
+
+#define elm_object_item_part_text_translatable_set(it, part, translatable) elm_object_item_domain_part_text_translatable_set((it), (part), NULL, (translatable))
+
+#define elm_object_item_domain_text_translatable_set(it, domain, translatable) elm_object_item_domain_part_text_translatable_set((it), NULL, (domain), (translatable))
/**
* Set the text to read out when in accessibility mode
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 5ca6b9903..3f205f9e4 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -5143,6 +5143,36 @@ _elm_widget_item_translatable_part_text_get(const Elm_Widget_Item *item,
return NULL;
}
+EAPI void
+_elm_widget_item_domain_part_text_translatable_set(Elm_Widget_Item *item,
+ const char *part,
+ const char *domain,
+ Eina_Bool translatable)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ Elm_Translate_String_Data *ts;
+ const char *text;
+
+ ts = _part_text_translatable_set(&item->translate_strings, part,
+ translatable, EINA_TRUE);
+ if (!ts) return;
+ if (!ts->domain) ts->domain = eina_stringshare_add(domain);
+ else eina_stringshare_replace(&ts->domain, domain);
+
+ text = _elm_widget_item_part_text_get(item, part);
+ if (!text || !text[0]) return;
+
+ if (!ts->string) ts->string = eina_stringshare_add(text);
+
+//Try to translate text since we don't know the text is already translated.
+#ifdef HAVE_GETTEXT
+ text = dgettext(domain, text);
+#endif
+ item->on_translate = EINA_TRUE;
+ _elm_widget_item_part_text_set(item, part, text);
+ item->on_translate = EINA_FALSE;
+}
+
typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
struct _Elm_Widget_Item_Tooltip
@@ -5716,11 +5746,13 @@ _elm_widget_item_translate(Elm_Widget_Item *item)
#ifdef HAVE_GETTEXT
Elm_Translate_String_Data *ts;
const Eina_List *l;
-
EINA_LIST_FOREACH(item->translate_strings, l, ts)
{
+ if (!ts->string) continue;
const char *s = dgettext(ts->domain, ts->string);
+ item->on_translate = EINA_TRUE;
_elm_widget_item_part_text_set(item, ts->id, s);
+ item->on_translate = EINA_FALSE;
}
#endif
}
diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h
index 86f743500..71d6c1d67 100644
--- a/src/lib/elm_widget.h
+++ b/src/lib/elm_widget.h
@@ -765,6 +765,7 @@ EAPI void _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, E
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);
+EAPI void _elm_widget_item_domain_part_text_translatable_set(Elm_Widget_Item *item, const char *part, const char *domain, Eina_Bool translatable);
/**
* Function to operate on a given widget's scrollabe children when necessary.