~jconti/recent-notifications/trunk

« back to all changes in this revision

Viewing changes to tests/test_pixbuf.py

  • Committer: Jason Conti
  • Date: 2011-05-18 21:17:09 UTC
  • Revision ID: jason.conti@gmail.com-20110518211709-inr5d289rvcabeor
Removing the indicator directory. indicator-notifications is now hosted at lp:recent-notifications/indicator. Also cleaned up the root directory a bit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""
2
 
test_pixbuf.py
3
 
 
4
 
Loads a pixbuf from a file, and sends it as data in a notification.
5
 
"""
6
 
 
7
 
import gtk
8
 
import os
9
 
import pynotify
10
 
import sys
11
 
 
12
 
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
13
 
ICON_PATH = os.path.join(SCRIPT_PATH, "..", "icons")
14
 
 
15
 
def main():
16
 
  if len(sys.argv) < 2:
17
 
    icon = os.path.join(ICON_PATH, "recent-notifications.svg")
18
 
  else:
19
 
    icon = os.path.join(ICON_PATH, sys.argv[1])
20
 
 
21
 
  if not pynotify.init("test_pixbuf"):
22
 
    print "Failed to initialize notifications."
23
 
    sys.exit(1)
24
 
 
25
 
  n = pynotify.Notification("TestPixbuf",
26
 
      "This is a test, this is only a test.")
27
 
 
28
 
  pixbuf = gtk.gdk.pixbuf_new_from_file(icon)
29
 
 
30
 
  n.set_icon_from_pixbuf(pixbuf)
31
 
 
32
 
  if not n.show():
33
 
    print "Failed to send notification."
34
 
    sys.exit(1)
35
 
 
36
 
if __name__ == "__main__":
37
 
  main()