libbonboui and gnome_program_init



Hi Michael,
	It seemed a bit backward to me to have bonobo_ui_init calling
gnome_program_init so I hacked up a patch to add GnomeModuleInfo
support to libbonoboui.

	May I commit?

Cheers,
Mark.
Index: libbonoboui/ChangeLog
===================================================================
RCS file: /cvs/gnome/libbonoboui/ChangeLog,v
retrieving revision 1.129
diff -u -p -r1.129 ChangeLog
--- libbonoboui/ChangeLog	2001/09/26 08:24:19	1.129
+++ libbonoboui/ChangeLog	2001/09/28 11:58:22
@@ -1,3 +1,18 @@
+2001-09-28  Mark McLoughlin  <mark skynet ie>
+
+	* bonobo/bonobo-ui-main.[ch]
+	(bonobo_ui_post_args_parse, bonobo_ui_module_info_get,
+	 GNOME_BONOBO_UI_MODULE): implement GnomeModuleInfo stuff.
+	(bonobo_ui_init): Add docs and deprecation warning.
+	(bonobo_ui_init_full): only bonobo_init if full_init
+	if #TRUE. Add docs and deprecation warning.
+
+	* samples/bonoboui-hello/main.c, tests/test-filesel.c,
+	  tests/test-focus.c, tests/test-reparent.c,
+	  tests/test-selector.c, tests/test-sensitivity.c,
+	  tests/test-toolbar.c, tests/test-ui.c: use
+	gnome_program_init instead of bonobo_ui_init.
+
 2001-09-27  Michael Meeks  <michael ximian com>
 
 	* Version 1.103
Index: libbonoboui/bonobo/bonobo-ui-main.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/bonobo/bonobo-ui-main.c,v
retrieving revision 1.9
diff -u -p -r1.9 bonobo-ui-main.c
--- libbonoboui/bonobo/bonobo-ui-main.c	2001/09/07 15:14:45	1.9
+++ libbonoboui/bonobo/bonobo-ui-main.c	2001/09/28 11:58:22
@@ -19,6 +19,7 @@
 #include <libgnome/gnome-init.h>
 
 #include <gtk/gtkmain.h>
+#include <gtk/gtkversion.h>
 
 #include <X11/Xlib.h>
 
@@ -87,6 +88,21 @@ bonobo_ui_is_initialized (void)
 	return bonobo_ui_inited;
 }
 
+
+/**
+ * bonobo_ui_init:
+ * @app_name: the application name.
+ * @app_version: the application version.
+ * @argc: a pointer to the number of arguments
+ * @argv: the array of arguments
+ *
+ * Initializes the bonobo UI component model.
+ *
+ * Note: This is deprecated - please gnome_program_init with 
+ *       GNOME_BONOBO_UI_MODULE.
+ *
+ * Returns %TRUE on success, or %FALSE on failure.
+ */
 gboolean
 bonobo_ui_init (const gchar *app_name, const gchar *app_version,
 		int *argc, char **argv)
@@ -95,6 +111,27 @@ bonobo_ui_init (const gchar *app_name, c
 				    NULL, NULL, NULL, TRUE);
 }
 
