File: test-gir.py

package info (click to toggle)
libnotify 0.7.6-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,116 kB
  • ctags: 437
  • sloc: sh: 11,088; ansic: 2,402; xml: 1,255; makefile: 263; python: 23
file content (55 lines) | stat: -rwxr-xr-x 1,693 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python

# @file tests/test-gir.py Unit test: Test GI repository
#
# @Copyright (C) 2010 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA  02111-1307, USA.

import os

# use our local typelib
os.environ['GI_TYPELIB_PATH'] = 'libnotify:' + os.environ.get('GI_TYPELIB_PATH', '')

from gi.repository import Notify

assert Notify.is_initted() == False
Notify.init('test')
assert Notify.is_initted() == True

print 'server info:', Notify.get_server_info()
print 'server capabilities:', Notify.get_server_caps()

n = Notify.Notification.new('title', None, None)
n.show()
n = Notify.Notification.new('title', 'text', None)
n.show()
n = Notify.Notification.new('title', 'text', 'gtk-ok')
n.show()

n.update('New Title', None, None)
n.show()
n.update('Newer Title', 'New Body', None)
n.show()

def callback():
    print 'Do it! Callback'

n = Notify.Notification.new('Action', 'Here we go!', 'gtk-alert')
n.add_action('doit', 'Do it!', callback, None, None)
n.show()