Elementary: Add various missing functions

This commit is contained in:
Kai Huuhko 2013-10-04 09:29:45 +03:00
parent 0004c58c9b
commit 914c6ffd6b
16 changed files with 208 additions and 44 deletions

4
TODO
View File

@ -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.

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -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)

View File

@ -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.

View File

@ -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)

View File

@ -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.

View File

@ -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)

View File

@ -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)

View File

@ -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