kuuko pushed a commit to branch master.

commit 4f8256a793d0e73b09ee390211fa53ec7b3737b5
Author: Kai Huuhko <[email protected]>
Date:   Sat Apr 20 17:32:43 2013 +0000

    Elementary: Add the new translatable text functions.
---
 efl/elementary/object.pxd      |  4 ++--
 efl/elementary/object.pyx      | 53 ++++++++++++++++++++++++++++++------------
 efl/elementary/object_item.pxd |  3 +++
 efl/elementary/object_item.pyx | 52 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 95 insertions(+), 17 deletions(-)

diff --git a/efl/elementary/object.pxd b/efl/elementary/object.pxd
index 1277fed..104070a 100644
--- a/efl/elementary/object.pxd
+++ b/efl/elementary/object.pxd
@@ -145,10 +145,10 @@ cdef extern from "Elementary.h":
     Eina_Bool               elm_object_tooltip_window_mode_get(Evas_Object 
*obj)
 
     # Object - Translatable text (elm_general.h) (py3: DONE)
-    void                    
elm_object_domain_translatable_text_part_set(Evas_Object *obj, const_char 
*part, const_char *domain, const_char *text)
+    void                    
elm_object_domain_translatable_part_text_set(Evas_Object *obj, const_char 
*part, const_char *domain, const_char *text)
     void                    
elm_object_domain_translatable_text_set(Evas_Object *obj, const_char *domain, 
const_char *text)
     void                    elm_object_translatable_text_set(Evas_Object *obj, 
const_char *text)
-    const_char *            elm_object_translatable_text_part_get(Evas_Object 
*obj, const_char *part)
+    const_char *            
elm_object_translatable_part_text_get(const_Evas_Object *obj, const_char *part)
     const_char *            elm_object_translatable_text_get(Evas_Object *obj)
 
     # TODO: CnP
diff --git a/efl/elementary/object.pyx b/efl/elementary/object.pyx
index 91aeb4b..943ddee 100644
--- a/efl/elementary/object.pyx
+++ b/efl/elementary/object.pyx
@@ -176,7 +176,7 @@ from cpython cimport PyObject, Py_INCREF, Py_DECREF, 
PyObject_GetAttr
 include "widget_header.pxi"
 include "tooltips.pxi"
 
-from efl.eo cimport _object_list_to_python
+from efl.eo cimport _object_list_to_python, _METHOD_DEPRECATED
 
 from efl.evas cimport EventKeyDown, EventKeyUp, EventMouseWheel
 from efl.evas cimport evas_object_smart_callback_add
@@ -1352,15 +1352,26 @@ cdef class Object(evasObject):
 
     #Translatable text
     def domain_translatable_text_part_set(self, part, domain, text):
-        """domain_translatable_text_part_set(unicode part, unicode domain, 
unicode text)
+        _METHOD_DEPRECATED(self, "Use domain_translatable_part_text_set() 
instead.")
+        if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
+        if isinstance(domain, unicode): domain = PyUnicode_AsUTF8String(domain)
+        if isinstance(text, unicode): text = PyUnicode_AsUTF8String(text)
+        elm_object_domain_translatable_part_text_set(self.obj,
+            <const_char *>part if part is not None else NULL,
+            <const_char *>domain if domain is not None else NULL,
+            <const_char *>text if text is not None else NULL)
 
-        Set the text for an objects' part, marking it as translatable.
+    def domain_translatable_part_text_set(self, part = None, domain = None, 
text = None):
+        """domain_translatable_part_text_set(part = None, domain = None, text 
= None)
+
+        Set the text for an object's part, marking it as translatable.
 
         The string to set as ``text`` must be the original one. Do not pass the
         return of ``gettext()`` here. Elementary will translate the string
-        internally and set it on the object using :py:func:`part_text_set()`,
+        internally and set it on the object using :py:func:`part_text_set`,
         also storing the original string so that it can be automatically
-        translated when the language is changed with :py:func:`language_set()`.
+        translated when the language is changed with
+        :py:func:`efl.elementary.general.language_set`.
 
         The ``domain`` will be stored along to find the translation in the
         correct catalog. It can be None, in which case it will use whatever
@@ -1370,21 +1381,21 @@ cdef class Object(evasObject):
         programs using the library.
 
         :param part: The name of the part to set
-        :type part: string
         :param domain: The translation domain to use
-        :type domain: string
         :param text: The original, non-translated text to set
-        :type text: string
+
+        :since: 1.8
 
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
         if isinstance(domain, unicode): domain = PyUnicode_AsUTF8String(domain)
         if isinstance(text, unicode): text = PyUnicode_AsUTF8String(text)
