[monkey-bubble: 583/753] Initialize the config databases in an idle handler as this will improve



commit da88ef0e1f335d1273eb01a2777c15b4479e1c99
Author: Martin Baulig <baulig suse de>
Date:   Fri Aug 3 20:08:13 2001 +0000

    Initialize the config databases in an idle handler as this will improve
    
    2001-08-03  Martin Baulig  <baulig suse de>
    
    	* libgnome-init.c (libbonobo_post_args_parse): Initialize the
    	config databases in an idle handler as this will improve the
    	startup time of the application.

 libgnome/ChangeLog    |    6 +++
 libgnome/gnome-init.c |   96 ++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 77 insertions(+), 25 deletions(-)
---
diff --git a/libgnome/ChangeLog b/libgnome/ChangeLog
index a25f8b4..90a5ac4 100644
--- a/libgnome/ChangeLog
+++ b/libgnome/ChangeLog
@@ -1,5 +1,11 @@
 2001-08-03  Martin Baulig  <baulig suse de>
 
+	* libgnome-init.c (libbonobo_post_args_parse): Initialize the
+	config databases in an idle handler as this will improve the
+	startup time of the application.
+
+2001-08-03  Martin Baulig  <baulig suse de>
+
 	* Makefile.am: Create gnomesoundplugin_csl.la and install it
 	in $(libdir)/gnome-2.0/sound-plugins/ if we have CSL.
 
