[monkey-bubble: 211/753] New property. (GNOME_PARAM_DESKTOP_CONFIG_MONIKER): Likewise.



commit 96d7f7b21006efa60d921920802a7660a0f818a6
Author: Martin Baulig <baulig suse de>
Date:   Sun Apr 29 14:19:58 2001 +0000

    New property. (GNOME_PARAM_DESKTOP_CONFIG_MONIKER): Likewise.
    
    2001-04-29  Martin Baulig  <baulig suse de>
    
    	* libgnome-init.[ch]
    	(GNOME_PARAM_DESKTOP_CONFIG_DATABASE): New property.
    	(GNOME_PARAM_DESKTOP_CONFIG_MONIKER): Likewise.
    	(gnome_program_get_desktop_config_database): New function.
    
    	* gnome-preferences.[ch]: New files; this has the same API than
    	libgnomeui/gnome-preferences.[ch], but it's using bonobo-conf
    	internally.

 libgnome/ChangeLog           |   11 ++++
 libgnome/Makefile.am         |    2 +
 libgnome/gnome-init.c        |   57 ++++++++++++++++++-
 libgnome/gnome-init.h        |   12 ++++
 libgnome/gnome-preferences.c |  130 ++++++++++++++++++++++++++++++++++++++++++
 libgnome/gnome-preferences.h |   67 +++++++++++++++++++++
 libgnome/libgnome.h          |    2 +
 7 files changed, 280 insertions(+), 1 deletions(-)
---
diff --git a/libgnome/ChangeLog b/libgnome/ChangeLog
index aa68c62..636c105 100644
--- a/libgnome/ChangeLog
+++ b/libgnome/ChangeLog
@@ -1,3 +1,14 @@
+2001-04-29  Martin Baulig  <baulig suse de>
+
+	* libgnome-init.[ch]
+	(GNOME_PARAM_DESKTOP_CONFIG_DATABASE): New property.
+	(GNOME_PARAM_DESKTOP_CONFIG_MONIKER): Likewise.
+	(gnome_program_get_desktop_config_database): New function.
+
+	* gnome-preferences.[ch]: New files; this has the same API than
+	libgnomeui/gnome-preferences.[ch], but it's using bonobo-conf
+	internally.
+
 2001-04-24  Martin Baulig  <baulig suse de>
 
 	* Makefile.am (libgnome_headers): Added gnome-i18n.h.
diff --git a/libgnome/Makefile.am b/libgnome/Makefile.am
index b56f7d8..b4c84c3 100644
--- a/libgnome/Makefile.am
+++ b/libgnome/Makefile.am
@@ -51,6 +51,7 @@ libgnome_2_la_SOURCES = \
 	gnome-url.c		\
 	gnome-util.c		\
 	gnome-paper.c		\
+	gnome-preferences.c	\
 	libgnome-init.c		\
 	libgnometypes.c
 
@@ -68,6 +69,7 @@ libgnome_headers = \
 	gnome-url.h		\
 	gnome-util.h   		\
 	gnome-paper.h		\
+	gnome-preferences.h	\
 	libgnome-init.h		\
 	libgnome.h
 
diff --git a/libgnome/gnome-init.c b/libgnome/gnome-init.c
index 1e4392a..01d4377 100644
--- a/libgnome/gnome-init.c
+++ b/libgnome/gnome-init.c
@@ -85,6 +85,8 @@ GnomeModuleInfo gnome_oaf_module_info = {
  *****************************************************************************/
 
 typedef struct {
+    guint desktop_config_database_id;
+    guint desktop_config_moniker_id;
     guint config_database_id;
     guint config_moniker_id;
 } GnomeProgramClass_libbonobo;
@@ -94,6 +96,9 @@ typedef struct {
 
     gchar *config_moniker;
     BonoboObjectClient *config_database;
+
+    gchar *desktop_config_moniker;
+    BonoboObjectClient *desktop_config_database;
 } GnomeProgramPrivate_libbonobo;
 
 static GQuark quark_gnome_program_private_libbonobo = 0;
@@ -120,6 +125,27 @@ gnome_program_get_config_database (GnomeProgram *program)
     return corba_retval;
 }
 
