Skeleton of GNOME buildbot applet.
authorTim Potter <tpot@hp.com>
Tue, 8 Apr 2008 06:24:29 +0000 (16:24 +1000)
committerTim Potter <tpot@hp.com>
Tue, 8 Apr 2008 06:24:29 +0000 (16:24 +1000)
Run with command line arg 'run-in-window' to avoid having to muck around with
bonobo for testing.

bbapplet [new file with mode: 0755]

diff --git a/bbapplet b/bbapplet
new file mode 100755 (executable)
index 0000000..b60ada4
--- /dev/null
+++ b/bbapplet
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+
+import pygtk
+pygtk.require('2.0')
+
+from twisted.internet import gtk2reactor
+gtk2reactor.install()
+
+from twisted.internet import reactor
+
+import sys, gtk, gnomeapplet, pynotify
+
+class BuildbotApplet:
+      
+      def __init__(self, applet, icon):
+        applet.add(icon)
+        applet.show_all()
+
+def BuildbotApplet_factory(applet, iid):
+
+    pynotify.init("bbapplet")
+
+    icon = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU)
+    BuildbotApplet(applet, icon)
+
+    return gtk.TRUE
+
+if __name__ == "__main__":
+    
+    if len(sys.argv) == 2 and sys.argv[1] == "run-in-window":
+
+        # Run in a window, for debugging
+
+        main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+        main_window.set_title("buildbot applet")
+        main_window.connect('destroy', gtk.main_quit)
+
+        app = gnomeapplet.Applet()
+
+        BuildbotApplet_factory(app, None)
+
+        app.reparent(main_window)
+
+        main_window.show_all()
+        reactor.run()
+
+    else:
+
+        # Run as bonobo component
+
+        reactor.startRunning()
+        reactor.simulate()
+
+        gnome.applet.bonobo_factory("OAFIID:GNOME_BuildbotApplet_Factory",
+                                    gnome.applet.Applet.__gtype__,
+                                    "bbapplet", "0", BuildbotApplet_factory)