kuuko pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=914c6ffd6b8f1632fce60486890b3b6158126942

commit 914c6ffd6b8f1632fce60486890b3b6158126942
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Fri Oct 4 09:29:45 2013 +0300

    Elementary: Add various missing functions
---
 TODO                              |  4 +-
 efl/elementary/entry.pxd          |  6 +--
 efl/elementary/entry.pyx          | 78 ++++++++++++++++++++-------------------
 efl/elementary/general.pxd        |  4 ++
 efl/elementary/general.pyx        | 23 ++++++++++++
 efl/elementary/menu.pxd           |  1 +
 efl/elementary/menu.pyx           |  6 +++
 efl/elementary/object.pxd         |  1 +
 efl/elementary/object.pyx         | 30 +++++++++++++++
 efl/elementary/object_item.pxd    |  1 +
 efl/elementary/object_item.pyx    | 30 +++++++++++++++
 efl/elementary/spinner.pxd        |  2 +
 efl/elementary/spinner.pyx        | 32 ++++++++++++++++
 efl/elementary/table.pxd          |  4 +-
 efl/elementary/table.pyx          | 14 ++++++-
 examples/elementary/test_entry.py | 16 ++++++++
 16 files changed, 208 insertions(+), 44 deletions(-)

diff --git a/TODO b/TODO
index f03a65b..ea4c3b0 100644
--- a/TODO
+++ b/TODO
@@ -25,7 +25,7 @@ TODO
 * include python-ethumb
 * Review the internal functions and name them consistently
 * Add more documentation for the use of callbacks
-* Document our use of exceptions
+* Review and document our use of exceptions
 * update links and text on:
   http://www.freedesktop.org/wiki/Software/DBusBindings
 * Split base object defines from includes/efl.evas.pxd so that everything
@@ -34,7 +34,7 @@ TODO
 * Add more scrollables once the documentation issue (and others) is solved.
 * Review the new elm list type object item system.
 * Check for documentation changes.
-* Elm Drag-n-Drop
+* Elm Drag-n-Drop (in progress/kuuko)
 * Unit tests for elm, things like top_widget and getting child objects
   can be done easily.
 
diff --git a/efl/elementary/entry.pxd b/efl/elementary/entry.pxd
index 17ae521..b4634f2 100644
--- a/efl/elementary/entry.pxd
+++ b/efl/elementary/entry.pxd
@@ -100,9 +100,9 @@ cdef extern from "Elementary.h":
     # TODO: void               elm_entry_item_provider_append(Evas_Object 
*obj, Elm_Entry_Item_Provider_Cb func, void *data)
     # TODO: void               elm_entry_item_provider_prepend(Evas_Object 
*obj, Elm_Entry_Item_Provider_Cb func, void *data)
     # TODO: void               elm_entry_item_provider_remove(Evas_Object 
*obj, Elm_Entry_Item_Provider_Cb func, void *data)
-    # TODO: void               elm_entry_markup_filter_append(Evas_Object 
*obj, Elm_Entry_Filter_Cb func, void *data)
-    # TODO: void               elm_entry_markup_filter_prepend(Evas_Object 
*obj, Elm_Entry_Filter_Cb func, void *data)
-    # TODO: void               elm_entry_markup_filter_remove(Evas_Object 
*obj, Elm_Entry_Filter_Cb func, void *data)
+    void               elm_entry_markup_filter_append(Evas_Object *obj, 
Elm_Entry_Filter_Cb func, void *data)
+    void               elm_entry_markup_filter_prepend(Evas_Object *obj, 
Elm_Entry_Filter_Cb func, void *data)
+    void               elm_entry_markup_filter_remove(Evas_Object *obj, 
Elm_Entry_Filter_Cb func, void *data)
     char *                  elm_entry_markup_to_utf8(const_char *s)
     char *                  elm_entry_utf8_to_markup(const_char *s)
     Eina_Bool               elm_entry_file_set(Evas_Object *obj, const_char 
*file, Elm_Text_Format format)
diff --git a/efl/elementary/entry.pyx b/efl/elementary/entry.pyx
index 312953e..a59f537 100644
--- a/efl/elementary/entry.pyx
+++ b/efl/elementary/entry.pyx
@@ -653,7 +653,7 @@ cdef class FilterAcceptSet(object):
         def __get__(self):
             return _ctouni(self.fltr.rejected)
 