+/**
+ * bonobo_init_full:
+ * @app_name: the application name.
+ * @app_version: the application version.
+ * @argc: a pointer to the number of arguments
+ * @argv: the array of arguments
+ * @opt_orb: the ORB in which we run
+ * @opt_poa: optional, a POA
+ * @opt_manager: optional, a POA Manager
+ * @full_init: whether to initialise bonoboui's dependancies.
+ *
+ * Initializes the bonobo UI document model.
+ *
+ * This method should not be invoked directly from an application
+ * with @full_init set to #TRUE.
+ * 
+ * Note: This is deprecated - please gnome_program_init with 
+ *       GNOME_BONOBO_UI_MODULE.
+ *
+ * Returns %TRUE on success, or %FALSE on failure.
+ */
 gboolean
 bonobo_ui_init_full (const gchar *app_name, const gchar *app_version,
 		     int *argc, char **argv, CORBA_ORB orb,
@@ -106,18 +143,15 @@ bonobo_ui_init_full (const gchar *app_na
 	else
 		bonobo_ui_inited = TRUE;
 
-	if (!bonobo_init (argc, argv))
-		return FALSE;
-
 	g_set_prgname (app_name);
 
 	if (full_init) {
-		/*
-		 * Initialize all our dependencies.
-		 */
-		gnome_program_init (
-			app_name, app_version, libgnome_module_info_get (),
-			*argc, argv, NULL);
+		if (!bonobo_init (argc, argv))
+			return FALSE;
+
+		gnome_program_init (app_name, app_version, LIBGNOME_MODULE,
+				    *argc, argv, NULL);
+
 	}
 
 	gtk_init (argc, &argv);
@@ -125,4 +159,52 @@ bonobo_ui_init_full (const gchar *app_na
 	bonobo_setup_x_error_handler ();
 
 	return TRUE;
+}
+
+static void
+bonobo_ui_post_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
+{
+	int    dumb_argc = 1;
+	char  *dumb_argv[] = {NULL};
+
+	dumb_argv [0] = g_get_prgname ();
+
+	bonobo_ui_init_full (dumb_argv [0], NULL, &dumb_argc, dumb_argv,
+			     NULL, NULL, NULL, FALSE);
+}
+
+/**
+ * libgnome_module_info_get:
+ *
+ * Retrieves the current bonoboui version and the modules it depends on.
+ *
+ * Returns: a new #GnomeModuleInfo structure describing bonoboui 
+ *          and its the versions of the dependents.
+ */
+const GnomeModuleInfo *
+bonobo_ui_module_info_get (void)
+{
+	static GnomeModuleInfo module_info = {
+		"bonoboui", VERSION, N_("Bonobo UI Support"),
+		NULL, NULL,
+		NULL, bonobo_ui_post_args_parse,
+		NULL, NULL, NULL, NULL, NULL
+	};
+
+	if (module_info.requirements == NULL) {
+		static GnomeModuleRequirement req [3];
+
+		req [0].required_version = "1.101.2";
+		req [0].module_info = GNOME_BONOBO_MODULE;
+
+		req [1].required_version = "1.102.0";
+		req [1].module_info = LIBGNOME_MODULE;
+
+		req [2].required_version = NULL;
+		req [2].module_info = NULL;
+
+		module_info.requirements = req;
+	}
+
+	return &module_info;
 }
Index: libbonoboui/bonobo/bonobo-ui-main.h
===================================================================
RCS file: /cvs/gnome/libbonoboui/bonobo/bonobo-ui-main.h,v
retrieving revision 1.2
diff -u -p -r1.2 bonobo-ui-main.h
--- libbonoboui/bonobo/bonobo-ui-main.h	2001/07/17 17:05:55	1.2
+++ libbonoboui/bonobo/bonobo-ui-main.h	2001/09/28 11:58:22
@@ -14,8 +14,14 @@
 #define __BONOBO_UI_MAIN_H__ 1
 
 #include <bonobo/bonobo-main.h>
+#include <libgnome/gnome-init.h>
 
 G_BEGIN_DECLS
+
+#define GNOME_BONOBO_UI_MODULE bonobo_ui_module_info_get ()
+
+const GnomeModuleInfo *
+           bonobo_ui_module_info_get    (void) G_GNUC_CONST;
 
 gboolean   bonobo_ui_is_initialized     (void);
 gboolean   bonobo_ui_init               (const gchar *app_name,
Index: libbonoboui/samples/bonoboui-hello/main.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/samples/bonoboui-hello/main.c,v
retrieving revision 1.4
diff -u -p -r1.4 main.c
--- libbonoboui/samples/bonoboui-hello/main.c	2001/09/15 12:33:14	1.4
+++ libbonoboui/samples/bonoboui-hello/main.c	2001/09/28 11:58:22
@@ -75,13 +75,15 @@ main(int argc, char* argv[])
 {
   /*** gnomehello-parsing */
   GtkWidget* app;
+  GnomeProgram *gnome_hello;
 
   //GnomeClient* client;
   bindtextdomain(PACKAGE, GNOMELOCALEDIR);  
   textdomain(PACKAGE);
 
-  if (!bonobo_ui_init_full ("BonoboUI-Hello", VERSION, &argc, argv, NULL, NULL, NULL, TRUE))
-	  g_error (_("Cannot init libbonoboui code"));
+  gnome_hello = gnome_program_init("BonoboUI-Hello", VERSION, GNOME_BONOBO_UI_MODULE,
+				   argc, argv,
+				   GNOME_PARAM_POPT_TABLE, options, NULL);
 
   /* Argument parsing */
   //args = poptGetArgs(pctx);
Index: libbonoboui/tests/test-filesel.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/tests/test-filesel.c,v
retrieving revision 1.1
diff -u -p -r1.1 test-filesel.c
--- libbonoboui/tests/test-filesel.c	2001/08/24 16:38:56	1.1
+++ libbonoboui/tests/test-filesel.c	2001/09/28 11:58:22
@@ -53,8 +53,9 @@ main (int argc, char *argv[])
 
 	textdomain (PACKAGE);
 
-	if (!bonobo_ui_init ("test-filesel", VERSION, &argc, argv))
-		g_error (_("Cannot bonobo_ui_init ()"));
+	if (!gnome_program_init ("test-filesel", VERSION, GNOME_BONOBO_UI_MODULE,
+				 argc, argv, NULL))
+		g_error (_("Cannot gnome_program_init ()"));
 
 	bonobo_activate ();
 
Index: libbonoboui/tests/test-focus.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/tests/test-focus.c,v
retrieving revision 1.4
diff -u -p -r1.4 test-focus.c
--- libbonoboui/tests/test-focus.c	2001/08/14 18:11:26	1.4
+++ libbonoboui/tests/test-focus.c	2001/09/28 11:58:22
@@ -35,8 +35,9 @@ main (int argc, char **argv)
 
 	textdomain (PACKAGE);
 
-	if (!bonobo_ui_init ("test-focus", VERSION, &argc, argv))
-		g_error (_("Can not bonobo_ui_init"));
+        if (!gnome_program_init ("test-focus", VERSION, GNOME_BONOBO_UI_MODULE,
+                                 argc, argv, NULL))
+                g_error (_("Cannot gnome_program_init ()"));
 
 	orb = bonobo_orb ();
 
Index: libbonoboui/tests/test-reparent.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/tests/test-reparent.c,v
retrieving revision 1.6
diff -u -p -r1.6 test-reparent.c
--- libbonoboui/tests/test-reparent.c	2001/07/17 17:05:56	1.6
+++ libbonoboui/tests/test-reparent.c	2001/09/28 11:58:22
@@ -96,10 +96,10 @@ quit_cb (GtkWindow *window, GdkEvent *ev
 int
 main (int argc, char **argv)
 {
-	if (bonobo_ui_init ("test-reparent", VERSION, &argc, argv) == FALSE) {
-		g_error ("Bigger problems than controls not working");
-		exit (0);
-	}
+
+        if (!gnome_program_init ("test-reparent", VERSION, GNOME_BONOBO_UI_MODULE,
+                                 argc, argv, NULL))
+                g_error (_("Cannot gnome_program_init ()"));
 
 	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 	vbox = gtk_vbox_new (FALSE, 0);
Index: libbonoboui/tests/test-selector.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/tests/test-selector.c,v
retrieving revision 1.22
diff -u -p -r1.22 test-selector.c
--- libbonoboui/tests/test-selector.c	2001/09/07 14:27:56	1.22
+++ libbonoboui/tests/test-selector.c	2001/09/28 11:58:22
@@ -7,7 +7,9 @@ main (int argc, char *argv[])
 {
 	gchar *text;
 
-	bonobo_ui_init ("BonoboSelector Test", VERSION, &argc, argv);
+	gnome_program_init ("BonoboSelector Test", VERSION, 
+			    GNOME_BONOBO_UI_MODULE,
+			    argc, argv, NULL);
 
 	text = bonobo_selector_select_id (_("Select an object"), NULL);
 	g_print ("OAFIID: '%s'\n", text ? text : "<Null>");
Index: libbonoboui/tests/test-sensitivity.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/tests/test-sensitivity.c,v
retrieving revision 1.5
diff -u -p -r1.5 test-sensitivity.c
--- libbonoboui/tests/test-sensitivity.c	2001/07/31 00:30:25	1.5
+++ libbonoboui/tests/test-sensitivity.c	2001/09/28 11:58:22
@@ -189,8 +189,10 @@ main (int argc, char **argv)
 	/* Encorage -lefence to play ball */
 	{ char *tmp = malloc (4); if (tmp) free (tmp); }
 
-	if (!bonobo_ui_init ("test-sensitivity", VERSION, &argc, argv))
-		g_error (_("Can not bonobo_ui_init"));
+	if (!gnome_program_init ("test-sensitivity", VERSION, 
+				 GNOME_BONOBO_UI_MODULE,
+				 argc, argv, NULL))
+		g_error (_("Cannot gnome_program_init ()"));
 
 	orb = bonobo_orb ();
 
Index: libbonoboui/tests/test-toolbar.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/tests/test-toolbar.c,v
retrieving revision 1.3
diff -u -p -r1.3 test-toolbar.c
--- libbonoboui/tests/test-toolbar.c	2001/05/01 17:27:53	1.3
+++ libbonoboui/tests/test-toolbar.c	2001/09/28 11:58:22
@@ -46,8 +46,10 @@ main (int argc, char **argv)
 	/* ElectricFence rules. */
 	free (malloc (1));
 
-	if (!bonobo_ui_init ("test-toolbar", VERSION, &argc, argv))
-		g_error (_("Can not bonobo_ui_init"));
+        if (!gnome_program_init ("test-toolbar", VERSION,
+                                 GNOME_BONOBO_UI_MODULE,
+                                 argc, argv, NULL))
+                g_error (_("Cannot gnome_program_init ()"));
 
 	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
Index: libbonoboui/tests/test-ui.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/tests/test-ui.c,v
retrieving revision 1.72
diff -u -p -r1.72 test-ui.c
--- libbonoboui/tests/test-ui.c	2001/09/06 06:21:57	1.72
+++ libbonoboui/tests/test-ui.c	2001/09/28 11:58:22
@@ -225,9 +225,10 @@ main (int argc, char **argv)
 
 	free (malloc (8));
 
-	if (!bonobo_ui_init_full ("test-ui", VERSION, &argc, argv,
-				  NULL, NULL, NULL, TRUE))
-		g_error (_("Cannot init libbonoboui code"));
+	if (!gnome_program_init ("BonoboUI-Hello", VERSION, 
+				 GNOME_BONOBO_UI_MODULE,
+				 argc, argv, NULL))
+		g_error (_("Cannot gnome_program_init ()"));
 
 	textdomain (PACKAGE);
 


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