Skeleton of GNOME buildbot applet.
[tpot/bbremote.git] / bbapplet
1 #!/usr/bin/python
2
3 import pygtk
4 pygtk.require('2.0')
5
6 from twisted.internet import gtk2reactor
7 gtk2reactor.install()
8
9 from twisted.internet import reactor
10
11 import sys, gtk, gnomeapplet, pynotify
12
13 class BuildbotApplet:
14       
15       def __init__(self, applet, icon):
16         applet.add(icon)
17         applet.show_all()
18
19 def BuildbotApplet_factory(applet, iid):
20
21     pynotify.init("bbapplet")
22
23     icon = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU)
24     BuildbotApplet(applet, icon)
25
26     return gtk.TRUE
27
28 if __name__ == "__main__":
29     
30     if len(sys.argv) == 2 and sys.argv[1] == "run-in-window":
31
32         # Run in a window, for debugging
33
34         main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
35         main_window.set_title("buildbot applet")
36         main_window.connect('destroy', gtk.main_quit)
37
38         app = gnomeapplet.Applet()
39
40         BuildbotApplet_factory(app, None)
41
42         app.reparent(main_window)
43
44         main_window.show_all()
45         reactor.run()
46
47     else:
48
49         # Run as bonobo component
50
51         reactor.startRunning()
52         reactor.simulate()
53
54         gnome.applet.bonobo_factory("OAFIID:GNOME_BuildbotApplet_Factory",
55                                     gnome.applet.Applet.__gtype__,
56                                     "bbapplet", "0", BuildbotApplet_factory)