summaryrefslogtreecommitdiff
path: root/efl/elementary
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-03-24 09:05:40 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2015-03-24 09:05:40 +0200
commit73b54938c696be49098edf1fd54126d18edb8e32 (patch)
tree8c5d7df46ae6e7a0db80d3f5bd90fa74c8cf40ba /efl/elementary
parentaaaa3a143848324c03b647155fe295de4a2d05aa (diff)
Elm.Naviframe: Add item_pop_cb, missing event_info for events
Diffstat (limited to 'efl/elementary')
-rw-r--r--efl/elementary/naviframe.pxd3
-rw-r--r--efl/elementary/naviframe.pyx67
2 files changed, 48 insertions, 22 deletions
diff --git a/efl/elementary/naviframe.pxd b/efl/elementary/naviframe.pxd
index 8afc192..a88495b 100644
--- a/efl/elementary/naviframe.pxd
+++ b/efl/elementary/naviframe.pxd
@@ -2,6 +2,8 @@ from efl.evas cimport Evas_Object, Eina_Bool, Eina_List
2from object_item cimport Elm_Object_Item 2from object_item cimport Elm_Object_Item
3 3
4cdef extern from "Elementary.h": 4cdef extern from "Elementary.h":
5 ctypedef Eina_Bool (*Elm_Naviframe_Item_Pop_Cb)(void *data, Elm_Object_Item *it)
6
5 Evas_Object *elm_naviframe_add(Evas_Object *parent) 7 Evas_Object *elm_naviframe_add(Evas_Object *parent)
6 Elm_Object_Item *elm_naviframe_item_push(Evas_Object *obj, const char *title_label, Evas_Object *prev_btn, Evas_Object *next_btn, Evas_Object *content, const char *item_style) 8 Elm_Object_Item *elm_naviframe_item_push(Evas_Object *obj, const char *title_label, Evas_Object *prev_btn, Evas_Object *next_btn, Evas_Object *content, const char *item_style)
7 Elm_Object_Item *elm_naviframe_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *title_label, Evas_Object *prev_btn, Evas_Object *next_btn, Evas_Object *content, const char *item_style) 9 Elm_Object_Item *elm_naviframe_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *title_label, Evas_Object *prev_btn, Evas_Object *next_btn, Evas_Object *content, const char *item_style)
@@ -26,3 +28,4 @@ cdef extern from "Elementary.h":
26 Eina_Bool elm_naviframe_event_enabled_get(const Evas_Object *obj) 28 Eina_Bool elm_naviframe_event_enabled_get(const Evas_Object *obj)
27 Elm_Object_Item *elm_naviframe_item_simple_push(Evas_Object *obj, Evas_Object *content) 29 Elm_Object_Item *elm_naviframe_item_simple_push(Evas_Object *obj, Evas_Object *content)
28 void elm_naviframe_item_simple_promote(Evas_Object *obj, Evas_Object *content) 30 void elm_naviframe_item_simple_promote(Evas_Object *obj, Evas_Object *content)
31 void elm_naviframe_item_pop_cb_set(Elm_Object_Item *it, Elm_Naviframe_Item_Pop_Cb func, void *data)
diff --git a/efl/elementary/naviframe.pyx b/efl/elementary/naviframe.pyx
index 301c03f..4053adf 100644
--- a/efl/elementary/naviframe.pyx
+++ b/efl/elementary/naviframe.pyx
@@ -121,6 +121,28 @@ from object_item cimport _object_item_to_python, _object_item_list_to_python, \
121 121
122from efl.utils.deprecated cimport DEPRECATED 122from efl.utils.deprecated cimport DEPRECATED
123 123
124import traceback
125
126cdef object _cb_object_item_conv(void *addr):
127 return _object_item_to_python(<Elm_Object_Item *>addr)
128
129cdef Eina_Bool py_elm_naviframe_item_pop_cb(void *data, Elm_Object_Item *it):
130 cdef:
131 ObjectItem item = _object_item_to_python(it)
132 object func
133 tuple args
134 dict kwargs
135 bint ret
136
137 try:
138 func, args, kwargs = item.pop_cb_spec
139 ret = func(*args, **kwargs)
140 except Exception:
141 traceback.print_exc()
142
143 return ret
144
145
124cdef class NaviframeItem(ObjectItem): 146cdef class NaviframeItem(ObjectItem):
125 """ 147 """
126 148
@@ -133,6 +155,7 @@ cdef class NaviframeItem(ObjectItem):
133 Evas_Object *prev_btn 155 Evas_Object *prev_btn
134 Evas_Object *next_btn 156 Evas_Object *next_btn
135 Evas_Object *item_content 157 Evas_Object *item_content
158 tuple pop_cb_spec
136 159
137 def __cinit__(self): 160 def __cinit__(self):
138 self.prev_btn = NULL 161 self.prev_btn = NULL
@@ -381,30 +404,30 @@ cdef class NaviframeItem(ObjectItem):
381 elm_naviframe_item_title_enabled_set(self.item, enabled, transition) 404 elm_naviframe_item_title_enabled_set(self.item, enabled, transition)
382 405
383 def title_enabled_set(self, enabled, transition): 406 def title_enabled_set(self, enabled, transition):
384 """title_enabled_set(self, enabled, transition) 407 elm_naviframe_item_title_enabled_set(self.item, enabled, transition)
385
386 Enable/Disable the title area with transition effect.
387 408
388 :param enabled: if `True`, title area will be visible, hidden otherwise. 409 def title_enabled_get(self):
389 :type enabled: bool 410 return bool(elm_naviframe_item_title_enabled_get(self.item))
390 :param transition: if `True`, transition effect of the title will be visible.
391 :type transition: bool
392 411
393 .. versionadded:: 1.9 412 def pop_cb_set(self, func, *args, **kwargs):
413 """Set a function to be called when the item is going to be popped.
394 414
395 """ 415 :param func: the callback function.
396 elm_naviframe_item_title_enabled_set(self.item, enabled, transition)
397 416
398 def title_enabled_get(self): 417 .. warning::
399 """
400 418
401 :return: `True` if the title is visible. 419 Don't set "clicked" callback to the prev button additionally if the
402 :rtype: bool 420 function does an exact same logic with this ``func``. When hardware
421 back key is pressed then both callbacks will be called.
403 422
404 .. versionadded:: 1.9 423 .. versionadded:: 1.14
405 424
406 """ 425 """
407 return bool(elm_naviframe_item_title_enabled_get(self.item)) 426 if not callable(func):
427 raise ValueError("func must be callable!")
428
429 self.pop_cb_spec = (func, args, kwargs)
430 elm_naviframe_item_pop_cb_set(self.item, py_elm_naviframe_item_pop_cb, NULL)
408 431
409 432
410cdef class Naviframe(LayoutClass): 433cdef class Naviframe(LayoutClass):
@@ -572,24 +595,24 @@ cdef class Naviframe(LayoutClass):
572 595
573 def callback_transition_finished_add(self, func, *args, **kwargs): 596 def callback_transition_finished_add(self, func, *args, **kwargs):
574 """When the transition is finished in changing the item.""" 597 """When the transition is finished in changing the item."""
575 self._callback_add("transition,finished", func, args, kwargs) 598 self._callback_add_full("transition,finished", _cb_object_item_conv, func, args, kwargs)
576 599
577 def callback_transition_finished_del(self, func): 600 def callback_transition_finished_del(self, func):
578 self._callback_del("transition,finished", func) 601 self._callback_del_full("transition,finished", _cb_object_item_conv, func)
579 602
580 def callback_title_transition_finished_add(self, func, *args, **kwargs): 603 def callback_title_transition_finished_add(self, func, *args, **kwargs):
581 """When the title transition is finished.""" 604 """When the title transition is finished."""
582 self._callback_add("title,transition,finished", func, args, kwargs) 605 self._callback_add_full("title,transition,finished", _cb_object_item_conv, func, args, kwargs)
583 606
584 def callback_title_transition_finished_del(self, func): 607 def callback_title_transition_finished_del(self, func):
585 self._callback_del("title,transition,finished", func) 608 self._callback_del_full("title,transition,finished", _cb_object_item_conv, func)
586 609
587 def callback_title_clicked_add(self, func, *args, **kwargs): 610 def callback_title_clicked_add(self, func, *args, **kwargs):
588 """User clicked title area.""" 611 """User clicked title area."""
589 self._callback_add("title,clicked", func, args, kwargs) 612 self._callback_add_full("title,clicked", _cb_object_item_conv, func, args, kwargs)
590 613
591 def callback_title_clicked_del(self, func): 614 def callback_title_clicked_del(self, func):
592 self._callback_del("title,clicked", func) 615 self._callback_del_full("title,clicked", _cb_object_item_conv, func)
593 616
594 def callback_focused_add(self, func, *args, **kwargs): 617 def callback_focused_add(self, func, *args, **kwargs):
595 """When the naviframe has received focus. 618 """When the naviframe has received focus.