summaryrefslogtreecommitdiff
path: root/efl/eo
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2016-03-04 11:07:51 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2016-03-04 11:10:11 +0200
commit05c19962dc966f4ca1d64435ad29c7f9d49ef170 (patch)
tree3e35fde81866efbe66dd2d7a995d4a397a7211ff /efl/eo
parentfea03a787c706f5d179910e0b06b4c95ed84ff67 (diff)
Follow changes in Eo
- version 4 (eo_add changes coming later) - events
Diffstat (limited to 'efl/eo')
-rw-r--r--efl/eo/efl.eo.pyx62
1 files changed, 22 insertions, 40 deletions
diff --git a/efl/eo/efl.eo.pyx b/efl/eo/efl.eo.pyx
index 391c4a7..aa5bbaf 100644
--- a/efl/eo/efl.eo.pyx
+++ b/efl/eo/efl.eo.pyx
@@ -36,15 +36,15 @@ from efl.eina cimport Eina_Bool, \
36 Eina_Hash, eina_hash_string_superfast_new, eina_hash_add, eina_hash_del, \ 36 Eina_Hash, eina_hash_string_superfast_new, eina_hash_add, eina_hash_del, \
37 eina_hash_find, EINA_LOG_DOM_DBG, EINA_LOG_DOM_INFO, \ 37 eina_hash_find, EINA_LOG_DOM_DBG, EINA_LOG_DOM_INFO, \
38 Eina_Iterator, eina_iterator_next, eina_iterator_free 38 Eina_Iterator, eina_iterator_next, eina_iterator_free
39from efl.c_eo cimport Eo as cEo, eo_init, eo_shutdown, eo_del, eo_do, \ 39from efl.c_eo cimport Eo as cEo, eo_init, eo_shutdown, eo_del, \
40 eo_do_ret, eo_class_name_get, eo_class_get, eo_base_class_get,\ 40 eo_class_name_get, eo_class_get, eo_base_class_get,\
41 eo_key_data_set, eo_key_data_get, eo_key_data_del, \ 41 eo_key_data_set, eo_key_data_get, eo_key_data_del, \
42 eo_event_callback_add, eo_event_callback_del, EO_EV_DEL, \ 42 eo_event_callback_add, eo_event_callback_del, EO_EV_DEL, \
43 eo_parent_get, eo_parent_set, Eo_Event_Description, \ 43 eo_parent_get, eo_parent_set, Eo_Event_Description, \
44 eo_event_freeze, eo_event_thaw, eo_event_freeze_count_get, \ 44 eo_event_freeze, eo_event_thaw, eo_event_freeze_count_get, \
45 eo_event_global_freeze, eo_event_global_thaw, \ 45 eo_event_global_freeze, eo_event_global_thaw, \
46 eo_event_global_freeze_count_get, EO_CALLBACK_STOP, \ 46 eo_event_global_freeze_count_get, EO_CALLBACK_STOP, \
47 eo_children_iterator_new 47 eo_children_iterator_new, Eo_Event2
48 48
49from efl.utils.logger cimport add_logger 49from efl.utils.logger cimport add_logger
50 50
@@ -71,18 +71,13 @@ init()
71atexit.register(shutdown) 71atexit.register(shutdown)
72 72
73def event_global_freeze_count_get(): 73def event_global_freeze_count_get():
74 cdef int fcount = 0 74 return eo_event_global_freeze_count_get(<const cEo *>eo_base_class_get())
75 fcount = <int>eo_do_ret(<const cEo *>eo_base_class_get(), fcount,
76 eo_event_global_freeze_count_get())
77 return fcount
78 75
79def event_global_freeze(): 76def event_global_freeze():
80 eo_do(<const cEo *>eo_base_class_get(), 77 eo_event_global_freeze(<const cEo *>eo_base_class_get())
81 eo_event_global_freeze())
82 78
83def event_global_thaw(): 79def event_global_thaw():
84 eo_do(<const cEo *>eo_base_class_get(), 80 eo_event_global_thaw(<const cEo *>eo_base_class_get())
85 eo_event_global_thaw())
86 81
87###################################################################### 82######################################################################
88 83
@@ -125,7 +120,7 @@ cdef api object object_from_instance(cEo *obj):
125 if obj == NULL: 120 if obj == NULL:
126 return None 121 return None
127 122
128 data = eo_do_ret(obj, data, eo_key_data_get("python-eo")) 123 data = eo_key_data_get(obj, "python-eo")
129 if data != NULL: 124 if data != NULL:
130 EINA_LOG_DOM_DBG(PY_EFL_EO_LOG_DOMAIN, 125 EINA_LOG_DOM_DBG(PY_EFL_EO_LOG_DOMAIN,
131 "Returning a Python object instance for Eo of type %s.", cls_name) 126 "Returning a Python object instance for Eo of type %s.", cls_name)
@@ -187,18 +182,15 @@ cdef void _register_decorated_callbacks(Eo obj):
187###################################################################### 182######################################################################
188 183
189 184
190cdef Eina_Bool _eo_event_del_cb(void *data, cEo *obj, 185cdef Eina_Bool _eo_event_del_cb(void *data, const Eo_Event2 *event) with gil:
191 const Eo_Event_Description *desc,
192 void *event_info) with gil:
193 cdef: 186 cdef:
194 Eo self = <Eo>data 187 Eo self = <Eo>data
195 const char *cls_name = eo_class_name_get(eo_class_get(obj)) 188 const char *cls_name = eo_class_name_get(eo_class_get(self.obj))
196 189
197 EINA_LOG_DOM_DBG(PY_EFL_EO_LOG_DOMAIN, "Deleting Eo: %s", cls_name) 190 EINA_LOG_DOM_DBG(PY_EFL_EO_LOG_DOMAIN, "Deleting Eo: %s", cls_name)
198 191
199 eo_do(self.obj, 192 eo_event_callback_del(self.obj, EO_EV_DEL, _eo_event_del_cb, <const void *>self)
200 eo_event_callback_del(EO_EV_DEL, _eo_event_del_cb, <const void *>self)) 193 eo_key_data_del(self.obj, "python-eo")
201 eo_do(self.obj, eo_key_data_del("python-eo"))
202 self.obj = NULL 194 self.obj = NULL
203 Py_DECREF(self) 195 Py_DECREF(self)
204 196
@@ -244,7 +236,7 @@ cdef class Eo(object):
244 def __repr__(self): 236 def __repr__(self):
245 cdef cEo *parent = NULL 237 cdef cEo *parent = NULL
246 if self.obj != NULL: 238 if self.obj != NULL:
247 parent = <cEo *>eo_do_ret(self.obj, parent, eo_parent_get()) 239 parent = eo_parent_get(self.obj)
248 return ("<%s object (Eo) at %#x (obj=%#x, parent=%#x, refcount=%d)>") % ( 240 return ("<%s object (Eo) at %#x (obj=%#x, parent=%#x, refcount=%d)>") % (
249 type(self).__name__, 241 type(self).__name__,
250 <uintptr_t><void *>self, 242 <uintptr_t><void *>self,
@@ -260,9 +252,8 @@ cdef class Eo(object):
260 assert obj != NULL, "Cannot set a NULL object" 252 assert obj != NULL, "Cannot set a NULL object"
261 253
262 self.obj = obj 254 self.obj = obj
263 eo_do(self.obj, eo_key_data_set("python-eo", <void *>self)) 255 eo_key_data_set(self.obj, "python-eo", <void *>self)
264 eo_do(self.obj, 256 eo_event_callback_add(self.obj, EO_EV_DEL, _eo_event_del_cb, <const void *>self)
265 eo_event_callback_add(EO_EV_DEL, _eo_event_del_cb, <const void *>self))
266 Py_INCREF(self) 257 Py_INCREF(self)
267 258
268 return 1 259 return 1
@@ -274,10 +265,7 @@ cdef class Eo(object):
274 return 1 265 return 1
275 266
276 def __iter__(self): 267 def __iter__(self):
277 cdef: 268 return EoIterator.create(eo_children_iterator_new(self.obj))
278 void *tmp = NULL
279 eo_do_ret(self.obj, tmp, eo_children_iterator_new())
280 return EoIterator.create(<Eina_Iterator *>tmp)
281 269
282 def delete(self): 270 def delete(self):
283 """Delete the object and free internal resources. 271 """Delete the object and free internal resources.
@@ -305,28 +293,24 @@ cdef class Eo(object):
305 293
306 """ 294 """
307 def __set__(self, Eo parent): 295 def __set__(self, Eo parent):
308 eo_do(self.obj, eo_parent_set(parent.obj)) 296 eo_parent_set(self.obj, parent.obj)
309 297
310 def __get__(self): 298 def __get__(self):
311 cdef cEo *parent = NULL 299 return object_from_instance(eo_parent_get(self.obj))
312 parent = <cEo *>eo_do_ret(self.obj, parent, eo_parent_get())
313 return object_from_instance(parent)
314 300
315 def parent_set(self, Eo parent): 301 def parent_set(self, Eo parent):
316 eo_do(self.obj, eo_parent_set(parent.obj)) 302 eo_parent_set(self.obj, parent.obj)
317 303
318 def parent_get(self): 304 def parent_get(self):
319 cdef cEo *parent = NULL 305 return object_from_instance(eo_parent_get(self.obj))
320 parent = <cEo *>eo_do_ret(self.obj, parent, eo_parent_get())
321 return object_from_instance(parent)
322 306
323 def event_freeze(self): 307 def event_freeze(self):
324 """Pause event propagation for this object.""" 308 """Pause event propagation for this object."""
325 eo_do(self.obj, eo_event_freeze()) 309 eo_event_freeze(self.obj)
326 310
327 def event_thaw(self): 311 def event_thaw(self):
328 """Restart event propagation for this object.""" 312 """Restart event propagation for this object."""
329 eo_do(self.obj, eo_event_thaw()) 313 eo_event_thaw(self.obj)
330 314
331 def event_freeze_count_get(self): 315 def event_freeze_count_get(self):
332 """Get the event freeze count for this object. 316 """Get the event freeze count for this object.
@@ -335,6 +319,4 @@ cdef class Eo(object):
335 :rtype: int 319 :rtype: int
336 320
337 """ 321 """
338 cdef int fcount = 0 322 return eo_event_freeze_count_get(self.obj)
339 fcount = <int>eo_do_ret(self.obj, fcount, eo_event_freeze_count_get())
340 return fcount