-cdef void entry_filter_cb(void *data, Evas_Object *entry, char **text):
+cdef void py_elm_entry_filter_cb(void *data, Evas_Object *entry, char **text) 
with gil:
     """This callback type is used by entry filters to modify text.
 
     :param data: The data specified as the last param when adding the filter
@@ -672,7 +672,10 @@ cdef void entry_filter_cb(void *data, Evas_Object *entry, 
char **text):
     except:
         traceback.print_exc()
 
-    # TODO: replace text with returned value
+    if ret is None:
+        return
+
+    # TODO: text[0] = <char *>ret
 
 class EntryAnchorInfo(object):
     """
@@ -1343,52 +1346,53 @@ cdef class Entry(Object):
     #     """
     #     elm_entry_item_provider_remove(self.obj, Elm_Entry_Item_Provider_Cb 
func, void *data)
 
-    # TODO:
-    # def markup_filter_append(self, func, data):
-    #     """Append a markup filter function for text inserted in the entry
+    def markup_filter_append(self, func, data):
+        """Append a markup filter function for text inserted in the entry
 
-    #     Append the given callback to the list. This functions will be called
-    #     whenever any text is inserted into the entry, with the text to be 
inserted
-    #     as a parameter. The type of given text is always markup.
-    #     The callback function is free to alter the text in any way it wants, 
but
-    #     it must remember to free the given pointer and update it.
-    #     If the new text is to be discarded, the function can free it and set 
its
-    #     text parameter to NULL. This will also prevent any following filters 
from
-    #     being called.
+        Append the given callback to the list. This functions will be called
+        whenever any text is inserted into the entry, with the text to be 
inserted
+        as a parameter. The type of given text is always markup.
+        The callback function is free to alter the text in any way it wants, 
but
+        it must remember to free the given pointer and update it.
+        If the new text is to be discarded, the function can free it and set 
its
+        text parameter to NULL. This will also prevent any following filters 
from
+        being called.
 
-    #     :param func: The function to use as text filter
-    #     :param data: User data to pass to ``func``
+        :param func: The function to use as text filter
+        :param data: User data to pass to ``func``
 
-    #     """
-    #     cb_data = (func, data)
-    #     Py_INCREF(cb_data)
-    #     elm_entry_markup_filter_append(self.obj, entry_filter_cb, <void 
*>cb_data)
+        """
+        cb_data = (func, data)
+        Py_INCREF(cb_data)
+        elm_entry_markup_filter_append(self.obj, py_elm_entry_filter_cb, <void 
*>cb_data)
 
-    # TODO:
-    # def markup_filter_prepend(self, func, data):
-    #     """Prepend a markup filter function for text inserted in the entry
+    def markup_filter_prepend(self, func, data):
+        """Prepend a markup filter function for text inserted in the entry
 
-    #     Prepend the given callback to the list. See 
elm_entry_markup_filter_append()
-    #     for more information
+        Prepend the given callback to the list. See 
elm_entry_markup_filter_append()
+        for more information
 
-    #     :param func: The function to use as text filter
-    #     :param data: User data to pass to ``func``
+        :param func: The function to use as text filter
+        :param data: User data to pass to ``func``
 
-    #     """
-    #     elm_entry_markup_filter_prepend(self.obj, Elm_Entry_Filter_Cb func, 
void *data)
+        """
+        cb_data = (func, data)
+        Py_INCREF(cb_data)
+        elm_entry_markup_filter_prepend(self.obj, py_elm_entry_filter_cb, 
<void *>cb_data)
 
-    # TODO:
-    # def markup_filter_remove(self, func, data):
-    #     """Remove a markup filter from the list
+    def markup_filter_remove(self, func, data):
+        """Remove a markup filter from the list
 
-    #     Removes the given callback from the filter list. See
-    #     elm_entry_markup_filter_append() for more information.
+        Removes the given callback from the filter list. See
+        elm_entry_markup_filter_append() for more information.
 
-    #     :param func: The filter function to remove
-    #     :param data: The user data passed when adding the function
+        :param func: The filter function to remove
+        :param data: The user data passed when adding the function
 
-    #     """
-    #     elm_entry_markup_filter_remove(self.obj, Elm_Entry_Filter_Cb func, 
void *data)
+        """
+        cb_data = (func, data)
+        Py_INCREF(cb_data)
+        elm_entry_markup_filter_remove(self.obj, py_elm_entry_filter_cb, <void 
*>cb_data)
 
     markup_to_utf8 = staticmethod(Entry_markup_to_utf8)
 
diff --git a/efl/elementary/general.pxd b/efl/elementary/general.pxd
index fbb0d0d..300bb67 100644
--- a/efl/elementary/general.pxd
+++ b/efl/elementary/general.pxd
@@ -119,3 +119,7 @@ cdef extern from "Elementary.h":
     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)
+
+    # Debug
+    void elm_object_tree_dump(const_Evas_Object *top)
+    void elm_object_tree_dot_dump(const_Evas_Object *top, const_char *file)
diff --git a/efl/elementary/general.pyx b/efl/elementary/general.pyx
index e380228..0533734 100644
--- a/efl/elementary/general.pyx
+++ b/efl/elementary/general.pyx
@@ -50,6 +50,8 @@ Quit policy types
 from cpython cimport PyObject, Py_INCREF, Py_DECREF, PyUnicode_AsUTF8String, \
     PyMem_Malloc, PyMem_Free
 
+from efl.evas cimport Object as evasObject
+
 from efl.utils.conversions cimport _touni, _ctouni, \
     python_list_strings_to_eina_list, \
     eina_list_strings_to_python_list
@@ -396,3 +398,24 @@ def font_fontconfig_name_get(font_name, style = None):
 #     """
 #     elm_font_available_hash_del(Eina_Hash *hash)
 
