[monkey-bubble: 189/753] Removed typedef. (GnomeModuleClassInitHook): New typedef.
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monkey-bubble: 189/753] Removed typedef. (GnomeModuleClassInitHook): New typedef.
- Date: Wed, 14 Jul 2010 22:11:33 +0000 (UTC)
commit 2df1e832fbe9b56e117a77ea467c59f86abebaa7
Author: Martin Baulig <baulig suse de>
Date: Mon Apr 23 21:20:31 2001 +0000
Removed typedef. (GnomeModuleClassInitHook): New typedef.
2001-04-23 Martin Baulig <baulig suse de>
* gnome-program.h (GnomeModuleConstructor): Removed typedef.
(GnomeModuleClassInitHook): New typedef.
(GnomeModuleInfo): Removed `constructor' and added `class_init'
and `instance_init' functions.
(gnome_program_module_load): Return a `const GnomeModuleInfo *'.
(gnome_program_init): Added `GnomeModuleInfo *' argument.
(gnome_program_initv): Added `GType' and `GnomeModuleInfo *'
arguments.
* gnome-program.c (gnome_program_constructor): Removed.
(gnome_program_initv): Load and initialize all modules based
on the `GnomeModuleInfo *' argument; for the moment, we don't
use the GNOME_PARAM_MODULE_INFO and GNOME_PARAM_MODULES
properties.
* libgnome-init.h (gnome_gconf_module_info): Removed.
(gnome_program_get_gconf_client, GNOME_PARAM_GCONF_CLIENT): Removed.
(gnome_program_get_config_database): New function.
(GNOME_PARAM_CONFIG_DATABASE, GNOME_PARAM_CONFIG_MONIKER):
New properties.
* libgnome-init.c: Don't initialize GConf.
libgnome/ChangeLog | 25 +++++
libgnome/gnome-init.c | 262 ++++++++++++++++++----------------------------
libgnome/gnome-init.h | 10 +-
libgnome/gnome-program.c | 198 ++++++++++++++---------------------
libgnome/gnome-program.h | 15 ++-
libgnome/test-libgnome.c | 28 ++---
6 files changed, 232 insertions(+), 306 deletions(-)
---
diff --git a/libgnome/ChangeLog b/libgnome/ChangeLog
index 2d9a0d8..1429803 100644
--- a/libgnome/ChangeLog
+++ b/libgnome/ChangeLog
@@ -1,3 +1,28 @@
+2001-04-23 Martin Baulig <baulig suse de>
+
+ * gnome-program.h (GnomeModuleConstructor): Removed typedef.
+ (GnomeModuleClassInitHook): New typedef.
+ (GnomeModuleInfo): Removed `constructor' and added `class_init'
+ and `instance_init' functions.
+ (gnome_program_module_load): Return a `const GnomeModuleInfo *'.
+ (gnome_program_init): Added `GnomeModuleInfo *' argument.
+ (gnome_program_initv): Added `GType' and `GnomeModuleInfo *'
+ arguments.
+
+ * gnome-program.c (gnome_program_constructor): Removed.
+ (gnome_program_initv): Load and initialize all modules based
+ on the `GnomeModuleInfo *' argument; for the moment, we don't
+ use the GNOME_PARAM_MODULE_INFO and GNOME_PARAM_MODULES
+ properties.
+
+ * libgnome-init.h (gnome_gconf_module_info): Removed.
+ (gnome_program_get_gconf_client, GNOME_PARAM_GCONF_CLIENT): Removed.
+ (gnome_program_get_config_database): New function.
+ (GNOME_PARAM_CONFIG_DATABASE, GNOME_PARAM_CONFIG_MONIKER):
+ New properties.
+
+ * libgnome-init.c: Don't initialize GConf.
+
2001-04-23 Dietmar Maurer <dietmar ximian com>
* test-libgnome.c: replace #include <bonobo/libbonobo.h> with
diff --git a/libgnome/gnome-init.c b/libgnome/gnome-init.c
index fb37c78..1e4392a 100644
--- a/libgnome/gnome-init.c
+++ b/libgnome/gnome-init.c
@@ -35,10 +35,6 @@
#include <glib.h>
-#define GCONF_ENABLE_INTERNALS 1
-#include <gconf/gconf-client.h>
-extern struct poptOption gconf_options[];
-
#include <libgnome/libgnome-init.h>
#include "libgnomeP.h"
@@ -79,7 +75,7 @@ gnome_oaf_post_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
GnomeModuleInfo gnome_oaf_module_info = {
"gnome-oaf", VERSION, N_("GNOME OAF Support"),
- NULL,
+ NULL, NULL,
gnome_oaf_pre_args_parse, gnome_oaf_post_args_parse,
oaf_popt_options
};
@@ -88,111 +84,48 @@ GnomeModuleInfo gnome_oaf_module_info = {
* libbonobo
*****************************************************************************/
-static void
-libbonobo_post_args_parse (GnomeProgram *program,
- GnomeModuleInfo *mod_info)
-{
- int dumb_argc = 1;
- char *dumb_argv[] = {NULL};
-
- dumb_argv [0] = program_invocation_name;
-
- bonobo_init (&dumb_argc, dumb_argv);
-}
-
-static GnomeModuleRequirement libbonobo_requirements[] = {
- {VERSION, &gnome_oaf_module_info},
- {NULL}
-};
-
-GnomeModuleInfo libbonobo_module_info = {
- "libbonobo", VERSION, N_("Bonobo Support"),
- libbonobo_requirements,
- NULL, libbonobo_post_args_parse,
- NULL,
- NULL, NULL, NULL, NULL
-};
-
-/*****************************************************************************
- * gconf
- *****************************************************************************/
-
typedef struct {
- guint gconf_client_id;
-} GnomeProgramClass_gnome_gconf;
+ guint config_database_id;
+ guint config_moniker_id;
+} GnomeProgramClass_libbonobo;
typedef struct {
- GConfClient *client;
-} GnomeProgramPrivate_gnome_gconf;
+ gboolean constructed;
-GConfClient *
-gnome_program_get_gconf_client (GnomeProgram *program)
-{
- GValue value = { 0, };
- GConfClient *retval = NULL;
+ gchar *config_moniker;
+ BonoboObjectClient *config_database;
+} GnomeProgramPrivate_libbonobo;
- g_return_val_if_fail (program != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_PROGRAM (program), NULL);
+static GQuark quark_gnome_program_private_libbonobo = 0;
+static GQuark quark_gnome_program_class_libbonobo = 0;
- g_value_init (&value, GCONF_TYPE_CLIENT);
- g_object_get_property (G_OBJECT (program), GNOME_PARAM_GCONF_CLIENT, &value);
- retval = (GConfClient *) g_value_dup_object (&value);
- g_value_unset (&value);
-
- return retval;
-}
-
-static gchar *
-gnome_gconf_get_gnome_libs_settings_relative (const gchar *subkey)
+Bonobo_ConfigDatabase
+gnome_program_get_config_database (GnomeProgram *program)
{
- gchar *dir;
- gchar *key;
-
- dir = g_strconcat ("/apps/gnome-settings/",
- gnome_program_get_name (gnome_program_get ()),
- NULL);
-
- if (subkey && *subkey) {
- key = gconf_concat_dir_and_key (dir, subkey);
- g_free (dir);
- } else {
- /* subkey == "" */
- key = dir;
- }
-
- return key;
-}
-
-static gchar * G_GNUC_UNUSED
-gnome_gconf_get_app_settings_relative (const gchar *subkey)
-{
- gchar *dir;
- gchar *key;
-
- dir = g_strconcat ("/apps/",
- gnome_program_get_name (gnome_program_get ()),
- NULL);
-
- if (subkey && *subkey) {
- key = gconf_concat_dir_and_key (dir, subkey);
- g_free (dir);
- } else {
- /* subkey == "" */
- key = dir;
- }
+ GValue value = { 0, };
+ Bonobo_ConfigDatabase corba_retval = CORBA_OBJECT_NIL;
+ BonoboObjectClient *object_client;
+
+ g_return_val_if_fail (program != NULL, CORBA_OBJECT_NIL);
+ g_return_val_if_fail (GNOME_IS_PROGRAM (program), CORBA_OBJECT_NIL);
+
+ g_value_init (&value, BONOBO_OBJECT_CLIENT_TYPE);
+ g_object_get_property (G_OBJECT (program), GNOME_PARAM_CONFIG_DATABASE, &value);
+ object_client = (BonoboObjectClient *) g_value_get_object (&value);
+ if (object_client)
+ corba_retval = bonobo_object_dup_ref
+ (bonobo_object_corba_objref (BONOBO_OBJECT (object_client)), NULL);
+ g_value_unset (&value);
- return key;
+ return corba_retval;
}
-static GQuark quark_gnome_program_private_gnome_gconf = 0;
-static GQuark quark_gnome_program_class_gnome_gconf = 0;
-
static void
-gnome_gconf_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec *pspec)
+libbonobo_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec *pspec)
{
- GnomeProgramClass_gnome_gconf *cdata;
- GnomeProgramPrivate_gnome_gconf *priv;
+ GnomeProgramClass_libbonobo *cdata;
+ GnomeProgramPrivate_libbonobo *priv;
GnomeProgram *program;
g_return_if_fail (object != NULL);
@@ -200,21 +133,23 @@ gnome_gconf_get_property (GObject *object, guint param_id, GValue *value,
program = GNOME_PROGRAM (object);
- cdata = g_type_get_qdata (G_OBJECT_TYPE (program), quark_gnome_program_class_gnome_gconf);
- priv = g_object_get_qdata (G_OBJECT (program), quark_gnome_program_private_gnome_gconf);
+ 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);
- if (param_id == cdata->gconf_client_id)
- g_value_set_object (value, (GObject *) priv->client);
+ if (param_id == cdata->config_database_id)
+ g_value_set_object (value, (GObject *) priv->config_database);
+ else if (param_id == cdata->config_moniker_id)
+ g_value_set_string (value, priv->config_moniker);
else
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
}
static void
-gnome_gconf_set_property (GObject *object, guint param_id,
+libbonobo_set_property (GObject *object, guint param_id,
const GValue *value, GParamSpec *pspec)
{
- GnomeProgramClass_gnome_gconf *cdata;
- GnomeProgramPrivate_gnome_gconf *priv;
+ GnomeProgramClass_libbonobo *cdata;
+ GnomeProgramPrivate_libbonobo *priv;
GnomeProgram *program;
g_return_if_fail (object != NULL);
@@ -222,87 +157,96 @@ gnome_gconf_set_property (GObject *object, guint param_id,
program = GNOME_PROGRAM (object);
- cdata = g_type_get_qdata (G_OBJECT_TYPE (program), quark_gnome_program_class_gnome_gconf);
- priv = g_object_get_qdata (G_OBJECT (program), quark_gnome_program_private_gnome_gconf);
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ 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);
+
+ if (!priv->constructed) {
+ if (param_id == cdata->config_database_id) {
+ priv->config_database = (BonoboObjectClient *) g_value_get_object (value);
+ if (priv->config_database)
+ bonobo_object_client_ref (priv->config_database, NULL);
+ } else if (param_id == cdata->config_moniker_id)
+ priv->config_moniker = g_value_dup_string (value);
+ else
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ } else {
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ }
}
static void
-gnome_gconf_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_properties,
- const GnomeModuleInfo *mod_info)
+libbonobo_init_pass (const GnomeModuleInfo *mod_info)
{
- GnomeProgramClass_gnome_gconf *cdata = g_new0 (GnomeProgramClass_gnome_gconf, 1);
- GnomeProgramClass *pclass;
+ if (!quark_gnome_program_private_libbonobo)
+ quark_gnome_program_private_libbonobo = g_quark_from_static_string
+ ("gnome-program-private:libbonobo");
- if (!quark_gnome_program_private_gnome_gconf)
- quark_gnome_program_private_gnome_gconf = g_quark_from_static_string
- ("gnome-program-private:gnome-gconf");
+ if (!quark_gnome_program_class_libbonobo)
+ quark_gnome_program_class_libbonobo = g_quark_from_static_string
+ ("gnome-program-class:libbonobo");
+}
- if (!quark_gnome_program_class_gnome_gconf)
- quark_gnome_program_class_gnome_gconf = g_quark_from_static_string
- ("gnome-program-class:gnome-gconf");
+static void
+libbonobo_class_init (GnomeProgramClass *klass, const GnomeModuleInfo *mod_info)
+{
+ GnomeProgramClass_libbonobo *cdata = g_new0 (GnomeProgramClass_libbonobo, 1);
- pclass = GNOME_PROGRAM_CLASS (g_type_class_peek (type));
+ g_type_set_qdata (G_OBJECT_CLASS_TYPE (klass), quark_gnome_program_class_libbonobo, cdata);
- g_type_set_qdata (G_OBJECT_CLASS_TYPE (pclass), quark_gnome_program_class_gnome_gconf, cdata);
+ 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,
+ NULL,
+ (G_PARAM_READABLE | G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY)));
- cdata->gconf_client_id = gnome_program_install_property
- (pclass, gnome_gconf_get_property, gnome_gconf_set_property,
- g_param_spec_object (GNOME_PARAM_GCONF_CLIENT, NULL, NULL,
- GCONF_TYPE_CLIENT,
+ cdata->config_database_id = gnome_program_install_property
+ (klass, libbonobo_get_property, libbonobo_set_property,
+ g_param_spec_object (GNOME_PARAM_CONFIG_DATABASE, NULL, NULL,
+ BONOBO_OBJECT_CLIENT_TYPE,
(G_PARAM_READABLE | G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY)));
}
static void
-gnome_gconf_pre_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
+libbonobo_instance_init (GnomeProgram *program, GnomeModuleInfo *mod_info)
{
- GnomeProgramPrivate_gnome_gconf *priv = g_new0 (GnomeProgramPrivate_gnome_gconf, 1);
+ GnomeProgramPrivate_libbonobo *priv = g_new0 (GnomeProgramPrivate_libbonobo, 1);
- g_object_set_qdata (G_OBJECT (program), quark_gnome_program_private_gnome_gconf, priv);
-
- gconf_preinit (program, mod_info);
+ g_object_set_qdata (G_OBJECT (program), quark_gnome_program_private_libbonobo, priv);
}
static void
-gnome_gconf_post_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
+libbonobo_post_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
{
- GnomeProgramPrivate_gnome_gconf *priv;
- gchar *settings_dir;
+ int dumb_argc = 1;
+ char *dumb_argv[] = {NULL};
+ GnomeProgramPrivate_libbonobo *priv = g_new0 (GnomeProgramPrivate_libbonobo, 1);
- gconf_postinit (program, mod_info);
+ g_message (G_STRLOC);
- priv = g_object_get_qdata (G_OBJECT (program), quark_gnome_program_private_gnome_gconf);
+ dumb_argv [0] = program_invocation_name;
- priv->client = gconf_client_get_default ();
+ bonobo_init (&dumb_argc, dumb_argv);
- gconf_client_add_dir (priv->client,
- "/desktop/gnome",
- GCONF_CLIENT_PRELOAD_NONE, NULL);
+ priv = g_object_get_qdata (G_OBJECT (program), quark_gnome_program_private_libbonobo);
- settings_dir = gnome_gconf_get_gnome_libs_settings_relative ("");
+ priv->constructed = TRUE;
- gconf_client_add_dir (priv->client,
- settings_dir,
- /* Possibly we should turn preload on for this */
- GCONF_CLIENT_PRELOAD_NONE,
- NULL);
- g_free (settings_dir);
+ g_message (G_STRLOC ": %p - `%s'", priv->config_database, priv->config_moniker);
}
-static GnomeModuleRequirement gnome_gconf_requirements[] = {
- { VERSION, &libbonobo_module_info },
- { NULL, NULL }
+static GnomeModuleRequirement libbonobo_requirements[] = {
+ {VERSION, &gnome_oaf_module_info},
+ {NULL}
};
-GnomeModuleInfo gnome_gconf_module_info = {
- "gnome-gconf", VERSION, N_("GNOME GConf Support"),
- gnome_gconf_requirements,
- gnome_gconf_pre_args_parse, gnome_gconf_post_args_parse,
- gconf_options,
- NULL, gnome_gconf_constructor,
+GnomeModuleInfo libbonobo_module_info = {
+ "libbonobo", VERSION, N_("Bonobo Support"),
+ libbonobo_requirements, libbonobo_instance_init,
+ NULL, libbonobo_post_args_parse,
+ NULL,
+ libbonobo_init_pass, libbonobo_class_init,
NULL, NULL
};
@@ -332,7 +276,7 @@ static struct poptOption gnomelib_options[] = {
GnomeModuleInfo gnome_vfs_module_info = {
"gnome-vfs", GNOMEVFSVERSION, "GNOME Virtual Filesystem",
- NULL,
+ NULL, NULL,
(GnomeModuleHook) gnome_vfs_preinit, (GnomeModuleHook) gnome_vfs_postinit,
NULL,
(GnomeModuleInitHook) gnome_vfs_loadinit,
@@ -341,14 +285,14 @@ GnomeModuleInfo gnome_vfs_module_info = {
static GnomeModuleRequirement libgnome_requirements[] = {
{VERSION, &libbonobo_module_info},
- {VERSION, &gnome_gconf_module_info},
+ {VERSION, &libbonobo_module_info},
{"0.3.0", &gnome_vfs_module_info},
{NULL}
};
GnomeModuleInfo libgnome_module_info = {
"libgnome", VERSION, "GNOME Library",
- libgnome_requirements,
+ libgnome_requirements, NULL,
NULL, libgnome_post_args_parse,
gnomelib_options,
NULL, NULL, NULL, NULL
diff --git a/libgnome/gnome-init.h b/libgnome/gnome-init.h
index 104ed67..2047b90 100644
--- a/libgnome/gnome-init.h
+++ b/libgnome/gnome-init.h
@@ -28,17 +28,17 @@
#include <libgnome/gnome-program.h>
-#include <gconf/gconf-client.h>
+#include <bonobo/bonobo-config-database.h>
G_BEGIN_DECLS
-GConfClient *
-gnome_program_get_gconf_client (GnomeProgram *program);
+Bonobo_ConfigDatabase
+gnome_program_get_config_database (GnomeProgram *program);
-#define GNOME_PARAM_GCONF_CLIENT "gconf-client"
+#define GNOME_PARAM_CONFIG_DATABASE "config-database"
+#define GNOME_PARAM_CONFIG_MONIKER "config-moniker"
extern GnomeModuleInfo gnome_oaf_module_info;
-extern GnomeModuleInfo gnome_gconf_module_info;
extern GnomeModuleInfo gnome_vfs_module_info;
extern GnomeModuleInfo libgnome_module_info;
diff --git a/libgnome/gnome-program.c b/libgnome/gnome-program.c
index 0bd8a7b..2c318ee 100644
--- a/libgnome/gnome-program.c
+++ b/libgnome/gnome-program.c
@@ -268,7 +268,7 @@ gnome_program_get_property (GObject *object, guint param_id, GValue *value,
}
static void
-add_to_module_list (const gchar *module_name)
+add_to_module_list (GPtrArray *module_list, const gchar *module_name)
{
char **modnames;
int i, j;
@@ -276,16 +276,13 @@ add_to_module_list (const gchar *module_name)
if (!module_name)
return;
- if (!program_module_list)
- program_module_list = g_ptr_array_new ();
-
modnames = g_strsplit (module_name, ",", -1);
for (i = 0; modnames && modnames[i]; i++) {
- for (j = 0; j < program_module_list->len; j++)
- if (!strcmp (modnames[i], g_ptr_array_index (program_module_list, j)))
+ for (j = 0; j < module_list->len; j++)
+ if (!strcmp (modnames[i], g_ptr_array_index (module_list, j)))
return;
- g_ptr_array_add (program_module_list, g_strdup (modnames[i]));
+ g_ptr_array_add (module_list, g_strdup (modnames[i]));
}
g_strfreev (modnames);
}
@@ -377,103 +374,6 @@ gnome_program_module_list_order (void)
program_modules->len * sizeof(gpointer));
}
-static GObject*
-gnome_program_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- GnomeProgram *program = NULL;
- GnomeModuleInfo *module_info = NULL;
- GObjectConstructParam *cparams = NULL;
- guint n_modinfos = 0, n_cparams = 0, i;
-
- if (!program_module_list)
- program_module_list = g_ptr_array_new ();
-
- if (!program_modules)
- program_modules = g_ptr_array_new ();
-
- /*
- * First walk the list of construction properties and sort out
- * GNOME_PARAM_MODULES and GNOME_PARAM_MODULE_INFO; we need to
- * handle this here so we can load the modules before we create
- * the GnomeProgram object.
- */
-
- for (i = 0; i < n_construct_properties; i++) {
- GValue *value = construct_properties[i].value;
- GParamSpec *pspec = construct_properties[i].pspec;
-
- if (!strcmp (pspec->name, GNOME_PARAM_MODULES)) {
- if (program_initialized)
- g_warning (G_STRLOC ": cannot use construction property \"%s\" "
- "when program is already initialized", pspec->name);
- else
- add_to_module_list (g_value_get_string (value));
- } else if (!strcmp (pspec->name, GNOME_PARAM_MODULE_INFO)) {
- if (!n_modinfos || n_modinfos >= PREALLOC_MODINFOS)
- module_info = g_renew (GnomeModuleInfo, module_info,
- MAX (n_modinfos + 1, PREALLOC_MODINFOS));
- module_info[n_modinfos] = * (GnomeModuleInfo *)
- g_value_get_boxed (value);
- n_modinfos++;
- } else {
- if (!n_cparams || n_cparams >= PREALLOC_CPARAMS)
- cparams = g_renew (GObjectConstructParam, cparams,
- MAX (n_cparams + 1, PREALLOC_CPARAMS));
- cparams[n_cparams].pspec = pspec;
- cparams[n_cparams].value = value;
- n_cparams++;
- }
- }
-
- if (!program_initialized) {
- /*
- * Load all the modules.
- */
-
- for (i = 0; i < n_modinfos; i++)
- gnome_program_module_register (&module_info[i]);
-
- for (i = 0; i < program_module_list->len; i++) {
- gchar *modname = g_ptr_array_index (program_module_list, i);
-
- gnome_program_module_load (modname);
- }
-
- for (i = 0; i < program_modules->len; i++) {
- GnomeModuleInfo *a_module = g_ptr_array_index (program_modules, i);
-
- if (a_module && a_module->init_pass)
- a_module->init_pass (a_module);
- }
-
- /* Make sure the array is NULL-terminated */
- g_ptr_array_add (program_modules, NULL);
-
- /* 2. Order the module list for dependencies */
- gnome_program_module_list_order ();
-
- for (i = 0; i < program_modules->len; i++) {
- GnomeModuleInfo *a_module = g_ptr_array_index (program_modules, i);
-
- if (a_module && a_module->constructor)
- a_module->constructor (type, n_cparams, cparams, a_module);
- }
- }
-
- program = (GnomeProgram *) G_OBJECT_CLASS (parent_class)->constructor
- (type, n_cparams, cparams);
-
- if (!program_initialized) {
- global_program = program;
- g_object_ref (G_OBJECT (global_program));
-
- program_initialized = TRUE;
- }
-
- return G_OBJECT (program);
-}
-
static void
gnome_program_class_init (GnomeProgramClass *class)
{
@@ -485,7 +385,6 @@ gnome_program_class_init (GnomeProgramClass *class)
quark_set_prop = g_quark_from_static_string ("gnome-program-set-property");
quark_get_prop = g_quark_from_static_string ("gnome-program-g-property");
- object_class->constructor = gnome_program_constructor;
object_class->set_property = gnome_program_set_property;
object_class->get_property = gnome_program_get_property;
@@ -596,9 +495,18 @@ gnome_program_class_init (GnomeProgramClass *class)
static void
gnome_program_instance_init (GnomeProgram *program)
{
+ guint i;
+
program->_priv = g_new0 (GnomeProgramPrivate, 1);
program->_priv->state = APP_CREATE_DONE;
+
+ for (i = 0; i < program_modules->len; i++) {
+ GnomeModuleInfo *a_module = g_ptr_array_index (program_modules, i);
+
+ if (a_module && a_module->instance_init)
+ a_module->instance_init (program, a_module);
+ }
}
static void
@@ -1200,19 +1108,14 @@ gnome_program_preinit (GnomeProgram *program,
* Loads a shared library that contains a
* 'GnomeModuleInfo dynamic_module_info' structure.
*/
-void
+const GnomeModuleInfo *
gnome_program_module_load (const char *mod_name)
{
GModule *mh;
- GnomeModuleInfo *gmi;
+ const GnomeModuleInfo *gmi;
char tbuf[1024];
- g_return_if_fail (mod_name != NULL);
-
- if (program_initialized) {
- g_warning (G_STRLOC ": cannot load modules after program is initialized");
- return;
- }
+ g_return_val_if_fail (mod_name != NULL, NULL);
g_snprintf (tbuf, sizeof(tbuf), "lib%s.so.0", mod_name);
@@ -1224,13 +1127,16 @@ gnome_program_module_load (const char *mod_name)
}
if (!mh)
- return;
+ return NULL;
if (g_module_symbol (mh, "dynamic_module_info", (gpointer *)&gmi)) {
gnome_program_module_register (gmi);
g_module_make_resident (mh);
- } else
+ return gmi;
+ } else {
g_module_close (mh);
+ return NULL;
+ }
}
/**
@@ -1316,22 +1222,28 @@ gnome_program_postinit (GnomeProgram *program)
*/
GnomeProgram *
gnome_program_init (const char *app_id, const char *app_version,
+ const GnomeModuleInfo *module_info,
int argc, char **argv,
const char *first_property_name, ...)
{
GnomeProgram *program;
va_list args;
+ libgnome_type_init ();
+
va_start(args, first_property_name);
- program = gnome_program_initv (app_id, app_version, argc, argv,
- first_property_name, args);
+ program = gnome_program_initv (GNOME_TYPE_PROGRAM,
+ app_id, app_version, module_info,
+ argc, argv, first_property_name, args);
va_end(args);
return program;
}
GnomeProgram *
-gnome_program_initv (const char *app_id, const char *app_version,
+gnome_program_initv (GType type,
+ const char *app_id, const char *app_version,
+ const GnomeModuleInfo *module_info,
int argc, char **argv,
const char *first_property_name, va_list args)
{
@@ -1341,24 +1253,70 @@ gnome_program_initv (const char *app_id, const char *app_version,
libgnome_type_init ();
if (!program_initialized) {
+ GnomeProgramClass *klass;
const char *ctmp;
+ klass = g_type_class_ref (type);
+
program_module_list = g_ptr_array_new ();
program_modules = g_ptr_array_new ();
+ /* Always register libgnome. */
+ gnome_program_module_register (&libgnome_module_info);
+
+ /* Register the requested modules. */
+ gnome_program_module_register (module_info);
+
/* We have to handle --load-modules=foo,bar,baz specially */
for (i = 0; i < argc; i++) {
if (!strncmp (argv[i], "--load-modules=", strlen ("--load-modules=")))
- add_to_module_list (argv[i] + strlen("--load-modules="));
+ add_to_module_list (program_module_list, argv[i] + strlen("--load-modules="));
}
if ((ctmp = g_getenv ("GNOME_MODULES")))
- add_to_module_list (ctmp);
+ add_to_module_list (program_module_list, ctmp);
+
+ /*
+ * Load all the modules.
+ */
+
+ for (i = 0; i < program_module_list->len; i++) {
+ gchar *modname = g_ptr_array_index (program_module_list, i);
+
+ gnome_program_module_load (modname);
+ }
+
+ for (i = 0; i < program_modules->len; i++) {
+ GnomeModuleInfo *a_module = g_ptr_array_index (program_modules, i);
+
+ if (a_module && a_module->init_pass)
+ a_module->init_pass (a_module);
+ }
+
+ /* Make sure the array is NULL-terminated */
+ g_ptr_array_add (program_modules, NULL);
+
+ /* Order the module list for dependencies */
+ gnome_program_module_list_order ();
+
+ for (i = 0; i < program_modules->len; i++) {
+ GnomeModuleInfo *a_module = g_ptr_array_index (program_modules, i);
+
+ if (a_module && a_module->class_init)
+ a_module->class_init (klass, a_module);
+ }
}
program = g_object_new_valist (GNOME_TYPE_PROGRAM,
first_property_name, args);
+ if (!program_initialized) {
+ global_program = program;
+ g_object_ref (G_OBJECT (global_program));
+
+ program_initialized = TRUE;
+ }
+
gnome_program_preinit (program, app_id, app_version, argc, argv);
gnome_program_parse_args (program);
gnome_program_postinit (program);
diff --git a/libgnome/gnome-program.h b/libgnome/gnome-program.h
index 0a2ad84..47ff9ca 100644
--- a/libgnome/gnome-program.h
+++ b/libgnome/gnome-program.h
@@ -129,9 +129,8 @@ struct _GnomeModuleRequirement {
};
typedef void (*GnomeModuleInitHook) (const GnomeModuleInfo *mod_info);
-typedef void (*GnomeModuleConstructor) (GType type, guint n_construct_props,
- GObjectConstructParam *construct_props,
- const GnomeModuleInfo *mod_info);
+typedef void (*GnomeModuleClassInitHook) (GnomeProgramClass *klass,
+ const GnomeModuleInfo *mod_info);
typedef void (*GnomeModuleHook) (GnomeProgram *program,
GnomeModuleInfo *mod_info);
@@ -139,6 +138,7 @@ struct _GnomeModuleInfo {
const char *name, *version, *description;
GnomeModuleRequirement *requirements; /* last element has NULL version */
+ GnomeModuleHook instance_init;
GnomeModuleHook pre_args_parse, post_args_parse;
struct poptOption *options;
@@ -149,7 +149,7 @@ struct _GnomeModuleInfo {
module cannot assume its required
modules are initialized (they aren't). */
- GnomeModuleConstructor constructor;
+ GnomeModuleClassInitHook class_init;
gpointer expansion1, expansion2;
};
@@ -163,7 +163,7 @@ gnome_program_module_register (const GnomeModuleInfo *module_info);
gboolean
gnome_program_module_registered (const GnomeModuleInfo *module_info);
-void
+const GnomeModuleInfo *
gnome_program_module_load (const char *mod_name);
guint
@@ -193,11 +193,14 @@ gnome_program_postinit (GnomeProgram *program);
popt parse all args, and then call gnomelib_postinit() */
GnomeProgram *
gnome_program_init (const char *app_id, const char *app_version,
+ const GnomeModuleInfo *module_info,
int argc, char **argv,
const char *first_property_name, ...);
GnomeProgram *
-gnome_program_initv (const char *app_id, const char *app_version,
+gnome_program_initv (GType type,
+ const char *app_id, const char *app_version,
+ const GnomeModuleInfo *module_info,
int argc, char **argv,
const char *first_property_name, va_list args);
diff --git a/libgnome/test-libgnome.c b/libgnome/test-libgnome.c
index d91766d..3db117b 100644
--- a/libgnome/test-libgnome.c
+++ b/libgnome/test-libgnome.c
@@ -78,22 +78,18 @@ test_init_pass (const GnomeModuleInfo *mod_info)
}
static void
-test_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_properties,
+test_constructor (GnomeProgramClass *klass,
const GnomeModuleInfo *mod_info)
{
- GnomeProgramClass *pclass;
guint test_id;
- pclass = GNOME_PROGRAM_CLASS (g_type_class_peek (type));
-
test_id = gnome_program_install_property
- (pclass, get_property, set_property,
+ (klass, get_property, set_property,
g_param_spec_boolean ("test", NULL, NULL,
FALSE,
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
- g_message (G_STRLOC ": %p - %d", pclass, test_id);
+ g_message (G_STRLOC ": %p - %d", klass, test_id);
}
static GnomeModuleRequirement test_requirements[] = {
@@ -103,7 +99,7 @@ static GnomeModuleRequirement test_requirements[] = {
GnomeModuleInfo test_moduleinfo = {
"test", VERSION, "Test Application",
- test_requirements,
+ test_requirements, NULL,
test_pre_args_parse, test_post_args_parse,
NULL,
test_init_pass, test_constructor,
@@ -132,15 +128,13 @@ static void
test_bonobo (GnomeProgram *program)
{
Bonobo_ConfigDatabase db;
- CORBA_Environment ev;
- CORBA_exception_init (&ev);
+ db = gnome_program_get_config_database (program);
- db = bonobo_get_object ("gconf:test-program", "IDL:Bonobo/ConfigDatabase:1.0", &ev);
+ g_object_set (G_OBJECT (program), GNOME_PARAM_CONFIG_MONIKER,
+ "gconf:/test/foo", NULL);
g_message (G_STRLOC ": %p", db);
-
- CORBA_exception_free (&ev);
}
int
@@ -152,12 +146,14 @@ main (int argc, char **argv)
const gchar *human_readable_name;
gchar *gnome_path;
- program = gnome_program_init ("test-libgnome", VERSION, argc, argv,
+ program = gnome_program_init ("test-libgnome", VERSION,
+ &test_moduleinfo, argc, argv,
GNOME_PARAM_POPT_TABLE, options,
GNOME_PARAM_HUMAN_READABLE_NAME,
_("The Application Name"),
- GNOME_PARAM_MODULE_INFO,
- &test_moduleinfo, NULL);
+ GNOME_PARAM_CONFIG_MONIKER,
+ "gconf:/test/foo",
+ NULL);
g_value_init (&value, G_TYPE_STRING);
g_object_get_property (G_OBJECT (program), "app_prefix", &value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]