Debian Codegraph @

tests/test-gir.py

raw
1 #!/usr/bin/python
2
3 # @file tests/test-gir.py Unit test: Test GI repository
4 #
5 # @Copyright (C) 2010 Canonical Ltd.
6 # Author: Martin Pitt <[email protected]>
7 #
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
12 #
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the
20 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 # Boston, MA 02111-1307, USA.
22
23 import os
24
25 # use our local typelib
26 os.environ['GI_TYPELIB_PATH'] = 'libnotify:' + os.environ.get('GI_TYPELIB_PATH', '')
27
28 from gi.repository import Notify
29
30 assert Notify.is_initted() == False
31 Notify.init('test')
32 assert Notify.is_initted() == True
33
34 print 'server info:', Notify.get_server_info()
35 print 'server capabilities:', Notify.get_server_caps()
36
37 n = Notify.Notification.new('title', None, None)
38 n.show()
39 n = Notify.Notification.new('title', 'text', None)
40 n.show()
41 n = Notify.Notification.new('title', 'text', 'gtk-ok')
42 n.show()
43
44 n.update('New Title', None, None)
45 n.show()
46 n.update('Newer Title', 'New Body', None)
47 n.show()
48
49 def callback():
50 print 'Do it! Callback'
51
52 n = Notify.Notification.new('Action', 'Here we go!', 'gtk-alert')
53 n.add_action('doit', 'Do it!', callback, None, None)
54 n.show()
55