+def object_tree_dump(evasObject top):
+    """object_tree_dump(Object top)
+
+    Print Tree object hierarchy in stdout
+
+    :param top: The root object
+
+    """
+    elm_object_tree_dump(top.obj)
+
+def object_tree_dot_dump(evasObject top, path):
+    """object_tree_dot_dump(Object top, unicode path)
+
+    Print Elm Objects tree hierarchy in file as dot(graphviz) syntax.
+
+    :param top: The root object
+    :param path: The path of output file
+
+    """
+    if isinstance(path, unicode): path = PyUnicode_AsUTF8String(path)
+    elm_object_tree_dot_dump(top.obj, <const_char *>path)
diff --git a/efl/elementary/menu.pxd b/efl/elementary/menu.pxd
index c6f1e29..845a033 100644
--- a/efl/elementary/menu.pxd
+++ b/efl/elementary/menu.pxd
@@ -19,6 +19,7 @@ cdef extern from "Elementary.h":
     Elm_Object_Item         *elm_menu_item_separator_add(Evas_Object *obj, 
Elm_Object_Item *parent)
     Eina_Bool                elm_menu_item_is_separator(Elm_Object_Item *it)
     Eina_List               *elm_menu_item_subitems_get(Elm_Object_Item *it)
+    void                     elm_menu_item_subitems_clear(Elm_Object_Item *it)
     int                      elm_menu_item_index_get(Elm_Object_Item *it)
     Elm_Object_Item         *elm_menu_selected_item_get(Evas_Object *obj)
     Elm_Object_Item         *elm_menu_last_item_get(Evas_Object *obj)
diff --git a/efl/elementary/menu.pyx b/efl/elementary/menu.pyx
index 131cfff..5e630c8 100644
--- a/efl/elementary/menu.pyx
+++ b/efl/elementary/menu.pyx
@@ -164,9 +164,15 @@ cdef class MenuItem(ObjectItem):
         def __get__(self):
             return 
_object_item_list_to_python(elm_menu_item_subitems_get(self.item))
 
+        def __del__(self):
+            elm_menu_item_subitems_clear(self.item)
+
     def subitems_get(self):
         return 
_object_item_list_to_python(elm_menu_item_subitems_get(self.item))
 
