Python-EFL: Implemented EdjeEdit API, with full unit tests.

Some stuff is not working on the C side, the unit test is full
of FIXME and TODO. The biggest problem is the PartState that
do not work at all, I will give a short look at this, but I'm
not so much intrested atm...If you want/need to help please
let me know.
This commit is contained in:
Davide Andreoli 2013-04-14 13:08:15 +02:00
parent 9c8405ee0c
commit 9d85805b13
11 changed files with 2905 additions and 3 deletions

4
TODO
View File

@ -3,6 +3,7 @@ BUGS
====
* Evas: smart object doesn't work
* EdjeEdit: PartState API does not work
* Docs: GenlistWidget is documented instead of Genlist
(all the scrollable are affected)
@ -22,7 +23,6 @@ TODO
* ecore.FileMonitor
* alert on signal and subprocess module usage (was in python-ecore/ecore/__init__.py)
* evas.SmartObject
* edje.Edit
* edje: complete the unit tests
* elm.Web need a test
* elm.GestureLayer need a test
@ -39,6 +39,7 @@ TODO
* Tests for evas.Textgrid
* update links and text on: http://www.freedesktop.org/wiki/Software/DBusBindings
IMAGES
======
@ -67,6 +68,7 @@ CHANGES FROM 1.7 to 1.8
* added efl container package
* ecore.file.Download => efl.ecore.FileDownload
* edje.edit.EdjeEdit => efl.edje_edit.EdjeEdit
* Emotion(module_filename="xxx") => Emotion(module_name="xxx")
* elementary.need_e_dbus => elementary.need_edbus
* elm.domain_translatable_text_part_set => elm.domain_translatable_part_text_set

495
efl/edje/efl.edje_edit.pyx Normal file
View File

