New line chars from CR/LF to LF

SVN revision: 83924
This commit is contained in:
Davide Andreoli 2013-02-14 20:54:53 +00:00
parent 69832134e7
commit 744fab5c92
10 changed files with 2456 additions and 2456 deletions

118
INSTALL
View File

@ -1,59 +1,59 @@
1. REQUIREMENTS:
1. Python 2.7 or higher (http://www.python.org/)
- Tested with Python 2.7 / 3.2
2. Cython 0.17.3 or higher (http://cython.org/)
- Tested with Cython 0.17.3
3. EFL core library
- eo, evas, ecore, edje, elementary and, optionally, emotion
4. pkg-config (http://www.freedesktop.org/wiki/Software/pkg-config)
- Windows executable (and GLib dependency) can be downloaded from
http://www.gtk.org/download/win32.php
2. BUILDING EFL
Once EFL is built and installed in your desired destination, proceed with
building the wrapper.
2a. BUILDING WITH GCC/G++ (Linux, OS X, etc.)
python setup.py build_ext
2b. BUILDING WITH Visual Studio (Windows)
python setup.py build_ext
2c. BUILDING WITH MINGW (Windows)
python setup.py build_ext -c mingw32
4. INSTALLATION
4a. For system-wide installation (needs administrator privileges):
python setup.py install
4b. For user installation:
python setup.py install --user
4c. To install for python3:
python3 setup.py install (also cython need to be installed with py3)
5. DEMOS and TESTS
You can run individual tests or use the 00_run_all_tests.py in each folder or
even in the tests/ base dir to run all the tests at once.
The tests in elementary are not unittest and are meant to be run by the user
as they usually require some sort of interaction.
1. REQUIREMENTS:
1. Python 2.7 or higher (http://www.python.org/)
- Tested with Python 2.7 / 3.2
2. Cython 0.17.3 or higher (http://cython.org/)
- Tested with Cython 0.17.3
3. EFL core library
- eo, evas, ecore, edje, elementary and, optionally, emotion
4. pkg-config (http://www.freedesktop.org/wiki/Software/pkg-config)
- Windows executable (and GLib dependency) can be downloaded from
http://www.gtk.org/download/win32.php
2. BUILDING EFL
Once EFL is built and installed in your desired destination, proceed with
building the wrapper.
2a. BUILDING WITH GCC/G++ (Linux, OS X, etc.)
python setup.py build_ext
2b. BUILDING WITH Visual Studio (Windows)
python setup.py build_ext
2c. BUILDING WITH MINGW (Windows)
python setup.py build_ext -c mingw32
4. INSTALLATION
4a. For system-wide installation (needs administrator privileges):
python setup.py install
4b. For user installation:
python setup.py install --user
4c. To install for python3:
python3 setup.py install (also cython need to be installed with py3)
5. DEMOS and TESTS
You can run individual tests or use the 00_run_all_tests.py in each folder or
even in the tests/ base dir to run all the tests at once.
The tests in elementary are not unittest and are meant to be run by the user
as they usually require some sort of interaction.

116
TODO
View File

@ -1,58 +1,58 @@
BUGS:
* Evas: smart object doesn't work
* test_map3.py is buggy
* test_mapbuf.py line 14 should work
* test_video.py have problems
* test_naviframe is broken (also in the python-elementary version)
* test_core_evas_canvas_callbacks.py have 2 lines commented out
* test_emotion.py loop on shutdown (parent issue)
* edje.color_class_list() is broken in C (disabled in edje/test_01_basics.py)
* edje.text_class_list() is broken in C (disabled out in edje/test_01_basics.py)
TODO:
* Fix all the compilation warnings!
* ecore.Poller
* ecore.FileMonitor
* alert on signal and subprocess module usage (was in python-ecore/ecore/__init__.py)
* Ecore test_08_exe.py : Use unittests
* evas.SmartObject
* edje.Edit
* edje: complete the unit tests
* elm.Web need a test
* elm.GestureLayer need a test
* elm.PhotoCam need a test
* elm.Transit need a test
* elm.Conformant need a test
* include python-ethumb
* include python-e_dbus (or make edbus2 ??)
TODO FOR PYTHON 3:
* ecore.Exe (use new buffer interface)
* ecore.FdHandler (use new buffer interface)
* edje external
STUFF LEAVED OUT:
* EcoreEvas
* EcoreImf
* EcoreX
* EcoreWin32
* python-evas/evas/utils.py
* python-evas/evas/decorators.py
* python-evas/evas/debug.py
* python-evas old hack to rotate objects
* edje decorators callbacks
CHANGES FROM 1.7 to 1.8:
* added efl container package
* ecore.file.Download => efl.ecore.FileDownload
BUGS:
* Evas: smart object doesn't work
* test_map3.py is buggy
* test_mapbuf.py line 14 should work
* test_video.py have problems
* test_naviframe is broken (also in the python-elementary version)
* test_core_evas_canvas_callbacks.py have 2 lines commented out
* test_emotion.py loop on shutdown (parent issue)
* edje.color_class_list() is broken in C (disabled in edje/test_01_basics.py)
* edje.text_class_list() is broken in C (disabled out in edje/test_01_basics.py)
TODO:
* Fix all the compilation warnings!
* ecore.Poller
* ecore.FileMonitor
* alert on signal and subprocess module usage (was in python-ecore/ecore/__init__.py)
* Ecore test_08_exe.py : Use unittests
* evas.SmartObject
* edje.Edit
* edje: complete the unit tests
* elm.Web need a test
* elm.GestureLayer need a test
* elm.PhotoCam need a test
* elm.Transit need a test
* elm.Conformant need a test
* include python-ethumb
* include python-e_dbus (or make edbus2 ??)
TODO FOR PYTHON 3:
* ecore.Exe (use new buffer interface)
* ecore.FdHandler (use new buffer interface)
* edje external
STUFF LEAVED OUT:
* EcoreEvas
* EcoreImf
* EcoreX
* EcoreWin32
* python-evas/evas/utils.py
* python-evas/evas/decorators.py
* python-evas/evas/debug.py
* python-evas old hack to rotate objects
* edje decorators callbacks
CHANGES FROM 1.7 to 1.8:
* added efl container package
* ecore.file.Download => efl.ecore.FileDownload

View File

@ -1,139 +1,139 @@
# 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/>.
import traceback
from efl.eo cimport Eo
from efl.eo cimport _fruni, _cfruni
from efl.eo cimport PY_REFCOUNT
from cpython cimport Py_INCREF, Py_DECREF
ECORE_CALLBACK_CANCEL = 0
ECORE_CALLBACK_RENEW = 1
# Ecore_Fd_Handler_Flags:
ECORE_FD_READ = 1
ECORE_FD_WRITE = 2
ECORE_FD_ERROR = 4
ECORE_FD_ALL = 7
# Ecore_Exe_Flags:
ECORE_EXE_PIPE_READ = 1
ECORE_EXE_PIPE_WRITE = 2
ECORE_EXE_PIPE_ERROR = 4
ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8
ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16
ECORE_EXE_PIPE_AUTO = 32
ECORE_EXE_RESPAWN = 64
ECORE_EXE_USE_SH = 128
ECORE_EXE_NOT_LEADER = 256
ECORE_EXE_TERM_WITH_PARENT = 512
ECORE_EXE_PRIORITY_INHERIT = 9999
# Ecore_File_Progress_Return:
ECORE_FILE_PROGRESS_CONTINUE = 0
ECORE_FILE_PROGRESS_ABORT = 1
cdef Eina_Bool _ecore_task_cb(void *data) with gil:
cdef Eo obj = <Eo>data
cdef Eina_Bool ret
try:
ret = bool(obj._task_exec())
except Exception, e:
traceback.print_exc()
ret = 0
if not ret:
obj.delete()
return ret
cdef int _ecore_events_registered = 0
def init():
global _ecore_events_registered
r = ecore_init()
if r > 0 and _ecore_events_registered == 0:
_ecore_events_registered = 1
global _event_type_mapping
_event_type_mapping = {
ECORE_EVENT_SIGNAL_USER: EventSignalUser,
ECORE_EVENT_SIGNAL_HUP: EventSignalHup,
ECORE_EVENT_SIGNAL_EXIT: EventSignalExit,
ECORE_EVENT_SIGNAL_POWER: EventSignalPower,
ECORE_EVENT_SIGNAL_REALTIME: EventSignalRealtime,
ECORE_EXE_EVENT_ADD: EventExeAdd,
ECORE_EXE_EVENT_DEL: EventExeDel,
ECORE_EXE_EVENT_DATA: EventExeData,
ECORE_EXE_EVENT_ERROR: EventExeData,
}
ecore_file_init()
return r
def shutdown():
ecore_file_shutdown()
return ecore_shutdown()
def main_loop_quit():
ecore_main_loop_quit()
def main_loop_begin():
with nogil:
ecore_main_loop_begin()
def main_loop_iterate():
with nogil:
ecore_main_loop_iterate()
def main_loop_glib_integrate():
if not ecore_main_loop_glib_integrate():
raise SystemError("failed to integrate GLib main loop into ecore.")
def time_get():
return ecore_time_get()
def loop_time_get():
return ecore_loop_time_get()
include "efl.ecore_animator.pxi"
include "efl.ecore_timer.pxi"
include "efl.ecore_idler.pxi"
include "efl.ecore_fd_handler.pxi"
include "efl.ecore_events.pxi"
include "efl.ecore_exe.pxi"
include "efl.ecore_file_download.pxi"
init()
# 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/>.
import traceback
from efl.eo cimport Eo
from efl.eo cimport _fruni, _cfruni
from efl.eo cimport PY_REFCOUNT
from cpython cimport Py_INCREF, Py_DECREF
ECORE_CALLBACK_CANCEL = 0
ECORE_CALLBACK_RENEW = 1
# Ecore_Fd_Handler_Flags:
ECORE_FD_READ = 1
ECORE_FD_WRITE = 2
ECORE_FD_ERROR = 4
ECORE_FD_ALL = 7
# Ecore_Exe_Flags:
ECORE_EXE_PIPE_READ = 1
ECORE_EXE_PIPE_WRITE = 2
ECORE_EXE_PIPE_ERROR = 4
ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8
ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16
ECORE_EXE_PIPE_AUTO = 32
ECORE_EXE_RESPAWN = 64
ECORE_EXE_USE_SH = 128
ECORE_EXE_NOT_LEADER = 256
ECORE_EXE_TERM_WITH_PARENT = 512
ECORE_EXE_PRIORITY_INHERIT = 9999
# Ecore_File_Progress_Return:
ECORE_FILE_PROGRESS_CONTINUE = 0
ECORE_FILE_PROGRESS_ABORT = 1
cdef Eina_Bool _ecore_task_cb(void *data) with gil:
cdef Eo obj = <Eo>data
cdef Eina_Bool ret
try:
ret = bool(obj._task_exec())
except Exception, e:
traceback.print_exc()
ret = 0
if not ret:
obj.delete()
return ret
cdef int _ecore_events_registered = 0
def init():
global _ecore_events_registered
r = ecore_init()
if r > 0 and _ecore_events_registered == 0:
_ecore_events_registered = 1
global _event_type_mapping
_event_type_mapping = {
ECORE_EVENT_SIGNAL_USER: EventSignalUser,
ECORE_EVENT_SIGNAL_HUP: EventSignalHup,
ECORE_EVENT_SIGNAL_EXIT: EventSignalExit,
ECORE_EVENT_SIGNAL_POWER: EventSignalPower,
ECORE_EVENT_SIGNAL_REALTIME: EventSignalRealtime,
ECORE_EXE_EVENT_ADD: EventExeAdd,
ECORE_EXE_EVENT_DEL: EventExeDel,
ECORE_EXE_EVENT_DATA: EventExeData,
ECORE_EXE_EVENT_ERROR: EventExeData,
}
ecore_file_init()
return r
def shutdown():
ecore_file_shutdown()
return ecore_shutdown()
def main_loop_quit():
ecore_main_loop_quit()
def main_loop_begin():
with nogil:
ecore_main_loop_begin()
def main_loop_iterate():
with nogil:
ecore_main_loop_iterate()
def main_loop_glib_integrate():
if not ecore_main_loop_glib_integrate():
raise SystemError("failed to integrate GLib main loop into ecore.")
def time_get():
return ecore_time_get()
def loop_time_get():
return ecore_loop_time_get()
include "efl.ecore_animator.pxi"
include "efl.ecore_timer.pxi"
include "efl.ecore_idler.pxi"
include "efl.ecore_fd_handler.pxi"
include "efl.ecore_events.pxi"
include "efl.ecore_exe.pxi"
include "efl.ecore_file_download.pxi"
init()

View File

@ -1,279 +1,279 @@
# 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 cpython cimport PyObject, Py_INCREF, Py_DECREF
from efl cimport Eina_Bool, const_Eina_List, eina_list_append
from efl.c_eo cimport Eo as cEo
from efl.c_eo cimport eo_init, eo_shutdown, eo_del, eo_unref, eo_wref_add, eo_add, Eo_Class
from efl.c_eo cimport eo_do, eo_class_name_get, eo_class_get
from efl.c_eo cimport eo_base_data_set, eo_base_data_get, eo_base_data_del
from efl.c_eo cimport eo_event_callback_add, eo_event_callback_del, Eo_Event_Description
from efl.c_eo cimport eo_parent_get
from efl.c_eo cimport EO_EV_DEL
######################################################################
cdef int PY_REFCOUNT(object o):
cdef PyObject *obj = <PyObject *>o
return obj.ob_refcnt
cdef inline unicode _touni(char* s):
return s.decode('UTF-8', 'strict') if s else None
cdef inline unicode _ctouni(const_char_ptr s):
return s.decode('UTF-8', 'strict') if s else None
cdef inline char *_fruni(s):
cdef char *c_string
if s is None:
return NULL
if isinstance(s, unicode):
string = s.encode('UTF-8')
c_string = string
elif isinstance(s, str):
c_string = s
else:
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
return c_string
cdef inline const_char_ptr _cfruni(s):
cdef const_char_ptr c_string
if s is None:
return NULL
if isinstance(s, unicode):
string = s.encode('UTF-8')
c_string = string
elif isinstance(s, str):
c_string = s
else:
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
return c_string
cdef _strings_to_python(const_Eina_List *lst):
cdef const_char_ptr s
ret = []
while lst:
s = <const_char_ptr>lst.data
if s != NULL:
ret.append(_ctouni(s))
lst = lst.next
return ret
cdef Eina_List * _strings_from_python(strings):
cdef Eina_List *lst = NULL
for s in strings:
lst = eina_list_append(lst, _cfruni(s))
return lst
cdef inline _object_list_to_python(const_Eina_List *lst):
ret = []
while lst:
ret.append(object_from_instance(<cEo *>lst.data))
lst = lst.next
return ret
######################################################################
cdef object object_mapping
"""Object mapping is a dictionary into which object type names can be
registered. These can be used to find a bindings class for an object using
the object_from_instance function."""
object_mapping = dict()
cdef _object_mapping_register(char *name, cls):
# print("REGISTER: %s => %s" % (name, cls))
if name in object_mapping:
raise ValueError("object type name '%s' already registered." % name)
object_mapping[name] = cls
cdef _object_mapping_unregister(char *name):
object_mapping.pop(name)
cdef object object_from_instance(cEo *obj):
""" Create a python object from a C Eo object pointer. """
cdef void *data
cdef Eo o
if obj == NULL:
return None
eo_do(obj, eo_base_data_get("python-eo", &data))
if data != NULL:
# print("Found: %s" % Eo.__repr__(<Eo>data))
return <Eo>data
klass_name = eo_class_name_get(eo_class_get(obj))
if klass_name == NULL:
raise ValueError("Eo object %#x does not have a type!" % <long>obj)
# print("Klass name: %s" % klass_name)
klass = object_mapping.get(klass_name, None)
if klass == None:
raise ValueError("Eo object %#x of type %s does not have a mapping!" %
(<long>obj, klass_name))
# print "MAPPING OBJECT:", klass_name, "=>", klass
o = klass.__new__(klass)
o._set_obj(obj)
return o
#
# TODO extended object mapping (for SmartObject, EdjeExternal, etc)
#
# t = evas_object_type_get(obj)
# if t == NULL:
# raise ValueError("Evas object %#x does not have a type!" %
# <long>obj)
# ot = _ctouni(t)
# c = Canvas_from_instance(evas_object_evas_get(obj))
# cls = object_mapping.get(ot, None)
# if cls is None:
# cls_resolver = extended_object_mapping.get(ot, None)
# if cls_resolver is None:
# warnings.warn(
# ("Evas_Object %#x of type %s has no direct or "
# "extended mapping! Using generic wrapper.") %
# (<unsigned long>obj, ot))
# cls = Object
# else:
# cls = cls_resolver(<unsigned long>obj)
# o = cls.__new__(cls)
# o._set_evas(c)
######################################################################
EO_CALLBACK_STOP = 0
EO_CALLBACK_CONTINUE = 1
######################################################################
cdef Eina_Bool _eo_event_del_cb(void *data, cEo *obj, Eo_Event_Description *desc, void *event_info) with gil:
cdef Eo self = <Eo>data
# print("DEL CB: %s" % Eo.__repr__(self))
eo_do(self.obj, eo_event_callback_del(EO_EV_DEL, _eo_event_del_cb, <void *>self))
eo_do(self.obj, eo_base_data_del("python-eo"))
self.obj = NULL
Py_DECREF(self)
return EO_CALLBACK_STOP
cdef class Eo(object):
"""
Base class used by all the Eo object in the bindings, its not meant to be
used by users, but only by internal classes.
"""
# c globals declared in eo.pxd (to make the class available to others)
def __cinit__(self):
self.obj = NULL
self.data = dict()
def __init__(self):
# print("Eo __init__()")
pass
def __dealloc__(self):
# print("Eo __dealloc__(): %s" % Eo.__repr__(self))
pass
def __str__(self):
return ("Eo(class=%s, obj=%#x, parent=%#x, refcount=%d)") % \
(self.__class__.__name__, <unsigned long>self.obj,
<unsigned long>eo_parent_get(self.obj) if self.obj else 0,
PY_REFCOUNT(self))
def __repr__(self):
return ("Eo(class=%s, obj=%#x, parent=%#x, refcount=%d)") % \
(self.__class__.__name__, <unsigned long>self.obj,
<unsigned long>eo_parent_get(self.obj) if self.obj else 0,
PY_REFCOUNT(self))
# cdef _add_obj(self, Eo_Class *klass, cEo *parent):
# cdef cEo *obj
# assert self.obj == NULL, "Object must be clean"
# obj = eo_add(klass, parent)
# self._set_obj(obj)
# eo_unref(obj)
cdef _set_obj(self, cEo *obj):
assert self.obj == NULL, "Object must be clean"
assert obj != NULL, "Cannot set a NULL object"
self.obj = obj
eo_do(self.obj, eo_base_data_set("python-eo", <void *>self, NULL))
eo_do(self.obj, eo_event_callback_add(EO_EV_DEL, _eo_event_del_cb, <void *>self))
Py_INCREF(self)
# cdef _unset_obj(self): # __UNUSED__
# if self.obj != NULL:
# self.obj = NULL
# Py_DECREF(self) ????????????????????'
# TODO evas_object_data_del("python-eo") ??
# def delete(self):
# """
# Delete object and free it's internal (wrapped) resources.
#
# @note: after this operation the object will be still alive in
# Python, but it will be shallow and every operation
# will have no effect (and may raise exceptions).
# @raise ValueError: if object already deleted.
# """
# if self.obj == NULL:
# raise ValueError("Object already deleted")
# print("Eo delete: %s" % Eo.__repr__(self))
# eo_del(self.obj)
def is_deleted(self):
"""
Check if the Eo object associated with this python object has been
deleted, thus leaving the object as shallow.
"""
return bool(self.obj == NULL)
def init():
return eo_init()
def shutdown():
return eo_shutdown()
init()
# 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 cpython cimport PyObject, Py_INCREF, Py_DECREF
from efl cimport Eina_Bool, const_Eina_List, eina_list_append
from efl.c_eo cimport Eo as cEo
from efl.c_eo cimport eo_init, eo_shutdown, eo_del, eo_unref, eo_wref_add, eo_add, Eo_Class
from efl.c_eo cimport eo_do, eo_class_name_get, eo_class_get
from efl.c_eo cimport eo_base_data_set, eo_base_data_get, eo_base_data_del
from efl.c_eo cimport eo_event_callback_add, eo_event_callback_del, Eo_Event_Description
from efl.c_eo cimport eo_parent_get
from efl.c_eo cimport EO_EV_DEL
######################################################################
cdef int PY_REFCOUNT(object o):
cdef PyObject *obj = <PyObject *>o
return obj.ob_refcnt
cdef inline unicode _touni(char* s):
return s.decode('UTF-8', 'strict') if s else None
cdef inline unicode _ctouni(const_char_ptr s):
return s.decode('UTF-8', 'strict') if s else None
cdef inline char *_fruni(s):
cdef char *c_string
if s is None:
return NULL
if isinstance(s, unicode):
string = s.encode('UTF-8')
c_string = string
elif isinstance(s, str):
c_string = s
else:
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
return c_string
cdef inline const_char_ptr _cfruni(s):
cdef const_char_ptr c_string
if s is None:
return NULL
if isinstance(s, unicode):
string = s.encode('UTF-8')
c_string = string
elif isinstance(s, str):
c_string = s
else:
raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
return c_string
cdef _strings_to_python(const_Eina_List *lst):
cdef const_char_ptr s
ret = []
while lst:
s = <const_char_ptr>lst.data
if s != NULL:
ret.append(_ctouni(s))
lst = lst.next
return ret
cdef Eina_List * _strings_from_python(strings):
cdef Eina_List *lst = NULL
for s in strings:
lst = eina_list_append(lst, _cfruni(s))
return lst
cdef inline _object_list_to_python(const_Eina_List *lst):
ret = []
while lst:
ret.append(object_from_instance(<cEo *>lst.data))
lst = lst.next
return ret
######################################################################
cdef object object_mapping
"""Object mapping is a dictionary into which object type names can be
registered. These can be used to find a bindings class for an object using
the object_from_instance function."""
object_mapping = dict()
cdef _object_mapping_register(char *name, cls):
# print("REGISTER: %s => %s" % (name, cls))
if name in object_mapping:
raise ValueError("object type name '%s' already registered." % name)
object_mapping[name] = cls
cdef _object_mapping_unregister(char *name):
object_mapping.pop(name)
cdef object object_from_instance(cEo *obj):
""" Create a python object from a C Eo object pointer. """
cdef void *data
cdef Eo o
if obj == NULL:
return None
eo_do(obj, eo_base_data_get("python-eo", &data))
if data != NULL:
# print("Found: %s" % Eo.__repr__(<Eo>data))
return <Eo>data
klass_name = eo_class_name_get(eo_class_get(obj))
if klass_name == NULL:
raise ValueError("Eo object %#x does not have a type!" % <long>obj)
# print("Klass name: %s" % klass_name)
klass = object_mapping.get(klass_name, None)
if klass == None:
raise ValueError("Eo object %#x of type %s does not have a mapping!" %
(<long>obj, klass_name))
# print "MAPPING OBJECT:", klass_name, "=>", klass
o = klass.__new__(klass)
o._set_obj(obj)
return o
#
# TODO extended object mapping (for SmartObject, EdjeExternal, etc)
#
# t = evas_object_type_get(obj)
# if t == NULL:
# raise ValueError("Evas object %#x does not have a type!" %
# <long>obj)
# ot = _ctouni(t)
# c = Canvas_from_instance(evas_object_evas_get(obj))
# cls = object_mapping.get(ot, None)
# if cls is None:
# cls_resolver = extended_object_mapping.get(ot, None)
# if cls_resolver is None:
# warnings.warn(
# ("Evas_Object %#x of type %s has no direct or "
# "extended mapping! Using generic wrapper.") %
# (<unsigned long>obj, ot))
# cls = Object
# else:
# cls = cls_resolver(<unsigned long>obj)
# o = cls.__new__(cls)
# o._set_evas(c)
######################################################################
EO_CALLBACK_STOP = 0
EO_CALLBACK_CONTINUE = 1
######################################################################
cdef Eina_Bool _eo_event_del_cb(void *data, cEo *obj, Eo_Event_Description *desc, void *event_info) with gil:
cdef Eo self = <Eo>data
# print("DEL CB: %s" % Eo.__repr__(self))
eo_do(self.obj, eo_event_callback_del(EO_EV_DEL, _eo_event_del_cb, <void *>self))
eo_do(self.obj, eo_base_data_del("python-eo"))
self.obj = NULL
Py_DECREF(self)
return EO_CALLBACK_STOP
cdef class Eo(object):
"""
Base class used by all the Eo object in the bindings, its not meant to be
used by users, but only by internal classes.
"""
# c globals declared in eo.pxd (to make the class available to others)
def __cinit__(self):
self.obj = NULL
self.data = dict()
def __init__(self):
# print("Eo __init__()")
pass
def __dealloc__(self):
# print("Eo __dealloc__(): %s" % Eo.__repr__(self))
pass
def __str__(self):
return ("Eo(class=%s, obj=%#x, parent=%#x, refcount=%d)") % \
(self.__class__.__name__, <unsigned long>self.obj,
<unsigned long>eo_parent_get(self.obj) if self.obj else 0,
PY_REFCOUNT(self))
def __repr__(self):
return ("Eo(class=%s, obj=%#x, parent=%#x, refcount=%d)") % \
(self.__class__.__name__, <unsigned long>self.obj,
<unsigned long>eo_parent_get(self.obj) if self.obj else 0,
PY_REFCOUNT(self))
# cdef _add_obj(self, Eo_Class *klass, cEo *parent):
# cdef cEo *obj
# assert self.obj == NULL, "Object must be clean"
# obj = eo_add(klass, parent)
# self._set_obj(obj)
# eo_unref(obj)
cdef _set_obj(self, cEo *obj):
assert self.obj == NULL, "Object must be clean"
assert obj != NULL, "Cannot set a NULL object"
self.obj = obj
eo_do(self.obj, eo_base_data_set("python-eo", <void *>self, NULL))
eo_do(self.obj, eo_event_callback_add(EO_EV_DEL, _eo_event_del_cb, <void *>self))
Py_INCREF(self)
# cdef _unset_obj(self): # __UNUSED__
# if self.obj != NULL:
# self.obj = NULL
# Py_DECREF(self) ????????????????????'
# TODO evas_object_data_del("python-eo") ??
# def delete(self):
# """
# Delete object and free it's internal (wrapped) resources.
#
# @note: after this operation the object will be still alive in
# Python, but it will be shallow and every operation
# will have no effect (and may raise exceptions).
# @raise ValueError: if object already deleted.
# """
# if self.obj == NULL:
# raise ValueError("Object already deleted")
# print("Eo delete: %s" % Eo.__repr__(self))
# eo_del(self.obj)
def is_deleted(self):
"""
Check if the Eo object associated with this python object has been
deleted, thus leaving the object as shallow.
"""
return bool(self.obj == NULL)
def init():
return eo_init()
def shutdown():
return eo_shutdown()
init()

View File

@ -1,304 +1,304 @@
# 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/>.
import traceback
from cpython cimport bool
from efl cimport *
from efl.eo cimport Eo, object_from_instance, _object_mapping_register
from efl.eo cimport _ctouni, _cfruni, _touni, _fruni
EVAS_LAYER_MIN = -32768
EVAS_LAYER_MAX = 32767
EVAS_HINT_EXPAND = 1.0
EVAS_HINT_FILL = -1.0
EVAS_CALLBACK_MOUSE_IN = 0
EVAS_CALLBACK_MOUSE_OUT = 1
EVAS_CALLBACK_MOUSE_DOWN = 2
EVAS_CALLBACK_MOUSE_UP = 3
EVAS_CALLBACK_MOUSE_MOVE = 4
EVAS_CALLBACK_MOUSE_WHEEL = 5
EVAS_CALLBACK_MULTI_DOWN = 6
EVAS_CALLBACK_MULTI_UP = 7
EVAS_CALLBACK_MULTI_MOVE = 8
EVAS_CALLBACK_FREE = 9
EVAS_CALLBACK_KEY_DOWN = 10
EVAS_CALLBACK_KEY_UP = 11
EVAS_CALLBACK_FOCUS_IN = 12
EVAS_CALLBACK_FOCUS_OUT = 13
EVAS_CALLBACK_SHOW = 14
EVAS_CALLBACK_HIDE = 15
EVAS_CALLBACK_MOVE = 16
EVAS_CALLBACK_RESIZE = 17
EVAS_CALLBACK_RESTACK = 18
EVAS_CALLBACK_DEL = 19
EVAS_CALLBACK_HOLD = 20
EVAS_CALLBACK_CHANGED_SIZE_HINTS = 21
EVAS_CALLBACK_IMAGE_PRELOADED = 22
EVAS_CALLBACK_CANVAS_FOCUS_IN = 23
EVAS_CALLBACK_CANVAS_FOCUS_OUT = 24
EVAS_CALLBACK_RENDER_FLUSH_PRE = 25
EVAS_CALLBACK_RENDER_FLUSH_POST = 26
EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN = 27
EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT = 28
EVAS_CALLBACK_IMAGE_UNLOADED = 29
EVAS_CALLBACK_RENDER_PRE = 30
EVAS_CALLBACK_RENDER_POST = 31
EVAS_CALLBACK_IMAGE_RESIZE = 32
EVAS_CALLBACK_DEVICE_CHANGED = 33
EVAS_CALLBACK_LAST = 34
EVAS_BUTTON_NONE = 0
EVAS_BUTTON_DOUBLE_CLICK = 1
EVAS_BUTTON_TRIPLE_CLICK = 2
EVAS_EVENT_FLAG_NONE = 0
EVAS_EVENT_FLAG_ON_HOLD = 1 << 0
EVAS_RENDER_BLEND = 0
EVAS_RENDER_BLEND_REL = 1
EVAS_RENDER_COPY = 2
EVAS_RENDER_COPY_REL = 3
EVAS_RENDER_ADD = 4
EVAS_RENDER_ADD_REL = 5
EVAS_RENDER_SUB = 6
EVAS_RENDER_SUB_REL = 7
EVAS_RENDER_TINT = 8
EVAS_RENDER_TINT_REL = 9
EVAS_RENDER_MASK = 10
EVAS_RENDER_MUL = 11
EVAS_TEXTURE_REFLECT = 0
EVAS_TEXTURE_REPEAT = 1
EVAS_TEXTURE_RESTRICT = 2
EVAS_TEXTURE_RESTRICT_REFLECT = 3
EVAS_TEXTURE_RESTRICT_REPEAT = 4
EVAS_TEXTURE_PAD = 5
EVAS_ALLOC_ERROR_NONE = 0
EVAS_ALLOC_ERROR_FATAL = 1
EVAS_ALLOC_ERROR_RECOVERED = 2
EVAS_LOAD_ERROR_NONE = 0
EVAS_LOAD_ERROR_GENERIC = 1
EVAS_LOAD_ERROR_DOES_NOT_EXIST = 2
EVAS_LOAD_ERROR_PERMISSION_DENIED = 3
EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = 4
EVAS_LOAD_ERROR_CORRUPT_FILE = 5
EVAS_LOAD_ERROR_UNKNOWN_FORMAT = 6
EVAS_COLOR_SPACE_ARGB = 0
EVAS_COLOR_SPACE_AHSV = 1
EVAS_COLORSPACE_ARGB8888 = 0
EVAS_COLORSPACE_YCBCR422P601_PL = 1
EVAS_COLORSPACE_YCBCR422P709_PL = 2
EVAS_COLORSPACE_RGB565_A5P = 3
EVAS_PIXEL_FORMAT_NONE = 0
EVAS_PIXEL_FORMAT_ARGB32 = 1
EVAS_PIXEL_FORMAT_YUV420P_601 = 2
EVAS_FONT_HINTING_NONE = 0
EVAS_FONT_HINTING_AUTO = 1
EVAS_FONT_HINTING_BYTECODE = 2
EVAS_TEXT_STYLE_PLAIN = 0
EVAS_TEXT_STYLE_SHADOW = 1
EVAS_TEXT_STYLE_OUTLINE = 2
EVAS_TEXT_STYLE_SOFT_OUTLINE = 3
EVAS_TEXT_STYLE_GLOW = 4
EVAS_TEXT_STYLE_OUTLINE_SHADOW = 5
EVAS_TEXT_STYLE_FAR_SHADOW = 6
EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW = 7
EVAS_TEXT_STYLE_SOFT_SHADOW = 8
EVAS_TEXT_STYLE_FAR_SOFT_SHADOW = 9
EVAS_TEXT_INVALID = -1
EVAS_TEXT_SPECIAL = -2
EVAS_TEXTBLOCK_TEXT_RAW = 0
EVAS_TEXTBLOCK_TEXT_PLAIN = 1
EVAS_OBJECT_POINTER_MODE_AUTOGRAB = 0
EVAS_OBJECT_POINTER_MODE_NOGRAB = 1
EVAS_IMAGE_ROTATE_NONE = 0
EVAS_IMAGE_ROTATE_90 = 1
EVAS_IMAGE_ROTATE_180 = 2
EVAS_IMAGE_ROTATE_270 = 3
EVAS_ASPECT_CONTROL_NONE = 0
EVAS_ASPECT_CONTROL_NEITHER = 1
EVAS_ASPECT_CONTROL_HORIZONTAL = 2
EVAS_ASPECT_CONTROL_VERTICAL = 3
EVAS_ASPECT_CONTROL_BOTH = 4
def init():
# when changing these, also change __init__.py!
# if evas_object_event_callbacks_len != EVAS_CALLBACK_LAST:
# raise SystemError("Number of object callbacks changed from %d to %d." %
# (evas_object_event_callbacks_len, EVAS_CALLBACK_LAST))
# if evas_canvas_event_callbacks_len != EVAS_CALLBACK_LAST:
# raise SystemError("Number of canvas callbacks changed from %d to %d." %
# (evas_canvas_event_callbacks_len, EVAS_CALLBACK_LAST))
return evas_init()
def shutdown():
return evas_shutdown()
def render_method_lookup(name):
return evas_render_method_lookup(_cfruni(name))
def render_method_list():
cdef Eina_List *lst
ret = []
lst = evas_render_method_list()
while lst != NULL:
ret.append(<char*> lst.data)
lst = lst.next
evas_render_method_list_free(lst)
return ret
def color_parse(desc, is_premul=None):
cdef unsigned long c, desc_len
cdef int r, g, b, a
r = 0
g = 0
b = 0
a = 0
if isinstance(desc, str):
if not desc or desc[0] != "#":
raise ValueError("Invalid color description")
desc_len = len(desc)
c = int(desc[1:], 16)
r = (c >> 16) & 0xff
g = (c >> 8) & 0xff
b = c & 0xff
if is_premul is None:
is_premul = False
if desc_len == 9:
a = (c >> 24) & 0xff
elif desc_len == 7:
a = 255
else:
raise ValueError("Invalid color description")
elif isinstance(desc, (int, long)):
c = desc
a = (c >> 24) & 0xff
r = (c >> 16) & 0xff
g = (c >> 8) & 0xff
b = c & 0xff
if is_premul is None:
is_premul = False
elif isinstance(desc, (list, tuple)):
if is_premul is None:
is_premul = True
if len(desc) == 3:
a = 255
r, g, b = desc
else:
r, g, b, a = desc
else:
raise TypeError("Unsupported type %s for color description." %
type(desc))
if is_premul is False:
evas_color_argb_premul(a, &r, &g, &b)
return (r, g, b, a)
def color_argb_premul(int r, int g, int b, int a):
evas_color_argb_premul(a, &r, &g, &b)
return (r, g, b, a)
def color_argb_unpremul(int r, int g, int b, int a):
evas_color_argb_unpremul(a, &r, &g, &b)
return (r, g, b, a)
def color_hsv_to_rgb(float h, float s, float v):
cdef int r, g, b
evas_color_hsv_to_rgb(h, s, v, &r, &g, &b)
return (r, g, b)
def color_rgb_to_hsv(int r, int g, int b):
cdef float h, s, v
evas_color_rgb_to_hsv(r, g, b, &h, &s, &v)
return (h, s, v)
class EvasLoadError(Exception):
def __init__(self, int code, filename, key):
if code == EVAS_LOAD_ERROR_NONE:
msg = "No error on load"
elif code == EVAS_LOAD_ERROR_GENERIC:
msg = "A non-specific error occurred"
elif code == EVAS_LOAD_ERROR_DOES_NOT_EXIST:
msg = "File (or file path) does not exist"
elif code == EVAS_LOAD_ERROR_PERMISSION_DENIED:
msg = "Permission deinied to an existing file (or path)"
elif code == EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
msg = "Allocation of resources failure prevented load"
elif code == EVAS_LOAD_ERROR_CORRUPT_FILE:
msg = "File corrupt (but was detected as a known format)"
elif code == EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
msg = "File is not a known format"
self.code = code
self.file = filename
self.key = key
Exception.__init__(self, "%s (file=%s, key=%s)" % (msg, filename, key))
include "efl.evas_rect.pxi"
include "efl.evas_map.pxi"
include "efl.evas_canvas_callbacks.pxi"
include "efl.evas_canvas.pxi"
include "efl.evas_object_events.pxi"
include "efl.evas_object_callbacks.pxi"
include "efl.evas_object.pxi"
include "efl.evas_object_smart.pxi"
include "efl.evas_object_image.pxi"
include "efl.evas_object_line.pxi"
include "efl.evas_object_rectangle.pxi"
include "efl.evas_object_polygon.pxi"
include "efl.evas_object_text.pxi"
include "efl.evas_object_textblock.pxi"
include "efl.evas_object_box.pxi"
init()
# 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/>.
import traceback
from cpython cimport bool
from efl cimport *
from efl.eo cimport Eo, object_from_instance, _object_mapping_register
from efl.eo cimport _ctouni, _cfruni, _touni, _fruni
EVAS_LAYER_MIN = -32768
EVAS_LAYER_MAX = 32767
EVAS_HINT_EXPAND = 1.0
EVAS_HINT_FILL = -1.0
EVAS_CALLBACK_MOUSE_IN = 0
EVAS_CALLBACK_MOUSE_OUT = 1
EVAS_CALLBACK_MOUSE_DOWN = 2
EVAS_CALLBACK_MOUSE_UP = 3
EVAS_CALLBACK_MOUSE_MOVE = 4
EVAS_CALLBACK_MOUSE_WHEEL = 5
EVAS_CALLBACK_MULTI_DOWN = 6
EVAS_CALLBACK_MULTI_UP = 7
EVAS_CALLBACK_MULTI_MOVE = 8
EVAS_CALLBACK_FREE = 9
EVAS_CALLBACK_KEY_DOWN = 10
EVAS_CALLBACK_KEY_UP = 11
EVAS_CALLBACK_FOCUS_IN = 12
EVAS_CALLBACK_FOCUS_OUT = 13
EVAS_CALLBACK_SHOW = 14
EVAS_CALLBACK_HIDE = 15
EVAS_CALLBACK_MOVE = 16
EVAS_CALLBACK_RESIZE = 17
EVAS_CALLBACK_RESTACK = 18
EVAS_CALLBACK_DEL = 19
EVAS_CALLBACK_HOLD = 20
EVAS_CALLBACK_CHANGED_SIZE_HINTS = 21
EVAS_CALLBACK_IMAGE_PRELOADED = 22
EVAS_CALLBACK_CANVAS_FOCUS_IN = 23
EVAS_CALLBACK_CANVAS_FOCUS_OUT = 24
EVAS_CALLBACK_RENDER_FLUSH_PRE = 25
EVAS_CALLBACK_RENDER_FLUSH_POST = 26
EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN = 27
EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT = 28
EVAS_CALLBACK_IMAGE_UNLOADED = 29
EVAS_CALLBACK_RENDER_PRE = 30
EVAS_CALLBACK_RENDER_POST = 31
EVAS_CALLBACK_IMAGE_RESIZE = 32
EVAS_CALLBACK_DEVICE_CHANGED = 33
EVAS_CALLBACK_LAST = 34
EVAS_BUTTON_NONE = 0
EVAS_BUTTON_DOUBLE_CLICK = 1
EVAS_BUTTON_TRIPLE_CLICK = 2
EVAS_EVENT_FLAG_NONE = 0
EVAS_EVENT_FLAG_ON_HOLD = 1 << 0
EVAS_RENDER_BLEND = 0
EVAS_RENDER_BLEND_REL = 1
EVAS_RENDER_COPY = 2
EVAS_RENDER_COPY_REL = 3
EVAS_RENDER_ADD = 4
EVAS_RENDER_ADD_REL = 5
EVAS_RENDER_SUB = 6
EVAS_RENDER_SUB_REL = 7
EVAS_RENDER_TINT = 8
EVAS_RENDER_TINT_REL = 9
EVAS_RENDER_MASK = 10
EVAS_RENDER_MUL = 11
EVAS_TEXTURE_REFLECT = 0
EVAS_TEXTURE_REPEAT = 1
EVAS_TEXTURE_RESTRICT = 2
EVAS_TEXTURE_RESTRICT_REFLECT = 3
EVAS_TEXTURE_RESTRICT_REPEAT = 4
EVAS_TEXTURE_PAD = 5
EVAS_ALLOC_ERROR_NONE = 0
EVAS_ALLOC_ERROR_FATAL = 1
EVAS_ALLOC_ERROR_RECOVERED = 2
EVAS_LOAD_ERROR_NONE = 0
EVAS_LOAD_ERROR_GENERIC = 1
EVAS_LOAD_ERROR_DOES_NOT_EXIST = 2
EVAS_LOAD_ERROR_PERMISSION_DENIED = 3
EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = 4
EVAS_LOAD_ERROR_CORRUPT_FILE = 5
EVAS_LOAD_ERROR_UNKNOWN_FORMAT = 6
EVAS_COLOR_SPACE_ARGB = 0
EVAS_COLOR_SPACE_AHSV = 1
EVAS_COLORSPACE_ARGB8888 = 0
EVAS_COLORSPACE_YCBCR422P601_PL = 1
EVAS_COLORSPACE_YCBCR422P709_PL = 2
EVAS_COLORSPACE_RGB565_A5P = 3
EVAS_PIXEL_FORMAT_NONE = 0
EVAS_PIXEL_FORMAT_ARGB32 = 1
EVAS_PIXEL_FORMAT_YUV420P_601 = 2
EVAS_FONT_HINTING_NONE = 0
EVAS_FONT_HINTING_AUTO = 1
EVAS_FONT_HINTING_BYTECODE = 2
EVAS_TEXT_STYLE_PLAIN = 0
EVAS_TEXT_STYLE_SHADOW = 1
EVAS_TEXT_STYLE_OUTLINE = 2
EVAS_TEXT_STYLE_SOFT_OUTLINE = 3
EVAS_TEXT_STYLE_GLOW = 4
EVAS_TEXT_STYLE_OUTLINE_SHADOW = 5
EVAS_TEXT_STYLE_FAR_SHADOW = 6
EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW = 7
EVAS_TEXT_STYLE_SOFT_SHADOW = 8
EVAS_TEXT_STYLE_FAR_SOFT_SHADOW = 9
EVAS_TEXT_INVALID = -1
EVAS_TEXT_SPECIAL = -2
EVAS_TEXTBLOCK_TEXT_RAW = 0
EVAS_TEXTBLOCK_TEXT_PLAIN = 1
EVAS_OBJECT_POINTER_MODE_AUTOGRAB = 0
EVAS_OBJECT_POINTER_MODE_NOGRAB = 1
EVAS_IMAGE_ROTATE_NONE = 0
EVAS_IMAGE_ROTATE_90 = 1
EVAS_IMAGE_ROTATE_180 = 2
EVAS_IMAGE_ROTATE_270 = 3
EVAS_ASPECT_CONTROL_NONE = 0
EVAS_ASPECT_CONTROL_NEITHER = 1
EVAS_ASPECT_CONTROL_HORIZONTAL = 2
EVAS_ASPECT_CONTROL_VERTICAL = 3
EVAS_ASPECT_CONTROL_BOTH = 4
def init():
# when changing these, also change __init__.py!
# if evas_object_event_callbacks_len != EVAS_CALLBACK_LAST:
# raise SystemError("Number of object callbacks changed from %d to %d." %
# (evas_object_event_callbacks_len, EVAS_CALLBACK_LAST))
# if evas_canvas_event_callbacks_len != EVAS_CALLBACK_LAST:
# raise SystemError("Number of canvas callbacks changed from %d to %d." %
# (evas_canvas_event_callbacks_len, EVAS_CALLBACK_LAST))
return evas_init()
def shutdown():
return evas_shutdown()
def render_method_lookup(name):
return evas_render_method_lookup(_cfruni(name))
def render_method_list():
cdef Eina_List *lst
ret = []
lst = evas_render_method_list()
while lst != NULL:
ret.append(<char*> lst.data)
lst = lst.next
evas_render_method_list_free(lst)
return ret
def color_parse(desc, is_premul=None):
cdef unsigned long c, desc_len
cdef int r, g, b, a
r = 0
g = 0
b = 0
a = 0
if isinstance(desc, str):
if not desc or desc[0] != "#":
raise ValueError("Invalid color description")
desc_len = len(desc)
c = int(desc[1:], 16)
r = (c >> 16) & 0xff
g = (c >> 8) & 0xff
b = c & 0xff
if is_premul is None:
is_premul = False
if desc_len == 9:
a = (c >> 24) & 0xff
elif desc_len == 7:
a = 255
else:
raise ValueError("Invalid color description")
elif isinstance(desc, (int, long)):
c = desc
a = (c >> 24) & 0xff
r = (c >> 16) & 0xff
g = (c >> 8) & 0xff
b = c & 0xff
if is_premul is None:
is_premul = False
elif isinstance(desc, (list, tuple)):
if is_premul is None:
is_premul = True
if len(desc) == 3:
a = 255
r, g, b = desc
else:
r, g, b, a = desc
else:
raise TypeError("Unsupported type %s for color description." %
type(desc))
if is_premul is False:
evas_color_argb_premul(a, &r, &g, &b)
return (r, g, b, a)
def color_argb_premul(int r, int g, int b, int a):
evas_color_argb_premul(a, &r, &g, &b)
return (r, g, b, a)
def color_argb_unpremul(int r, int g, int b, int a):
evas_color_argb_unpremul(a, &r, &g, &b)
return (r, g, b, a)
def color_hsv_to_rgb(float h, float s, float v):
cdef int r, g, b
evas_color_hsv_to_rgb(h, s, v, &r, &g, &b)
return (r, g, b)
def color_rgb_to_hsv(int r, int g, int b):
cdef float h, s, v
evas_color_rgb_to_hsv(r, g, b, &h, &s, &v)
return (h, s, v)
class EvasLoadError(Exception):
def __init__(self, int code, filename, key):
if code == EVAS_LOAD_ERROR_NONE:
msg = "No error on load"
elif code == EVAS_LOAD_ERROR_GENERIC:
msg = "A non-specific error occurred"
elif code == EVAS_LOAD_ERROR_DOES_NOT_EXIST:
msg = "File (or file path) does not exist"
elif code == EVAS_LOAD_ERROR_PERMISSION_DENIED:
msg = "Permission deinied to an existing file (or path)"
elif code == EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
msg = "Allocation of resources failure prevented load"
elif code == EVAS_LOAD_ERROR_CORRUPT_FILE:
msg = "File corrupt (but was detected as a known format)"