kuuko pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=9e1b6a676c5793242f09307bceeaba5c277d45ad

commit 9e1b6a676c5793242f09307bceeaba5c277d45ad
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Thu Oct 3 00:30:23 2013 +0300

    Elementary.general: Enable functions that were previously problematic.
---
 efl/elementary/general.pxd |  10 ++---
 efl/elementary/general.pyx | 109 +++++++++++++++++++++++++++++----------------
 2 files changed, 75 insertions(+), 44 deletions(-)

diff --git a/efl/elementary/general.pxd b/efl/elementary/general.pxd
index dabaea3..fbb0d0d 100644
--- a/efl/elementary/general.pxd
+++ b/efl/elementary/general.pxd
@@ -104,7 +104,7 @@ cdef extern from "Elementary.h":
     int                     elm_policy_get(unsigned int policy)
 
     # General - Language
-    # TODO: void                    elm_language_set(const_char *lang)
+    void                    elm_language_set(const_char *lang)
 
     # Cache
     void                    elm_cache_all_flush()
@@ -113,9 +113,9 @@ cdef extern from "Elementary.h":
     void                    elm_coords_finger_size_adjust(int times_w, 
Evas_Coord *w, int times_h, Evas_Coord *h)
 
     # Font (elm_font.h)
-    # TODO: Elm_Font_Properties *   elm_font_properties_get(const_char *font)
-    # TODO: void                    
elm_font_properties_free(Elm_Font_Properties *efp)
-    # TODO: char *                  elm_font_fontconfig_name_get(const_char 
*name, const_char *style)
-    # TODO: void                    elm_font_fontconfig_name_free(char *name)
+    Elm_Font_Properties *   elm_font_properties_get(const_char *font)
+    void                    elm_font_properties_free(Elm_Font_Properties *efp)
+    char *                  elm_font_fontconfig_name_get(const_char *name, 
const_char *style)
+    void                    elm_font_fontconfig_name_free(char *name)
     # TODO: Eina_Hash *             elm_font_available_hash_add(Eina_List 
*list)
     # TODO: void                    elm_font_available_hash_del(Eina_Hash 
*hash)
diff --git a/efl/elementary/general.pyx b/efl/elementary/general.pyx
index bcd7915..e380228 100644
--- a/efl/elementary/general.pyx
+++ b/efl/elementary/general.pyx
@@ -276,6 +276,28 @@ def coords_finger_size_adjust(int times_w, int w, int 
times_h, int h):
     elm_coords_finger_size_adjust(times_w, &width, times_h, &height)
     return (width, height)
 
+def language_set(lang not None):
+    """language_set(unicode lang)
+    Change the language of the current application
+
+    The @p lang passed must be the full name of the locale to use, for
+    example "en_US.utf8" or "es_ES@euro".
+
+    Changing language with this function will make Elementary run through
+    all its widgets, translating strings set with
+    elm_object_domain_translatable_part_text_set(). This way, an entire
+    UI can have its language changed without having to restart the program.
+
+    For more complex cases, like having formatted strings that need
+    translation, widgets will also emit a "language,changed" signal that
+    the user can listen to and manually translate the text.
+
+    :param lang: Language to set, must be the full name of the locale
+
+    """
+    if isinstance(lang, unicode): lang = PyUnicode_AsUTF8String(lang)
+    elm_language_set(<const char *>lang)
+
 def cache_all_flush():
     """cache_all_flush()
 
@@ -287,56 +309,65 @@ def cache_all_flush():
     """
     elm_cache_all_flush()
 
-# XXX: These create some weird parsing error in Cython
-# def font_properties_get(font):
-#     """Translate a font (family) name string in fontconfig's font names
-#     syntax into a FontProperties object.
+def font_properties_get(font not None):
+    """font_properties_get(unicode font) -> FontProperties
 
-#     :param font: The font name and styles string
-#     :return: the font properties object
+    Translate a font (family) name string in fontconfig's font names
+    syntax into a FontProperties object.
 
-#     .. note:: The reverse translation can be achieved with
-#         :py:func:`font_fontconfig_name_get`, for one style only (single font
-#         instance, not family).
+    :param font: The font name and styles string
+    :return: the font properties object
 
-#     """
-#     if isinstance(font, unicode): font = PyUnicode_AsUTF8String(font)
-#     cdef:
-#         Elm_Font_Properties *efp
-#         FontProperties ret = FontProperties.__new__()
+    .. note:: The reverse translation can be achieved with
+        :py:func:`font_fontconfig_name_get`, for one style only (single font
+        instance, not family).
 
-    #ret.efp = elm_font_properties_get(<const char *>font if font is not None 
else NULL)
+    """
+    if isinstance(font, unicode): font = PyUnicode_AsUTF8String(font)
+    cdef FontProperties ret = FontProperties.__new__()
+
+    ret.efp = elm_font_properties_get(<const char *>font)
 
-    # elm_font_properties_free(efp)
-    # return ret
+    return ret
 
-# def font_fontconfig_name_get(font_name, style = None):
-#     """font_fontconfig_name_get(unicode font_name, unicode style = None) -> 
unicode
+def font_properties_free(FontProperties fp):
+    """Free font properties return by font_properties_get().
 
-#     Translate a font name, bound to a style, into fontconfig's font names
-#     syntax.
+    :param fp: the font properties struct
 
-#     :param font_name: The font (family) name
-#     :param style: The given style (may be None)
+    """
+    elm_font_properties_free(fp.efp)
+    Py_DECREF(fp)
 
-#     :return: the font name and style string
+def font_fontconfig_name_get(font_name, style = None):
+    """font_fontconfig_name_get(unicode font_name, unicode style = None) -> 
unicode
 
-#     .. note:: The reverse translation can be achieved with
-#         :py:func:`font_properties_get`, for one style only (single font
-#         instance, not family).
+    Translate a font name, bound to a style, into fontconfig's font names
+    syntax.
 
-#     """
-#     cdef:
-#         unicode ret
-#         char *fc_name
-#     if isinstance(font_name, unicode): font_name = 
PyUnicode_AsUTF8String(font_name)
-#     if isinstance(style, unicode): style = PyUnicode_AsUTF8String(style)
-#     fc_name = elm_font_fontconfig_name_get(<const char *>font_name,
-#         <const char *>style if style is not None else NULL))
-
-#     ret = _touni(fc_name)
-#     elm_font_fontconfig_name_free(fc_name)
-#     return ret
+    :param font_name: The font (family) name
+    :param style: The given style (may be None)
+
+    :return: the font name and style string
+
+    .. note:: The reverse translation can be achieved with
+        :py:func:`font_properties_get`, for one style only (single font
+        instance, not family).
+
+    """
+    cdef:
+        unicode ret
+        char *fc_name
+    if isinstance(font_name, unicode): font_name = 
PyUnicode_AsUTF8String(font_name)
+    if isinstance(style, unicode): style = PyUnicode_AsUTF8String(style)
+    fc_name = elm_font_fontconfig_name_get(
+        <const char *>font_name,
+        <const char *>style if style is not None else NULL
+        )
+
+    ret = _touni(fc_name)
+    elm_font_fontconfig_name_free(fc_name)
+    return ret
 
 # TODO: Create an Eina_Hash -> dict conversion function for this
 # def font_available_hash_add(list):

-- 


Reply via email to