@ -0,0 +1,495 @@
# 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 efl.eo cimport _touni, _ctouni, convert_eina_list_strings_to_python_list
from efl.edje cimport Edje_Part_Type
from efl.edje import EDJE_PART_TYPE_EXTERNAL
# Edje_Edit_Image_Comp
EDJE_EDIT_IMAGE_COMP_RAW = 0
EDJE_EDIT_IMAGE_COMP_USER = 1
EDJE_EDIT_IMAGE_COMP_COMP = 2
EDJE_EDIT_IMAGE_COMP_LOSSY = 3
cdef class EdjeEdit(Edje):
def __init__(self, Canvas canvas not None, **kargs):
self._set_obj(edje_edit_object_add(canvas.obj))
self._set_common_params(**kargs)
# General
def compiler_get(self):
cdef const_char *s = edje_edit_compiler_get(self.obj)
r = _ctouni(s)
if s != NULL:
edje_edit_string_free(s)
return r
def save(self):
return bool(edje_edit_save(self.obj))
def save_all(self):
return bool(edje_edit_save_all(self.obj))
def print_internal_status(self):
edje_edit_print_internal_status(self.obj)
# Group
property current_group:
def __get__(self):
return Group(self)
def group_add(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_group_add(self.obj,
<const_char *>name if name is not None else NULL))
def group_del(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_group_del(self.obj,
<const_char *>name if name is not None else NULL))
def group_exist(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_group_exist(self.obj,
<const_char *>name if name is not None else NULL))
# Data
property data:
def __get__(self):
cdef:
Eina_List *lst
list ret
lst = edje_edit_data_list_get(self.obj)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def data_get(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
cdef const_char *val = edje_edit_data_value_get(self.obj,
<const_char *>name if name is not None else NULL)
r = _ctouni(val)
edje_edit_string_free(val)
return r
def data_set(self, name, value):
if isinstance(name, unicode): name = name.encode("UTF-8")
if isinstance(value, unicode): value = value.encode("UTF-8")
return bool(edje_edit_data_value_set(self.obj,
<const_char *>name if name is not None else NULL,
<const_char *>value if value is not None else NULL))
def data_add(self, name, value):
if isinstance(name, unicode): name = name.encode("UTF-8")
if isinstance(value, unicode): value = value.encode("UTF-8")
return bool(edje_edit_data_add(self.obj,
<const_char *>name if name is not None else NULL,
<const_char *>value if value is not None else NULL))
def data_rename(self, old, new):
if isinstance(old, unicode): old = old.encode("UTF-8")
if isinstance(new, unicode): new = new.encode("UTF-8")
return bool(edje_edit_data_name_set(self.obj,
<const_char *>old if old is not None else NULL,
<const_char *>new if new is not None else NULL))
def data_del(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_data_del(self.obj,
<const_char *>name if name is not None else NULL))
# Group Data
property group_data:
def __get__(self):
cdef:
Eina_List *lst
list ret
lst = edje_edit_group_data_list_get(self.obj)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def group_data_get(self, name):
cdef const_char *val
if isinstance(name, unicode): name = name.encode("UTF-8")
val = edje_edit_group_data_value_get(self.obj,
<const_char *>name if name is not None else NULL)
r = _ctouni(val)
edje_edit_string_free(val)
return r
def group_data_set(self, name, value):
if isinstance(name, unicode): name = name.encode("UTF-8")
if isinstance(value, unicode): value = value.encode("UTF-8")
return bool(edje_edit_group_data_value_set(self.obj,
<const_char *>name if name is not None else NULL,
<const_char *>value if value is not None else NULL))
def group_data_add(self, name, value):
if isinstance(name, unicode): name = name.encode("UTF-8")
if isinstance(value, unicode): value = value.encode("UTF-8")
return bool(edje_edit_group_data_add(self.obj,
<const_char *>name if name is not None else NULL,
<const_char *>value if value is not None else NULL))
def group_data_rename(self, old, new):
if isinstance(old, unicode): old = old.encode("UTF-8")
if isinstance(new, unicode): new = new.encode("UTF-8")
return bool(edje_edit_group_data_name_set(self.obj,
<const_char *>old if old is not None else NULL,
<const_char *>new if new is not None else NULL))
def group_data_del(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_group_data_del(self.obj,
<const_char *>name if name is not None else NULL))
# Text Style
property text_styles:
def __get__(self):
cdef Eina_List *lst
lst = edje_edit_styles_list_get(self.obj)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def text_style_get(self, name):
return Text_Style(self, name)
def text_style_add(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_style_add(self.obj,
<const_char *>name if name is not None else NULL))
def text_style_del(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
edje_edit_style_del(self.obj,
<const_char *>name if name is not None else NULL)
return True
# Color Classes
property color_classes:
def __get__(self):
cdef Eina_List *lst
lst = edje_edit_color_classes_list_get(self.obj)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def color_class_get(self, name):
return Color_Class(self, name)
def color_class_add(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_color_class_add(self.obj,
<const_char *>name if name is not None else NULL))
def color_class_del(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_color_class_del(self.obj,
<const_char *>name if name is not None else NULL))
# Externals
property externals:
def __get__(self):
cdef Eina_List *lst
lst = edje_edit_externals_list_get(self.obj)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def external_add(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_external_add(self.obj,
<const_char *>name if name is not None else NULL))
def external_del(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_external_del(self.obj,
<const_char *>name if name is not None else NULL))
# Fonts
property fonts:
def __get__(self):
cdef Eina_List *lst
lst = edje_edit_fonts_list_get(self.obj)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def font_add(self, font, alias=None):
if isinstance(font, unicode): font = font.encode("UTF-8")
if isinstance(alias, unicode): alias = alias.encode("UTF-8")
return bool(edje_edit_font_add(self.obj,
<const_char *>font if font is not None else NULL,
<const_char *>alias if alias is not None else NULL))
def font_del(self, alias):
if isinstance(alias, unicode): alias = alias.encode("UTF-8")
return bool(edje_edit_font_del(self.obj,
<const_char *>alias if alias is not None else NULL))
# Parts
property parts:
def __get__(self):
cdef Eina_List *lst
lst = edje_edit_parts_list_get(self.obj)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def part_get(self, name):
if self.part_exist(name):
return Part(self, name)
return None
def part_add(self, name, int type, char *source=""):
if isinstance(name, unicode): name = name.encode("UTF-8")
if type != EDJE_PART_TYPE_EXTERNAL:
return bool(edje_edit_part_add(self.obj,
<const_char *>name if name is not None else NULL,
<Edje_Part_Type>type))
else:
return bool(edje_edit_part_external_add(self.obj, name, source))
def part_del(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_part_del(self.obj,
<const_char *>name if name is not None else NULL))
def part_exist(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_part_exist(self.obj,
<const_char *>name if name is not None else NULL))
# Images
property images:
def __get__(self):
cdef Eina_List *lst
lst = edje_edit_images_list_get(self.obj)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def image_id_get(self, image):
if isinstance(image, unicode): image = image.encode("UTF-8")
return edje_edit_image_id_get(self.obj,
<const_char *>image if image is not None else NULL)
def image_add(self, path):
if isinstance(path, unicode): path = path.encode("UTF-8")
return bool(edje_edit_image_add(self.obj,
<const_char *>path if path is not None else NULL))
def image_del(self, image):
if isinstance(image, unicode): image = image.encode("UTF-8")
return bool(edje_edit_image_del(self.obj,
<const_char *>image if image is not None else NULL))
# Programs
property programs:
def __get__(self):
cdef Eina_List *lst
lst = edje_edit_programs_list_get(self.obj)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def program_get(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
if self.program_exist(name):
return Program(self, name)
return None
def program_add(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_program_add(self.obj,
<const_char *>name if name is not None else NULL))
def program_del(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_program_del(self.obj,
<const_char *>name if name is not None else NULL))
def program_exist(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_program_exist(self.obj,
<const_char *>name if name is not None else NULL))
"""
property error:
def __get__(self):
last_error = c_evas.eina_error_get()
if last_error:
return c_evas.eina_error_msg_get(last_error)
return None
"""
# Scripts
property script:
def __get__(self):
cdef char *code
code = edje_edit_script_get(self.obj)
ret = _touni(code)
free(code)
return ret
def __set__(self, code):
if isinstance(code, unicode): code = code.encode("UTF-8")
edje_edit_script_set(self.obj,
<char *>code if code is not None else NULL)
def __del__(self):
edje_edit_script_set(self.obj, NULL)
def script_compile(self):
return bool(edje_edit_script_compile(self.obj))
property script_errors:
def __get__(self):
cdef const_Eina_List *lst
cdef Edje_Edit_Script_Error *se
ret = []
lst = edje_edit_script_error_list_get(self.obj)
while lst:
se = <Edje_Edit_Script_Error*>lst.data
if se.program_name != NULL:
pr = se.program_name
else:
pr = ''
err = (pr, _ctouni(se.error_str))
ret.append(err)
lst = lst.next
return ret
cdef class Text_Style(object):
cdef EdjeEdit edje
cdef object name
def __init__(self, EdjeEdit e, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
self.edje = e
self.name = name
property tags:
def __get__(self):
cdef Eina_List *lst
lst = edje_edit_style_tags_list_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def tag_get(self, name):
return Text_Style_Tag(self, name)
def tag_add(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_style_tag_add(self.edje.obj, self.name,
<const_char *>name if name is not None else NULL))
def tag_del(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
edje_edit_style_tag_del(self.edje.obj, self.name,
<const_char *>name if name is not None else NULL)
return True
cdef class Text_Style_Tag(object):
cdef Text_Style text_style
cdef object name
def __init__(self, Text_Style text_style, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
self.text_style = text_style
self.name = name
property value:
def __get__(self):
cdef const_char *val
val = edje_edit_style_tag_value_get(self.text_style.edje.obj,
self.text_style.name,
<const_char *>self.name if self.name is not None else NULL)
ret = _ctouni(val)
edje_edit_string_free(val)
return ret
def __set__(self, value):
if isinstance(value, unicode): value = value.encode("UTF-8")
edje_edit_style_tag_value_set(self.text_style.edje.obj,
self.text_style.name, self.name,
<const_char *>value if value is not None else NULL)
def rename(self, newname):
if isinstance(newname, unicode): newname = newname.encode("UTF-8")
edje_edit_style_tag_name_set(self.text_style.edje.obj,
self.text_style.name,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>newname if newname is not None else NULL)
self.name = <const_char *>newname if newname is not None else NULL
return True
cdef class Color_Class(object):
cdef EdjeEdit edje
cdef object name
def __init__(self, EdjeEdit e, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
self.edje = e
self.name = name
property name:
def __get__(self):
return self.name.decode('UTF-8', 'strict')
def __set__(self, newname):
self.rename(newname)
def rename(self, newname):
cdef Eina_Bool ret
if isinstance(newname, unicode): newname = newname.encode("UTF-8")
ret = edje_edit_color_class_name_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>newname if newname is not None else NULL)
if ret == 0:
return False
self.name = newname
return True
def colors_get(self):
cdef int r, g, b, a, r2, g2, b2, a2, r3, g3, b3, a3
edje_edit_color_class_colors_get(self.edje.obj, self.name,
&r, &g, &b, &a, &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3)
return ((r, g, b, a), (r2, g2, b2, a2), (r3, g3, b3, a3))
def colors_set(self, int r, int g, int b, int a,
int r2, int g2, int b2, int a2,
int r3, int g3, int b3, int a3):
edje_edit_color_class_colors_set(self.edje.obj, self.name,
r, g, b, a, r2, g2, b2, a2, r3, g3, b3, a3)
include "efl.edje_edit_group.pxi"
include "efl.edje_edit_part.pxi"
include "efl.edje_edit_part_state.pxi"
include "efl.edje_edit_program.pxi"

View File

@ -0,0 +1,56 @@
# 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/>.
cdef class Group(object):
cdef EdjeEdit edje
def __init__(self, EdjeEdit e):
self.edje = e
def delete(self):
return False
property w_min: # TODO rename to min_w !!
def __get__(self):
return edje_edit_group_min_w_get(self.edje.obj)
def __set__(self, value):
edje_edit_group_min_w_set(self.edje.obj, value)
property w_max: # TODO rename to max_w !!
def __get__(self):
return edje_edit_group_max_w_get(self.edje.obj)
def __set__(self, value):
edje_edit_group_max_w_set(self.edje.obj, value)
property h_min: # TODO rename to min_h !!
def __get__(self):
return edje_edit_group_min_h_get(self.edje.obj)
def __set__(self, value):
edje_edit_group_min_h_set(self.edje.obj, value)
property h_max: # TODO rename to max_h !!
def __get__(self):
return edje_edit_group_max_h_get(self.edje.obj)
def __set__(self, value):
edje_edit_group_max_h_set(self.edje.obj, value)
def rename(self, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
return bool(edje_edit_group_name_set(self.edje.obj,
<const_char *>name if name is not None else NULL))

View File

@ -0,0 +1,331 @@
# 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/>.
cdef class Part(object):
cdef EdjeEdit edje
cdef object name
def __init__(self, EdjeEdit e, name):
if isinstance(name, unicode): name = name.encode("UTF-8")
self.edje = e
self.name = name
property name:
def __get__(self):
return self.name.decode('UTF-8', 'strict')
def __set__(self, name):
self.rename(name)
def rename(self, newname):
cdef Eina_Bool ret
if isinstance(newname, unicode): newname = newname.encode("UTF-8")
ret = edje_edit_part_name_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>newname if newname is not None else NULL)
if ret == 0:
return False
self.name = newname
return True
def above_get(self):
cdef:
const_char *part
object ret
part = edje_edit_part_above_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
ret = _ctouni(part)
edje_edit_string_free(part)
return ret
def below_get(self):
cdef:
const_char *part
object ret
part = edje_edit_part_below_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
ret = _ctouni(part)
edje_edit_string_free(part)
return ret
def restack_below(self):
return bool(edje_edit_part_restack_below(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL))
def restack_above(self):
return bool(edje_edit_part_restack_above(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL))
property type:
def __get__(self):
return edje_edit_part_type_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
property states:
def __get__(self):
cdef Eina_List *lst
lst = edje_edit_part_states_list_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
ret = convert_eina_list_strings_to_python_list(lst)
edje_edit_string_list_free(lst)
return ret
def state_get(self, sname, double value=0.0):
if self.state_exist(sname, value):
return State(self, sname, value)
def state_add(self, sname, double value=0.0):
if isinstance(sname, unicode): sname = sname.encode("UTF-8")
return bool(edje_edit_state_add(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>sname if sname is not None else NULL,
value))
def state_del(self, sname, double value=0.0):
if isinstance(sname, unicode): sname = sname.encode("UTF-8")
return bool(edje_edit_state_del(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>sname if sname is not None else NULL,
value))
def state_exist(self, sname, double value=0.0):
if isinstance(sname, unicode): sname = sname.encode("UTF-8")
return bool(edje_edit_state_exist(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>sname if sname is not None else NULL,
value))
def state_copy(self, sfrom, double vfrom, sto, double vto):
if isinstance(sfrom, unicode): sfrom = sfrom.encode("UTF-8")
if isinstance(sto, unicode): sto = sto.encode("UTF-8")
return bool(edje_edit_state_copy(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>sfrom if sfrom is not None else NULL, vfrom,
<const_char *>sto if sto is not None else NULL, vto))
def state_selected_get(self):
cdef const_char *sel
cdef double val
sel = edje_edit_part_selected_state_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL, &val)
if sel == NULL: return None
r = _ctouni(sel)
v = val
edje_edit_string_free(sel)
return (r, v)
def state_selected_set(self, state, double value=0.0):
if isinstance(state, unicode): state = state.encode("UTF-8")
edje_edit_part_selected_state_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>state if state is not None else NULL,
value)
property clip_to:
def __get__(self):
cdef const_char *clipper
clipper = edje_edit_part_clip_to_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
ret = _ctouni(clipper)
edje_edit_string_free(clipper)
return ret
def __set__(self, clipper):
if isinstance(clipper, unicode): clipper = clipper.encode("UTF-8")
edje_edit_part_clip_to_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>clipper if clipper is not None else NULL)
def __del__(self):
edje_edit_part_clip_to_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
NULL)
property source:
def __get__(self):
cdef const_char *source
source = edje_edit_part_source_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
ret = _ctouni(source)
edje_edit_string_free(source)
return ret
def __set__(self, source):
if isinstance(source, unicode): source = source.encode("UTF-8")
edje_edit_part_source_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>source if source is not None else NULL)
def __del__(self):
edje_edit_part_source_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
NULL)
property mouse_events:
def __get__(self):
return bool(edje_edit_part_mouse_events_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL))
def __set__(self, me):
edje_edit_part_mouse_events_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
1 if me else 0)
property repeat_events:
def __get__(self):
return bool(edje_edit_part_repeat_events_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL))
def __set__(self, re):
edje_edit_part_repeat_events_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
1 if re else 0)
property effect:
def __get__(self):
return edje_edit_part_effect_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
def __set__(self, effect):
edje_edit_part_effect_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
effect)
property ignore_flags:
def __get__(self):
return edje_edit_part_ignore_flags_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
def __set__(self, flags):
edje_edit_part_ignore_flags_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
flags)
property scale:
def __get__(self):
return bool(edje_edit_part_scale_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL))
def __set__(self, scale):
edje_edit_part_scale_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
1 if scale else 0)
property drag:
def __get__(self):
cdef int x, y
x = edje_edit_part_drag_x_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
y = edje_edit_part_drag_y_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
return (x, y)
def __set__(self, val):
x, y = val
edje_edit_part_drag_x_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL, x)
edje_edit_part_drag_y_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL, y)
property drag_step:
def __get__(self):
cdef int x, y
x = edje_edit_part_drag_step_x_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
y = edje_edit_part_drag_step_y_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
return (x, y)
def __set__(self, val):
x, y = val
edje_edit_part_drag_step_x_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL, x)
edje_edit_part_drag_step_y_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL, y)
property drag_count:
def __get__(self):
cdef int x, y
x = edje_edit_part_drag_count_x_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
y = edje_edit_part_drag_count_y_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
return (x, y)
def __set__(self, val):
x, y = val
edje_edit_part_drag_count_x_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL, x)
edje_edit_part_drag_count_y_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL, y)
property drag_confine:
def __get__(self):
cdef const_char *confine
confine = edje_edit_part_drag_confine_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
ret = _ctouni(confine)
edje_edit_string_free(confine)
return ret
def __set__(self, confine):
if isinstance(confine, unicode): confine = confine.encode("UTF-8")
edje_edit_part_drag_confine_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>confine if confine is not None else NULL)
property drag_event:
def __get__(self):
cdef const_char *event
event = edje_edit_part_drag_event_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
ret = _ctouni(event)
edje_edit_string_free(event)
return ret
def __set__(self, event):
if isinstance(event, unicode): event = event.encode("UTF-8")
edje_edit_part_drag_event_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>event if event is not None else NULL)
property api:
def __get__(self):
cdef:
const_char *name
const_char *description
name = edje_edit_part_api_name_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
description = edje_edit_part_api_description_get(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL)
n, d = _ctouni(name), _ctouni(description)
edje_edit_string_free(name)
edje_edit_string_free(description)
return (n, d)
def __set__(self, value):
cdef object name, desc
name, desc = value
if isinstance(name, unicode): name = name.encode("UTF-8")
if isinstance(desc, unicode): desc = desc.encode("UTF-8")
edje_edit_part_api_name_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>name if name is not None else NULL)
edje_edit_part_api_description_set(self.edje.obj,
<const_char *>self.name if self.name is not None else NULL,
<const_char *>desc if desc is not None else NULL)

