blob: 885d227797d08fcb9cdd8e0c3bbcd734d6ec8bf9 (
plain)
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
|
#!/usr/bin/python
# A test for libdbusmenu to ensure its quality. This is the Python GI version
# of test-gtk-shortcut-client.c
#
# Copyright 2011 Canonical Ltd.
# Authors:
# Martin Pitt <martin.pitt@ubuntu.com>
import sys
import gobject
from gi.repository import Gtk, DbusmenuGtk
Gtk.require_version('2.0')
passed = True
main_loop = gobject.MainLoop()
def timer_func(data):
passed = True
main_loop.quit()
return False
# main
print 'Building Window'
window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
menubar = Gtk.MenuBar()
menuitem = Gtk.MenuItem(label='Test')
dmenu = DbusmenuGtk.Menu(dbus_name='glib.label.test', dbus_object='/org/test')
dclient = dmenu.get_client()
agroup = Gtk.AccelGroup()
dclient.set_accel_group(agroup)
menuitem.set_submenu(dmenu)
menuitem.show()
menubar.append(menuitem)
menubar.show()
window.add(menubar)
window.set_title('libdbusmenu-gtk test')
window.add_accel_group(agroup)
window.show_all()
gobject.timeout_add_seconds(10, timer_func, window)
print 'Entering Mainloop'
main_loop.run()
if passed:
print 'Quiting'
else:
print "Quiting as we're a failure"
sys.exit(1)
|