[PATCH] Make components quit



Hello bonobo loving people
Obviously the most important component needs to be working right, so here's a
patch to make the gnomines component count the number of running objects and
quit when there's none left, like a good bonobo component should.

enjoy
iain

Index: bonobo-application-x-mines.c
===================================================================
RCS file: /cvs/gnome/bonobo/components/application-x-gnomine/bonobo-application-x-mines.c,v
retrieving revision 1.14
diff -U2 -r1.14 bonobo-application-x-mines.c
--- bonobo-application-x-mines.c	2000/05/05 13:37:15	1.14
+++ bonobo-application-x-mines.c	2000/05/13 00:24:00
@@ -22,4 +22,10 @@
 #include "minefield.h"
 
+/*
+ * Number of running objects
+ */
+static int running_objects = 0;
+static BonoboEmbeddableFactory *factory = NULL;
+
 typedef struct {
 	BonoboEmbeddable     *embeddable;
@@ -291,4 +297,14 @@
 	
 	g_free (embeddable_data); 
+
+	running_objects--;
+	if (running_objects > 0)
+		return;
+	
+	/*
+	 * When the last object has gone, unref the factory & quit.
+	 */
+	bonobo_object_unref (BONOBO_OBJECT (factory));
+	gtk_main_quit ();
 }
 
@@ -464,4 +480,9 @@
 
 	/*
+	 * Count the new running object
+	 */
+	running_objects++;
+
+	/*
 	 * If the Embeddable encounters a fatal CORBA exception, it
 	 * will emit a "system_exception" signal, notifying us that
@@ -489,5 +510,4 @@
 init_simple_mines_factory (void)
 {
-	BonoboEmbeddableFactory *factory;
 #if USING_OAF
 	factory = bonobo_embeddable_factory_new (





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]