summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-06-01 17:43:11 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2014-06-01 17:43:11 +0300
commit59f2835f53b2bf45365f45d6c5c921a191d2317b (patch)
treea07fb363ff0163301cf94631803b015adbcb1857
parent4f702bc04d21aba5243a76acd21135bfba50e8f0 (diff)
Elementary.multibuttonentry: Inject a Python object to created items
-rw-r--r--efl/elementary/multibuttonentry.pyx48
1 files changed, 33 insertions, 15 deletions
diff --git a/efl/elementary/multibuttonentry.pyx b/efl/elementary/multibuttonentry.pyx
index 99fe720..a244c70 100644
--- a/efl/elementary/multibuttonentry.pyx
+++ b/efl/elementary/multibuttonentry.pyx
@@ -39,11 +39,14 @@ This widget emits the following signals, besides the ones sent from
39- ``item,selected`` - this is called when an item is selected by 39- ``item,selected`` - this is called when an item is selected by
40 api, user interaction, and etc. this is also called when a 40 api, user interaction, and etc. this is also called when a
41 user press back space while cursor is on the first field of 41 user press back space while cursor is on the first field of
42 entry. 42 entry. event_info contains the item.
43- ``item,added`` - when a new multi-button entry item is added. 43- ``item,added`` - when a new multi-button entry item is added.
44 event_info contains the item.
44- ``item,deleted`` - when a multi-button entry item is deleted. 45- ``item,deleted`` - when a multi-button entry item is deleted.
46 event_info contains the item.
45- ``item,clicked`` - this is called when an item is clicked by user 47- ``item,clicked`` - this is called when an item is clicked by user
46 interaction. Both "item,selected" and "item,clicked" are needed. 48 interaction. Both "item,selected" and "item,clicked" are needed.
49 event_info contains the item.
47- ``clicked`` - when multi-button entry is clicked. 50- ``clicked`` - when multi-button entry is clicked.
48- ``focused`` - when multi-button entry is focused. 51- ``focused`` - when multi-button entry is focused.
49- ``unfocused`` - when multi-button entry is unfocused. 52- ``unfocused`` - when multi-button entry is unfocused.
@@ -67,13 +70,18 @@ from libc.stdint cimport uintptr_t
67 70
68from efl.eo cimport _object_mapping_register, object_from_instance, PY_REFCOUNT 71from efl.eo cimport _object_mapping_register, object_from_instance, PY_REFCOUNT
69from efl.utils.conversions cimport _ctouni 72from efl.utils.conversions cimport _ctouni
70from efl.evas cimport Object as evasObject 73from efl.evas cimport Object as evasObject, evas_object_smart_callback_add
71 74
72from libc.string cimport strdup 75from libc.string cimport strdup
73from object cimport Object 76from object cimport Object
74import traceback 77import traceback
75from object_item cimport _object_item_callback, _object_item_callback2, \ 78from object_item cimport _object_item_callback, _object_item_callback2, \
76 _object_item_to_python, _object_item_list_to_python, ObjectItem 79 _object_item_to_python, _object_item_list_to_python, ObjectItem, \
80 elm_object_item_data_get
81
82def _cb_object_item_conv(uintptr_t addr):
83 cdef Elm_Object_Item *it = <Elm_Object_Item *>addr
84 return _object_item_to_python(it)
77 85
78cdef Eina_Bool _multibuttonentry_filter_callback(Evas_Object *obj, \ 86cdef Eina_Bool _multibuttonentry_filter_callback(Evas_Object *obj, \
79 const char *item_label, void *item_data, void *data) with gil: 87 const char *item_label, void *item_data, void *data) with gil:
@@ -235,17 +243,27 @@ cdef class MultiButtonEntryItem(ObjectItem):
235 def next_get(self): 243 def next_get(self):
236 return _object_item_to_python(elm_multibuttonentry_item_next_get(self.item)) 244 return _object_item_to_python(elm_multibuttonentry_item_next_get(self.item))
237 245
246cdef void _py_elm_mbe_item_added_cb(
247 void *data, Evas_Object *o, void *event_info) with gil:
248 cdef:
249 MultiButtonEntryItem it
250 Elm_Object_Item *item = <Elm_Object_Item *>event_info
251
252 if elm_object_item_data_get(item) == NULL:
253 it = MultiButtonEntryItem.__new__(MultiButtonEntryItem)
254 it._set_obj(item)
255
238cdef class MultiButtonEntry(Object): 256cdef class MultiButtonEntry(Object):
239 257
240 """This is the class that actually implements the widget.""" 258 """This is the class that actually implements the widget."""
241 259
242 def __init__(self, evasObject parent, *args, **kwargs): 260 def __init__(self, evasObject parent, *args, **kwargs):
243 self._set_obj(elm_multibuttonentry_add(parent.obj)) 261 self._set_obj(elm_multibuttonentry_add(parent.obj))
262 evas_object_smart_callback_add(
263 self.obj, "item,added",
264 _py_elm_mbe_item_added_cb, NULL
265 )
244 self._set_properties_from_keyword_args(kwargs) 266 self._set_properties_from_keyword_args(kwargs)
245 #
246 # TODO: Add callbacks for item added and item deleted, inject
247 # the python instance into Elm_Object_Item's data
248 #
249 267
250 property entry: 268 property entry:
251 """The Entry object child of the multibuttonentry. 269 """The Entry object child of the multibuttonentry.
@@ -470,28 +488,28 @@ cdef class MultiButtonEntry(Object):
470 Py_INCREF(cbdata) 488 Py_INCREF(cbdata)
471 489
472 def callback_item_selected_add(self, func, *args, **kwargs): 490 def callback_item_selected_add(self, func, *args, **kwargs):
473 self._callback_add("item,selected", func, *args, **kwargs) 491 self._callback_add_full("item,selected", _cb_object_item_conv, func, *args, **kwargs)
474 492
475 def callback_item_selected_del(self, func): 493 def callback_item_selected_del(self, func):
476 self._callback_del("item,selected", func) 494 self._callback_del_full("item,selected", _cb_object_item_conv, func)
477 495
478 def callback_item_added_add(self, func, *args, **kwargs): 496 def callback_item_added_add(self, func, *args, **kwargs):
479 self._callback_add("item,added", func, *args, **kwargs) 497 self._callback_add_full("item,added", _cb_object_item_conv, func, *args, **kwargs)
480 498
481 def callback_item_added_del(self, func): 499 def callback_item_added_del(self, func):
482 self._callback_del("item,added", func) 500 self._callback_del_full("item,added", _cb_object_item_conv, func)
483 501
484 def callback_item_deleted_add(self, func, *args, **kwargs): 502 def callback_item_deleted_add(self, func, *args, **kwargs):
485 self._callback_add("item,deleted", func, *args, **kwargs) 503 self._callback_add_full("item,deleted", _cb_object_item_conv, func, *args, **kwargs)
486 504
487 def callback_item_deleted_del(self, func): 505 def callback_item_deleted_del(self, func):
488 self._callback_del("item,deleted", func) 506 self._callback_del_full("item,deleted", _cb_object_item_conv, func)
489 507
490 def callback_item_clicked_add(self, func, *args, **kwargs): 508 def callback_item_clicked_add(self, func, *args, **kwargs):
491 self._callback_add("item,clicked", func, *args, **kwargs) 509 self._callback_add_full("item,clicked", _cb_object_item_conv, func, *args, **kwargs)
492 510
493 def callback_item_clicked_del(self, func): 511 def callback_item_clicked_del(self, func):
494 self._callback_del("item,clicked", func) 512 self._callback_del_full("item,clicked", _cb_object_item_conv, func)
495 513
496 def callback_clicked_add(self, func, *args, **kwargs): 514 def callback_clicked_add(self, func, *args, **kwargs):
497 self._callback_add("clicked", func, *args, **kwargs) 515 self._callback_add("clicked", func, *args, **kwargs)