+Bonobo_ConfigDatabase
+gnome_program_get_desktop_config_database (GnomeProgram *program)
+{
+    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_DESKTOP_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 corba_retval;
+}
+
 static void
 libbonobo_get_property (GObject *object, guint param_id, GValue *value,
 			GParamSpec *pspec)
@@ -140,13 +166,17 @@ libbonobo_get_property (GObject *object, guint param_id, GValue *value,
 	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 if (param_id == cdata->desktop_config_database_id)
+	g_value_set_object (value, (GObject *) priv->desktop_config_database);
+    else if (param_id == cdata->desktop_config_moniker_id)
+	g_value_set_string (value, priv->desktop_config_moniker);
     else
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
 }
 
 static void
 libbonobo_set_property (GObject *object, guint param_id,
-			  const GValue *value, GParamSpec *pspec)
+			const GValue *value, GParamSpec *pspec)
 {
     GnomeProgramClass_libbonobo *cdata;
     GnomeProgramPrivate_libbonobo *priv;
@@ -167,6 +197,12 @@ libbonobo_set_property (GObject *object, guint param_id,
 		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 if (param_id == cdata->desktop_config_database_id) {
+	    priv->desktop_config_database = (BonoboObjectClient *) g_value_get_object (value);
+	    if (priv->desktop_config_database)
+		bonobo_object_client_ref (priv->desktop_config_database, NULL);
+	} else if (param_id == cdata->desktop_config_moniker_id)
+	    priv->desktop_config_moniker = g_value_dup_string (value);
 	else
 	    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
     } else {
@@ -206,6 +242,20 @@ libbonobo_class_init (GnomeProgramClass *klass, const GnomeModuleInfo *mod_info)
 			      BONOBO_OBJECT_CLIENT_TYPE,
 			      (G_PARAM_READABLE | G_PARAM_WRITABLE |
 			       G_PARAM_CONSTRUCT_ONLY)));
+
+    cdata->desktop_config_moniker_id = gnome_program_install_property
+	(klass, libbonobo_get_property, libbonobo_set_property,
+	 g_param_spec_string (GNOME_PARAM_DESKTOP_CONFIG_MONIKER, NULL, NULL,
+			      NULL,
+			      (G_PARAM_READABLE | G_PARAM_WRITABLE |
+			       G_PARAM_CONSTRUCT_ONLY)));
+
+    cdata->desktop_config_database_id = gnome_program_install_property
+	(klass, libbonobo_get_property, libbonobo_set_property,
+	 g_param_spec_object (GNOME_PARAM_DESKTOP_CONFIG_DATABASE, NULL, NULL,
+			      BONOBO_OBJECT_CLIENT_TYPE,
+			      (G_PARAM_READABLE | G_PARAM_WRITABLE |
+			       G_PARAM_CONSTRUCT_ONLY)));
 }
 
 static void
@@ -222,6 +272,7 @@ 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);
 
@@ -234,6 +285,10 @@ libbonobo_post_args_parse (GnomeProgram *program, GnomeModuleInfo *mod_info)
     priv->constructed = TRUE;
 
     g_message (G_STRLOC ": %p - `%s'", priv->config_database, priv->config_moniker);