diff --git a/libgnome/gnome-init.c b/libgnome/gnome-init.c
index a7cd52d..63384c4 100644
--- a/libgnome/gnome-init.c
+++ b/libgnome/gnome-init.c
@@ -99,6 +99,8 @@ typedef struct {
 typedef struct {
 	gboolean constructed;
 
+	gchar *app_id;
+
 	gchar *config_moniker;
 	Bonobo_ConfigDatabase config_database;
 
@@ -109,15 +111,79 @@ typedef struct {
 static GQuark quark_gnome_program_private_libbonobo = 0;
 static GQuark quark_gnome_program_class_libbonobo = 0;
 
+static gboolean
+libbonobo_delay_init (GnomeProgramPrivate_libbonobo *priv)
+
+{
+	g_message (G_STRLOC ": %p", priv);
+
+	if (priv->constructed)
+	    return FALSE;
+
+	priv->constructed = TRUE;
+
+	if (priv->desktop_config_database == CORBA_OBJECT_NIL) {
+		CORBA_Environment ev;
+
+		g_message (G_STRLOC);
+
+		CORBA_exception_init (&ev);
+		priv->desktop_config_database = bonobo_get_object
+			(priv->desktop_config_moniker,
+			 "Bonobo/ConfigDatabase", &ev);
+		CORBA_exception_free (&ev);
+	}
+
+	if (priv->config_database == CORBA_OBJECT_NIL) {
+		CORBA_Environment ev;
+
+		g_message (G_STRLOC);
+
+		if (!priv->config_moniker)
+			priv->config_moniker = g_strdup_printf
+				("config:/gnome/%s/", priv->app_id);
+
+		g_message (G_STRLOC ": |%s|", priv->config_moniker);
+
+		CORBA_exception_init (&ev);
+		priv->config_database = bonobo_get_object
+			(priv->config_moniker, "Bonobo/ConfigDatabase", &ev);
+		CORBA_exception_free (&ev);
+	}
+
+	if ((priv->config_database != CORBA_OBJECT_NIL) &&
+	    (priv->desktop_config_database != CORBA_OBJECT_NIL)) {
+	    CORBA_Environment ev;
+
+	    CORBA_exception_init (&ev);
+	    Bonobo_ConfigDatabase_addDatabase
+		(priv->config_database,
+		 priv->desktop_config_database,
+		 "/Gnome/",
+		 Bonobo_ConfigDatabase_DEFAULT,
+		 &ev);
+	    CORBA_exception_free (&ev);
+	}
+
+	g_message (G_STRLOC);
+
+	return FALSE;
+}
+
 static Bonobo_ConfigDatabase
 get_db (GnomeProgram *program, const char *key, CORBA_Environment *opt_ev)
 {
 	GValue value = { 0, };
 	Bonobo_ConfigDatabase database;
+	GnomeProgramPrivate_libbonobo *priv;
 
 	g_return_val_if_fail (program != NULL, CORBA_OBJECT_NIL);
 	g_return_val_if_fail (GNOME_IS_PROGRAM (program), CORBA_OBJECT_NIL);
 
+	priv = g_object_get_qdata (G_OBJECT (program), quark_gnome_program_private_libbonobo);
+	while (!priv->constructed && libbonobo_delay_init (priv))
+	    ;
+
 	g_value_init (&value, G_TYPE_POINTER);
 	g_object_get_property (G_OBJECT (program), key, &value);
 	database = (Bonobo_ConfigDatabase) g_value_get_pointer (&value);
@@ -192,6 +258,8 @@ libbonobo_set_property (GObject *object, guint param_id,
 	cdata = g_type_get_qdata (G_OBJECT_TYPE (program), quark_gnome_program_class_libbonobo);
 	priv = g_object_get_qdata (G_OBJECT (program), quark_gnome_program_private_libbonobo);
 
+	g_message (G_STRLOC ": %d - %d", priv->constructed, param_id);
+
 	if (!priv->constructed) {
 		if (param_id == cdata->config_database_id) {
 			bonobo_object_release_unref (priv->config_database, NULL);
@@ -237,7 +305,7 @@ libbonobo_class_init (GnomeProgramClass *klass, const GnomeModuleInfo *mod_info)
 	cdata->config_moniker_id = gnome_program_install_property
 		(klass, libbonobo_get_property, libbonobo_set_property,
 		 g_param_spec_string (GNOME_PARAM_CONFIG_MONIKER, NULL, NULL,
-				      "config:",
+				      NULL,
 				      (G_PARAM_READABLE | G_PARAM_WRITABLE |
 				       G_PARAM_CONSTRUCT_ONLY)));
 
@@ -278,7 +346,6 @@ libbonobo_post_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
 	int dumb_argc = 1;
 	char *dumb_argv[] = {NULL};
 	GnomeProgramPrivate_libbonobo *priv = g_new0 (GnomeProgramPrivate_libbonobo, 1);
-	CORBA_Environment ev;
 
 	g_message (G_STRLOC);
 
@@ -288,30 +355,9 @@ libbonobo_post_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
 
 	priv = g_object_get_qdata (G_OBJECT (program), quark_gnome_program_private_libbonobo);
 
-	priv->constructed = TRUE;
-
-	g_message (G_STRLOC ": %p - `%s'", priv->config_database, priv->config_moniker);
-
-	CORBA_exception_init (&ev);
-	priv->config_database = bonobo_get_object (priv->config_moniker, "Bonobo/ConfigDatabase", &ev);
-	CORBA_exception_free (&ev);
-
-	CORBA_exception_init (&ev);
-	priv->desktop_config_database = bonobo_get_object (priv->desktop_config_moniker,
-							   "Bonobo/ConfigDatabase", &ev);
-	CORBA_exception_free (&ev);
-
-	if (priv->config_database != CORBA_OBJECT_NIL) {
-	    CORBA_exception_init (&ev);
-	    Bonobo_ConfigDatabase_addDatabase (priv->config_database, priv->desktop_config_database,
-					       "/Gnome/",
-					       Bonobo_ConfigDatabase_DEFAULT,
-					       &ev);
-	    CORBA_exception_free (&ev);
-	}
+	priv->app_id = g_strdup (program_invocation_short_name);
 
-	g_message (G_STRLOC ": %p - `%s'", priv->config_database, priv->config_moniker);
-	g_message (G_STRLOC ": %p - `%s'", priv->desktop_config_database, priv->desktop_config_moniker);
+	g_idle_add ((GSourceFunc) libbonobo_delay_init, priv);
 }
 
 static GnomeModuleRequirement libbonobo_requirements [] = {



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