-        elm_object_domain_translatable_text_part_set(self.obj,
+        elm_object_domain_translatable_part_text_set(self.obj,
             <const_char *>part if part is not None else NULL,
             <const_char *>domain if domain is not None else NULL,
             <const_char *>text if text is not None else NULL)
 
+
     def domain_translatable_text_set(self, domain, text):
         """domain_translatable_text_set(unicode domain, unicode text)
 
@@ -1396,26 +1407,38 @@ cdef class Object(evasObject):
             <const_char *>text if text is not None else NULL)
 
     def translatable_text_part_get(self, part):
-        """domain_translatable_text_part_get(unicode part) -> unicode
+        _METHOD_DEPRECATED(self, "Use translatable_part_text_get() instead.")
+        if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
+        return _ctouni(elm_object_translatable_part_text_get(self.obj,
+            <const_char *>part if part is not None else NULL))
+
+
+    def translatable_part_text_get(self, part = None):
+        """translatable_part_text_get(part = None) -> unicode
 
         Gets the original string set as translatable for an object
 
-        When setting translated strings, the function 
:py:func:`part_text_get()`
-        will return the translation returned by *gettext()*. To get the
+        When setting translated strings, the function :py:func:`part_text_get`
+        will return the translation returned by ``gettext()``. To get the
         original string use this function.
 
         :param part: The name of the part that was set
-        :type part: string
+        :type part: unicode
 
         :return: The original, untranslated string
-        :rtype: string
+        :rtype: unicode
+
+        :see: :py:func:`translatable_part_text_set`
+
+        :since: 1.8
 
         """
         if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
-        return _ctouni(elm_object_translatable_text_part_get(self.obj,
+        return _ctouni(elm_object_translatable_part_text_get(self.obj,
             <const_char *>part if part is not None else NULL))
 
     property translatable_text:
+        # TODO: Document this
         def __get__(self):
             return self.translatable_text_get()
         def __set__(self, text):
diff --git a/efl/elementary/object_item.pxd b/efl/elementary/object_item.pxd
index b518837..35aa37c 100644
--- a/efl/elementary/object_item.pxd
+++ b/efl/elementary/object_item.pxd
@@ -21,6 +21,9 @@ cdef extern from "Elementary.h":
     void            elm_object_item_text_set(Elm_Object_Item *item, const_char 
*label)
     const_char *    elm_object_item_part_text_get(Elm_Object_Item *item, 
const_char *part)
     const_char *    elm_object_item_text_get(Elm_Object_Item *item)
+    void            
elm_object_item_domain_translatable_part_text_set(Elm_Object_Item *it, 
const_char *part, const_char *domain, const_char *text)
+    const_char *    
elm_object_item_translatable_part_text_get(const_Elm_Object_Item *it, 
const_char *part)
+
     void            elm_object_item_access_info_set(Elm_Object_Item *it, 
const_char *txt)
     void *          elm_object_item_data_get(Elm_Object_Item *item)
     void            elm_object_item_data_set(Elm_Object_Item *item, void *data)
diff --git a/efl/elementary/object_item.pyx b/efl/elementary/object_item.pyx
index 56ac115..b0c60e3 100644
--- a/efl/elementary/object_item.pyx
+++ b/efl/elementary/object_item.pyx
@@ -234,6 +234,58 @@ cdef class ObjectItem(object):
         return _ctouni(elm_object_item_part_text_get(self.item,
             <const_char *>part if part is not None else NULL))
 
+    def domain_translatable_part_text_set(self, part = None, domain = None, 
text = None):
+        """domain_translatable_part_text_set(part = None, domain = None, text 
= None)
+
+        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 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
+
+        """
+        if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
+        if isinstance(domain, unicode): domain = PyUnicode_AsUTF8String(domain)
+        if isinstance(text, unicode): text = PyUnicode_AsUTF8String(text)
+        elm_object_item_domain_translatable_part_text_set(self.item,
+            <const_char *>part if part is not None else NULL,
+            <const_char *>domain if domain is not None else NULL,
+            <const_char *>text if text is not None else NULL)
+
+    def translatable_part_text_get(self, part = None):
+        """translatable_part_text_get(part = None)
+
+        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 part: The name of the part that was set
+
+        :return: The original, untranslated string
+
+        :since: 1.8
+
+        """
+        if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
+        return _ctouni(elm_object_item_translatable_part_text_get(self.item,
+            <const_char *>part if part is not None else NULL))
+
     property text:
         """The main text for this object.
 

-- 

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

Reply via email to