summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-02-26 09:43:15 +0100
committerDave Andreoli <dave@gurumeditation.it>2017-02-26 09:43:15 +0100
commit6f92607ba4dd1f1fc922fa23daf7adea781a3cfa (patch)
treeb34f6e615ecd9b18214c4f87452b4d4235d9058e
parentf76e2729901ab880a4aa709c6789b94cf05af59f (diff)
New 1.19 API: elm.Panel "toggled" signal
with test
-rw-r--r--doc/elementary/panel.rst5
-rw-r--r--efl/elementary/panel.pxi10
-rw-r--r--examples/elementary/test_panel.py26
3 files changed, 39 insertions, 2 deletions
diff --git a/doc/elementary/panel.rst b/doc/elementary/panel.rst
index 3c2da1e..d3629ad 100644
--- a/doc/elementary/panel.rst
+++ b/doc/elementary/panel.rst
@@ -14,6 +14,11 @@ A panel is a type of animated container that contains subobjects.
14It can be expanded or contracted by clicking the button on it's edge. 14It can be expanded or contracted by clicking the button on it's edge.
15 15
16 16
17Emitted signals
18===============
19
20- ``toggled`` - Emitted when the panel has been toggled. (since 1.19)
21
17 22
18Layout content parts 23Layout content parts
19==================== 24====================
diff --git a/efl/elementary/panel.pxi b/efl/elementary/panel.pxi
index cbaf47b..ab65b61 100644
--- a/efl/elementary/panel.pxi
+++ b/efl/elementary/panel.pxi
@@ -118,5 +118,15 @@ cdef class Panel(LayoutClass):
118 """Toggle the hidden state of the panel from code.""" 118 """Toggle the hidden state of the panel from code."""
119 elm_panel_toggle(self.obj) 119 elm_panel_toggle(self.obj)
120 120
121 def callback_toggled_add(self, func, *args, **kwargs):
122 """ The panel has been toggled.
123
124 .. versionadded:: 1.19
125
126 """
127 self._callback_add("toggled", func, args, kwargs)
128
129 def callback_toggled_del(self, func):
130 self._callback_del("toggled", func)
121 131
122_object_mapping_register("Elm.Panel", Panel) 132_object_mapping_register("Elm.Panel", Panel)
diff --git a/examples/elementary/test_panel.py b/examples/elementary/test_panel.py
index cba098c..87e886e 100644
--- a/examples/elementary/test_panel.py
+++ b/examples/elementary/test_panel.py
@@ -21,6 +21,20 @@ from efl.elementary.toolbar import Toolbar, ELM_TOOLBAR_SHRINK_NONE
21script_path = os.path.dirname(os.path.abspath(__file__)) 21script_path = os.path.dirname(os.path.abspath(__file__))
22img_file = os.path.join(script_path, "images", "plant_01.jpg") 22img_file = os.path.join(script_path, "images", "plant_01.jpg")
23 23
24
25def toolbar_item_clicked_cb(toolbar, item, win):
26 p = win.data["panel1"]
27 print("The top panel is currently %s" % ("hidden" if p.hidden else "shown"))
28 p = win.data["panel2"]
29 print("The left panel is currently %s" % ("hidden" if p.hidden else "shown"))
30 p = win.data["panel3"]
31 print("The right panel is currently %s" % ("hidden" if p.hidden else "shown"))
32 p = win.data["panel4"]
33 print("The bottom panel is currently %s" % ("hidden" if p.hidden else "shown"))
34
35def panel_toggled_cb(panel):
36 print("Panel toggled")
37
24def panel_clicked(obj): 38def panel_clicked(obj):
25 win = StandardWindow("panel", "Panel test", autodel=True, size=(320, 400)) 39 win = StandardWindow("panel", "Panel test", autodel=True, size=(320, 400))
26 if obj is None: 40 if obj is None:
@@ -33,12 +47,14 @@ def panel_clicked(obj):
33 # top panel (toolbar content) 47 # top panel (toolbar content)
34 panel1 = Panel(bx, orient=ELM_PANEL_ORIENT_TOP, 48 panel1 = Panel(bx, orient=ELM_PANEL_ORIENT_TOP,
35 size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) 49 size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
50 panel1.callback_toggled_add(panel_toggled_cb)
36 bx.pack_end(panel1) 51 bx.pack_end(panel1)
37 panel1.show() 52 panel1.show()
53 win.data['panel1'] = panel1
38 54
39 toolbar = Toolbar(panel1, homogeneous=False, 55 toolbar = Toolbar(panel1, homogeneous=False,
40 shrink_mode=ELM_TOOLBAR_SHRINK_NONE) 56 shrink_mode=ELM_TOOLBAR_SHRINK_NONE)
41 toolbar.item_append("user-home", "Hello Toolbar") 57 toolbar.item_append("user-home", "Hello", toolbar_item_clicked_cb, win)
42 panel1.content = toolbar 58 panel1.content = toolbar
43 toolbar.show() 59 toolbar.show()
44 60
@@ -55,6 +71,7 @@ def panel_clicked(obj):
55 # left panel (list content) 71 # left panel (list content)
56 panel2 = Panel(table, orient=ELM_PANEL_ORIENT_LEFT, 72 panel2 = Panel(table, orient=ELM_PANEL_ORIENT_LEFT,
57 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) 73 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
74 panel2.callback_toggled_add(panel_toggled_cb)
58 table.pack(panel2, 0, 0, 2, 4) 75 table.pack(panel2, 0, 0, 2, 4)
59 panel2.show() 76 panel2.show()
60 77
@@ -64,12 +81,15 @@ def panel_clicked(obj):
64 li.item_append("Item #%d" % i, ic) 81 li.item_append("Item #%d" % i, ic)
65 panel2.content = li 82 panel2.content = li
66 li.show() 83 li.show()
84 win.data['panel2'] = panel2
67 85
68 # right panel (button content) 86 # right panel (button content)
69 panel3 = Panel(table, orient=ELM_PANEL_ORIENT_RIGHT, hidden=True, 87 panel3 = Panel(table, orient=ELM_PANEL_ORIENT_RIGHT, hidden=True,
70 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) 88 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
89 panel3.callback_toggled_add(panel_toggled_cb)
71 table.pack(panel3, 2, 0, 2, 4); 90 table.pack(panel3, 2, 0, 2, 4);
72 panel3.show() 91 panel3.show()
92 win.data['panel3'] = panel3
73 93
74 bt = Button(panel3, text="HIDE ME :)", size_hint_weight=EXPAND_BOTH, 94 bt = Button(panel3, text="HIDE ME :)", size_hint_weight=EXPAND_BOTH,
75 size_hint_align=FILL_BOTH) 95 size_hint_align=FILL_BOTH)
@@ -80,13 +100,15 @@ def panel_clicked(obj):
80 # bottom panel (toolbar content) 100 # bottom panel (toolbar content)
81 panel4 = Panel(table, orient=ELM_PANEL_ORIENT_BOTTOM, hidden=True, 101 panel4 = Panel(table, orient=ELM_PANEL_ORIENT_BOTTOM, hidden=True,
82 size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) 102 size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
103 panel4.callback_toggled_add(panel_toggled_cb)
83 table.pack(panel4, 0, 4, 4, 1) 104 table.pack(panel4, 0, 4, 4, 1)
84 panel4.show() 105 panel4.show()
106 win.data['panel4'] = panel4
85 107
86 toolbar = Toolbar(panel4, homogeneous=False, 108 toolbar = Toolbar(panel4, homogeneous=False,
87 shrink_mode=ELM_TOOLBAR_SHRINK_NONE, 109 shrink_mode=ELM_TOOLBAR_SHRINK_NONE,
88 size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) 110 size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
89 toolbar.item_append("user-home", "Hello Toolbar") 111 toolbar.item_append(None, "Hello", toolbar_item_clicked_cb, win)
90 panel4.content = toolbar 112 panel4.content = toolbar
91 toolbar.show() 113 toolbar.show()
92 114