summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-03-11 15:37:06 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2015-03-11 15:37:06 +0200
commita407e1129807922a087c4bf16bc2ae89b30b4461 (patch)
tree4c63ea57345814373e2f1c8fd0aab64282d155b1
parentd36b61e97e98e2067f50a3aa510071f420cf6c30 (diff)
Evas: Change SmartCb event_info conversions into C functions
-rw-r--r--efl/elementary/actionslider.pyx7
-rw-r--r--efl/elementary/colorselector.pyx6
-rw-r--r--efl/elementary/diskselector.pyx9
-rw-r--r--efl/elementary/entry.pyx86
-rw-r--r--efl/elementary/fileselector.pyx6
-rw-r--r--efl/elementary/fileselector_button.pyx7
-rw-r--r--efl/elementary/fileselector_entry.pyx7
-rw-r--r--efl/elementary/gengrid.pyx6
-rw-r--r--efl/elementary/genlist.pyx6
-rw-r--r--efl/elementary/hoversel.pyx6
-rw-r--r--efl/elementary/image.pyx52
-rw-r--r--efl/elementary/index.pyx7
-rw-r--r--efl/elementary/list.pyx6
-rw-r--r--efl/elementary/multibuttonentry.pyx7
-rw-r--r--efl/elementary/photocam.pyx46
-rw-r--r--efl/elementary/popup.pyx8
-rw-r--r--efl/elementary/segment_control.pyx7
-rw-r--r--efl/elementary/slideshow.pyx7
-rw-r--r--efl/elementary/toolbar.pyx6
-rw-r--r--efl/elementary/web.pyx42
-rw-r--r--efl/evas/efl.evas_object_smart.pxi28
-rwxr-xr-xexamples/elementary/test.py2
-rw-r--r--examples/elementary/test_genlist.py6
-rw-r--r--include/efl.evas.pxd9
24 files changed, 206 insertions, 173 deletions
diff --git a/efl/elementary/actionslider.pyx b/efl/elementary/actionslider.pyx
index e10c454..00a74d0 100644
--- a/efl/elementary/actionslider.pyx
+++ b/efl/elementary/actionslider.pyx
@@ -102,6 +102,7 @@ Inheritance diagram
102""" 102"""
103 103
104from libc.stdint cimport uintptr_t 104from libc.stdint cimport uintptr_t
105from cpython cimport PyObject
105 106
106from efl.eo cimport _object_mapping_register 107from efl.eo cimport _object_mapping_register
107from efl.utils.conversions cimport _ctouni 108from efl.utils.conversions cimport _ctouni
@@ -109,9 +110,9 @@ from efl.evas cimport Object as evasObject
109from layout_class cimport LayoutClass 110from layout_class cimport LayoutClass
110 111
111 112
112def _cb_string_conv(uintptr_t addr): 113cdef object _cb_string_conv(void *addr):
113 cdef const char *s = <const char *>addr 114 return _ctouni(<const char *>addr) if addr is not NULL else None
114 return _ctouni(s) if s is not NULL else None 115
115 116
116cdef class Actionslider(LayoutClass): 117cdef class Actionslider(LayoutClass):
117 """ 118 """
diff --git a/efl/elementary/colorselector.pyx b/efl/elementary/colorselector.pyx
index a1ed028..2fc507e 100644
--- a/efl/elementary/colorselector.pyx
+++ b/efl/elementary/colorselector.pyx
@@ -89,9 +89,9 @@ from object_item cimport ObjectItem, _object_item_to_python
89from layout_class cimport LayoutClass 89from layout_class cimport LayoutClass
90 90
91 91
92def _cb_object_item_conv(uintptr_t addr): 92cdef object _cb_object_item_conv(void *addr):
93 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 93 return _object_item_to_python(<Elm_Object_Item *>addr)
94 return _object_item_to_python(it) 94
95 95
96cdef class ColorselectorPaletteItem(ObjectItem): 96cdef class ColorselectorPaletteItem(ObjectItem):
97 """ 97 """
diff --git a/efl/elementary/diskselector.pyx b/efl/elementary/diskselector.pyx
index a1805f2..ecc6aaf 100644
--- a/efl/elementary/diskselector.pyx
+++ b/efl/elementary/diskselector.pyx
@@ -97,9 +97,12 @@ from efl.utils.deprecated cimport DEPRECATED
97from scroller cimport elm_scroller_policy_get, elm_scroller_policy_set, \ 97from scroller cimport elm_scroller_policy_get, elm_scroller_policy_set, \
98 elm_scroller_bounce_get, elm_scroller_bounce_set, Elm_Scroller_Policy 98 elm_scroller_bounce_get, elm_scroller_bounce_set, Elm_Scroller_Policy
99 99
100def _cb_object_item_conv(uintptr_t addr): 100cdef _cb_object_item_conv(void *addr):
101 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 101 return _object_item_to_python(<Elm_Object_Item *>addr)
102 return _object_item_to_python(it) 102
103# def _cb_object_item_conv(uintptr_t addr):
104# cdef Elm_Object_Item *it = <Elm_Object_Item *>addr
105# return _object_item_to_python(it)
103 106
104 107
105cdef class DiskselectorItem(ObjectItem): 108cdef class DiskselectorItem(ObjectItem):
diff --git a/efl/elementary/entry.pyx b/efl/elementary/entry.pyx
index 57f7fab..cda125d 100644
--- a/efl/elementary/entry.pyx
+++ b/efl/elementary/entry.pyx
@@ -797,7 +797,8 @@ cdef void py_elm_entry_filter_cb(void *data, Evas_Object *entry, char **text) wi
797 797
798 text[0] = strdup(<char *>ret) 798 text[0] = strdup(<char *>ret)
799 799
800class EntryAnchorInfo(object): 800
801cdef class EntryAnchorInfo(object):
801 """EntryAnchorInfo(...) 802 """EntryAnchorInfo(...)
802 803
803 The info sent in the callback for the ``anchor,clicked`` signals emitted 804 The info sent in the callback for the ``anchor,clicked`` signals emitted
@@ -811,15 +812,26 @@ class EntryAnchorInfo(object):
811 :var h: Anchor geometry, relative to canvas. 812 :var h: Anchor geometry, relative to canvas.
812 813
813 """ 814 """
814 def __init__(self): 815 cdef:
815 self.name = None 816 readonly unicode name
816 self.button = 0 817 readonly int button, x, y, w, h
817 self.x = 0 818
818 self.y = 0 819 @staticmethod
819 self.w = 0 820 cdef EntryAnchorInfo create(Elm_Entry_Anchor_Info *addr):
820 self.h = 0 821 cdef EntryAnchorInfo self = EntryAnchorInfo.__new__(EntryAnchorInfo)
821 822 self.name = _ctouni(addr.name)
822class EntryAnchorHoverInfo(object): 823 self.button = addr.button
824 self.x = addr.x
825 self.y = addr.y
826 self.w = addr.w
827 self.h = addr.h
828 return self
829
830cdef object _entryanchor_conv(void *addr):
831 return EntryAnchorInfo.create(<Elm_Entry_Anchor_Info *>addr)
832
833
834cdef class EntryAnchorHoverInfo(object):
823 """EntryAnchorHoverInfo(...) 835 """EntryAnchorHoverInfo(...)
824 836
825 The info sent in the callback for ``anchor,clicked`` signals emitted by 837 The info sent in the callback for ``anchor,clicked`` signals emitted by
@@ -834,38 +846,28 @@ class EntryAnchorHoverInfo(object):
834 :var hover_bottom: Hint indicating content fits below the hover. 846 :var hover_bottom: Hint indicating content fits below the hover.
835 847
836 """ 848 """
837 def __init__(self): 849 cdef:
838 self.anchor_info = None 850 readonly EntryAnchorInfo anchor_info
839 self.hover = None 851 readonly object hover
840 self.hover_parent = (0, 0, 0, 0) 852 readonly tuple hover_parent
841 self.hover_left = False 853 readonly bint hover_left, hover_right, hover_top, hover_bottom
842 self.hover_right = False 854
843 self.hover_top = False 855 @staticmethod
844 self.hover_bottom = False 856 cdef EntryAnchorHoverInfo create(Elm_Entry_Anchor_Hover_Info *addr):
845 857 cdef EntryAnchorHoverInfo self = EntryAnchorHoverInfo.__new__(EntryAnchorHoverInfo)
846def _entryanchor_conv(uintptr_t addr): 858 self.anchor_info = _entryanchor_conv(addr.anchor_info)
847 cdef Elm_Entry_Anchor_Info *ei = <Elm_Entry_Anchor_Info *>addr 859 self.hover = object_from_instance(addr.hover)
848 eai = EntryAnchorInfo() 860 self.hover_parent = (addr.hover_parent.x, addr.hover_parent.y,
849 eai.name = _ctouni(ei.name) 861 addr.hover_parent.w, addr.hover_parent.h)
850 eai.button = ei.button 862 self.hover_left = addr.hover_left
851 eai.x = ei.x 863 self.hover_right = addr.hover_right
852 eai.y = ei.y 864 self.hover_top = addr.hover_top
853 eai.w = ei.w 865 self.hover_bottom = addr.hover_bottom
854 eai.h = ei.h 866 return self
855 return eai 867
856 868cdef object _entryanchorhover_conv(void *addr):
857def _entryanchorhover_conv(uintptr_t addr): 869 return EntryAnchorHoverInfo.create(<Elm_Entry_Anchor_Hover_Info *>addr)
858 cdef Elm_Entry_Anchor_Hover_Info *ehi = <Elm_Entry_Anchor_Hover_Info *>addr 870
859 eahi = EntryAnchorHoverInfo()
860 eahi.anchor_info = _entryanchor_conv(<uintptr_t><void *>ehi.anchor_info)
861 eahi.hover = object_from_instance(ehi.hover)
862 eahi.hover_parent = (ehi.hover_parent.x, ehi.hover_parent.y,
863 ehi.hover_parent.w, ehi.hover_parent.h)
864 eahi.hover_left = ehi.hover_left
865 eahi.hover_right = ehi.hover_right
866 eahi.hover_top = ehi.hover_top
867 eahi.hover_bottom = ehi.hover_bottom
868 return eahi
869 871
870cdef class Entry(LayoutClass): 872cdef class Entry(LayoutClass):
871 """ 873 """
diff --git a/efl/elementary/fileselector.pyx b/efl/elementary/fileselector.pyx
index 54e484d..7cd090b 100644
--- a/efl/elementary/fileselector.pyx
+++ b/efl/elementary/fileselector.pyx
@@ -165,9 +165,9 @@ from layout_class cimport LayoutClass
165import traceback 165import traceback
166 166
167 167
168def _cb_string_conv(uintptr_t addr): 168cdef _cb_string_conv(void *addr):
169 cdef const char *s = <const char *>addr 169 return _ctouni(<const char *>addr) if addr is not NULL else None
170 return _ctouni(s) if s is not NULL else None 170
171 171
172cdef Eina_Bool py_elm_fileselector_custom_filter_cb(const char *path, Eina_Bool is_dir, void *data) with gil: 172cdef Eina_Bool py_elm_fileselector_custom_filter_cb(const char *path, Eina_Bool is_dir, void *data) with gil:
173 cb_func, cb_data = <object>data 173 cb_func, cb_data = <object>data
diff --git a/efl/elementary/fileselector_button.pyx b/efl/elementary/fileselector_button.pyx
index 7e9fd3d..38ea009 100644
--- a/efl/elementary/fileselector_button.pyx
+++ b/efl/elementary/fileselector_button.pyx
@@ -108,9 +108,10 @@ from fileselector cimport elm_fileselector_path_set, \
108 elm_fileselector_folder_only_get, elm_fileselector_is_save_set, \ 108 elm_fileselector_folder_only_get, elm_fileselector_is_save_set, \
109 elm_fileselector_is_save_get 109 elm_fileselector_is_save_get
110 110
111def _cb_string_conv(uintptr_t addr): 111
112 cdef const char *s = <const char *>addr 112cdef _cb_string_conv(void *addr):
113 return _ctouni(s) if s is not NULL else None 113 return _ctouni(<const char *>addr) if addr is not NULL else None
114
114 115
115cdef class FileselectorButton(Button): 116cdef class FileselectorButton(Button):
116 """ 117 """
diff --git a/efl/elementary/fileselector_entry.pyx b/efl/elementary/fileselector_entry.pyx
index e5ead41..ce27d4f 100644
--- a/efl/elementary/fileselector_entry.pyx
+++ b/efl/elementary/fileselector_entry.pyx
@@ -122,9 +122,10 @@ from fileselector cimport elm_fileselector_path_set, \
122 elm_fileselector_is_save_get, elm_fileselector_selected_set, \ 122 elm_fileselector_is_save_get, elm_fileselector_selected_set, \
123 elm_fileselector_selected_get 123 elm_fileselector_selected_get
124 124
125def _cb_string_conv(uintptr_t addr): 125
126 cdef const char *s = <const char *>addr 126cdef _cb_string_conv(void *addr):
127 return _ctouni(s) if s is not NULL else None 127 return _ctouni(<const char *>addr) if addr is not NULL else None
128
128 129
129cdef class FileselectorEntry(LayoutClass): 130cdef class FileselectorEntry(LayoutClass):
130 """ 131 """
diff --git a/efl/elementary/gengrid.pyx b/efl/elementary/gengrid.pyx
index 105291a..6c3ed3f 100644
--- a/efl/elementary/gengrid.pyx
+++ b/efl/elementary/gengrid.pyx
@@ -360,9 +360,9 @@ from scroller cimport elm_scroller_policy_get, elm_scroller_policy_set, \
360 elm_scroller_bounce_get, elm_scroller_bounce_set, Elm_Scroller_Policy 360 elm_scroller_bounce_get, elm_scroller_bounce_set, Elm_Scroller_Policy
361 361
362 362
363def _cb_object_item_conv(uintptr_t addr): 363cdef object _cb_object_item_conv(void *addr):
364 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 364 return _object_item_to_python(<Elm_Object_Item *>addr)
365 return _object_item_to_python(it) 365
366 366
367cdef char *_py_elm_gengrid_item_text_get(void *data, Evas_Object *obj, const char *part) with gil: 367cdef char *_py_elm_gengrid_item_text_get(void *data, Evas_Object *obj, const char *part) with gil:
368 cdef: 368 cdef:
diff --git a/efl/elementary/genlist.pyx b/efl/elementary/genlist.pyx
index 93a5cd9..495ad43 100644
--- a/efl/elementary/genlist.pyx
+++ b/efl/elementary/genlist.pyx
@@ -553,9 +553,9 @@ import traceback
553import logging 553import logging
554 554
555 555
556def _cb_object_item_conv(uintptr_t addr): 556cdef object _cb_object_item_conv(void *addr):
557 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 557 return _object_item_to_python(<Elm_Object_Item *>addr)
558 return _object_item_to_python(it) 558
559 559
560cdef char *_py_elm_genlist_item_text_get(void *data, Evas_Object *obj, const char *part) with gil: 560cdef char *_py_elm_genlist_item_text_get(void *data, Evas_Object *obj, const char *part) with gil:
561 cdef: 561 cdef:
diff --git a/efl/elementary/hoversel.pyx b/efl/elementary/hoversel.pyx
index 9ac501f..91504f8 100644
--- a/efl/elementary/hoversel.pyx
+++ b/efl/elementary/hoversel.pyx
@@ -101,9 +101,9 @@ from object_item cimport ObjectItem, _object_item_callback, \
101from button cimport Button 101from button cimport Button
102 102
103 103
104def _cb_object_item_conv(uintptr_t addr): 104cdef object _cb_object_item_conv(void *addr):
105 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 105 return _object_item_to_python(<Elm_Object_Item *>addr)
106 return _object_item_to_python(it) 106
107 107
108cdef class HoverselItem(ObjectItem): 108cdef class HoverselItem(ObjectItem):
109 """ 109 """
diff --git a/efl/elementary/image.pyx b/efl/elementary/image.pyx
index 4c5d758..08690b1 100644
--- a/efl/elementary/image.pyx
+++ b/efl/elementary/image.pyx
@@ -122,12 +122,11 @@ from efl.utils.conversions cimport _ctouni
122from efl.evas cimport Object as evasObject 122from efl.evas cimport Object as evasObject
123 123
124 124
125def _cb_string_conv(uintptr_t addr): 125cdef _cb_string_conv(void *addr):
126 cdef const char *s = <const char *>addr 126 return _ctouni(<const char *>addr) if addr is not NULL else None
127 return _ctouni(s) if s is not NULL else None
128 127
129 128
130class ImageProgressInfo(object): 129cdef class ImageProgressInfo(object):
131 """ImageProgressInfo(...) 130 """ImageProgressInfo(...)
132 131
133 The info sent in the callback for the ``download,progress`` signals emitted 132 The info sent in the callback for the ``download,progress`` signals emitted
@@ -139,18 +138,21 @@ class ImageProgressInfo(object):
139 .. versionadded:: 1.8 138 .. versionadded:: 1.8
140 139
141 """ 140 """
142 def __init__(self): 141 cdef:
143 self.now = 0 142 readonly double now, total
144 self.total = 0 143
145 144 @staticmethod
146def _image_download_progress_conv(uintptr_t addr): 145 cdef ImageProgressInfo create(Elm_Image_Progress *addr):
147 cdef Elm_Image_Progress *ip = <Elm_Image_Progress *>addr 146 cdef ImageProgressInfo self = ImageProgressInfo.__new__(ImageProgressInfo)
148 ipi = ImageProgressInfo() 147 self.now = addr.now
149 ipi.now = ip.now 148 self.total = addr.total
150 ipi.total = ip.total 149 return self
151 return ipi 150
152 151cdef object _image_download_progress_conv(void *addr):
153class ImageErrorInfo(object): 152 return ImageProgressInfo.create(<Elm_Image_Progress *>addr)
153
154
155cdef class ImageErrorInfo(object):
154 """ImageErrorInfo(...) 156 """ImageErrorInfo(...)
155 157
156 The info sent in the callback for the ``download,error`` signals emitted 158 The info sent in the callback for the ``download,error`` signals emitted
@@ -162,17 +164,19 @@ class ImageErrorInfo(object):
162 .. versionadded:: 1.8 164 .. versionadded:: 1.8
163 165
164 """ 166 """
165 def __init__(self): 167 cdef:
168 readonly int status
169 readonly bint open_error
170
171 @staticmethod
172 cdef ImageErrorInfo create(Elm_Image_Error *addr):
173 cdef ImageErrorInfo self = ImageErrorInfo.__new__(ImageErrorInfo)
166 self.status = 0 174 self.status = 0
167 self.open_error = False 175 self.open_error = False
176 return self
168 177
169def _image_download_error_conv(uintptr_t addr): 178cdef object _image_download_error_conv(void *addr):
170 cdef Elm_Image_Error *ie = <Elm_Image_Error *>addr 179 return ImageErrorInfo.create(<Elm_Image_Error *>addr)
171 iei = ImageErrorInfo()
172 iei.status = ie.status
173 iei.open_error = ie.open_error
174 return iei
175
176 180
177 181
178cdef class Image(Object): 182cdef class Image(Object):
diff --git a/efl/elementary/index.pyx b/efl/elementary/index.pyx
index 42d309a..631563a 100644
--- a/efl/elementary/index.pyx
+++ b/efl/elementary/index.pyx
@@ -90,9 +90,10 @@ from object_item cimport _object_item_to_python, elm_object_item_data_get, \
90 90
91import traceback 91import traceback
92 92
93def _cb_object_item_conv(uintptr_t addr): 93
94 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 94cdef object _cb_object_item_conv(void *addr):
95 return _object_item_to_python(it) 95 return _object_item_to_python(<Elm_Object_Item *>addr)
96
96 97
97cdef int _index_compare_func(const void *data1, const void *data2) with gil: 98cdef int _index_compare_func(const void *data1, const void *data2) with gil:
98 """Comparison by IndexItem objects""" 99 """Comparison by IndexItem objects"""
diff --git a/efl/elementary/list.pyx b/efl/elementary/list.pyx
index a2fd941..f33e562 100644
--- a/efl/elementary/list.pyx
+++ b/efl/elementary/list.pyx
@@ -191,9 +191,9 @@ from scroller cimport elm_scroller_policy_get, elm_scroller_policy_set, \
191 elm_scroller_bounce_get, elm_scroller_bounce_set, Elm_Scroller_Policy 191 elm_scroller_bounce_get, elm_scroller_bounce_set, Elm_Scroller_Policy
192 192
193 193
194def _cb_object_item_conv(uintptr_t addr): 194cdef object _cb_object_item_conv(void *addr):
195 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 195 return _object_item_to_python(<Elm_Object_Item *>addr)
196 return _object_item_to_python(it) 196
197 197
198cdef class ListItem(ObjectItem): 198cdef class ListItem(ObjectItem):
199 """ 199 """
diff --git a/efl/elementary/multibuttonentry.pyx b/efl/elementary/multibuttonentry.pyx
index 91cd95d..ea2fe89 100644
--- a/efl/elementary/multibuttonentry.pyx
+++ b/efl/elementary/multibuttonentry.pyx
@@ -89,9 +89,10 @@ from object_item cimport _object_item_callback, _object_item_callback2, \
89 _object_item_to_python, _object_item_list_to_python, ObjectItem, \ 89 _object_item_to_python, _object_item_list_to_python, ObjectItem, \
90 elm_object_item_data_get 90 elm_object_item_data_get
91 91
92def _cb_object_item_conv(uintptr_t addr): 92
93 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 93cdef object _cb_object_item_conv(void *addr):
94 return _object_item_to_python(it) 94 return _object_item_to_python(<Elm_Object_Item *>addr)
95
95 96
96cdef Eina_Bool _multibuttonentry_filter_callback(Evas_Object *obj, \ 97cdef Eina_Bool _multibuttonentry_filter_callback(Evas_Object *obj, \
97 const char *item_label, void *item_data, void *data) with gil: 98 const char *item_label, void *item_data, void *data) with gil:
diff --git a/efl/elementary/photocam.pyx b/efl/elementary/photocam.pyx
index e9dc25a..5c48b50 100644
--- a/efl/elementary/photocam.pyx
+++ b/efl/elementary/photocam.pyx
@@ -125,7 +125,7 @@ from scroller cimport elm_scroller_policy_get, elm_scroller_policy_set, \
125 elm_scroller_bounce_get, elm_scroller_bounce_set, Elm_Scroller_Policy 125 elm_scroller_bounce_get, elm_scroller_bounce_set, Elm_Scroller_Policy
126 126
127 127
128class PhotocamProgressInfo(object): 128cdef class PhotocamProgressInfo(object):
129 """PhotocamProgressInfo(...) 129 """PhotocamProgressInfo(...)
130 130
131 The info sent in the callback for the ``download,progress`` signals emitted 131 The info sent in the callback for the ``download,progress`` signals emitted
@@ -137,18 +137,21 @@ class PhotocamProgressInfo(object):
137 .. versionadded:: 1.8 137 .. versionadded:: 1.8
138 138
139 """ 139 """
140 def __init__(self): 140 cdef:
141 self.now = 0 141 readonly double now, total
142 self.total = 0 142
143 143 @staticmethod
144def _photocam_download_progress_conv(uintptr_t addr): 144 cdef PhotocamProgressInfo create(Elm_Photocam_Progress *addr):
145 cdef Elm_Photocam_Progress *pp = <Elm_Photocam_Progress *>addr 145 cdef PhotocamProgressInfo self = PhotocamProgressInfo.__new__(PhotocamProgressInfo)
146 ppi = PhotocamProgressInfo() 146 self.now = addr.now
147 ppi.now = pp.now 147 self.total = addr.total
148 ppi.total = pp.total 148 return self
149 return ppi 149
150 150cdef object _photocam_download_progress_conv(void *addr):
151class PhotocamErrorInfo(object): 151 return PhotocamProgressInfo.create(<Elm_Photocam_Progress *>addr)
152
153
154cdef class PhotocamErrorInfo(object):
152 """PhotocamErrorInfo(...) 155 """PhotocamErrorInfo(...)
153 156
154 The info sent in the callback for the ``download,error`` signals emitted 157 The info sent in the callback for the ``download,error`` signals emitted
@@ -160,16 +163,19 @@ class PhotocamErrorInfo(object):
160 .. versionadded:: 1.8 163 .. versionadded:: 1.8
161 164
162 """ 165 """
163 def __init__(self): 166 cdef:
167 readonly int status
168 readonly bint open_error
169
170 @staticmethod
171 cdef PhotocamErrorInfo create(Elm_Photocam_Error *addr):
172 cdef PhotocamErrorInfo self = PhotocamErrorInfo.__new__(PhotocamErrorInfo)
164 self.status = 0 173 self.status = 0
165 self.open_error = False 174 self.open_error = False
175 return self
166 176
167def _photocam_download_error_conv(uintptr_t addr): 177cdef object _photocam_download_error_conv(void *addr):
168 cdef Elm_Photocam_Error *pe = <Elm_Photocam_Error *>addr 178 return PhotocamErrorInfo.create(<Elm_Photocam_Error *>addr)
169 pei = PhotocamErrorInfo()
170 pei.status = pe.status
171 pei.open_error = pe.open_error
172 return pei
173 179
174 180
175cdef class Photocam(Object): 181cdef class Photocam(Object):
diff --git a/efl/elementary/popup.pyx b/efl/elementary/popup.pyx
index 9f76c7f..887ede2 100644
--- a/efl/elementary/popup.pyx
+++ b/efl/elementary/popup.pyx
@@ -198,9 +198,9 @@ from object_item cimport _object_item_callback, _object_item_callback2, \
198 ObjectItem, _object_item_to_python 198 ObjectItem, _object_item_to_python
199 199
200 200
201def _cb_object_item_conv(uintptr_t addr): 201cdef object _cb_object_item_conv(void *addr):
202 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 202 return _object_item_to_python(<Elm_Object_Item *>addr)
203 return _object_item_to_python(it) 203
204 204
205cdef class PopupItem(ObjectItem): 205cdef class PopupItem(ObjectItem):
206 """ 206 """
@@ -441,7 +441,7 @@ cdef class Popup(LayoutClass):
441 441
442 def callback_item_focused_add(self, func, *args, **kwargs): 442 def callback_item_focused_add(self, func, *args, **kwargs):
443 """When the popup item has received focus. 443 """When the popup item has received focus.
444 444
445 .. versionadded:: 1.10 445 .. versionadded:: 1.10
446 446
447 """ 447 """
diff --git a/efl/elementary/segment_control.pyx b/efl/elementary/segment_control.pyx
index 5e13fd2..bd987d6 100644
--- a/efl/elementary/segment_control.pyx
+++ b/efl/elementary/segment_control.pyx
@@ -75,9 +75,10 @@ from layout_class cimport LayoutClass
75 75
76from object_item cimport _object_item_to_python, ObjectItem 76from object_item cimport _object_item_to_python, ObjectItem
77 77
78def _cb_object_item_conv(uintptr_t addr): 78
79 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 79cdef object _cb_object_item_conv(void *addr):
80 return _object_item_to_python(it) 80 return _object_item_to_python(<Elm_Object_Item *>addr)
81
81 82
82cdef class SegmentControlItem(ObjectItem): 83cdef class SegmentControlItem(ObjectItem):
83 """ 84 """
diff --git a/efl/elementary/slideshow.pyx b/efl/elementary/slideshow.pyx
index 92f211d..19249a7 100644
--- a/efl/elementary/slideshow.pyx
+++ b/efl/elementary/slideshow.pyx
@@ -104,9 +104,10 @@ import traceback
104from object_item cimport _object_item_to_python, _object_item_list_to_python, \ 104from object_item cimport _object_item_to_python, _object_item_list_to_python, \
105 ObjectItem 105 ObjectItem
106 106
107def _cb_object_item_conv(uintptr_t addr): 107
108 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 108cdef object _cb_object_item_conv(void *addr):
109 return _object_item_to_python(it) 109 return _object_item_to_python(<Elm_Object_Item *>addr)
110
110 111
111cdef Evas_Object *_py_elm_slideshow_item_get(void *data, Evas_Object *obj) with gil: 112cdef Evas_Object *_py_elm_slideshow_item_get(void *data, Evas_Object *obj) with gil:
112 cdef SlideshowItem item = <object>data 113 cdef SlideshowItem item = <object>data
diff --git a/efl/elementary/toolbar.pyx b/efl/elementary/toolbar.pyx
index 21a2200..47abfca 100644
--- a/efl/elementary/toolbar.pyx
+++ b/efl/elementary/toolbar.pyx
@@ -202,9 +202,9 @@ from scroller cimport elm_scroller_policy_get, elm_scroller_policy_set, \
202import traceback 202import traceback
203 203
204 204
205def _cb_object_item_conv(uintptr_t addr): 205cdef object _cb_object_item_conv(void *addr):
206 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr 206 return _object_item_to_python(<Elm_Object_Item *>addr)
207 return _object_item_to_python(it) 207
208 208
209cdef void _toolbar_item_state_callback(void *data, Evas_Object *obj, void *event_info) with gil: 209cdef void _toolbar_item_state_callback(void *data, Evas_Object *obj, void *event_info) with gil:
210 cdef ToolbarItemState state = <object>data 210 cdef ToolbarItemState state = <object>data
diff --git a/efl/elementary/web.pyx b/efl/elementary/web.pyx
index a8a654c..c25b517 100644
--- a/efl/elementary/web.pyx
+++ b/efl/elementary/web.pyx
@@ -169,40 +169,42 @@ from object cimport Object
169import traceback 169import traceback
170 170
171 171
172def _cb_string_conv(uintptr_t addr): 172cdef _cb_string_conv(void *addr):
173 cdef const char *s = <const char *>addr 173 return _ctouni(<const char *>addr) if addr is not NULL else None
174 return _ctouni(s) if s is not NULL else None
175 174
176def _cb_bool_conv(uintptr_t addr): 175
177 cdef Eina_Bool *info = <Eina_Bool *>addr 176cdef _cb_bool_conv(void *addr):
178 if info == NULL: 177 if addr == NULL:
179 return None 178 return None
180 return info[0] 179 cdef Eina_Bool *ret = <Eina_Bool *>addr
180 return <bint>ret[0]
181
181 182
182def _web_double_conv(uintptr_t addr): 183cdef _web_double_conv(void *addr):
183 cdef double *info = <double *>addr 184 if addr == NULL:
184 if info == NULL:
185 return None 185 return None
186 return info[0] 186 cdef double *ret = <double *>addr
187 return ret[0]
187 188
188def _web_load_frame_error_conv(uintptr_t addr): 189
189 cdef Elm_Web_Frame_Load_Error *err = <Elm_Web_Frame_Load_Error *>addr 190cdef _web_load_frame_error_conv(void *addr):
190 if err == NULL: 191 cdef Elm_Web_Frame_Load_Error *err
192 if addr == NULL:
191 return None 193 return None
192 ret = {"code": err.code, "is_cancellation": bool(err.is_cancellation), 194 err = <Elm_Web_Frame_Load_Error *>addr
195 return {"code": err.code, "is_cancellation": bool(err.is_cancellation),
193 "domain": _ctouni(err.domain) if err.domain else None, 196 "domain": _ctouni(err.domain) if err.domain else None,
194 "description": _ctouni(err.description) if err.description else None, 197 "description": _ctouni(err.description) if err.description else None,
195 "failing_url": _ctouni(err.failing_url) if err.failing_url else None, 198 "failing_url": _ctouni(err.failing_url) if err.failing_url else None,
196 "frame": object_from_instance(err.frame) if err.frame else None} 199 "frame": object_from_instance(err.frame) if err.frame else None}
197 200
198 return ret
199
200 201
201def _web_link_hover_in_conv(uintptr_t addr): 202cdef _web_link_hover_in_conv(void *addr):
202 cdef char **info = <char **>addr 203 cdef char **info
203 if info == NULL: 204 if addr == NULL:
204 url = title = None 205 url = title = None
205 else: 206 else:
207 info = <char **>addr
206 url = None if info[0] == NULL else info[0] 208 url = None if info[0] == NULL else info[0]
207 title = None if info[1] == NULL else info[1] 209 title = None if info[1] == NULL else info[1]
208 return (url, title) 210 return (url, title)
diff --git a/efl/evas/efl.evas_object_smart.pxi b/efl/evas/efl.evas_object_smart.pxi
index e505178..cc9ee11 100644
--- a/efl/evas/efl.evas_object_smart.pxi
+++ b/efl/evas/efl.evas_object_smart.pxi
@@ -325,6 +325,7 @@ cdef void _smart_callback(void *data, Evas_Object *o, void *event_info) with gil
325 void *tmp = NULL 325 void *tmp = NULL
326 SmartObject obj 326 SmartObject obj
327 object ei 327 object ei
328 object(*event_conv)(void*)
328 329
329 eo_do_ret(o, tmp, eo_key_data_get("python-eo")) 330 eo_do_ret(o, tmp, eo_key_data_get("python-eo"))
330 if tmp == NULL: 331 if tmp == NULL:
@@ -337,13 +338,18 @@ cdef void _smart_callback(void *data, Evas_Object *o, void *event_info) with gil
337 EINA_LOG_DOM_ERR(PY_EFL_EVAS_LOG_DOMAIN, "data is NULL!", NULL) 338 EINA_LOG_DOM_ERR(PY_EFL_EVAS_LOG_DOMAIN, "data is NULL!", NULL)
338 return 339 return
339 else: 340 else:
340 event_conv, func, args, kargs = <tuple>data 341 conv, func, args, kargs = <tuple>data
342
343 if conv != 0:
344 event_conv = <object(*)(void*)><void *><uintptr_t>conv
345 else:
346 event_conv = NULL
341 347
342 try: 348 try:
343 if event_conv is None: 349 if event_conv is NULL:
344 func(obj, *args, **kargs) 350 func(obj, *args, **kargs)
345 else: 351 else:
346 ei = event_conv(<uintptr_t>event_info) 352 ei = event_conv(event_info)
347 func(obj, ei, *args, **kargs) 353 func(obj, ei, *args, **kargs)
348 except Exception: 354 except Exception:
349 traceback.print_exc() 355 traceback.print_exc()
@@ -724,7 +730,7 @@ cdef class SmartObject(Object):
724 # ========= 730 # =========
725 # 731 #
726 732
727 cdef int _callback_add_full(self, event, event_conv, func, tuple args, dict kargs) except 0: 733 cdef int _callback_add_full(self, event, object(*event_conv)(void *), func, tuple args, dict kargs) except 0:
728 """Add a callback for the smart event specified by event. 734 """Add a callback for the smart event specified by event.
729 735
730 :param event: event name 736 :param event: event name
@@ -747,11 +753,9 @@ cdef class SmartObject(Object):
747 """ 753 """
748 if not callable(func): 754 if not callable(func):
749 raise TypeError("func must be callable") 755 raise TypeError("func must be callable")
750 if event_conv is not None and not callable(event_conv):
751 raise TypeError("event_conv must be None or callable")
752 if isinstance(event, unicode): event = PyUnicode_AsUTF8String(event) 756 if isinstance(event, unicode): event = PyUnicode_AsUTF8String(event)
753 757
754 spec = (event_conv, func, args, kargs) 758 spec = (<uintptr_t><void *>event_conv, func, args, kargs)
755 self._owned_references.append(spec) 759 self._owned_references.append(spec)
756 #Py_INCREF(spec) 760 #Py_INCREF(spec)
757 761
@@ -761,7 +765,7 @@ cdef class SmartObject(Object):
761 765
762 return 1 766 return 1
763 767
764 cdef int _callback_del_full(self, event, event_conv, func) except 0: 768 cdef int _callback_del_full(self, event, object(*event_conv)(void *), func) except 0:
765 """Remove a smart callback. 769 """Remove a smart callback.
766 770
767 Removes a callback that was added by :py:func:`_callback_add_full()`. 771 Removes a callback that was added by :py:func:`_callback_add_full()`.
@@ -810,7 +814,7 @@ cdef class SmartObject(Object):
810 :raise TypeError: if **func** is not callable. 814 :raise TypeError: if **func** is not callable.
811 815
812 """ 816 """
813 return self._callback_add_full(event, None, func, args, kargs) 817 return self._callback_add_full(event, NULL, func, args, kargs)
814 818
815 cdef int _callback_del(self, event, func) except 0: 819 cdef int _callback_del(self, event, func) except 0:
816 """Remove a smart callback. 820 """Remove a smart callback.
@@ -828,7 +832,7 @@ cdef class SmartObject(Object):
828 :raise ValueError: if there was no **func** connected with this event. 832 :raise ValueError: if there was no **func** connected with this event.
829 833
830 """ 834 """
831 return self._callback_del_full(event, None, func) 835 return self._callback_del_full(event, NULL, func)
832 836
833 def callback_add(self, name, func, *args, **kargs): 837 def callback_add(self, name, func, *args, **kargs):
834 """Add a callback for the smart event specified by event. 838 """Add a callback for the smart event specified by event.
@@ -847,7 +851,7 @@ cdef class SmartObject(Object):
847 signal is provided by a C-only class, it will crash. 851 signal is provided by a C-only class, it will crash.
848 852
849 """ 853 """
850 self._callback_add_full(name, None, func, args, kargs) 854 self._callback_add_full(name, NULL, func, args, kargs)
851 855
852 def callback_del(self, name, func): 856 def callback_del(self, name, func):
853 """Remove a smart callback. 857 """Remove a smart callback.
@@ -861,7 +865,7 @@ cdef class SmartObject(Object):
861 865
862 :raise ValueError: if there was no **func** connected with this event. 866 :raise ValueError: if there was no **func** connected with this event.
863 """ 867 """
864 self._callback_del_full(name, None, func) 868 self._callback_del_full(name, NULL, func)
865 869
866 def callback_call(self, name, event_info=None): 870 def callback_call(self, name, event_info=None):
867 """Call any smart callbacks for event. 871 """Call any smart callbacks for event.
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index 0ce1d16..4f9bb19 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -44,7 +44,7 @@ items = [
44 ("Evas Object Callbacks", "test_core_evas_object_callbacks", 44 ("Evas Object Callbacks", "test_core_evas_object_callbacks",
45 "core_evas_object_callbacks_clicked"), 45 "core_evas_object_callbacks_clicked"),
46 ("Evas Textgrid", "test_evas_textgrid", "evas_textgrid_clicked"), 46 ("Evas Textgrid", "test_evas_textgrid", "evas_textgrid_clicked"),
47 # ("Evas Smart Object","test_core_evas_smart","core_evas_smart_clicked"), 47 ("Evas Smart Object","test_core_evas_smart","core_evas_smart_clicked"),
48 ]), 48 ]),
49 ("3D", [ 49 ("3D", [
50 ("Evas Map 3D", "test_3d", "evas3d_clicked"), 50 ("Evas Map 3D", "test_3d", "evas3d_clicked"),
diff --git a/examples/elementary/test_genlist.py b/examples/elementary/test_genlist.py
index 6b14eb0..bc9c907 100644
--- a/examples/elementary/test_genlist.py
+++ b/examples/elementary/test_genlist.py
@@ -160,9 +160,9 @@ def genlist_clicked(obj, item=None):
160 gli.tooltip_content_cb_set(tooltip_content_cb) 160 gli.tooltip_content_cb_set(tooltip_content_cb)
161 161
162 if i == 50: 162 if i == 50:
163 bt_50._callback_add("clicked", lambda bt, it: it.bring_in(), gli) 163 bt_50.callback_clicked_add(lambda bt, it: it.bring_in(), gli)
164 elif i == 1500: 164 elif i == 1500:
165 bt_1500._callback_add("clicked", lambda bt, it: it.bring_in(), gli) 165 bt_1500.callback_clicked_add(lambda bt, it: it.bring_in(), gli)
166 166
167 win.resize(480, 800) 167 win.resize(480, 800)
168 win.show() 168 win.show()
@@ -793,7 +793,7 @@ def genlist11_clicked(obj, item=None):
793 gl.item_append(itc11, i) 793 gl.item_append(itc11, i)
794 bx.pack_end(gl) 794 bx.pack_end(gl)
795 gl.show() 795 gl.show()
796 796
797 win.show() 797 win.show()
798 798
799if __name__ == "__main__": 799if __name__ == "__main__":
diff --git a/include/efl.evas.pxd b/include/efl.evas.pxd
index 6eebd65..2f1c94f 100644
--- a/include/efl.evas.pxd
+++ b/include/efl.evas.pxd
@@ -15,6 +15,7 @@
15# You should have received a copy of the GNU Lesser General Public License 15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>. 16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
17 17
18from cpython cimport PyObject
18from efl.eina cimport * 19from efl.eina cimport *
19from efl.eo cimport Eo 20from efl.eo cimport Eo
20from efl.c_eo cimport Eo as cEo, Eo_Class 21from efl.c_eo cimport Eo as cEo, Eo_Class
@@ -1204,12 +1205,16 @@ cdef class Textblock(Object):
1204 pass 1205 pass
1205 1206
1206 1207
1208# cdef extern from *:
1209# ctypedef object(*Smart_Conv_Func)(void *)
1210
1211
1207cdef class SmartObject(Object): 1212cdef class SmartObject(Object):
1208 cdef: 1213 cdef:
1209 list _owned_references 1214 list _owned_references
1210 int _set_obj(self, cEo *obj) except 0 1215 int _set_obj(self, cEo *obj) except 0
1211 int _callback_add_full(self, event, event_conv, func, tuple args, dict kargs) except 0 1216 int _callback_add_full(self, event, object(*)(void*), func, tuple args, dict kargs) except 0
1212 int _callback_del_full(self, event, event_conv, func) except 0 1217 int _callback_del_full(self, event, object(*)(void*), func) except 0
1213 int _callback_add(self, event, func, args, kargs) except 0 1218 int _callback_add(self, event, func, args, kargs) except 0
1214 int _callback_del(self, event, func) except 0 1219 int _callback_del(self, event, func) except 0
1215 1220