View File

@ -0,0 +1,851 @@
# 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/>.
cdef class State:
cdef EdjeEdit edje
cdef object part
cdef object name
cdef object part_obj
cdef object value
def __init__(self, Part part, name, double value=0.0):
if isinstance(name, unicode): name = name.encode("UTF-8")
self.part_obj = part
self.edje = part.edje
self.part = part.name
self.name = name
self.value = value
property name:
def __get__(self):
return self.name
property value:
def __get__(self):
return self.value
def part_get(self):
return self.part_obj
def name_set(self, new_name, new_value=None):
if new_value == None:
new_value = self.value
return bool(edje_edit_state_name_set(self.edje.obj, self.part,
self.name, self.value, new_name,
new_value))
"""
def copy_from(self, from_state, from_value=0.0):
return bool(edje_edit_state_copy(self.edje.obj, self.part,
from_state, from_value, self.name,
self.value))
"""
def rel1_to_get(self):
cdef const_char *tx, *ty
tx = edje_edit_state_rel1_to_x_get(self.edje.obj, self.part, self.name,
self.value)
ty = edje_edit_state_rel1_to_y_get(self.edje.obj, self.part, self.name,
self.value)
if tx != NULL:
x = tx
edje_edit_string_free(tx)
else:
x = None
if ty != NULL:
y = ty
edje_edit_string_free(ty)
else:
y = None
return (x, y)
"""
def rel1_to_set(self, x, y):
if x:
edje_edit_state_rel1_to_x_set(self.edje.obj, self.part, self.name,
self.value, x)
else:
edje_edit_state_rel1_to_x_set(self.edje.obj, self.part, self.name,
self.value, NULL)
if y:
edje_edit_state_rel1_to_y_set(self.edje.obj, self.part, self.name,
self.value, y)
else:
edje_edit_state_rel1_to_y_set(self.edje.obj, self.part, self.name,
self.value, NULL)
# remove when fixed in edje_edit
edje_edit_part_selected_state_set(self.edje.obj, self.part, self.name,
self.value)
property rel1_to:
def __get__(self):
return self.rel1_to_get()
def __set__(self, rel1_to):
self.rel1_to_set(*rel1_to)
def rel1_to_x_set(self, x):
if x:
edje_edit_state_rel1_to_x_set(self.edje.obj, self.part, self.name,
self.value, x)
else:
edje_edit_state_rel1_to_x_set(self.edje.obj, self.part, self.name,
self.value, NULL)
# remove when fixed in edje_edit
edje_edit_part_selected_state_set(self.edje.obj, self.part, self.name,
self.value)
def rel1_to_y_set(self, y):
if y:
edje_edit_state_rel1_to_y_set(self.edje.obj, self.part, self.name,
self.value, y)
else:
edje_edit_state_rel1_to_y_set(self.edje.obj, self.part, self.name,
self.value, NULL)
# remove when fixed in edje_edit
edje_edit_part_selected_state_set(self.edje.obj, self.part, self.name,
self.value)
def rel1_relative_get(self):
cdef double x, y
x = edje_edit_state_rel1_relative_x_get(self.edje.obj, self.part,
self.name, self.value)
y = edje_edit_state_rel1_relative_y_get(self.edje.obj, self.part,
self.name, self.value)
return (x, y)
def rel1_relative_set(self, double x, double y):
edje_edit_state_rel1_relative_x_set(self.edje.obj, self.part, self.name,
self.value, x)
edje_edit_state_rel1_relative_y_set(self.edje.obj, self.part, self.name,
self.value, y)
property rel1_relative:
def __get__(self):
return self.rel1_relative_get()
def __set__(self, value):
self.rel1_relative_set(*value)
def rel1_relative_x_set(self, double x):
edje_edit_state_rel1_relative_x_set(self.edje.obj, self.part, self.name,
self.value, x)
def rel1_relative_y_set(self, double y):
edje_edit_state_rel1_relative_y_set(self.edje.obj, self.part, self.name,
self.value, y)
def rel1_offset_get(self):
cdef int x, y
x = edje_edit_state_rel1_offset_x_get(self.edje.obj, self.part,
self.name, self.value)
y = edje_edit_state_rel1_offset_y_get(self.edje.obj, self.part,
self.name, self.value)
return (x, y)
def rel1_offset_set(self, int x, int y):
edje_edit_state_rel1_offset_x_set(self.edje.obj, self.part, self.name,
self.value, x)
edje_edit_state_rel1_offset_y_set(self.edje.obj, self.part, self.name,
self.value, y)
property rel1_offset:
def __get__(self):
return self.rel1_offset_get()
def __set__(self, value):
self.rel1_offset_set(*value)
def rel1_offset_x_set(self, int x):
edje_edit_state_rel1_offset_x_set(self.edje.obj, self.part, self.name,
self.value, x)
def rel1_offset_y_set(self, int y):
edje_edit_state_rel1_offset_y_set(self.edje.obj, self.part, self.name,
self.value, y)
def rel2_to_get(self):
cdef const_char_ptr tx, ty
tx = edje_edit_state_rel2_to_x_get(self.edje.obj, self.part, self.name,
self.value)
ty = edje_edit_state_rel2_to_y_get(self.edje.obj, self.part, self.name,
self.value)
if tx != NULL:
x = tx
edje_edit_string_free(tx)
else:
x = None
if ty != NULL:
y = ty
edje_edit_string_free(ty)
else:
y = None
return (x, y)
def rel2_to_set(self, x, y):
if x:
edje_edit_state_rel2_to_x_set(self.edje.obj, self.part, self.name,
self.value, x)
else:
edje_edit_state_rel2_to_x_set(self.edje.obj, self.part, self.name,
self.value, NULL)
if y:
edje_edit_state_rel2_to_y_set(self.edje.obj, self.part, self.name,
self.value, y)
else:
edje_edit_state_rel2_to_y_set(self.edje.obj, self.part, self.name,
self.value, NULL)
# remove when fixed in edje_edit
edje_edit_part_selected_state_set(self.edje.obj, self.part, self.name,
self.value)
property rel2_to:
def __get__(self):
return self.rel2_to_get()
def __set__(self, rel2_to):
self.rel2_to_set(*rel2_to)
def rel2_to_x_set(self, x):
if x:
edje_edit_state_rel2_to_x_set(self.edje.obj, self.part, self.name,
self.value, x)
else:
edje_edit_state_rel2_to_x_set(self.edje.obj, self.part, self.name,
self.value, NULL)
# remove when fixed in edje_edit
edje_edit_part_selected_state_set(self.edje.obj, self.part, self.name,
self.value)
def rel2_to_y_set(self, y):
if y:
edje_edit_state_rel2_to_y_set(self.edje.obj, self.part, self.name,
self.value, y)
else:
edje_edit_state_rel2_to_y_set(self.edje.obj, self.part, self.name,
self.value, NULL)
# remove when fixed in edje_edit
edje_edit_part_selected_state_set(self.edje.obj, self.part, self.name,
self.value)
def rel2_relative_get(self):
cdef double x, y
x = edje_edit_state_rel2_relative_x_get(self.edje.obj, self.part,
self.name, self.value)
y = edje_edit_state_rel2_relative_y_get(self.edje.obj, self.part,
self.name, self.value)
return (x, y)
def rel2_relative_set(self, double x, double y):
edje_edit_state_rel2_relative_x_set(self.edje.obj, self.part, self.name,
self.value, x)
edje_edit_state_rel2_relative_y_set(self.edje.obj, self.part, self.name,
self.value, y)
property rel2_relative:
def __get__(self):
return self.rel2_relative_get()
def __set__(self, value):
self.rel2_relative_set(*value)
def rel2_relative_x_set(self, double x):
edje_edit_state_rel2_relative_x_set(self.edje.obj, self.part, self.name,
self.value, x)
def rel2_relative_y_set(self, double y):
edje_edit_state_rel2_relative_y_set(self.edje.obj, self.part, self.name,
self.value, y)
def rel2_offset_get(self):
cdef int x, y
x = edje_edit_state_rel2_offset_x_get(self.edje.obj, self.part,
self.name, self.value)
y = edje_edit_state_rel2_offset_y_get(self.edje.obj, self.part,
self.name, self.value)
return (x, y)
def rel2_offset_set(self, int x, int y):
edje_edit_state_rel2_offset_x_set(self.edje.obj, self.part, self.name,
self.value, x)
edje_edit_state_rel2_offset_y_set(self.edje.obj, self.part, self.name,
self.value, y)
property rel2_offset:
def __get__(self):
return self.rel2_offset_get()
def __set__(self, value):
self.rel2_offset_set(*value)
def rel2_offset_x_set(self, int x):
edje_edit_state_rel2_offset_x_set(self.edje.obj, self.part, self.name,
self.value, x)
def rel2_offset_y_set(self, int y):
edje_edit_state_rel2_offset_y_set(self.edje.obj, self.part, self.name,
self.value, y)
def color_get(self):
cdef int r, g, b, a
edje_edit_state_color_get(self.edje.obj, self.part, self.name,
self.value, &r, &g, &b, &a)
return (r, g, b, a)
def color_set(self, int r, int g, int b, int a):
edje_edit_state_color_set(self.edje.obj, self.part, self.name,
self.value, r, g, b, a)
property color:
def __get__(self):
return self.color_get()
def __set__(self, color):
self.color_set(*color)
def color2_get(self):
cdef int r, g, b, a
edje_edit_state_color2_get(self.edje.obj, self.part, self.name,
self.value, &r, &g, &b, &a)
return (r, g, b, a)
def color2_set(self, int r, int g, int b, int a):
edje_edit_state_color2_set(self.edje.obj, self.part, self.name,
self.value, r, g, b, a)
property color2:
def __get__(self):
return self.color2_get()
def __set__(self, color):
self.color2_set(*color)
def color3_get(self):
cdef int r, g, b, a
edje_edit_state_color3_get(self.edje.obj, self.part, self.name,
self.value, &r, &g, &b, &a)
return (r, g, b, a)
def color3_set(self, int r, int g, int b, int a):
edje_edit_state_color3_set(self.edje.obj, self.part, self.name,
self.value, r, g, b, a)
property color3:
def __get__(self):
return self.color3_get()
def __set__(self, color):
self.color3_set(*color)
def align_get(self):
cdef double x, y
x = edje_edit_state_align_x_get(self.edje.obj, self.part, self.name,
self.value)
y = edje_edit_state_align_y_get(self.edje.obj, self.part, self.name,
self.value)
return (x, y)
def align_set(self, double x, double y):
edje_edit_state_align_x_set(self.edje.obj, self.part, self.name,
self.value, x)
edje_edit_state_align_y_set(self.edje.obj, self.part, self.name,
self.value, y)
property align:
def __get__(self):
return self.align_get()
def __set__(self, align):
self.align_set(*align)
def min_get(self):
cdef int w, h
w = edje_edit_state_min_w_get(self.edje.obj, self.part, self.name,
self.value)
h = edje_edit_state_min_h_get(self.edje.obj, self.part, self.name,
self.value)
return (w, h)
def min_set(self, int w, int h):
edje_edit_state_min_w_set(self.edje.obj, self.part, self.name,
self.value, w)
edje_edit_state_min_h_set(self.edje.obj, self.part, self.name,
self.value, h)
property min:
def __get__(self):
return self.min_get()
def __set__(self, min):
self.min_set(*min)
def max_get(self):
cdef int w, h
w = edje_edit_state_max_w_get(self.edje.obj, self.part, self.name,
self.value)
h = edje_edit_state_max_h_get(self.edje.obj, self.part, self.name,
self.value)
return (w, h)
def max_set(self, int w, int h):
edje_edit_state_max_w_set(self.edje.obj, self.part, self.name,
self.value, w)
edje_edit_state_max_h_set(self.edje.obj, self.part, self.name,
self.value, h)
property max:
def __get__(self):
return self.max_get()
def __set__(self, max):
self.max_set(*max)
def aspect_min_get(self):
return edje_edit_state_aspect_min_get(self.edje.obj, self.part,
self.name, self.value)
def aspect_min_set(self, double a):
edje_edit_state_aspect_min_set(self.edje.obj, self.part, self.name,
self.value, a)
def aspect_max_get(self):
return edje_edit_state_aspect_max_get(self.edje.obj, self.part,
self.name, self.value)
def aspect_max_set(self, double a):
edje_edit_state_aspect_max_set(self.edje.obj, self.part, self.name,
self.value, a)
def aspect_pref_get(self):
return edje_edit_state_aspect_pref_get(self.edje.obj, self.part,
self.name, self.value)
def aspect_pref_set(self, char a):
edje_edit_state_aspect_pref_set(self.edje.obj, self.part, self.name,
self.value, a)
def fill_origin_relative_get(self):
cdef double x, y
x = edje_edit_state_fill_origin_relative_x_get(self.edje.obj, self.part,
self.name, self.value)
y = edje_edit_state_fill_origin_relative_y_get(self.edje.obj, self.part,
self.name, self.value)
return (x, y)
def fill_origin_relative_set(self, double x, double y):
edje_edit_state_fill_origin_relative_x_set(self.edje.obj, self.part,
self.name, self.value, x)
edje_edit_state_fill_origin_relative_y_set(self.edje.obj, self.part,
self.name, self.value, y)
def fill_origin_offset_get(self):
cdef int x, y
x = edje_edit_state_fill_origin_offset_x_get(self.edje.obj, self.part,
self.name, self.value)
y = edje_edit_state_fill_origin_offset_y_get(self.edje.obj, self.part,
self.name, self.value)
return (x, y)
def fill_origin_offset_set(self, x, y):
edje_edit_state_fill_origin_offset_x_set(self.edje.obj, self.part,
self.name, self.value, x)
edje_edit_state_fill_origin_offset_y_set(self.edje.obj, self.part,
self.name, self.value, y)
def fill_size_relative_get(self):
cdef double x, y
x = edje_edit_state_fill_size_relative_x_get(self.edje.obj, self.part,
self.name, self.value)
y = edje_edit_state_fill_size_relative_y_get(self.edje.obj, self.part,
self.name, self.value)
return (x, y)
def fill_size_relative_set(self, double x, double y):
edje_edit_state_fill_size_relative_x_set(self.edje.obj, self.part,
self.name, self.value, x)
edje_edit_state_fill_size_relative_y_set(self.edje.obj, self.part,
self.name, self.value, y)
def fill_size_offset_get(self):
cdef int x, y
x = edje_edit_state_fill_size_offset_x_get(self.edje.obj, self.part,
self.name, self.value)
y = edje_edit_state_fill_size_offset_y_get(self.edje.obj, self.part,
self.name, self.value)
return (x, y)
def fill_size_offset_set(self, x, y):
edje_edit_state_fill_size_offset_x_set(self.edje.obj, self.part,
self.name, self.value, x)
edje_edit_state_fill_size_offset_y_set(self.edje.obj, self.part,
self.name, self.value, y)
property visible:
def __get__(self):
return bool(edje_edit_state_visible_get(self.edje.obj, self.part,
self.name, self.value))
def __set__(self, v):
if v:
edje_edit_state_visible_set(self.edje.obj, self.part, self.name,
self.value, 1)
else:
edje_edit_state_visible_set(self.edje.obj, self.part, self.name, self.value, 0)
def color_class_get(self):
cdef const_char_ptr cc
cc = edje_edit_state_color_class_get(self.edje.obj, self.part,
self.name, self.value)
if cc == NULL:
return None
rcc = cc
edje_edit_string_free(cc)
return rcc