+
+    CORBA_exception_init (&ev);
+    bonobo_get_object (priv->config_moniker, "Bonobo/ConfigDatabase", &ev);
+    CORBA_exception_free (&ev);
 }
 
 static GnomeModuleRequirement libbonobo_requirements[] = {
diff --git a/libgnome/gnome-init.h b/libgnome/gnome-init.h
index 2047b90..8c148fd 100644
--- a/libgnome/gnome-init.h
+++ b/libgnome/gnome-init.h
@@ -32,6 +32,18 @@
 
 G_BEGIN_DECLS
 
+/*
+ * Bonobo::ConfigDatabase for desktop-wide settings.
+ */
+Bonobo_ConfigDatabase
+gnome_program_get_desktop_config_database (GnomeProgram *program);
+
+#define GNOME_PARAM_DESKTOP_CONFIG_DATABASE "desktop-config-database"
+#define GNOME_PARAM_DESKTOP_CONFIG_MONIKER  "desktop-config-moniker"
+
+/*
+ * Bonobo::ConfigDatabase for per-application settings.
+ */
 Bonobo_ConfigDatabase
 gnome_program_get_config_database (GnomeProgram *program);
 
diff --git a/libgnome/gnome-preferences.c b/libgnome/gnome-preferences.c
new file mode 100644
index 0000000..155a711
--- /dev/null
+++ b/libgnome/gnome-preferences.c
@@ -0,0 +1,130 @@
+/* GNOME GUI Library: gnome-preferences.c
+ * Copyright (C) 1998 Free Software Foundation
+ * Author: Havoc Pennington
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
+ */
+
+#include <config.h>
+#include <libgnome/gnome-preferences.h>
+#include <libgnome/libgnome-init.h>
+#include <bonobo/bonobo-config-database.h>
+#include <string.h>
+
+static gboolean
+desktop_property_get_boolean (const gchar *name)
+{
+    Bonobo_ConfigDatabase cb;
+
+    cb = gnome_program_get_desktop_config_database (gnome_program_get ());
+    if (cb == CORBA_OBJECT_NIL)
+	return FALSE;
+
+    return bonobo_config_get_boolean (cb, name, NULL);
+}
+
+static void
+desktop_property_set_boolean (const gchar *name, gboolean value)
+{
+    Bonobo_ConfigDatabase cb;
+
+    cb = gnome_program_get_desktop_config_database (gnome_program_get ());
+    if (cb == CORBA_OBJECT_NIL)
+	return;
+
+    bonobo_config_set_boolean (cb, name, value, NULL);
+}
+
+#define DEFINE_DESKTOP_PROP_BOOLEAN(c_name, prop_name)  \
+gboolean                                                \
+gnome_preferences_get_##c_name## (void)                 \
+{                                                       \
+    return desktop_property_get_boolean (##prop_name##);\
+}                                                       \
+void                                                    \
+gnome_preferences_set_##c_name## (gboolean value)       \
+{                                                       \
+    desktop_property_set_boolean (##prop_name##, value);\
+}
+
+/**
+ * Description:
+ * Determine whether or not the statusbar is a dialog.
+ **/
+DEFINE_DESKTOP_PROP_BOOLEAN (statusbar_dialog, "statusbar-dialog");
+
+/**
+ * Description:
+ * Determine whether or not the statusbar is interactive.
+ **/
+DEFINE_DESKTOP_PROP_BOOLEAN (statusbar_interactive, "statusbar-interactive");
+
+/**
+ * Description:
+ * Determine whether or not the statusbar's meter is on the right-hand side. 
+ **/
+DEFINE_DESKTOP_PROP_BOOLEAN (statusbar_meter_on_right, "statusbar-meter-on-right");
+
+/**
+ * Description:
+ * Determine whether or not a menu bar is, by default,
+ * detachable from its parent frame.
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (menubar_detachable, "menubar-detachable");
+
+/**
+ * Description:
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (menubar_relief, "menubar-relief");
+
+/**
+ * Description:
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (toolbar_detachable, "toolbar-detachable");
+
+/**
+ * Description:
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (toolbar_relief, "toolbar-relief");
+
+/**
+ * Description:
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (toolbar_relief_btn, "toolbar-relief-btn");
+
+/**
+ * Description:
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (toolbar_lines, "toolbar-lines");
+
+/**
+ * Description:
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (toolbar_labels, "toolbar-labels");
+
+/**
+ * Description:
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (dialog_centered, "dialog-centered");
+
+/**
+ * Description:
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (menus_have_tearoff, "menus-have-tearoff");
+
+/**
+ * Description:
+ */
+DEFINE_DESKTOP_PROP_BOOLEAN (menus_have_icons, "menus-have-icons");
diff --git a/libgnome/gnome-preferences.h b/libgnome/gnome-preferences.h
new file mode 100644
index 0000000..6259584
--- /dev/null
+++ b/libgnome/gnome-preferences.h
@@ -0,0 +1,67 @@
+#ifndef GNOME_PREFERENCES_H
+#define GNOME_PREFERENCES_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/* Whether to use the statusbar instead of dialogs when possible:
+   TRUE means use the statusbar */
+gboolean          gnome_preferences_get_statusbar_dialog     (void);
+void              gnome_preferences_set_statusbar_dialog     (gboolean statusbar);
+
+/* Whether the statusbar can be used for interactive questions 
+   TRUE means the statusbar is interactive */
+gboolean          gnome_preferences_get_statusbar_interactive(void);
+void              gnome_preferences_set_statusbar_interactive(gboolean b);
+
+/* Whether the AppBar progress meter goes on the right or left */
+gboolean          gnome_preferences_get_statusbar_meter_on_right (void);
+void              gnome_preferences_set_statusbar_meter_on_right (gboolean status_meter_on_right);
+
+
+/* Whether menubars can be detached */
+gboolean          gnome_preferences_get_menubar_detachable   (void);
+void              gnome_preferences_set_menubar_detachable   (gboolean b);
+
+/* Whether menubars have a beveled edge */
+gboolean          gnome_preferences_get_menubar_relief       (void);
+void              gnome_preferences_set_menubar_relief       (gboolean b);
+
+/* Whether toolbars can be detached */
+gboolean          gnome_preferences_get_toolbar_detachable   (void);
+void              gnome_preferences_set_toolbar_detachable   (gboolean b);
+
+/* Whether toolbars have a beveled edge  */
+gboolean          gnome_preferences_get_toolbar_relief       (void);
+void              gnome_preferences_set_toolbar_relief       (gboolean b);
+
+/* Whether toolbar buttons have a beveled edge */
+gboolean          gnome_preferences_get_toolbar_relief_btn   (void);
+void              gnome_preferences_set_toolbar_relief_btn   (gboolean b);
+
+/* Whether toolbars show lines in separators  */
+gboolean          gnome_preferences_get_toolbar_lines        (void);
+void              gnome_preferences_set_toolbar_lines        (gboolean b);
+
+/* Whether toolbars show labels  */
+gboolean          gnome_preferences_get_toolbar_labels       (void);
+void              gnome_preferences_set_toolbar_labels       (gboolean b);
+
+/* Whether to try to center dialogs over their parent window.
+   If it's possible, dialog_position is ignored. If not,
+   fall back to dialog_position. */
+gboolean          gnome_preferences_get_dialog_centered      (void);
+void              gnome_preferences_set_dialog_centered      (gboolean b);
+
+/* Whether menus can be torn off */
+gboolean          gnome_preferences_get_menus_have_tearoff   (void);
+void              gnome_preferences_set_menus_have_tearoff   (gboolean b);
+
+/* Whether menu items have icons in them or not */
+int               gnome_preferences_get_menus_have_icons (void);
+void              gnome_preferences_set_menus_have_icons (int have_icons);
+
+G_END_DECLS
+
+#endif
diff --git a/libgnome/libgnome.h b/libgnome/libgnome.h
index baf93b0..d508d23 100644
--- a/libgnome/libgnome.h
+++ b/libgnome/libgnome.h
@@ -41,6 +41,8 @@
 #include <libgnome/gnome-url.h>
 #include <libgnome/gnome-ditem.h>
 
+#include <libgnome/gnome-preferences.h>
+
 #include <libgnome/libgnome-init.h>
 
 #ifdef COMPAT_1_0



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