kuuko pushed a commit to branch master.
commit dd6f479d7d2a065f189126d70ebc64995be7a03e
Author: Kai Huuhko <[email protected]>
Date: Tue Apr 2 17:12:56 2013 +0000
Elm: More _cfruni removal, and fix init() broken by my previous commit.
---
efl/elementary/general.pyx | 7 +++--
efl/elementary/gengrid.pyx | 36 ++++++++++++++---------
efl/elementary/hoversel.pyx | 71 +++++++++++++++++++++++++--------------------
efl/elementary/icon.pyx | 20 ++++++++-----
4 files changed, 80 insertions(+), 54 deletions(-)
diff --git a/efl/elementary/general.pyx b/efl/elementary/general.pyx
index 51b13f6..6106289 100644
--- a/efl/elementary/general.pyx
+++ b/efl/elementary/general.pyx
@@ -146,10 +146,13 @@ def init():
# FIXME: Why pass the cl args to elm_init?
cdef int argc, i, arg_len
cdef char **argv, *arg
+
argc = len(sys.argv)
argv = <char **>PyMem_Malloc(argc * sizeof(char *))
- for i from 0 <= i < argc:
- arg = sys.argv[i]
+ for i in range(argc):
+ t = sys.argv[i]
+ if isinstance(t, unicode): t = t.encode("UTF-8")
+ arg = t
arg_len = len(arg)
argv[i] = <char *>PyMem_Malloc(arg_len + 1)
memcpy(argv[i], arg, arg_len + 1)
diff --git a/efl/elementary/gengrid.pyx b/efl/elementary/gengrid.pyx
index 3fcb4d0..92c4c37 100644
--- a/efl/elementary/gengrid.pyx
+++ b/efl/elementary/gengrid.pyx
@@ -541,17 +541,20 @@ cdef class GengridItem(ObjectItem):
"""
def __get__(self):
- return _ctouni(elm_gengrid_item_tooltip_style_get(self.item))
+ return self.tooltip_style_get()
def __set__(self, style):
- elm_gengrid_item_tooltip_style_set(self.item, _cfruni(style) if
style is not None else NULL)
+ self.tooltip_style_set(style)
- def tooltip_style_set(self, style=None):
- elm_gengrid_item_tooltip_style_set(self.item, _cfruni(style) if style
is not None else NULL)
- def tooltip_style_get(self):
+ cpdef tooltip_style_set(self, style=None):
+ if isinstance(style, unicode): style = style.encode("UTF-8")
+ elm_gengrid_item_tooltip_style_set(self.item,
+ <const_char *>style if style is not None else NULL)
+ cpdef tooltip_style_get(self):
return _ctouni(elm_gengrid_item_tooltip_style_get(self.item))
property tooltip_window_mode:
+ # TODO: document this
def __get__(self):
return bool(elm_gengrid_item_tooltip_window_mode_get(self.item))
@@ -570,34 +573,40 @@ cdef class GengridItem(ObjectItem):
"""
def __get__(self):
- return _ctouni(elm_gengrid_item_cursor_get(self.item))
+ return self.cursor_get()
def __set__(self, cursor):
- elm_gengrid_item_cursor_set(self.item, _cfruni(cursor))
+ self.cursor_set(cursor)
def __del__(self):
- elm_gengrid_item_cursor_unset(self.item)
+ self.cursor_unset()
- def cursor_set(self, char *cursor):
- elm_gengrid_item_cursor_set(self.item, _cfruni(cursor))
+ def cursor_set(self, cursor):
+ if isinstance(cursor, unicode): cursor = cursor.encode("UTF-8")
+ elm_gengrid_item_cursor_set(self.item,
+ <const_char *>cursor if cursor is not None else NULL)
def cursor_get(self):
return _ctouni(elm_gengrid_item_cursor_get(self.item))
def cursor_unset(self):
elm_gengrid_item_cursor_unset(self.item)
property cursor_style:
+ # TODO: document this
def __get__(self):
- return _ctouni(elm_gengrid_item_cursor_style_get(self.item))
+ return self.cursor_style_get()
def __set__(self, style):
- elm_gengrid_item_cursor_style_set(self.item, _cfruni(style) if
style is not None else NULL)
+ self.cursor_style_set(style)
def cursor_style_set(self, style=None):
- elm_gengrid_item_cursor_style_set(self.item, _cfruni(style) if style
is not None else NULL)
+ if isinstance(style, unicode): style = style.encode("UTF-8")
+ elm_gengrid_item_cursor_style_set(self.item,
+ <const_char *>style if style is not None else NULL)
def cursor_style_get(self):
return _ctouni(elm_gengrid_item_cursor_style_get(self.item))
property cursor_engine_only:
+ # TODO: document this
def __get__(self):
return elm_gengrid_item_cursor_engine_only_get(self.item)
@@ -610,6 +619,7 @@ cdef class GengridItem(ObjectItem):
return elm_gengrid_item_cursor_engine_only_get(self.item)
property select_mode:
+ # TODO: document this
def __get__(self):
return elm_gengrid_item_select_mode_get(self.item)
diff --git a/efl/elementary/hoversel.pyx b/efl/elementary/hoversel.pyx
index 814b9a6..f2c6563 100644
--- a/efl/elementary/hoversel.pyx
+++ b/efl/elementary/hoversel.pyx
@@ -49,10 +49,10 @@ cdef class HoverselItem(ObjectItem):
An item for the :py:class:`Hoversel` widget.
"""
-
- cdef const_char *label, *icon_file
- cdef Elm_Icon_Type icon_type
- cdef Evas_Smart_Cb cb
+ cdef:
+ object label, icon_file, icon_group
+ Elm_Icon_Type icon_type
+ Evas_Smart_Cb cb
def __cinit__(self):
self.cb = NULL
@@ -74,8 +74,10 @@ cdef class HoverselItem(ObjectItem):
:type callback: function
"""
- self.label = _cfruni(label) if label is not None else NULL
- self.icon_file = _cfruni(icon_file) if icon_file is not None else NULL
+ if isinstance(label, unicode): label = label.encode("UTF-8")
+ if isinstance(icon_file, unicode): icon_file =
icon_file.encode("UTF-8")
+ self.label = label
+ self.icon_file = icon_file
self.icon_type = icon_type
if callback:
@@ -101,11 +103,11 @@ cdef class HoverselItem(ObjectItem):
"""
item = elm_hoversel_item_add( hoversel.obj,
- self.label,
- self.icon_file,
- self.icon_type,
- self.cb,
- <void*>self)
+ <const_char *>self.label if self.label is not None else NULL,
+ <const_char *>self.icon_file if self.icon_file is not None else
NULL,
+ self.icon_type,
+ self.cb,
+ <void*>self)
if item != NULL:
self._set_obj(item)
@@ -124,31 +126,36 @@ cdef class HoverselItem(ObjectItem):
"""
def __set__(self, value):
icon_file, icon_group, icon_type = value
- if self.item == NULL:
- self.icon_file = _cfruni(icon_file)
- self.icon_type = icon_type
- else:
- elm_hoversel_item_icon_set(self.item, _cfruni(icon_file),
_cfruni(icon_group), icon_type)
+ self.icon_set(icon_file, icon_group, icon_type)
def __get__(self):
- cdef const_char *icon_file, *icon_group
- cdef Elm_Icon_Type icon_type
- if self.item == NULL:
- icon_file = self.icon_file
- icon_group = NULL
- icon_type = self.icon_type
- else:
- elm_hoversel_item_icon_get(self.item, &icon_file, &icon_group,
&icon_type)
+ return self.icon_get()
+
+ cpdef icon_set(self, icon_file, icon_group, icon_type):
+ a1, a2, a3 = icon_file, icon_group, icon_type
+ if isinstance(a1, unicode): a1 = a1.encode("UTF-8")
+ if isinstance(a2, unicode): a2 = a2.encode("UTF-8")
+ if self.item == NULL:
+ self.icon_file = a1
+ self.icon_group = a2
+ self.icon_type = a3
+ else:
+ elm_hoversel_item_icon_set(self.item,
+ <const_char *>a1 if a1 is not None else NULL,
+ <const_char *>a2 if a2 is not None else NULL,
+ a3)
+ cpdef icon_get(self):
+ cdef const_char *icon_file, *icon_group
+ cdef Elm_Icon_Type icon_type
+ if self.item == NULL:
+ a1 = self.icon_file.decode("UTF-8")
+ a2 = self.icon_group.decode("UTF-8")
+ a3 = self.icon_type
+ return (a1, a2, a3)
+ else:
+ elm_hoversel_item_icon_get(self.item, &icon_file, &icon_group,
&icon_type)
return (_ctouni(icon_file), _ctouni(icon_group), icon_type)
- def icon_set(self, icon_file, icon_group, icon_type):
- elm_hoversel_item_icon_set(self.item, _cfruni(icon_file),
_cfruni(icon_group), icon_type)
- def icon_get(self):
- cdef const_char *cicon_file, *cicon_group
- cdef Elm_Icon_Type cicon_type
- elm_hoversel_item_icon_get(self.item, &cicon_file, &cicon_group,
&cicon_type)
- return (_ctouni(cicon_file), _ctouni(cicon_group), cicon_type)
-
cdef class Hoversel(Button):
"""
diff --git a/efl/elementary/icon.pyx b/efl/elementary/icon.pyx
index bfb63df..44eaf0e 100644
--- a/efl/elementary/icon.pyx
+++ b/efl/elementary/icon.pyx
@@ -169,10 +169,14 @@ cdef class Icon(Image):
else:
filename = value
group = None
- elm_icon_thumb_set(self.obj, _cfruni(filename) if filename is not
None else NULL, _cfruni(group) if group is not None else NULL)
+ self.thumb_set(filename, group)
- def thumb_set(self, filename, group = None):
- elm_icon_thumb_set(self.obj, _cfruni(filename) if filename is not None
else NULL, _cfruni(group) if group is not None else NULL)
+ cpdef thumb_set(self, filename, group = None):
+ if isinstance(filename, unicode): filename = filename.encode("UTF-8")
+ if isinstance(group, unicode): group = group.encode("UTF-8")
+ elm_icon_thumb_set(self.obj,
+ <const_char *>filename if filename is not None else NULL,
+ <const_char *>group if group is not None else NULL)
property standard:
"""The icon standards name.
@@ -195,13 +199,15 @@ cdef class Icon(Image):
"""
def __get__(self):
- return _ctouni(elm_icon_standard_get(self.obj))
+ return self.standard_get()
def __set__(self, name):
- if not bool(elm_icon_standard_set(self.obj, _cfruni(name) if name
is not None else NULL)):
- raise RuntimeError("Setting standard icon failed")
+ self.standard_set(name)
def standard_set(self, name):
- return bool(elm_icon_standard_set(self.obj, _cfruni(name) if name is
not None else NULL))
+ if isinstance(name, unicode): name = name.encode("UTF-8")
+ if not elm_icon_standard_set(self.obj,
+ <const_char *>name if name is not None else NULL):
+ raise RuntimeError("Setting standard icon failed")
def standard_get(self):
return _ctouni(elm_icon_standard_get(self.obj))
--
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html