NotificationDevelopmentGuidelines
Attachment 'icon-summary-body.py'
Download 1 #!/usr/bin/python
2
3 ################################################################################
4 ##3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
5 ## 10 20 30 40 50 60 70 80
6 ##
7 ## Info:
8 ## Example of how to use libnotify correctly and at the same time comply to
9 ## the new jaunty notification spec (read: visual guidelines)
10 ##
11 ## Run:
12 ## chmod +x icon-summary-body.py
13 ## ./icon-summary-body.py
14 ##
15 ## Copyright 2009 Canonical Ltd.
16 ##
17 ## Author:
18 ## Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
19 ##
20 ## This program is free software: you can redistribute it and/or modify it
21 ## under the terms of the GNU General Public License version 3, as published
22 ## by the Free Software Foundation.
23 ##
24 ## This program is distributed in the hope that it will be useful, but
25 ## WITHOUT ANY WARRANTY; without even the implied warranties of
26 ## MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
27 ## PURPOSE. See the GNU General Public License for more details.
28 ##
29 ## You should have received a copy of the GNU General Public License along
30 ## with this program. If not, see <http://www.gnu.org/licenses/>.
31 ##
32 ################################################################################
33
34 import sys
35 import pynotify
36
37 # even in Python this is globally nasty :), do something nicer in your own code
38 capabilities = {'actions': False,
39 'body': False,
40 'body-hyperlinks': False,
41 'body-images': False,
42 'body-markup': False,
43 'icon-multi': False,
44 'icon-static': False,
45 'sound': False,
46 'image/svg+xml': False,
47 'private-synchronous': False,
48 'append': False,
49 'private-icon-only': False}
50
51 def initCaps ():
52 caps = pynotify.get_server_caps ()
53 if caps is None:
54 print "Failed to receive server caps."
55 sys.exit (1)
56
57 for cap in caps:
58 capabilities[cap] = True
59
60 def printCaps ():
61 info = pynotify.get_server_info ()
62 print "Name: " + info["name"]
63 print "Vendor: " + info["vendor"]
64 print "Version: " + info["version"]
65 print "Spec. Version: " + info["spec-version"]
66
67 caps = pynotify.get_server_caps ()
68 if caps is None:
69 print "Failed to receive server caps."
70 sys.exit (1)
71
72 print "Supported capabilities/hints:"
73 if capabilities['actions']:
74 print "\tactions"
75 if capabilities['body']:
76 print "\tbody"
77 if capabilities['body-hyperlinks']:
78 print "\tbody-hyperlinks"
79 if capabilities['body-images']:
80 print "\tbody-images"
81 if capabilities['body-markup']:
82 print "\tbody-markup"
83 if capabilities['icon-multi']:
84 print "\ticon-multi"
85 if capabilities['icon-static']:
86 print "\ticon-static"
87 if capabilities['sound']:
88 print "\tsound"
89 if capabilities['image/svg+xml']:
90 print "\timage/svg+xml"
91 if capabilities['private-synchronous']:
92 print "\tprivate-synchronous"
93 if capabilities['append']:
94 print "\tappend"
95 if capabilities['private-icon-only']:
96 print "\tprivate-icon-only"
97
98 print "Notes:"
99 if info["name"] == "notify-osd":
100 print "\tx- and y-coordinates hints are ignored"
101 print "\texpire-timeout is ignored"
102 print "\tbody-markup is accepted but filtered"
103 else:
104 print "\tnone"
105
106 if __name__ == '__main__':
107 if not pynotify.init ("icon-summary-body"):
108 sys.exit (1)
109
110 # call this so we can savely use capabilities dictionary later
111 initCaps ()
112
113 # show what's supported
114 printCaps ()
115
116 # try the icon-summary-body case
117 n = pynotify.Notification ("Cole Raby",
118 "Hey pal, what's up with the party "
119 "next weekend? Will you join me "
120 "and Anna?",
121 "notification-message-im")
122 n.show ()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.