summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-05-29 01:39:09 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2014-05-29 01:39:09 +0300
commit9ba009c46ad797eee1a78e698bbcb41ab5528296 (patch)
tree05c722b02608379886a49b6d1c100eb7082e3ae0
parent045f45bfb7226c632045f67ac9f22e9212d9aeb9 (diff)
Elementary: Add an example for sys_notify
-rwxr-xr-xexamples/elementary/test.py3
-rw-r--r--examples/elementary/test_sys_notify.py92
2 files changed, 95 insertions, 0 deletions
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index 30e3df6..462885f 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -202,6 +202,9 @@ items = [
202 ("Stored Surface Buffer", [ 202 ("Stored Surface Buffer", [
203 ("Launcher", "test_mapbuf", "mapbuf_clicked"), 203 ("Launcher", "test_mapbuf", "mapbuf_clicked"),
204 ]), 204 ]),
205 ("System", [
206 ("Notification", "test_sys_notify", "sys_notify_clicked"),
207 ]),
205 ("Text", [ 208 ("Text", [
206 ("Label", "test_label", "label_clicked"), 209 ("Label", "test_label", "label_clicked"),
207 ]), 210 ]),
diff --git a/examples/elementary/test_sys_notify.py b/examples/elementary/test_sys_notify.py
new file mode 100644
index 0000000..f0a0812
--- /dev/null
+++ b/examples/elementary/test_sys_notify.py
@@ -0,0 +1,92 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
5from efl import elementary
6from efl.elementary.window import StandardWindow
7from efl.elementary.box import Box
8from efl.elementary.button import Button
9from efl.elementary.notify import Notify
10from efl.elementary.label import Label
11from efl.elementary.entry import Entry, utf8_to_markup
12from efl.elementary.need import need_sys_notify
13from efl.elementary.general import on_sys_notify_action_invoked, \
14 on_sys_notify_notification_closed, sys_notify_send
15from efl.ecore import ECORE_CALLBACK_DONE
16
17EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
18EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
19FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
20FILL_HORIZ = EVAS_HINT_FILL, 0.5
21
22
23def _ev_handler(event, l, n):
24 print(event)
25 l.text = utf8_to_markup(str(event))
26 n.show()
27
28 return ECORE_CALLBACK_DONE
29
30
31def _bt_clicked(obj, s, b):
32 sys_notify_send(icon="", summary=s.entry, body=b.entry)
33
34
35def sys_notify_clicked(obj):
36
37 if not need_sys_notify():
38 raise SystemExit("Sys notify not available")
39
40 win = StandardWindow(
41 "sys_notify", "Sys notify test", autodel=True, size=(320, 160)
42 )
43 if obj is None:
44 win.callback_delete_request_add(lambda o: elementary.exit())
45
46 bx = Box(win, size_hint_weight=EXPAND_BOTH)
47 win.resize_object_add(bx)
48 bx.show()
49
50 l = Label(win)
51 l.show()
52
53 n = Notify(
54 win, size_hint_weight=EXPAND_BOTH, align=(0.5, 0.0), timeout=2.0,
55 content=l
56 )
57
58 on_sys_notify_action_invoked(_ev_handler, l, n)
59 on_sys_notify_notification_closed(_ev_handler, l, n)
60
61 bx = Box(win, size_hint_weight=EXPAND_BOTH)
62 win.resize_object_add(bx)
63 bx.show()
64
65 s = Entry(
66 win, single_line=True, scrollable=True, entry="Summary",
67 size_hint_align=FILL_BOTH
68 )
69 bx.pack_end(s)
70 s.show()
71
72 b = Entry(
73 win, single_line=True, scrollable=True, entry="Body long description.",
74 size_hint_align=FILL_BOTH
75 )
76 bx.pack_end(b)
77 b.show()
78
79 it = Button(win, text="Send Notification")
80 it.callback_clicked_add(_bt_clicked, s, b)
81 bx.pack_end(it)
82 it.show()
83
84 win.show()
85
86if __name__ == "__main__":
87 elementary.init()
88
89 sys_notify_clicked(None)
90
91 elementary.run()
92 elementary.shutdown()