+    def subitems_clear(self):
+        elm_menu_item_subitems_clear(self.item)
+
     property index:
         """Get the position of a menu item
 
diff --git a/efl/elementary/object.pxd b/efl/elementary/object.pxd
index 308f321..a2e051f 100644
--- a/efl/elementary/object.pxd
+++ b/efl/elementary/object.pxd
@@ -150,6 +150,7 @@ cdef extern from "Elementary.h":
     void                    elm_object_translatable_text_set(Evas_Object *obj, 
const_char *text)
     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)
+    void                    
elm_object_domain_part_text_translatable_set(Evas_Object *obj, const_char 
*part, const_char *domain, Eina_Bool translatable)
 
     # TODO: CnP
     Eina_Bool               elm_cnp_selection_set(Evas_Object *obj, 
Elm_Sel_Type selection, Elm_Sel_Format format, const_void *buf, size_t buflen)
diff --git a/efl/elementary/object.pyx b/efl/elementary/object.pyx
index b434303..4eca820 100644
--- a/efl/elementary/object.pyx
+++ b/efl/elementary/object.pyx
@@ -1468,6 +1468,36 @@ cdef class Object(evasObject):
         return _ctouni(elm_object_translatable_part_text_get(self.obj,
             <const_char *>part if part is not None else NULL))
 
+    def domain_part_text_translatable_set(self, part not None, domain not 
None, bint translatable):
+        """domain_part_text_translatable_set(self, part, domain, bool 
translatable)
+
+        Mark the part text to be translatable or not.
+
+        Once you mark the part text to be translatable, the text will be 
translated
+        internally regardless of elm_object_part_text_set() and
+        elm_object_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 part: The part name of the translatable text
+        :param domain: The translation domain to use
+        :param translatable: ``True``, the part text will be translated
+            internally. ``False``, otherwise.
+
+        :see: elm_object_domain_translatable_part_text_set()
+        :see: elm_object_part_text_set()
+        :see: elm_policy()
+
+        :since: 1.8
+
+        """
+        if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
+        if isinstance(domain, unicode): domain = PyUnicode_AsUTF8String(domain)
+        elm_object_domain_part_text_translatable_set(self.obj,
+            <const_char *>part,
+            <const_char *>domain,
+            translatable)
+
     property translatable_text:
         # TODO: Document this
         def __get__(self):
diff --git a/efl/elementary/object_item.pxd b/efl/elementary/object_item.pxd
index 63be325..6d764f2 100644
--- a/efl/elementary/object_item.pxd
+++ b/efl/elementary/object_item.pxd
@@ -23,6 +23,7 @@ cdef extern from "Elementary.h":
     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_domain_part_text_translatable_set(Elm_Object_Item *it, 
const_char *part, const_char *domain, Eina_Bool translatable)
 
     void            elm_object_item_access_info_set(Elm_Object_Item *it, 
const_char *txt)
     void *          elm_object_item_data_get(Elm_Object_Item *item)
diff --git a/efl/elementary/object_item.pyx b/efl/elementary/object_item.pyx
index a5ec3fb..ac770c9 100644
--- a/efl/elementary/object_item.pyx
+++ b/efl/elementary/object_item.pyx
@@ -295,6 +295,36 @@ cdef class ObjectItem(object):
         return _ctouni(elm_object_item_translatable_part_text_get(self.item,
             <const_char *>part if part is not None else NULL))
 
+    def domain_part_text_translatable_set(self, part not None, domain not 
None, bint translatable):
+        """domain_part_text_translatable_set(self, part, domain, bool 
translatable)
+
+        Mark the part text to be translatable or not.
+
+        Once you mark the part text to be translatable, the text will be 
translated
+        internally regardless of :py:func:`part_text_set` and
+        :py:func:`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 part: The part name of the translatable text
+        :param domain: The translation domain to use
+        :param translatable: ``True``, the part text will be translated
+            internally. ``False``, otherwise.
+
+        :see: :py:func:`domain_translatable_part_text_set`
+        :see: :py:func:`part_text_set`
+        :see: :py:func:`efl.elementary.general.policy`
+
+        :since: 1.8
+
+        """
+        if isinstance(part, unicode): part = PyUnicode_AsUTF8String(part)
+        if isinstance(domain, unicode): domain = PyUnicode_AsUTF8String(domain)
+        elm_object_item_domain_part_text_translatable_set(self.item,
+            <const_char *>part,
+            <const_char *>domain,
+            translatable)
+
     property text:
         """The main text for this object.
 
diff --git a/efl/elementary/spinner.pxd b/efl/elementary/spinner.pxd
index 06022c1..f3a5b41 100644
--- a/efl/elementary/spinner.pxd
+++ b/efl/elementary/spinner.pxd
@@ -16,6 +16,8 @@ cdef extern from "Elementary.h":
     void                     elm_spinner_editable_set(Evas_Object *obj, 
Eina_Bool editable)
     Eina_Bool                elm_spinner_editable_get(Evas_Object *obj)
     void                     elm_spinner_special_value_add(Evas_Object *obj, 
double value, const_char *label)
+    void                     elm_spinner_special_value_del(Evas_Object *obj, 
double value)
+    const_char *             elm_spinner_special_value_get(Evas_Object *obj, 
double value)
     void                     elm_spinner_interval_set(Evas_Object *obj, double 
interval)
     double                   elm_spinner_interval_get(Evas_Object *obj)
     void                     elm_spinner_base_set(Evas_Object *obj, double 
base)
diff --git a/efl/elementary/spinner.pyx b/efl/elementary/spinner.pyx
index 173057d..fd4ed26 100644
--- a/efl/elementary/spinner.pyx
+++ b/efl/elementary/spinner.pyx
@@ -264,6 +264,38 @@ cdef class Spinner(LayoutClass):
         elm_spinner_special_value_add(self.obj, value,
             <const_char *>label if label is not None else NULL)
 
+    def special_value_del(self, double value):
+        """special_value_del(float value)
+
+        Delete the special string display in the place of the numerical value.
+
+        :param value: The replaced value.
+
+        It will remove a previously added special value. After this, the 
spinner
+        will display the value itself instead of a label.
+
+        :see: elm_spinner_special_value_add() for more details.
+
+        :since: 1.8
+
+        """
+        elm_spinner_special_value_del(self.obj, value)
+
+    def special_value_get(self, double value):
+        """special_value_get(float value) -> unicode
+
+        Get the special string display in the place of the numerical value.
+
+        :param value: The replaced value.
+        :return: The used label.
+
+        :see: elm_spinner_special_value_add() for more details.
+
+        :since: 1.8
+
+        """
+        return _ctouni(elm_spinner_special_value_get(self.obj, value))
+
     property interval:
         """The interval on time updates for an user mouse button hold
         on spinner widgets' arrows.
diff --git a/efl/elementary/table.pxd b/efl/elementary/table.pxd
index 318b2da..3397ea7 100644
--- a/efl/elementary/table.pxd
+++ b/efl/elementary/table.pxd
@@ -1,4 +1,5 @@
-from efl.evas cimport Eina_Bool, Evas_Object, Evas_Coord
+from efl.evas cimport Eina_Bool, Evas_Object, const_Evas_Object, \
+    Evas_Coord
 
 cdef extern from "Elementary.h":
     Evas_Object             *elm_table_add(Evas_Object *parent)
@@ -11,3 +12,4 @@ cdef extern from "Elementary.h":
     void                     elm_table_clear(Evas_Object *obj, Eina_Bool clear)
     void                     elm_table_pack_set(Evas_Object *subobj, int x, 
int y, int w, int h)
     void                     elm_table_pack_get(Evas_Object *subobj, int *x, 
int *y, int *w, int *h)
+    Evas_Object             *elm_table_child_get(const_Evas_Object *obj, int 
col, int row)
diff --git a/efl/elementary/table.pyx b/efl/elementary/table.pyx
index ebb5ef4..acac984 100644
--- a/efl/elementary/table.pyx
+++ b/efl/elementary/table.pyx
@@ -143,6 +143,19 @@ cdef class Table(Object):
         """
         elm_table_clear(self.obj, clear)
 
+    def child_get(self, int col, int row):
+        """child_get(int col, int row) -> Object
+
+        Get child object of table at given coordinates.
+
+        :param int col: Column number of child object
+        :param int row: Row number of child object
+
+        :return: Child of object if find if not return None.
+
+        """
+        return object_from_instance(elm_table_child_get(self.obj, col, row))
+
 def table_pack_set(evasObject subobj, x, y, w, h):
     """table_pack_set(evas.Object subobj, int x, int y, int w, int h)
 
@@ -186,5 +199,4 @@ def table_pack_get(evasObject subobj):
     elm_table_pack_get(subobj.obj, &x, &y, &w, &h)
     return (x, y, w, h)
 
-
 _object_mapping_register("elm_table", Table)
diff --git a/examples/elementary/test_entry.py 
b/examples/elementary/test_entry.py
index 4e6f1c4..e24da1f 100644
--- a/examples/elementary/test_entry.py
+++ b/examples/elementary/test_entry.py
@@ -148,6 +148,9 @@ def scrolled_anchor_test(obj, anchor, data):
     en = data
     en.entry_insert("ANCHOR CLICKED")
 
+def my_filter(obj, text, data):
+    print(text, data)
+
 def entry_scrolled_clicked(obj, item = None):
     #static Elm_Entry_Filter_Accept_Set digits_filter_data, 
digits_filter_data2;
     #static Elm_Entry_Filter_Limit_Size limit_filter_data, limit_filter_data2;
@@ -220,6 +223,19 @@ def entry_scrolled_clicked(obj, item = None):
     en.show()
     bx.pack_end(en)
 
+    # Filter test
+    en = Entry(win)
+    en.scrollable = True
+    en.size_hint_weight = EVAS_HINT_EXPAND, 0.0
+    en.size_hint_align = EVAS_HINT_FILL, 0.5
+    en.text = "Filter test"
+    en.scrollbar_policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF
+    en.single_line = True
+    en.show()
+    bx.pack_end(en)
+
+    en.markup_filter_append(my_filter, "test")
+
     # # Only digits entry
     # en = Entry(win)
     # en.scrollable = True

-- 


Reply via email to