[monkey-bubble: 139/753] New GnomeProgram property. (gnome_program_get_gconf_client): New
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monkey-bubble: 139/753] New GnomeProgram property. (gnome_program_get_gconf_client): New
- Date: Wed, 14 Jul 2010 22:07:21 +0000 (UTC)
commit 847dd1143db78f6c58a17327edeaf5049ec88971
Author: Martin Baulig <baulig suse de>
Date: Sat Apr 14 17:29:41 2001 +0000
New GnomeProgram property. (gnome_program_get_gconf_client): New
2001-04-14 Martin Baulig <baulig suse de>
* gnome-program.h (GNOME_PARAM_GCONF_CLIENT): New GnomeProgram property.
(gnome_program_get_gconf_client): New convenience function to return the
GnomeProgram's GNOME_PARAM_GCONF_CLIENT property.
* gnome-program.c (gnome_program_get_property): Fixed a typo to make this
actually work.
* libgnome-init.c (gnome_gconf_constructor): New constructor function to
install the GnomeProgram's GNOME_PARAM_GCONF_CLIENT property.
(gnome_gconf_get_property, gnome_gconf_post_args_parse): Implement that
property; when creating a new GnomeProgram instance we set its
GNOME_PARAM_GCONF_CLIENT property to gnome_conf_client_get_default().
libgnome/ChangeLog | 15 +++++++
libgnome/Makefile.am | 2 +
libgnome/gnome-init.c | 100 +++++++++++++++++++++++++++++++++++++++++-----
libgnome/gnome-program.c | 19 ++++++++-
libgnome/gnome-program.h | 7 +++-
5 files changed, 131 insertions(+), 12 deletions(-)
---
diff --git a/libgnome/ChangeLog b/libgnome/ChangeLog
index 78683d8..ac0eb6a 100644
--- a/libgnome/ChangeLog
+++ b/libgnome/ChangeLog
@@ -1,3 +1,18 @@
+2001-04-14 Martin Baulig <baulig suse de>
+
+ * gnome-program.h (GNOME_PARAM_GCONF_CLIENT): New GnomeProgram property.
+ (gnome_program_get_gconf_client): New convenience function to return the
+ GnomeProgram's GNOME_PARAM_GCONF_CLIENT property.
+
+ * gnome-program.c (gnome_program_get_property): Fixed a typo to make this
+ actually work.
+
+ * libgnome-init.c (gnome_gconf_constructor): New constructor function to
+ install the GnomeProgram's GNOME_PARAM_GCONF_CLIENT property.
+ (gnome_gconf_get_property, gnome_gconf_post_args_parse): Implement that
+ property; when creating a new GnomeProgram instance we set its
+ GNOME_PARAM_GCONF_CLIENT property to gnome_conf_client_get_default().
+
2001-04-13 Martin Baulig <baulig suse de>
* libgnome-init.c (gnome_oaf_module_info, gnome_gconf_module_info):
diff --git a/libgnome/Makefile.am b/libgnome/Makefile.am
index 65e5a5f..9d982b4 100644
--- a/libgnome/Makefile.am
+++ b/libgnome/Makefile.am
@@ -26,6 +26,7 @@ INCLUDES = \
$(GCONF_CFLAGS) \
$(LIBXML_CFLAGS) \
$(GNOME_VFS_CFLAGS) \
+ $(LIBBONOBO_CFLAGS) \
-DGNOMEPREFIX=\""$(prefix)"\" \
-DGNOMELIBDIR=\""$(libdir)"\" \
-DGNOMEDATADIR=\""$(datadir)"\" \
@@ -134,6 +135,7 @@ libgnome_2_la_LIBADD = \
$(GCONF_LIBS) \
$(LIBXML_LIBS) \
$(GNOME_VFS_LIBS) \
+ $(LIBBONOBO_LIBS) \
$(GLIB_LIBS)
noinst_PROGRAMS = \
diff --git a/libgnome/gnome-init.c b/libgnome/gnome-init.c
index 5f4c40e..62907ab 100644
--- a/libgnome/gnome-init.c
+++ b/libgnome/gnome-init.c
@@ -43,6 +43,7 @@ extern struct poptOption gconf_options[];
#include <errno.h>
#include <gobject/gobject.h>
+#include <gobject/gparamspecs.h>
#include <gobject/gvaluetypes.h>
#include <liboaf/liboaf.h>
@@ -82,6 +83,14 @@ GnomeModuleInfo gnome_oaf_module_info = {
* gconf
*****************************************************************************/
+typedef struct {
+ guint gconf_client_id;
+} GnomeProgramClass_gnome_gconf;
+
+typedef struct {
+ GConfClient *client;
+} GnomeProgramPrivate_gnome_gconf;
+
static gchar *
gnome_gconf_get_gnome_libs_settings_relative (const gchar *subkey)
{
@@ -124,38 +133,107 @@ gnome_gconf_get_app_settings_relative (const gchar *subkey)
return key;
}
-static GConfClient* global_client = NULL;
+static GQuark quark_gnome_program_private_gnome_gconf = 0;
+static GQuark quark_gnome_program_class_gnome_gconf = 0;
-static GConfClient * G_GNUC_UNUSED
-gnome_get_gconf_client (void)
+static void
+gnome_gconf_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec *pspec)
{
- g_return_val_if_fail (global_client != NULL, NULL);
-
- return global_client;
+ GnomeProgramClass_gnome_gconf *cdata;
+ GnomeProgramPrivate_gnome_gconf *priv;
+ GnomeProgram *program;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNOME_IS_PROGRAM (object));
+
+ 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);
+
+ if (param_id == cdata->gconf_client_id)
+ g_value_set_object (value, (GObject *) priv->client);
+ else
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+}
+
+static void
+gnome_gconf_set_property (GObject *object, guint param_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ GnomeProgramClass_gnome_gconf *cdata;
+ GnomeProgramPrivate_gnome_gconf *priv;
+ GnomeProgram *program;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNOME_IS_PROGRAM (object));
+
+ 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);
+}
+
+static void
+gnome_gconf_constructor (GType type, guint n_construct_properties,
+ GObjectConstructParam *construct_properties,
+ const GnomeModuleInfo *mod_info)
+{
+ GnomeProgramClass_gnome_gconf *cdata = g_new0 (GnomeProgramClass_gnome_gconf, 1);
+ GnomeProgramClass *pclass;
+
+ 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_gnome_gconf)
+ quark_gnome_program_class_gnome_gconf = g_quark_from_static_string
+ ("gnome-program-class:gnome-gconf");
+
+ pclass = GNOME_PROGRAM_CLASS (g_type_class_peek (type));
+
+ g_type_set_qdata (G_OBJECT_CLASS_TYPE (pclass), quark_gnome_program_class_gnome_gconf, cdata);
+
+ 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,
+ (G_PARAM_READABLE | G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY)));
}
static void
gnome_gconf_pre_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
{
+ GnomeProgramPrivate_gnome_gconf *priv = g_new0 (GnomeProgramPrivate_gnome_gconf, 1);
+
+ g_object_set_qdata (G_OBJECT (program), quark_gnome_program_private_gnome_gconf, priv);
+
gconf_preinit (program, mod_info);
}
static void
gnome_gconf_post_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
{
+ GnomeProgramPrivate_gnome_gconf *priv;
gchar *settings_dir;
gconf_postinit (program, mod_info);
- global_client = gconf_client_get_default();
+ priv = g_object_get_qdata (G_OBJECT (program), quark_gnome_program_private_gnome_gconf);
+
+ priv->client = gconf_client_get_default ();
- gconf_client_add_dir (global_client,
+ gconf_client_add_dir (priv->client,
"/desktop/gnome",
GCONF_CLIENT_PRELOAD_NONE, NULL);
settings_dir = gnome_gconf_get_gnome_libs_settings_relative ("");
- gconf_client_add_dir (global_client,
+ gconf_client_add_dir (priv->client,
settings_dir,
/* Possibly we should turn preload on for this */
GCONF_CLIENT_PRELOAD_NONE,
@@ -172,7 +250,9 @@ 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
+ gconf_options,
+ NULL, gnome_gconf_constructor,
+ NULL, NULL
};
/*****************************************************************************
diff --git a/libgnome/gnome-program.c b/libgnome/gnome-program.c
index 3d748ea..fc7b2f2 100644
--- a/libgnome/gnome-program.c
+++ b/libgnome/gnome-program.c
@@ -256,7 +256,7 @@ gnome_program_get_property (GObject *object, guint param_id, GValue *value,
default: {
GObjectSetPropertyFunc get_func;
- get_func = g_param_spec_get_qdata (pspec, quark_set_prop);
+ get_func = g_param_spec_get_qdata (pspec, quark_get_prop);
if (get_func)
get_func (object, param_id, value, pspec);
else
@@ -746,6 +746,23 @@ gnome_program_install_property (GnomeProgramClass *pclass,
return last_property_id++;
}
+GConfClient *
+gnome_program_get_gconf_client (GnomeProgram *program)
+{
+ GValue value = { 0, };
+ GConfClient *retval = NULL;
+
+ g_return_val_if_fail (program != NULL, NULL);
+ g_return_val_if_fail (GNOME_IS_PROGRAM (program), NULL);
+
+ 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;
+}
+
/**
* gnome_program_locate_file:
* @domain: A domain (see GnomeFileDomain in gnome-program.h).
diff --git a/libgnome/gnome-program.h b/libgnome/gnome-program.h
index f2c0d72..dadc1a5 100644
--- a/libgnome/gnome-program.h
+++ b/libgnome/gnome-program.h
@@ -34,8 +34,9 @@
#include <popt.h>
#include <stdarg.h>
-#include "gnome-defs.h"
#include <gobject/gobject.h>
+#include <libgnome/gnome-defs.h>
+#include <gconf/gconf-client.h>
BEGIN_GNOME_DECLS
@@ -113,6 +114,7 @@ gnome_program_locate_file (GnomeProgram *program,
#define GNOME_PARAM_APP_LIBDIR "app-libdir"
#define GNOME_PARAM_HUMAN_READABLE_NAME "human-readable-name"
#define GNOME_PARAM_GNOME_PATH "gnome-path"
+#define GNOME_PARAM_GCONF_CLIENT "gconf-client"
/***** application modules (aka libraries :) ******/
#define GNOME_TYPE_MODULE_INFO (gnome_module_info_get_type ())
@@ -172,6 +174,9 @@ gnome_program_install_property (GnomeProgramClass *pclass,
GObjectSetPropertyFunc set_fn,
GParamSpec *pspec);
+GConfClient *
+gnome_program_get_gconf_client (GnomeProgram *program);
+
/*
* If the application writer wishes to use getopt()-style arg
* processing, they can do it using a while looped sandwiched between
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]