| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
import sys |
| 11 |
import gobject |
| 12 |
from gi.repository import Gtk, DbusmenuGtk |
| 13 |
Gtk.require_version('2.0') |
| 14 |
|
| 15 |
passed = True |
| 16 |
main_loop = gobject.MainLoop() |
| 17 |
|
| 18 |
def timer_func(data): |
| 19 |
passed = True |
| 20 |
main_loop.quit() |
| 21 |
return False |
| 22 |
|
| 23 |
|
| 24 |
print 'Building Window' |
| 25 |
window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL) |
| 26 |
menubar = Gtk.MenuBar() |
| 27 |
menuitem = Gtk.MenuItem(label='Test') |
| 28 |
|
| 29 |
dmenu = DbusmenuGtk.Menu(dbus_name='glib.label.test', dbus_object='/org/test') |
| 30 |
dclient = dmenu.get_client() |
| 31 |
agroup = Gtk.AccelGroup() |
| 32 |
dclient.set_accel_group(agroup) |
| 33 |
|
| 34 |
menuitem.set_submenu(dmenu) |
| 35 |
menuitem.show() |
| 36 |
menubar.append(menuitem) |
| 37 |
menubar.show() |
| 38 |
window.add(menubar) |
| 39 |
window.set_title('libdbusmenu-gtk test') |
| 40 |
window.add_accel_group(agroup) |
| 41 |
window.show_all() |
| 42 |
|
| 43 |
gobject.timeout_add_seconds(10, timer_func, window) |
| 44 |
|
| 45 |
print 'Entering Mainloop' |
| 46 |
main_loop.run() |
| 47 |
|
| 48 |
if passed: |
| 49 |
print 'Quiting' |
| 50 |
else: |
| 51 |
print "Quiting as we're a failure" |
| 52 |
sys.exit(1) |