kuuko pushed a commit to branch master.
commit 0d63acbee90109169e6dd4a7d9d41e0d4873447e
Author: Kai Huuhko <[email protected]>
Date: Fri Apr 19 12:05:36 2013 +0000
Elementary: Implement Accessible objects, with cbs TODO later.
---
doc/elementary/elementary.rst | 2 +
doc/elementary/module-access.rst | 8 +++
efl/elementary/access.pxd | 18 +++++
efl/elementary/access.pyx | 140 +++++++++++++++++++++++++++++++++++++++
efl/elementary/object.pxd | 6 +-
efl/elementary/object.pyx | 33 ++++++++-
efl/elementary/object_item.pxd | 78 ++++++++++++----------
efl/elementary/object_item.pyx | 40 +++++++++++
efl/eo/efl.eo.pyx | 11 ++-
include/efl.eo.pxd | 3 +-
setup.py | 1 +
11 files changed, 300 insertions(+), 40 deletions(-)
diff --git a/doc/elementary/elementary.rst b/doc/elementary/elementary.rst
index 7a23f1b..d76a077 100644
--- a/doc/elementary/elementary.rst
+++ b/doc/elementary/elementary.rst
@@ -118,6 +118,7 @@ Reference
.. toctree::
:maxdepth: 4
+ module-access
module-actionslider
module-background
module-box
@@ -191,6 +192,7 @@ Inheritance diagram
-------------------
.. inheritance-diagram::
+ efl.elementary.access
efl.elementary.actionslider
efl.elementary.background
efl.elementary.box
diff --git a/doc/elementary/module-access.rst b/doc/elementary/module-access.rst
new file mode 100644
index 0000000..0d61520
--- /dev/null
+++ b/doc/elementary/module-access.rst
@@ -0,0 +1,8 @@
+:mod:`access` Module
+--------------------
+
+.. automodule:: efl.elementary.access
+
+.. inheritance-diagram::
+ efl.elementary.access
+ :parts: 2
diff --git a/efl/elementary/access.pxd b/efl/elementary/access.pxd
new file mode 100644
index 0000000..6054019
--- /dev/null
+++ b/efl/elementary/access.pxd
@@ -0,0 +1,18 @@
+from libc.string cimport const_char
+from libc.stdlib cimport const_void
+
+from efl.evas cimport Evas_Object, const_Evas_Object
+from object_item cimport Elm_Object_Item
+
+cdef extern from "Elementary.h":
+ ctypedef char *(*Elm_Access_Info_Cb)(void *data, Evas_Object *obj)
+ ctypedef void (*Elm_Access_Activate_Cb)(void *data, Evas_Object *part_obj,
Elm_Object_Item *item)
+
+ Evas_Object * elm_access_object_register(Evas_Object *obj,
Evas_Object *parent)
+ void elm_access_info_set(Evas_Object *obj, int type,
const_char *text)
+ char * elm_access_info_get(const_Evas_Object *obj, int type)
+ # TODO: void elm_access_info_cb_set(Evas_Object *obj, int
type, Elm_Access_Info_Cb func, const_void *data)
+ # TODO: void elm_access_activate_cb_set(Evas_Object *obj,
Elm_Access_Activate_Cb func, void *data)
+ void elm_access_highlight_set(Evas_Object* obj)
+
+ Evas_Object * elm_object_item_access_register(Elm_Object_Item *item)
diff --git a/efl/elementary/access.pyx b/efl/elementary/access.pyx
new file mode 100644
index 0000000..20eade2
--- /dev/null
+++ b/efl/elementary/access.pyx
@@ -0,0 +1,140 @@
+# Copyright (C) 2007-2013 various contributors (see AUTHORS)
+#
+# This file is part of Python-EFL.
+#
+# Python-EFL is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# Python-EFL is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
+
+from object cimport Object
+from object_item cimport ObjectItem
+
+include "widget_header.pxi"
+
+ELM_ACCESS_TYPE = 0 # when reading out widget or item this is read first
+ELM_ACCESS_INFO = 1 # next read is info - this is normally label
+ELM_ACCESS_STATE = 2 # if there is a state (eg checkbox) then read state out
+ELM_ACCESS_CONTEXT_INFO = 3 # to give contextual information
+
+
+cdef char *access_info_cb(void *data, Evas_Object *obj):
+ pass
+
+cdef void access_activate_cb(void *data, Evas_Object *part_obj,
Elm_Object_Item *item):
+ pass
+
+cdef class Accessible(Object):
+
+ """An accessible object."""
+
+ def __init__(self, target, parent = None):
+ """__init__(target, parent = None)
+
+ Register evas object as an accessible object.
+
+ :since: 1.8
+
+ :param target: The evas object to register as an accessible object.
+ :param parent: The elementary object which is used for creating
+ accessible object.
+
+ """
+ cdef:
+ evasObject t, p
+ ObjectItem i
+ if isinstance(target, evasObject):
+ t = target
+ p = parent
+ self._set_obj(elm_access_object_register(t.obj, p.obj))
+ elif isinstance(target, ObjectItem):
+ i = target
+ self._set_obj(elm_object_item_access_register(i.item))
+ else:
+ raise TypeError("target is of unsupported type")
+
+ def info_set(self, int type, text):
+ """Set text to give information for specific type.
+
+ :since: 1.8
+
+ :param type: The type of content that will be read
+ :param text: The text information that will be read
+
+ :type:
+
+ :see: elm_access_info_cb_set
+
+ """
+ if isinstance(text, unicode): text = PyUnicode_AsUTF8String(text)
+ elm_access_info_set(self.obj, type,
+ <const_char *>text if text is not None else NULL)
+
+ def info_get(self, int type):
+ """Get text to give information for specific type.
+
+ :since: 1.8
+
+ :param type: The type of content that will be read
+
+ :see: elm_access_info_cb_set
+
+ """
+ return _touni(elm_access_info_get(self.obj, type))
+
+ # def info_cb_set(self, int type, func, *args, **kwargs):
+ # """Set content callback to give information for specific type.
+
+ # :since: 1.8
+
+ # :param type: The type of content that will be read
+ # :param func: The function to be called when the content is read
+ # :param data: The data pointer to be passed to @p func
+
+ # The type would be one of ELM_ACCESS_TYPE, ELM_ACCESS_INFO,
+ # ELM_ACCESS_STATE, ELM_ACCESS_CONTEXT_INFO.
+
+ # In the case of button widget, the content of ELM_ACCESS_TYPE would be
+ # "button". The label of button such as "ok", "cancel" is for
ELM_ACCESS_INFO.
+ # If the button is disabled, content of ELM_ACCESS_STATE would be
"disabled".
+ # And if there is contextual information, use ELM_ACCESS_CONTEXT_INFO.
+
+ # """
+ # if not callable(func):
+ # raise TypeError("func is not callable.")
+
+ # elm_access_info_cb_set(self.obj, type, access_info_cb, <const_void
*>self)
+
+ # def activate_cb_set(self, func, *args, **kwargs):
+ # """Set activate callback to activate highlight object.
+
+ # :since: 1.8
+
+ # :param func: The function to be called when the activate gesture is
detected
+ # :param data: The data pointer to be passed to @p func
+
+ # """
+ # if not callable(func):
+ # raise TypeError("func is not callable.")
+
+ # elm_access_activate_cb_set(self.obj, access_activate_cb, <void
*>self)
+
+ def access_highlight_set(self):
+ """Give the highlight to the object directly.
+
+ :since: 1.8
+
+ The object should be an elementary object or an access object.
+
+ """
+ elm_access_highlight_set(self.obj)
+
+_object_mapping_register("elm_access", Accessible)
diff --git a/efl/elementary/object.pxd b/efl/elementary/object.pxd
index 314fe6b..1277fed 100644
--- a/efl/elementary/object.pxd
+++ b/efl/elementary/object.pxd
@@ -30,7 +30,6 @@ cdef extern from "Edje.h":
ctypedef void (*Edje_Signal_Cb)(void *data, Evas_Object *obj, const_char
*emission, const_char *source)
cdef extern from "Elementary.h":
-
ctypedef struct Elm_Theme
ctypedef struct Elm_Selection_Data:
@@ -162,6 +161,11 @@ cdef extern from "Elementary.h":
# Eina_Bool elm_drag_start(Evas_Object *obj, Elm_Sel_Format
format, const_char *data, Elm_Xdnd_Action action, Elm_Drag_Icon_Create_Cb
createicon, void *createdata, Elm_Drag_Pos dragpos, void *dragdata,
Elm_Drag_Accept acceptcb, void *acceptdata, Elm_Drag_State dragdone, void
*donecbdata)
# Eina_Bool elm_drag_action_set(Evas_Object *obj,
Elm_Xdnd_Action action)
+ # Access (elm_access.h)
+ Evas_Object * elm_access_object_get(const_Evas_Object *obj)
+ void elm_access_highlight_set(Evas_Object* obj)
+ void elm_access_object_unregister(Evas_Object *obj)
+
cdef class Canvas(evasCanvas):
pass
diff --git a/efl/elementary/object.pyx b/efl/elementary/object.pyx
index 0e2cb83..91aeb4b 100644
--- a/efl/elementary/object.pyx
+++ b/efl/elementary/object.pyx
@@ -1555,9 +1555,7 @@ cdef class Object(evasObject):
"""
return <long>self.obj
-
-
- # TODO:
+ # TODO: Copy and Paste
# def cnp_selection_set(self, Elm_Sel_Type selection, Elm_Sel_Format
format, buf, buflen):
# """Set copy data for a widget.
@@ -1709,3 +1707,32 @@ cdef class Object(evasObject):
# if not elm_drag_action_set(Evas_Object *obj, action):
# raise RuntimeError("Could not set cnp xdnd action.")
+
+ def unregister(self):
+ """Unregister accessible object.
+
+ :since: 1.8
+
+ """
+ elm_access_object_unregister(self.obj)
+
+ property access_object:
+ """Get an accessible object of the evas object.
+
+ :since: 1.8
+
+ :type: Object
+
+ """
+ def __get__(self):
+ return object_from_instance(elm_access_object_get(self.obj))
+
+ def access_highlight_set(self):
+ """Give the highlight to the object directly.
+
+ :since: 1.8
+
+ The object should be an elementary object or an access object.
+
+ """
+ elm_access_highlight_set(self.obj)
diff --git a/efl/elementary/object_item.pxd b/efl/elementary/object_item.pxd
index b0c029e..b518837 100644
--- a/efl/elementary/object_item.pxd
+++ b/efl/elementary/object_item.pxd
@@ -1,4 +1,5 @@
-from efl.evas cimport Eina_Bool, const_Eina_List, Evas_Object, Evas_Smart_Cb
+from efl.evas cimport Eina_Bool, const_Eina_List, Evas_Object, Evas_Smart_Cb, \
+ Eina_List, const_Eina_List
from libc.string cimport const_char
cdef extern from "Elementary.h":
@@ -9,39 +10,48 @@ cdef extern from "Elementary.h":
ctypedef Evas_Object *(*Elm_Tooltip_Content_Cb) (void *data,
Evas_Object *obj, Evas_Object *tooltip)
ctypedef Evas_Object *(*Elm_Tooltip_Item_Content_Cb) (void *data,
Evas_Object *obj, Evas_Object *tooltip, void *item)
- Evas_Object *elm_object_item_widget_get(Elm_Object_Item *it)
- void elm_object_item_part_content_set(Elm_Object_Item
*it, const_char *part, Evas_Object* content)
- void elm_object_item_content_set(Elm_Object_Item *it,
Evas_Object* content)
- Evas_Object *elm_object_item_part_content_get(Elm_Object_Item
*it, const_char *part)
- Evas_Object *elm_object_item_content_get(Elm_Object_Item *it)
- Evas_Object
*elm_object_item_part_content_unset(Elm_Object_Item *it, const_char *part)
- Evas_Object *elm_object_item_content_unset(Elm_Object_Item *it)
- void elm_object_item_part_text_set(Elm_Object_Item
*item, const_char *part, const_char *label)
- 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_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)
- void elm_object_item_signal_emit(Elm_Object_Item *it,
const_char *emission, const_char *source)
- void elm_object_item_disabled_set(Elm_Object_Item *it,
Eina_Bool disabled)
- Eina_Bool elm_object_item_disabled_get(Elm_Object_Item *it)
- void elm_object_item_del_cb_set(Elm_Object_Item *it,
Evas_Smart_Cb del_cb)
- void elm_object_item_del(Elm_Object_Item *item)
- void elm_object_item_tooltip_text_set(Elm_Object_Item
*it, const_char *text)
- Eina_Bool
elm_object_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
- Eina_Bool
elm_object_item_tooltip_window_mode_get(Elm_Object_Item *it)
- void
elm_object_item_tooltip_content_cb_set(Elm_Object_Item *it,
Elm_Tooltip_Item_Content_Cb func, void *data, Evas_Smart_Cb del_cb)
- void elm_object_item_tooltip_unset(Elm_Object_Item *it)
- void elm_object_item_tooltip_style_set(Elm_Object_Item
*it, const_char *style)
- const_char * elm_object_item_tooltip_style_get(Elm_Object_Item
*it)
- void elm_object_item_cursor_set(Elm_Object_Item *it,
const_char *cursor)
- const_char * elm_object_item_cursor_get(Elm_Object_Item *it)
- void elm_object_item_cursor_unset(Elm_Object_Item *it)
- void elm_object_item_cursor_style_set(Elm_Object_Item
*it, const_char *style)
- const_char * elm_object_item_cursor_style_get(Elm_Object_Item *it)
- void
elm_object_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool
engine_only)
- Eina_Bool
elm_object_item_cursor_engine_only_get(Elm_Object_Item *it)
+ Evas_Object * elm_object_item_widget_get(Elm_Object_Item *it)
+ void elm_object_item_part_content_set(Elm_Object_Item *it,
const_char *part, Evas_Object* content)
+ void elm_object_item_content_set(Elm_Object_Item *it,
Evas_Object* content)
+ Evas_Object * elm_object_item_part_content_get(Elm_Object_Item *it,
const_char *part)
+ Evas_Object * elm_object_item_content_get(Elm_Object_Item *it)
+ Evas_Object * elm_object_item_part_content_unset(Elm_Object_Item *it,
const_char *part)
+ Evas_Object * elm_object_item_content_unset(Elm_Object_Item *it)
+ void elm_object_item_part_text_set(Elm_Object_Item *item,
const_char *part, const_char *label)
+ 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_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)
+ void elm_object_item_signal_emit(Elm_Object_Item *it,
const_char *emission, const_char *source)
+ void elm_object_item_disabled_set(Elm_Object_Item *it,
Eina_Bool disabled)
+ Eina_Bool elm_object_item_disabled_get(Elm_Object_Item *it)
+ void elm_object_item_del_cb_set(Elm_Object_Item *it,
Evas_Smart_Cb del_cb)
+ void elm_object_item_del(Elm_Object_Item *item)
+ void elm_object_item_tooltip_text_set(Elm_Object_Item *it,
const_char *text)
+ Eina_Bool elm_object_item_tooltip_window_mode_set(Elm_Object_Item
*it, Eina_Bool disable)
+ Eina_Bool elm_object_item_tooltip_window_mode_get(Elm_Object_Item
*it)
+ void elm_object_item_tooltip_content_cb_set(Elm_Object_Item
*it, Elm_Tooltip_Item_Content_Cb func, void *data, Evas_Smart_Cb del_cb)
+ void elm_object_item_tooltip_unset(Elm_Object_Item *it)
+ void elm_object_item_tooltip_style_set(Elm_Object_Item *it,
const_char *style)
+ const_char * elm_object_item_tooltip_style_get(Elm_Object_Item *it)
+ void elm_object_item_cursor_set(Elm_Object_Item *it, const_char
*cursor)
+ const_char * elm_object_item_cursor_get(Elm_Object_Item *it)
+ void elm_object_item_cursor_unset(Elm_Object_Item *it)
+ void elm_object_item_cursor_style_set(Elm_Object_Item *it,
const_char *style)
+ const_char * elm_object_item_cursor_style_get(Elm_Object_Item *it)
+ void elm_object_item_cursor_engine_only_set(Elm_Object_Item
*it, Eina_Bool engine_only)
+ Eina_Bool elm_object_item_cursor_engine_only_get(Elm_Object_Item *it)
+
+ Evas_Object * elm_object_item_access_register(Elm_Object_Item *item)
+ void elm_object_item_access_unregister(Elm_Object_Item *item)
+ Evas_Object * elm_object_item_access_object_get(const_Elm_Object_Item
*item)
+ void elm_object_item_access_order_set(Elm_Object_Item *item,
Eina_List *objs)
+ const_Eina_List *elm_object_item_access_order_get(const_Elm_Object_Item
*item)
+ void elm_object_item_access_order_unset(Elm_Object_Item *item)
+
+
cdef _object_item_to_python(Elm_Object_Item *it)
cdef Elm_Object_Item * _object_item_from_python(ObjectItem item) except NULL
diff --git a/efl/elementary/object_item.pyx b/efl/elementary/object_item.pyx
index 0c11614..831f75f 100644
--- a/efl/elementary/object_item.pyx
+++ b/efl/elementary/object_item.pyx
@@ -22,6 +22,8 @@ include "tooltips.pxi"
# cdef void _tooltip_item_data_del_cb(void *data, Evas_Object *o, void
*event_info) with gil:
# Py_DECREF(<object>data)
+from efl.eo cimport convert_python_list_objects_to_eina_list, \
+ _object_list_to_python
from object cimport Object
import traceback
@@ -497,4 +499,42 @@ cdef class ObjectItem(object):
return elm_object_item_cursor_engine_only_get(self.item)
+ def access_unregister(self):
+ """Unregister accessible object of the object item.
+ :since: 1.8
+
+ """
+ elm_object_item_access_unregister(self.item)
+
+ property access_object:
+ """Get an accessible object of the object item.
+
+ :since: 1.8
+
+ :return: Accessible object of the object item or NULL for any error
+
+ """
+ def __get__(self):
+ return
object_from_instance(elm_object_item_access_object_get(self.item))
+
+ property access_order:
+ """Access highlight order
+
+ :since: 1.8
+
+ :type: list of Objects
+
+ """
+ def __set__(self, list value):
+ elm_object_item_access_order_set(self.item,
+ convert_python_list_objects_to_eina_list(value))
+
+ def __get__(self):
+ _object_list_to_python(elm_object_item_access_order_get(self.item))
+
+ def __del__(self):
+ elm_object_item_access_order_unset(self.item)
+
+
_object_mapping_register("elm_object_item", ObjectItem)
+
diff --git a/efl/eo/efl.eo.pyx b/efl/eo/efl.eo.pyx
index 3184cbd..ab71051 100644
--- a/efl/eo/efl.eo.pyx
+++ b/efl/eo/efl.eo.pyx
@@ -131,7 +131,7 @@ cdef list
convert_eina_list_strings_to_python_list(const_Eina_List *lst):
return ret
-cdef Eina_List *convert_python_list_strings_to_eina_list(strings):
+cdef Eina_List *convert_python_list_strings_to_eina_list(list strings):
cdef Eina_List *lst = NULL
for s in strings:
if isinstance(s, unicode): s = PyUnicode_AsUTF8String(s)
@@ -147,6 +147,15 @@ cdef list _object_list_to_python(const_Eina_List *lst):
return ret
+cdef Eina_List *convert_python_list_objects_to_eina_list(list objects):
+ cdef:
+ Eina_List *lst
+ Eo o
+ for o in objects:
+ lst = eina_list_append(lst, o.obj)
+ return lst
+
+
cdef void _METHOD_DEPRECATED(object self, char *message):
cdef:
object stack
diff --git a/include/efl.eo.pxd b/include/efl.eo.pxd
index 39c60df..1a6cbbe 100644
--- a/include/efl.eo.pxd
+++ b/include/efl.eo.pxd
@@ -41,6 +41,7 @@ cdef unicode _ctouni(const_char *s)
cdef list convert_array_of_strings_to_python_list(char **array, int
array_length)
cdef const_char ** convert_python_list_strings_to_array_of_strings(list
strings) except NULL
cdef list convert_eina_list_strings_to_python_list(const_Eina_List *lst)
-cdef Eina_List * convert_python_list_strings_to_eina_list(strings)
+cdef Eina_List * convert_python_list_strings_to_eina_list(list strings)
cdef list _object_list_to_python(const_Eina_List *lst)
+cdef Eina_List *convert_python_list_objects_to_eina_list(list objects)
cdef void _METHOD_DEPRECATED(object self, char *message)
diff --git a/setup.py b/setup.py
index 2b48b7f..208c079 100755
--- a/setup.py
+++ b/setup.py
@@ -140,6 +140,7 @@ else:
# Elementary
elm_exts = [
+ Extension("efl.elementary.access", ["efl/elementary/access.pyx"]),
Extension("efl.elementary.actionslider",
["efl/elementary/actionslider.pyx"]),
Extension("efl.elementary.background",
["efl/elementary/background.pyx"]),
Extension("efl.elementary.box", ["efl/elementary/box.pyx"]),
--
------------------------------------------------------------------------------
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