summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-02-27 20:23:02 +0100
committerDave Andreoli <dave@gurumeditation.it>2017-02-27 20:23:02 +0100
commit9c00cbb0fe13ad51ded206a54462841fe54508bc (patch)
treee3a2550452dc4dd30ecae67863f7a66d765fa475
parent18e2d9c102dd6ee8251eb643105ea888a6b93ae1 (diff)
New 1.19 API: elm.Naviframe "item,activated" cb
with test refactor/reformat
-rw-r--r--doc/elementary/naviframe.rst1
-rw-r--r--efl/elementary/naviframe.pxi11
-rwxr-xr-xexamples/elementary/test.py2
-rw-r--r--examples/elementary/test_naviframe.py46
4 files changed, 35 insertions, 25 deletions
diff --git a/doc/elementary/naviframe.rst b/doc/elementary/naviframe.rst
index 8292caa..e8cdcd2 100644
--- a/doc/elementary/naviframe.rst
+++ b/doc/elementary/naviframe.rst
@@ -65,6 +65,7 @@ Emitted signals
65- ``transition,finished`` - When the transition is finished in changing the item 65- ``transition,finished`` - When the transition is finished in changing the item
66- ``title,transition,finished`` - When the title area's transition is finished 66- ``title,transition,finished`` - When the title area's transition is finished
67- ``title,clicked`` - User clicked title area 67- ``title,clicked`` - User clicked title area
68- ``item,activated`` - Naviframe item was activated (since 1.19)
68 69
69All the parts, for content and text, described here will also be 70All the parts, for content and text, described here will also be
70reachable by naviframe **items** direct calls: 71reachable by naviframe **items** direct calls:
diff --git a/efl/elementary/naviframe.pxi b/efl/elementary/naviframe.pxi
index a90ae8f..57e4314 100644
--- a/efl/elementary/naviframe.pxi
+++ b/efl/elementary/naviframe.pxi
@@ -502,5 +502,16 @@ cdef class Naviframe(LayoutClass):
502 def callback_title_clicked_del(self, func): 502 def callback_title_clicked_del(self, func):
503 self._callback_del_full("title,clicked", _cb_object_item_conv, func) 503 self._callback_del_full("title,clicked", _cb_object_item_conv, func)
504 504
505 def callback_item_activated_add(self, func, *args, **kwargs):
506 """ Naviframe item was activated
507
508 .. versionadded:: 1.19
509
510 """
511 self._callback_add_full("item,activated", _cb_object_item_conv, func, args, kwargs)
512
513 def callback_item_activated_del(self, func):
514 self._callback_del_full("item,activated", _cb_object_item_conv, func)
515
505 516
506_object_mapping_register("Elm.Naviframe", Naviframe) 517_object_mapping_register("Elm.Naviframe", Naviframe)
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index 3192006..260bde1 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -200,7 +200,7 @@ items = [
200 ("Themes", "test_theme", "theme_clicked"), 200 ("Themes", "test_theme", "theme_clicked"),
201 ]), 201 ]),
202 ("Naviframe", [ 202 ("Naviframe", [
203 ("Naviframe", "test_naviframe", "naviframe_clicked"), 203 ("Naviframe", "test_naviframe", "test_naviframe"),
204 ]), 204 ]),
205 ("Popups", [ 205 ("Popups", [
206 ("Ctxpopup", "test_ctxpopup", "ctxpopup_clicked"), 206 ("Ctxpopup", "test_ctxpopup", "ctxpopup_clicked"),
diff --git a/examples/elementary/test_naviframe.py b/examples/elementary/test_naviframe.py
index 9cfa75a..a3c6f47 100644
--- a/examples/elementary/test_naviframe.py
+++ b/examples/elementary/test_naviframe.py
@@ -3,14 +3,9 @@
3 3
4import os 4import os
5 5
6from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, EXPAND_BOTH, FILL_BOTH 6from efl import elementary as elm
7from efl import elementary 7from efl.elementary import StandardWindow, Box, Button, Icon, Naviframe, Photo
8from efl.elementary.window import StandardWindow 8from efl.evas import EXPAND_BOTH, FILL_BOTH
9from efl.elementary.box import Box
10from efl.elementary.button import Button
11from efl.elementary.icon import Icon
12from efl.elementary.naviframe import Naviframe
13from efl.elementary.photo import Photo
14 9
15 10
16script_path = os.path.dirname(os.path.abspath(__file__)) 11script_path = os.path.dirname(os.path.abspath(__file__))
@@ -29,7 +24,7 @@ def page2(bt, nf):
29 bt.callback_clicked_add(page3, nf) 24 bt.callback_clicked_add(page3, nf)
30 25
31 content = Photo(nf, file=os.path.join(img_path, "plant_01.jpg"), 26 content = Photo(nf, file=os.path.join(img_path, "plant_01.jpg"),
32 fill_inside=True, style="shadow") 27 fill_inside=True, style="shadow")
33 28
34 item = nf.item_push("Page 2", None, bt, content, "basic") 29 item = nf.item_push("Page 2", None, bt, content, "basic")
35 item.part_text_set("subtitle", "Here is sub-title part!") 30 item.part_text_set("subtitle", "Here is sub-title part!")
@@ -42,7 +37,7 @@ def page3(bt, nf):
42 bt2.callback_clicked_add(page4, nf) 37 bt2.callback_clicked_add(page4, nf)
43 38
44 content = Photo(nf, file=os.path.join(img_path, "rock_01.jpg"), 39 content = Photo(nf, file=os.path.join(img_path, "rock_01.jpg"),
45 fill_inside=True, style="shadow") 40 fill_inside=True, style="shadow")
46 41
47 item = nf.item_push("Page 3", bt, bt2, content, "basic") 42 item = nf.item_push("Page 3", bt, bt2, content, "basic")
48 43
@@ -55,7 +50,7 @@ def page4(bt, nf):
55 bt.callback_clicked_add(page5, nf) 50 bt.callback_clicked_add(page5, nf)
56 51
57 content = Photo(nf, file=os.path.join(img_path, "rock_02.jpg"), 52 content = Photo(nf, file=os.path.join(img_path, "rock_02.jpg"),
58 fill_inside=True, style="shadow") 53 fill_inside=True, style="shadow")
59 54
60 item = nf.item_push("Page 4", None, bt, content, "basic") 55 item = nf.item_push("Page 4", None, bt, content, "basic")
61 ic = Icon(nf, file=os.path.join(img_path, "logo_small.png")) 56 ic = Icon(nf, file=os.path.join(img_path, "logo_small.png"))
@@ -73,7 +68,7 @@ def page5(bt, nf):
73 bt2.callback_clicked_add(page6, nf) 68 bt2.callback_clicked_add(page6, nf)
74 69
75 content = Photo(nf, file=os.path.join(img_path, "sky_01.jpg"), 70 content = Photo(nf, file=os.path.join(img_path, "sky_01.jpg"),
76 fill_inside=True, style="shadow") 71 fill_inside=True, style="shadow")
77 72
78 item = nf.item_insert_after(nf.top_item_get(), "Page 5", bt, bt2, content, "basic") 73 item = nf.item_insert_after(nf.top_item_get(), "Page 5", bt, bt2, content, "basic")
79 item.part_text_set("subtitle", "This page is inserted without transition") 74 item.part_text_set("subtitle", "This page is inserted without transition")
@@ -86,7 +81,7 @@ def page6(bt, nf):
86 bt2.callback_clicked_add(page7, nf) 81 bt2.callback_clicked_add(page7, nf)
87 82
88 content = Photo(nf, file=os.path.join(img_path, "sky_03.jpg"), 83 content = Photo(nf, file=os.path.join(img_path, "sky_03.jpg"),
89 fill_inside=True, style="shadow") 84 fill_inside=True, style="shadow")
90 85
91 item = nf.item_push("Page 6", bt, bt2, content, "overlap") 86 item = nf.item_push("Page 6", bt, bt2, content, "overlap")
92 item.part_text_set("subtitle", "Overlap style!") 87 item.part_text_set("subtitle", "Overlap style!")
@@ -99,20 +94,24 @@ def page7(bt, nf):
99 bt2.callback_clicked_add(lambda x: nf.data["page1"].promote()) 94 bt2.callback_clicked_add(lambda x: nf.data["page1"].promote())
100 95
101 content = Photo(nf, file=os.path.join(img_path, "sky_02.jpg"), 96 content = Photo(nf, file=os.path.join(img_path, "sky_02.jpg"),
102 fill_inside=True, style="shadow") 97 fill_inside=True, style="shadow")
103 98
104 item = nf.item_push("Page 7", bt, bt2, content, "overlap") 99 item = nf.item_push("Page 7", bt, bt2, content, "overlap")
105 item.part_text_set("subtitle", "Overlap style!") 100 item.part_text_set("subtitle", "Overlap style!")
106 101
107 102
108def naviframe_clicked(obj): 103def push_pop_cb(nf, item, signal):
109 win = StandardWindow("naviframe", "Naviframe test", autodel=True, 104 print("Signal: '%s' on item: %s " % (signal, item))
110 size=(400, 400)) 105
106
107def test_naviframe(obj):
108 win = StandardWindow("naviframe", "Naviframe test",
109 autodel=True, size=(400, 400))
111 win.focus_highlight_enabled = True 110 win.focus_highlight_enabled = True
112 if obj is None:
113 win.callback_delete_request_add(lambda o: elementary.exit())
114 111
115 nf = Naviframe(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) 112 nf = Naviframe(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
113 nf.callback_transition_finished_add(push_pop_cb, "transition,finished")
114 nf.callback_item_activated_add(push_pop_cb, "item,activated")
116 win.resize_object_add(nf) 115 win.resize_object_add(nf)
117 nf.show() 116 nf.show()
118 117
@@ -120,7 +119,7 @@ def naviframe_clicked(obj):
120 bt.callback_clicked_add(page2, nf) 119 bt.callback_clicked_add(page2, nf)
121 120
122 content = Photo(nf, file=os.path.join(img_path, "logo.png"), 121 content = Photo(nf, file=os.path.join(img_path, "logo.png"),
123 fill_inside=True, style="shadow") 122 fill_inside=True, style="shadow")
124 123
125 item = nf.item_push("Page 1", None, bt, content, "basic") 124 item = nf.item_push("Page 1", None, bt, content, "basic")
126 nf.data["page1"] = item 125 nf.data["page1"] = item
@@ -129,7 +128,6 @@ def naviframe_clicked(obj):
129 128
130 129
131if __name__ == "__main__": 130if __name__ == "__main__":
132 131 elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
133 naviframe_clicked(None) 132 test_naviframe(None)
134 133 elm.run()
135 elementary.run()