Default to TRUE on enabled; check value of wallpaper_filename to set
2001-09-13 Bradford Hovinen <hovinen@ximian.com> * preferences.c (preferences_load_from_bonobo_db): (preferences_load_from_bonobo_pbag): Default to TRUE on enabled; check value of wallpaper_filename to set wallpaper_enabled if wallpaper_enabled could not be found * background-properties-capplet.c (setup_dialog): (apply_settings): Check for error condition after creating preferences object * preferences.c (preferences_destroy): Make this static (read_color_from_string): Made argument const (bonobo_color_to_gdk): Made argument const (DB_GET_VALUE): Removed (PB_GET_VALUE): Removed (preferences_load_from_bonobo_pbag): Use local_bonobo_property_bag_client_get_value_{color|filename} (preferences_new_from_bonobo_db): (preferences_new_from_bonobo_pbag): Deallocate object and return NULL if there was an error (local_bonobo_property_bag_client_get_value_color): (local_bonobo_property_bag_client_get_value_filename): Implement (MAKE_GET_SIMPLE): Implement (copy from bonobo-conf) (preferences_load_from_bonobo_pbag): Read enabled property (preferences_load_from_bonobo_pbag): Forgive wallpaper_enabled and enabled not being found * applier.c (applier_render_gradient_p): Implement (applier_destroy): Make this static * preferences.c (preferences_load_from_bonobo_db): Use bonobo_config_get_boolean rather than BONOBO_ARG_GET_BOOLEAN (DB_GET_VALUE ()). Ditto bonobo_config_get_long (preferences_load_from_bonobo_db): Pass ev pointer to each call to bonobo_config_get_* (preferences_load_from_bonobo_db): Check ev pointer after each call to bonobo_config_get_* and return if an exception is set (preferences_load_from_bonobo_db): Allow the enabled flag not to be present in the database since some older configurations don't have it included (all): Remove support for compiling without bonobo-conf
This commit is contained in:
parent
d64bf81275
commit
84cbbbff3e
6 changed files with 270 additions and 526 deletions
|
@ -1,3 +1,46 @@
|
||||||
|
2001-09-13 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* preferences.c (preferences_load_from_bonobo_db):
|
||||||
|
(preferences_load_from_bonobo_pbag): Default to TRUE on enabled;
|
||||||
|
check value of wallpaper_filename to set wallpaper_enabled if
|
||||||
|
wallpaper_enabled could not be found
|
||||||
|
|
||||||
|
* background-properties-capplet.c (setup_dialog):
|
||||||
|
(apply_settings): Check for error condition after creating
|
||||||
|
preferences object
|
||||||
|
|
||||||
|
* preferences.c (preferences_destroy): Make this static
|
||||||
|
(read_color_from_string): Made argument const
|
||||||
|
(bonobo_color_to_gdk): Made argument const
|
||||||
|
(DB_GET_VALUE): Removed
|
||||||
|
(PB_GET_VALUE): Removed
|
||||||
|
(preferences_load_from_bonobo_pbag): Use
|
||||||
|
local_bonobo_property_bag_client_get_value_{color|filename}
|
||||||
|
(preferences_new_from_bonobo_db):
|
||||||
|
(preferences_new_from_bonobo_pbag): Deallocate object and return
|
||||||
|
NULL if there was an error
|
||||||
|
(local_bonobo_property_bag_client_get_value_color):
|
||||||
|
(local_bonobo_property_bag_client_get_value_filename): Implement
|
||||||
|
(MAKE_GET_SIMPLE): Implement (copy from bonobo-conf)
|
||||||
|
(preferences_load_from_bonobo_pbag): Read enabled property
|
||||||
|
(preferences_load_from_bonobo_pbag): Forgive wallpaper_enabled and
|
||||||
|
enabled not being found
|
||||||
|
|
||||||
|
* applier.c (applier_render_gradient_p): Implement
|
||||||
|
(applier_destroy): Make this static
|
||||||
|
|
||||||
|
* preferences.c (preferences_load_from_bonobo_db): Use
|
||||||
|
bonobo_config_get_boolean rather than BONOBO_ARG_GET_BOOLEAN
|
||||||
|
(DB_GET_VALUE ()). Ditto bonobo_config_get_long
|
||||||
|
(preferences_load_from_bonobo_db): Pass ev pointer to each call to
|
||||||
|
bonobo_config_get_*
|
||||||
|
(preferences_load_from_bonobo_db): Check ev pointer after each
|
||||||
|
call to bonobo_config_get_* and return if an exception is set
|
||||||
|
(preferences_load_from_bonobo_db): Allow the enabled flag not to
|
||||||
|
be present in the database since some older configurations don't
|
||||||
|
have it included
|
||||||
|
(all): Remove support for compiling without bonobo-conf
|
||||||
|
|
||||||
2001-09-07 Richard Hestilow <hestilow@ximian.com>
|
2001-09-07 Richard Hestilow <hestilow@ximian.com>
|
||||||
|
|
||||||
* background-properties.glade: Redid UI a bit to add new enabled
|
* background-properties.glade: Redid UI a bit to add new enabled
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
/* -*- mode: c; style: linux -*- */
|
/* -*- mode: c; style: linux -*- */
|
||||||
|
|
||||||
/* apply.c
|
/* applier.c
|
||||||
* Copyright (C) 2000 Helix Code, Inc.
|
* Copyright (C) 2001 Ximian, Inc.
|
||||||
*
|
*
|
||||||
* Written by Bradford Hovinen <hovinen@helixcode.com>
|
* Written by Bradford Hovinen <hovinen@ximian.com>
|
||||||
* Parts written by Jamie Zawinski <jwz@jwz.org>
|
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -113,6 +112,8 @@ static void applier_get_arg (GtkObject *object,
|
||||||
GtkArg *arg,
|
GtkArg *arg,
|
||||||
guint arg_id);
|
guint arg_id);
|
||||||
|
|
||||||
|
static void applier_destroy (GtkObject *object);
|
||||||
|
|
||||||
static void run_render_pipeline (Renderer *renderer,
|
static void run_render_pipeline (Renderer *renderer,
|
||||||
Preferences *old_prefs,
|
Preferences *old_prefs,
|
||||||
Preferences *new_prefs,
|
Preferences *new_prefs,
|
||||||
|
@ -132,8 +133,10 @@ static void renderer_render_wallpaper (Renderer *renderer);
|
||||||
static void renderer_create_pixmap (Renderer *renderer);
|
static void renderer_create_pixmap (Renderer *renderer);
|
||||||
static void renderer_render_to_screen (Renderer *renderer);
|
static void renderer_render_to_screen (Renderer *renderer);
|
||||||
|
|
||||||
static guchar *fill_gradient (gint w, gint h,
|
static guchar *fill_gradient (gint w,
|
||||||
GdkColor *c1, GdkColor *c2,
|
gint h,
|
||||||
|
GdkColor *c1,
|
||||||
|
GdkColor *c2,
|
||||||
orientation_t orientation);
|
orientation_t orientation);
|
||||||
static void get_geometry (wallpaper_type_t wallpaper_type,
|
static void get_geometry (wallpaper_type_t wallpaper_type,
|
||||||
GdkPixbuf *pixbuf,
|
GdkPixbuf *pixbuf,
|
||||||
|
@ -268,7 +271,7 @@ applier_new (void)
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
applier_destroy (GtkObject *object)
|
applier_destroy (GtkObject *object)
|
||||||
{
|
{
|
||||||
Applier *applier;
|
Applier *applier;
|
||||||
|
@ -406,6 +409,12 @@ applier_apply_prefs (Applier *applier,
|
||||||
gtk_object_unref (GTK_OBJECT (new_prefs));
|
gtk_object_unref (GTK_OBJECT (new_prefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
applier_render_gradient_p (Applier *applier)
|
||||||
|
{
|
||||||
|
return render_gradient_p (applier->private->preview_renderer, applier->private->preview_prefs);
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
applier_get_preview_widget (Applier *applier)
|
applier_get_preview_widget (Applier *applier)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,16 +52,18 @@ struct _ApplierClass
|
||||||
GtkObjectClass klass;
|
GtkObjectClass klass;
|
||||||
};
|
};
|
||||||
|
|
||||||
guint applier_get_type (void);
|
guint applier_get_type (void);
|
||||||
|
|
||||||
GtkObject *applier_new (void);
|
GtkObject *applier_new (void);
|
||||||
void applier_destroy (GtkObject *object);
|
|
||||||
|
|
||||||
void applier_apply_prefs (Applier *applier, const Preferences *prefs,
|
void applier_apply_prefs (Applier *applier,
|
||||||
gboolean do_root, gboolean do_preview);
|
const Preferences *prefs,
|
||||||
|
gboolean do_root,
|
||||||
|
gboolean do_preview);
|
||||||
|
|
||||||
GtkWidget *applier_get_preview_widget (Applier *applier);
|
gboolean applier_render_gradient_p (Applier *applier);
|
||||||
|
|
||||||
GdkPixbuf *applier_get_wallpaper_pixbuf (Applier *applier);
|
GtkWidget *applier_get_preview_widget (Applier *applier);
|
||||||
|
GdkPixbuf *applier_get_wallpaper_pixbuf (Applier *applier);
|
||||||
|
|
||||||
#endif /* __APPLIER_H */
|
#endif /* __APPLIER_H */
|
||||||
|
|
|
@ -53,7 +53,7 @@ const struct poptOption options [] = {
|
||||||
static void
|
static void
|
||||||
apply_settings (Bonobo_ConfigDatabase db)
|
apply_settings (Bonobo_ConfigDatabase db)
|
||||||
{
|
{
|
||||||
Preferences *prefs;
|
GtkObject *prefs;
|
||||||
CORBA_Environment ev;
|
CORBA_Environment ev;
|
||||||
|
|
||||||
CORBA_exception_init (&ev);
|
CORBA_exception_init (&ev);
|
||||||
|
@ -66,9 +66,14 @@ apply_settings (Bonobo_ConfigDatabase db)
|
||||||
Bonobo_ConfigDatabase_sync (db, &ev);
|
Bonobo_ConfigDatabase_sync (db, &ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
prefs = PREFERENCES (preferences_new_from_bonobo_db (db, &ev));
|
prefs = preferences_new_from_bonobo_db (db, &ev);
|
||||||
applier_apply_prefs (applier, prefs, TRUE, FALSE);
|
|
||||||
gtk_object_destroy (GTK_OBJECT (prefs));
|
if (BONOBO_EX (&ev) || prefs == NULL) {
|
||||||
|
g_critical ("Could not retrieve configuration from database (%s)", ev._repo_id);
|
||||||
|
} else {
|
||||||
|
applier_apply_prefs (applier, PREFERENCES (prefs), TRUE, FALSE);
|
||||||
|
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||||
|
}
|
||||||
|
|
||||||
CORBA_exception_free (&ev);
|
CORBA_exception_free (&ev);
|
||||||
}
|
}
|
||||||
|
@ -267,6 +272,7 @@ setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||||
GladeXML *dialog;
|
GladeXML *dialog;
|
||||||
Applier *applier;
|
Applier *applier;
|
||||||
GtkObject *prefs;
|
GtkObject *prefs;
|
||||||
|
Bonobo_Property prop;
|
||||||
|
|
||||||
CORBA_Environment ev;
|
CORBA_Environment ev;
|
||||||
|
|
||||||
|
@ -293,7 +299,11 @@ setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||||
bonobo_property_bag_client_set_value_gboolean (bag, "enabled", TRUE, NULL);
|
bonobo_property_bag_client_set_value_gboolean (bag, "enabled", TRUE, NULL);
|
||||||
|
|
||||||
prefs = preferences_new_from_bonobo_pbag (bag, &ev);
|
prefs = preferences_new_from_bonobo_pbag (bag, &ev);
|
||||||
gtk_object_set_data (GTK_OBJECT (prefs), "glade-data", dialog);
|
|
||||||
|
if (BONOBO_EX (&ev) || prefs == NULL)
|
||||||
|
g_error ("Could not retrieve configuration from property bag (%s)", ev._repo_id);
|
||||||
|
|
||||||
|
gtk_object_set_data (prefs, "glade-data", dialog);
|
||||||
bonobo_event_source_client_add_listener (bag, (BonoboListenerCallbackFn) property_change_cb,
|
bonobo_event_source_client_add_listener (bag, (BonoboListenerCallbackFn) property_change_cb,
|
||||||
NULL, NULL, prefs);
|
NULL, NULL, prefs);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* -*- mode: c; style: linux -*- */
|
/* -*- mode: c; style: linux -*- */
|
||||||
|
|
||||||
/* preferences.c
|
/* preferences.c
|
||||||
* Copyright (C) 2000 Helix Code, Inc.
|
* Copyright (C) 2001 Ximian, Inc.
|
||||||
*
|
*
|
||||||
* Written by Bradford Hovinen <hovinen@helixcode.com>
|
* Written by Bradford Hovinen <hovinen@ximian.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -29,31 +29,58 @@
|
||||||
|
|
||||||
#include <gnome.h>
|
#include <gnome.h>
|
||||||
#include <gdk-pixbuf/gdk-pixbuf-xlibrgb.h>
|
#include <gdk-pixbuf/gdk-pixbuf-xlibrgb.h>
|
||||||
#include <capplet-widget.h>
|
#include <bonobo.h>
|
||||||
|
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "applier.h"
|
#include "applier.h"
|
||||||
|
|
||||||
|
/* Convenience macro to abort if there is an exception set */
|
||||||
|
|
||||||
|
#define RETURN_IF_EX(ev) if (BONOBO_EX (ev)) return
|
||||||
|
|
||||||
|
/* Copied from bonobo-conf bonobo-config-database.c
|
||||||
|
*
|
||||||
|
* Note to Dietmar: You should include these functions in
|
||||||
|
* bonobo-config-database.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAKE_GET_SIMPLE(c_type, default, name, corba_tc, extract_fn) \
|
||||||
|
static c_type local_bonobo_config_get_##name (Bonobo_ConfigDatabase db, \
|
||||||
|
const char *key, \
|
||||||
|
CORBA_Environment *opt_ev) \
|
||||||
|
{ \
|
||||||
|
CORBA_any *value; \
|
||||||
|
c_type retval; \
|
||||||
|
if (!(value = bonobo_config_get_value (db, key, corba_tc, opt_ev))) \
|
||||||
|
return default; \
|
||||||
|
retval = extract_fn; \
|
||||||
|
CORBA_free (value); \
|
||||||
|
return retval; \
|
||||||
|
}
|
||||||
|
|
||||||
static GtkObjectClass *parent_class;
|
static GtkObjectClass *parent_class;
|
||||||
static Applier *applier = NULL;
|
static Applier *applier = NULL;
|
||||||
|
|
||||||
static void preferences_init (Preferences *prefs);
|
static void preferences_init (Preferences *prefs);
|
||||||
static void preferences_class_init (PreferencesClass *class);
|
static void preferences_class_init (PreferencesClass *class);
|
||||||
|
|
||||||
#ifdef BONOBO_CONF_ENABLE
|
static void preferences_destroy (GtkObject *object);
|
||||||
#include <bonobo.h>
|
|
||||||
#else
|
|
||||||
static gint xml_read_int (xmlNodePtr node);
|
|
||||||
static xmlNodePtr xml_write_int (gchar *name,
|
|
||||||
gint number);
|
|
||||||
static gboolean xml_read_bool (xmlNodePtr node);
|
|
||||||
static xmlNodePtr xml_write_bool (gchar *name,
|
|
||||||
gboolean value);
|
|
||||||
|
|
||||||
static gint apply_timeout_cb (Preferences *prefs);
|
static GdkColor *read_color_from_string (const gchar *string);
|
||||||
#endif
|
static GdkColor *bonobo_color_to_gdk (const Bonobo_Config_Color *color);
|
||||||
|
|
||||||
static GdkColor *read_color_from_string (gchar *string);
|
static gulong local_bonobo_property_bag_client_get_value_gulong (Bonobo_PropertyBag pb,
|
||||||
|
const gchar *propname,
|
||||||
|
CORBA_Environment *ev);
|
||||||
|
static GdkColor *local_bonobo_property_bag_client_get_value_color (Bonobo_PropertyBag pb,
|
||||||
|
const gchar *propname,
|
||||||
|
CORBA_Environment *ev);
|
||||||
|
static gchar *local_bonobo_property_bag_client_get_value_filename (Bonobo_PropertyBag pb,
|
||||||
|
const gchar *propname,
|
||||||
|
CORBA_Environment *ev);
|
||||||
|
|
||||||
|
MAKE_GET_SIMPLE (gchar *, NULL, filename, TC_Bonobo_Config_FileName, g_strdup (((CORBA_char **) value->_value)[0]))
|
||||||
|
MAKE_GET_SIMPLE (GdkColor *, NULL, color, TC_Bonobo_Config_Color, bonobo_color_to_gdk ((Bonobo_Config_Color *) value->_value))
|
||||||
|
|
||||||
guint
|
guint
|
||||||
preferences_get_type (void)
|
preferences_get_type (void)
|
||||||
|
@ -160,7 +187,7 @@ preferences_clone (const Preferences *prefs)
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
preferences_destroy (GtkObject *object)
|
preferences_destroy (GtkObject *object)
|
||||||
{
|
{
|
||||||
Preferences *prefs;
|
Preferences *prefs;
|
||||||
|
@ -176,39 +203,6 @@ preferences_destroy (GtkObject *object)
|
||||||
parent_class->destroy (object);
|
parent_class->destroy (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BONOBO_CONF_ENABLE
|
|
||||||
|
|
||||||
static GdkColor*
|
|
||||||
bonobo_color_to_gdk (Bonobo_Config_Color *color)
|
|
||||||
{
|
|
||||||
GdkColor *ret;
|
|
||||||
|
|
||||||
g_return_val_if_fail (color != NULL, NULL);
|
|
||||||
|
|
||||||
ret = g_new0 (GdkColor, 1);
|
|
||||||
ret->red = color->r * 65535;
|
|
||||||
ret->green = color->g * 65535;
|
|
||||||
ret->blue = color->b * 65535;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gulong
|
|
||||||
bonobo_property_bag_client_get_value_gulong (Bonobo_PropertyBag pb, gchar *propname, CORBA_Environment *ev)
|
|
||||||
{
|
|
||||||
BonoboArg *arg;
|
|
||||||
gulong retval;
|
|
||||||
|
|
||||||
arg = bonobo_property_bag_client_get_value_any (pb, propname, ev);
|
|
||||||
if (BONOBO_EX (ev)) return 0;
|
|
||||||
retval = BONOBO_ARG_GET_GENERAL (arg, TC_ulong, CORBA_long, ev);
|
|
||||||
bonobo_arg_release (arg);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PB_GET_VALUE(v) (bonobo_property_bag_client_get_value_any (pb, (v), NULL))
|
|
||||||
|
|
||||||
GtkObject *
|
GtkObject *
|
||||||
preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb, CORBA_Environment *ev)
|
preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb, CORBA_Environment *ev)
|
||||||
{
|
{
|
||||||
|
@ -220,6 +214,11 @@ preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb, CORBA_Environment *ev)
|
||||||
prefs = PREFERENCES (preferences_new ());
|
prefs = PREFERENCES (preferences_new ());
|
||||||
preferences_load_from_bonobo_pbag (prefs, pb, ev);
|
preferences_load_from_bonobo_pbag (prefs, pb, ev);
|
||||||
|
|
||||||
|
if (BONOBO_EX (ev)) {
|
||||||
|
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return GTK_OBJECT (prefs);
|
return GTK_OBJECT (prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,19 +232,35 @@ preferences_load_from_bonobo_pbag (Preferences *prefs,
|
||||||
g_return_if_fail (pb != CORBA_OBJECT_NIL);
|
g_return_if_fail (pb != CORBA_OBJECT_NIL);
|
||||||
g_return_if_fail (ev != NULL);
|
g_return_if_fail (ev != NULL);
|
||||||
|
|
||||||
prefs->wallpaper_type = bonobo_property_bag_client_get_value_gulong (pb, "wallpaper_type", ev);
|
prefs->enabled = bonobo_property_bag_client_get_value_gboolean (pb, "enabled", ev);
|
||||||
prefs->wallpaper_filename = g_strdup (*((CORBA_char **)(PB_GET_VALUE ("wallpaper_filename"))->_value));
|
|
||||||
|
if (BONOBO_EX (ev) && !strcmp (ev->_repo_id, "IDL:Bonobo/PropertyBag/NotFound:1.0")) {
|
||||||
|
prefs->enabled = TRUE;
|
||||||
|
CORBA_exception_init (ev);
|
||||||
|
} else {
|
||||||
|
RETURN_IF_EX (ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
prefs->wallpaper_type = local_bonobo_property_bag_client_get_value_gulong (pb, "wallpaper_type", ev); RETURN_IF_EX (ev);
|
||||||
|
prefs->wallpaper_filename = local_bonobo_property_bag_client_get_value_filename (pb, "wallpaper_filename", ev); RETURN_IF_EX (ev);
|
||||||
|
|
||||||
prefs->wallpaper_enabled = bonobo_property_bag_client_get_value_gboolean (pb, "wallpaper_enabled", ev);
|
prefs->wallpaper_enabled = bonobo_property_bag_client_get_value_gboolean (pb, "wallpaper_enabled", ev);
|
||||||
|
|
||||||
prefs->color1 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(PB_GET_VALUE ("color1"))->_value);
|
|
||||||
prefs->color2 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(PB_GET_VALUE ("color2"))->_value);
|
|
||||||
|
|
||||||
prefs->opacity = BONOBO_ARG_GET_LONG (PB_GET_VALUE ("opacity"));
|
if (BONOBO_EX (ev) && !strcmp (ev->_repo_id, "IDL:Bonobo/PropertyBag/NotFound:1.0")) {
|
||||||
|
prefs->wallpaper_enabled = (prefs->wallpaper_filename != NULL && strcmp (prefs->wallpaper_filename, "(none)"));
|
||||||
|
CORBA_exception_init (ev);
|
||||||
|
} else {
|
||||||
|
RETURN_IF_EX (ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
prefs->color1 = local_bonobo_property_bag_client_get_value_color (pb, "color1", ev); RETURN_IF_EX (ev);
|
||||||
|
prefs->color2 = local_bonobo_property_bag_client_get_value_color (pb, "color2", ev); RETURN_IF_EX (ev);
|
||||||
|
|
||||||
|
prefs->opacity = bonobo_property_bag_client_get_value_glong (pb, "opacity", ev); RETURN_IF_EX (ev);
|
||||||
if (prefs->opacity >= 100 || prefs->opacity < 0)
|
if (prefs->opacity >= 100 || prefs->opacity < 0)
|
||||||
prefs->adjust_opacity = FALSE;
|
prefs->adjust_opacity = FALSE;
|
||||||
|
|
||||||
prefs->orientation = bonobo_property_bag_client_get_value_gulong (pb, "orientation", ev);
|
prefs->orientation = local_bonobo_property_bag_client_get_value_gulong (pb, "orientation", ev); RETURN_IF_EX (ev);
|
||||||
|
|
||||||
if (prefs->orientation == ORIENTATION_SOLID)
|
if (prefs->orientation == ORIENTATION_SOLID)
|
||||||
prefs->gradient_enabled = FALSE;
|
prefs->gradient_enabled = FALSE;
|
||||||
|
@ -253,8 +268,6 @@ preferences_load_from_bonobo_pbag (Preferences *prefs,
|
||||||
prefs->gradient_enabled = TRUE;
|
prefs->gradient_enabled = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DB_GET_VALUE(v) (bonobo_config_get_value (db, (v), NULL, NULL))
|
|
||||||
|
|
||||||
GtkObject *
|
GtkObject *
|
||||||
preferences_new_from_bonobo_db (Bonobo_ConfigDatabase db, CORBA_Environment *ev)
|
preferences_new_from_bonobo_db (Bonobo_ConfigDatabase db, CORBA_Environment *ev)
|
||||||
{
|
{
|
||||||
|
@ -266,6 +279,11 @@ preferences_new_from_bonobo_db (Bonobo_ConfigDatabase db, CORBA_Environment *ev)
|
||||||
prefs = PREFERENCES (preferences_new ());
|
prefs = PREFERENCES (preferences_new ());
|
||||||
preferences_load_from_bonobo_db (prefs, db, ev);
|
preferences_load_from_bonobo_db (prefs, db, ev);
|
||||||
|
|
||||||
|
if (BONOBO_EX (ev)) {
|
||||||
|
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return GTK_OBJECT (prefs);
|
return GTK_OBJECT (prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,33 +291,54 @@ void
|
||||||
preferences_load_from_bonobo_db (Preferences *prefs,
|
preferences_load_from_bonobo_db (Preferences *prefs,
|
||||||
Bonobo_ConfigDatabase db,
|
Bonobo_ConfigDatabase db,
|
||||||
CORBA_Environment *ev)
|
CORBA_Environment *ev)
|
||||||
{
|
{
|
||||||
g_return_if_fail (prefs != NULL);
|
g_return_if_fail (prefs != NULL);
|
||||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||||
g_return_if_fail (db != CORBA_OBJECT_NIL);
|
g_return_if_fail (db != CORBA_OBJECT_NIL);
|
||||||
g_return_if_fail (ev != NULL);
|
g_return_if_fail (ev != NULL);
|
||||||
|
|
||||||
prefs->enabled = bonobo_config_get_boolean (db, "/main/enabled", NULL);
|
prefs->enabled = bonobo_config_get_boolean (db, "/main/enabled", ev);
|
||||||
prefs->orientation = bonobo_config_get_ulong (db, "/main/orientation", NULL);
|
|
||||||
|
if (BONOBO_EX (ev) && !strcmp (ev->_repo_id, "IDL:Bonobo/ConfigDatabase/NotFound:1.0")) {
|
||||||
|
prefs->enabled = TRUE;
|
||||||
|
CORBA_exception_init (ev);
|
||||||
|
} else {
|
||||||
|
RETURN_IF_EX (ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
prefs->orientation = bonobo_config_get_ulong (db, "/main/orientation", ev); RETURN_IF_EX (ev);
|
||||||
|
|
||||||
if (prefs->orientation != ORIENTATION_SOLID)
|
if (prefs->orientation != ORIENTATION_SOLID)
|
||||||
prefs->gradient_enabled = TRUE;
|
prefs->gradient_enabled = TRUE;
|
||||||
else
|
else
|
||||||
prefs->gradient_enabled = FALSE;
|
prefs->gradient_enabled = FALSE;
|
||||||
|
|
||||||
prefs->wallpaper_type = bonobo_config_get_ulong (db, "/main/wallpaper_type", NULL);
|
prefs->wallpaper_type = bonobo_config_get_ulong (db, "/main/wallpaper_type", ev); RETURN_IF_EX (ev);
|
||||||
prefs->wallpaper_filename = g_strdup (*((CORBA_char **)(DB_GET_VALUE ("/main/wallpaper_filename"))->_value));
|
prefs->wallpaper_filename = local_bonobo_config_get_filename (db, "/main/wallpaper_filename", ev); RETURN_IF_EX (ev);
|
||||||
|
|
||||||
prefs->wallpaper_enabled = BONOBO_ARG_GET_BOOLEAN (DB_GET_VALUE ("/main/wallpaper_enabled"));
|
|
||||||
|
|
||||||
prefs->color1 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(DB_GET_VALUE ("/main/color1"))->_value);
|
prefs->wallpaper_enabled = bonobo_config_get_boolean (db, "/main/wallpaper_enabled", ev);
|
||||||
prefs->color2 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(DB_GET_VALUE ("/main/color2"))->_value);
|
|
||||||
|
if (BONOBO_EX (ev) && !strcmp (ev->_repo_id, "IDL:Bonobo/ConfigDatabase/NotFound:1.0")) {
|
||||||
|
prefs->wallpaper_enabled = (prefs->wallpaper_filename != NULL && strcmp (prefs->wallpaper_filename, "(none)"));
|
||||||
|
CORBA_exception_init (ev);
|
||||||
|
} else {
|
||||||
|
RETURN_IF_EX (ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
prefs->color1 = local_bonobo_config_get_color (db, "/main/color1", ev); RETURN_IF_EX (ev);
|
||||||
|
prefs->color2 = local_bonobo_config_get_color (db, "/main/color2", ev); RETURN_IF_EX (ev);
|
||||||
|
|
||||||
|
prefs->opacity = bonobo_config_get_long (db, "/main/opacity", ev); RETURN_IF_EX (ev);
|
||||||
|
|
||||||
prefs->opacity = BONOBO_ARG_GET_LONG (DB_GET_VALUE ("/main/opacity"));
|
|
||||||
if (prefs->opacity >= 100 || prefs->opacity < 0)
|
if (prefs->opacity >= 100 || prefs->opacity < 0)
|
||||||
prefs->adjust_opacity = FALSE;
|
prefs->adjust_opacity = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Parse the event name given (the event being notification of a property having
|
||||||
|
* changed and apply that change to the preferences structure. Eliminates the
|
||||||
|
* need to reload the structure entirely on every event notification
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
preferences_apply_event (Preferences *prefs,
|
preferences_apply_event (Preferences *prefs,
|
||||||
const gchar *event_name,
|
const gchar *event_name,
|
||||||
|
@ -361,410 +400,8 @@ preferences_apply_event (Preferences *prefs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !BONOBO_CONF_ENABLE */
|
|
||||||
|
|
||||||
void
|
|
||||||
preferences_load (Preferences *prefs)
|
|
||||||
{
|
|
||||||
gchar *string, *wp, *wp1;
|
|
||||||
int i, wps;
|
|
||||||
|
|
||||||
g_return_if_fail (prefs != NULL);
|
|
||||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
|
||||||
|
|
||||||
if (prefs->color1) g_free (prefs->color1);
|
|
||||||
string = gnome_config_get_string
|
|
||||||
("/Background/Default/color1=#39374b");
|
|
||||||
prefs->color1 = read_color_from_string (string);
|
|
||||||
g_free (string);
|
|
||||||
|
|
||||||
if (prefs->color2) g_free (prefs->color2);
|
|
||||||
string = gnome_config_get_string
|
|
||||||
("/Background/Default/color2=#42528f");
|
|
||||||
prefs->color2 = read_color_from_string (string);
|
|
||||||
g_free (string);
|
|
||||||
|
|
||||||
string = gnome_config_get_string ("/Background/Default/Enabled=True");
|
|
||||||
prefs->enabled = !(g_strcasecmp (string, "True"));
|
|
||||||
g_free (string);
|
|
||||||
|
|
||||||
string = gnome_config_get_string ("/Background/Default/type=simple");
|
|
||||||
if (!g_strcasecmp (string, "wallpaper"))
|
|
||||||
prefs->wallpaper_enabled = TRUE;
|
|
||||||
else if (g_strcasecmp (string, "simple"))
|
|
||||||
prefs->wallpaper_enabled = FALSE;
|
|
||||||
g_free (string);
|
|
||||||
|
|
||||||
string = gnome_config_get_string ("/Background/Default/simple=gradent");
|
|
||||||
if (!g_strcasecmp (string, "gradient"))
|
|
||||||
prefs->gradient_enabled = TRUE;
|
|
||||||
else if (g_strcasecmp (string, "solid"))
|
|
||||||
prefs->gradient_enabled = FALSE;
|
|
||||||
g_free (string);
|
|
||||||
|
|
||||||
string = gnome_config_get_string
|
|
||||||
("/Background/Default/gradient=vertical");
|
|
||||||
if (!g_strcasecmp (string, "vertical"))
|
|
||||||
prefs->orientation = ORIENTATION_VERT;
|
|
||||||
else if (!g_strcasecmp (string, "horizontal"))
|
|
||||||
prefs->orientation = ORIENTATION_HORIZ;
|
|
||||||
g_free (string);
|
|
||||||
|
|
||||||
prefs->wallpaper_type =
|
|
||||||
gnome_config_get_int ("/Background/Default/wallpaperAlign=0");
|
|
||||||
|
|
||||||
prefs->wallpaper_filename =
|
|
||||||
gnome_config_get_string
|
|
||||||
("/Background/Default/wallpaper=(None)");
|
|
||||||
prefs->wallpaper_sel_path =
|
|
||||||
gnome_config_get_string
|
|
||||||
("/Background/Default/wallpapers_dir=./");
|
|
||||||
|
|
||||||
prefs->auto_apply =
|
|
||||||
gnome_config_get_bool ("/Background/Default/autoApply=true");
|
|
||||||
|
|
||||||
if (!g_strcasecmp (prefs->wallpaper_filename, "(None)")) {
|
|
||||||
g_free (prefs->wallpaper_filename);
|
|
||||||
prefs->wallpaper_filename = NULL;
|
|
||||||
prefs->wallpaper_enabled = FALSE;
|
|
||||||
} else {
|
|
||||||
prefs->wallpaper_enabled = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
wps = gnome_config_get_int ("/Background/Default/wallpapers=0");
|
|
||||||
|
|
||||||
for (i = 0; i < wps; i++) {
|
|
||||||
wp = g_strdup_printf ("/Background/Default/wallpaper%d", i+1);
|
|
||||||
wp1 = gnome_config_get_string (wp);
|
|
||||||
g_free (wp);
|
|
||||||
|
|
||||||
if (wp1 == NULL) continue;
|
|
||||||
|
|
||||||
prefs->wallpapers = g_slist_prepend (prefs->wallpapers, wp1);
|
|
||||||
}
|
|
||||||
|
|
||||||
prefs->wallpapers = g_slist_reverse (prefs->wallpapers);
|
|
||||||
|
|
||||||
prefs->adjust_opacity =
|
|
||||||
gnome_config_get_bool
|
|
||||||
("/Background/Default/adjustOpacity=false");
|
|
||||||
|
|
||||||
prefs->opacity =
|
|
||||||
gnome_config_get_int ("/Background/Default/opacity=255");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
preferences_save (Preferences *prefs)
|
|
||||||
{
|
|
||||||
char buffer[16];
|
|
||||||
char *wp;
|
|
||||||
GSList *item;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
g_return_if_fail (prefs != NULL);
|
|
||||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
|
||||||
|
|
||||||
snprintf (buffer, sizeof(buffer), "#%02x%02x%02x",
|
|
||||||
prefs->color1->red >> 8,
|
|
||||||
prefs->color1->green >> 8,
|
|
||||||
prefs->color1->blue >> 8);
|
|
||||||
gnome_config_set_string ("/Background/Default/color1", buffer);
|
|
||||||
snprintf (buffer, sizeof(buffer), "#%02x%02x%02x",
|
|
||||||
prefs->color2->red >> 8,
|
|
||||||
prefs->color2->green >> 8,
|
|
||||||
prefs->color2->blue >> 8);
|
|
||||||
gnome_config_set_string ("/Background/Default/color2", buffer);
|
|
||||||
|
|
||||||
gnome_config_set_string ("/Background/Default/Enabled",
|
|
||||||
(prefs->enabled) ? "True" : "False");
|
|
||||||
|
|
||||||
gnome_config_set_string ("/Background/Default/simple",
|
|
||||||
(prefs->gradient_enabled) ?
|
|
||||||
"gradient" : "solid");
|
|
||||||
gnome_config_set_string ("/Background/Default/gradient",
|
|
||||||
(prefs->orientation == ORIENTATION_VERT) ?
|
|
||||||
"vertical" : "horizontal");
|
|
||||||
|
|
||||||
gnome_config_set_string ("/Background/Default/wallpaper",
|
|
||||||
(prefs->wallpaper_enabled) ?
|
|
||||||
prefs->wallpaper_filename : "(none)");
|
|
||||||
gnome_config_set_int ("/Background/Default/wallpaperAlign",
|
|
||||||
prefs->wallpaper_type);
|
|
||||||
|
|
||||||
gnome_config_set_int ("/Background/Default/wallpapers",
|
|
||||||
g_slist_length (prefs->wallpapers));
|
|
||||||
|
|
||||||
for (i = 1, item = prefs->wallpapers; item; i++, item = item->next) {
|
|
||||||
wp = g_strdup_printf ("/Background/Default/wallpaper%d", i);
|
|
||||||
gnome_config_set_string (wp, (char *)item->data);
|
|
||||||
g_free (wp);
|
|
||||||
}
|
|
||||||
|
|
||||||
gnome_config_set_bool ("/Background/Default/autoApply", prefs->auto_apply);
|
|
||||||
gnome_config_set_bool ("/Background/Default/adjustOpacity", prefs->adjust_opacity);
|
|
||||||
gnome_config_set_int ("/Background/Default/opacity",
|
|
||||||
prefs->opacity);
|
|
||||||
|
|
||||||
gnome_config_sync ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
preferences_changed (Preferences *prefs)
|
|
||||||
{
|
|
||||||
/* FIXME: This is a really horrible kludge... */
|
|
||||||
if (prefs->frozen > 1) return;
|
|
||||||
|
|
||||||
if (prefs->frozen == 0) {
|
|
||||||
if (prefs->timeout_id)
|
|
||||||
gtk_timeout_remove (prefs->timeout_id);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (prefs->auto_apply)
|
|
||||||
prefs->timeout_id =
|
|
||||||
gtk_timeout_add
|
|
||||||
(2000, (GtkFunction) apply_timeout_cb, prefs);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
preferences_apply_now (Preferences *prefs)
|
|
||||||
{
|
|
||||||
g_return_if_fail (prefs != NULL);
|
|
||||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
|
||||||
|
|
||||||
if (prefs->timeout_id)
|
|
||||||
gtk_timeout_remove (prefs->timeout_id);
|
|
||||||
|
|
||||||
prefs->timeout_id = 0;
|
|
||||||
|
|
||||||
applier_apply_prefs (applier, prefs, TRUE, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
preferences_apply_preview (Preferences *prefs)
|
|
||||||
{
|
|
||||||
g_return_if_fail (prefs != NULL);
|
|
||||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
|
||||||
|
|
||||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
preferences_freeze (Preferences *prefs)
|
|
||||||
{
|
|
||||||
prefs->frozen++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
preferences_thaw (Preferences *prefs)
|
|
||||||
{
|
|
||||||
if (prefs->frozen > 0) prefs->frozen--;
|
|
||||||
}
|
|
||||||
|
|
||||||
Preferences *
|
|
||||||
preferences_read_xml (xmlDocPtr xml_doc)
|
|
||||||
{
|
|
||||||
Preferences *prefs;
|
|
||||||
xmlNodePtr root_node, node;
|
|
||||||
char *str;
|
|
||||||
|
|
||||||
prefs = PREFERENCES (preferences_new ());
|
|
||||||
|
|
||||||
root_node = xmlDocGetRootElement (xml_doc);
|
|
||||||
|
|
||||||
if (strcmp (root_node->name, "background-properties"))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
prefs->wallpaper_enabled = FALSE;
|
|
||||||
prefs->gradient_enabled = FALSE;
|
|
||||||
prefs->orientation = ORIENTATION_VERT;
|
|
||||||
|
|
||||||
if (prefs->color1) {
|
|
||||||
g_free (prefs->color1);
|
|
||||||
prefs->color1 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prefs->color2) {
|
|
||||||
g_free (prefs->color2);
|
|
||||||
prefs->color2 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (node = root_node->childs; node; node = node->next) {
|
|
||||||
if (!strcmp (node->name, "bg-color1"))
|
|
||||||
prefs->color1 = read_color_from_string
|
|
||||||
(xmlNodeGetContent (node));
|
|
||||||
else if (!strcmp (node->name, "bg-color2"))
|
|
||||||
prefs->color2 = read_color_from_string
|
|
||||||
(xmlNodeGetContent (node));
|
|
||||||
else if (!strcmp (node->name, "enabled"))
|
|
||||||
prefs->enabled = xml_read_bool (node);
|
|
||||||
else if (!strcmp (node->name, "wallpaper"))
|
|
||||||
prefs->wallpaper_enabled = xml_read_bool (node);
|
|
||||||
else if (!strcmp (node->name, "gradient"))
|
|
||||||
prefs->gradient_enabled = xml_read_bool (node);
|
|
||||||
else if (!strcmp (node->name, "orientation")) {
|
|
||||||
str = xmlNodeGetContent (node);
|
|
||||||
|
|
||||||
if (!g_strcasecmp (str, "horizontal"))
|
|
||||||
prefs->orientation = ORIENTATION_HORIZ;
|
|
||||||
else if (!g_strcasecmp (str, "vertical"))
|
|
||||||
prefs->orientation = ORIENTATION_VERT;
|
|
||||||
}
|
|
||||||
else if (!strcmp (node->name, "wallpaper-type"))
|
|
||||||
prefs->wallpaper_type = xml_read_int (node);
|
|
||||||
else if (!strcmp (node->name, "wallpaper-filename"))
|
|
||||||
prefs->wallpaper_filename =
|
|
||||||
g_strdup (xmlNodeGetContent (node));
|
|
||||||
else if (!strcmp (node->name, "wallpaper-sel-path"))
|
|
||||||
prefs->wallpaper_sel_path =
|
|
||||||
g_strdup (xmlNodeGetContent (node));
|
|
||||||
else if (!strcmp (node->name, "auto-apply"))
|
|
||||||
prefs->auto_apply = xml_read_bool (node);
|
|
||||||
else if (!strcmp (node->name, "adjust-opacity"))
|
|
||||||
prefs->adjust_opacity = xml_read_bool (node);
|
|
||||||
else if (!strcmp (node->name, "opacity"))
|
|
||||||
prefs->opacity = xml_read_int (node);
|
|
||||||
}
|
|
||||||
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlDocPtr
|
|
||||||
preferences_write_xml (Preferences *prefs)
|
|
||||||
{
|
|
||||||
xmlDocPtr doc;
|
|
||||||
xmlNodePtr node;
|
|
||||||
char tmp[16];
|
|
||||||
|
|
||||||
doc = xmlNewDoc ("1.0");
|
|
||||||
|
|
||||||
node = xmlNewDocNode (doc, NULL, "background-properties", NULL);
|
|
||||||
|
|
||||||
snprintf (tmp, sizeof (tmp), "#%02x%02x%02x",
|
|
||||||
prefs->color1->red >> 8,
|
|
||||||
prefs->color1->green >> 8,
|
|
||||||
prefs->color1->blue >> 8);
|
|
||||||
xmlNewChild (node, NULL, "bg-color1", tmp);
|
|
||||||
|
|
||||||
snprintf (tmp, sizeof (tmp), "#%02x%02x%02x",
|
|
||||||
prefs->color2->red >> 8,
|
|
||||||
prefs->color2->green >> 8,
|
|
||||||
prefs->color2->blue >> 8);
|
|
||||||
xmlNewChild (node, NULL, "bg-color2", tmp);
|
|
||||||
|
|
||||||
xmlAddChild (node, xml_write_bool ("enabled", prefs->enabled));
|
|
||||||
xmlAddChild (node, xml_write_bool ("wallpaper",
|
|
||||||
prefs->wallpaper_enabled));
|
|
||||||
xmlAddChild (node, xml_write_bool ("gradient",
|
|
||||||
prefs->gradient_enabled));
|
|
||||||
|
|
||||||
xmlNewChild (node, NULL, "orientation",
|
|
||||||
(prefs->orientation == ORIENTATION_VERT) ?
|
|
||||||
"vertical" : "horizontal");
|
|
||||||
|
|
||||||
xmlAddChild (node, xml_write_int ("wallpaper-type",
|
|
||||||
prefs->wallpaper_type));
|
|
||||||
|
|
||||||
xmlNewChild (node, NULL, "wallpaper-filename",
|
|
||||||
prefs->wallpaper_filename);
|
|
||||||
xmlNewChild (node, NULL, "wallpaper-sel-path",
|
|
||||||
prefs->wallpaper_sel_path);
|
|
||||||
|
|
||||||
xmlAddChild (node, xml_write_bool ("auto-apply",
|
|
||||||
prefs->auto_apply));
|
|
||||||
|
|
||||||
if (prefs->adjust_opacity)
|
|
||||||
xmlNewChild (node, NULL, "adjust-opacity", NULL);
|
|
||||||
xmlAddChild (node, xml_write_int ("opacity",
|
|
||||||
prefs->opacity));
|
|
||||||
|
|
||||||
xmlDocSetRootElement (doc, node);
|
|
||||||
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read a numeric value from a node */
|
|
||||||
|
|
||||||
static gint
|
|
||||||
xml_read_int (xmlNodePtr node)
|
|
||||||
{
|
|
||||||
char *text;
|
|
||||||
|
|
||||||
text = xmlNodeGetContent (node);
|
|
||||||
|
|
||||||
if (text == NULL)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return atoi (text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write out a numeric value in a node */
|
|
||||||
|
|
||||||
static xmlNodePtr
|
|
||||||
xml_write_int (gchar *name, gint number)
|
|
||||||
{
|
|
||||||
xmlNodePtr node;
|
|
||||||
gchar *str;
|
|
||||||
|
|
||||||
g_return_val_if_fail (name != NULL, NULL);
|
|
||||||
|
|
||||||
str = g_strdup_printf ("%d", number);
|
|
||||||
node = xmlNewNode (NULL, name);
|
|
||||||
xmlNodeSetContent (node, str);
|
|
||||||
g_free (str);
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read a boolean value from a node */
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
xml_read_bool (xmlNodePtr node)
|
|
||||||
{
|
|
||||||
char *text;
|
|
||||||
|
|
||||||
text = xmlNodeGetContent (node);
|
|
||||||
|
|
||||||
if (text != NULL && !g_strcasecmp (text, "true"))
|
|
||||||
return TRUE;
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write out a boolean value in a node */
|
|
||||||
|
|
||||||
static xmlNodePtr
|
|
||||||
xml_write_bool (gchar *name, gboolean value)
|
|
||||||
{
|
|
||||||
xmlNodePtr node;
|
|
||||||
|
|
||||||
g_return_val_if_fail (name != NULL, NULL);
|
|
||||||
|
|
||||||
node = xmlNewNode (NULL, name);
|
|
||||||
|
|
||||||
if (value)
|
|
||||||
xmlNodeSetContent (node, "true");
|
|
||||||
else
|
|
||||||
xmlNodeSetContent (node, "false");
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
apply_timeout_cb (Preferences *prefs)
|
|
||||||
{
|
|
||||||
preferences_apply_now (prefs);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* BONOBO_CONF_ENABLE */
|
|
||||||
|
|
||||||
static GdkColor *
|
static GdkColor *
|
||||||
read_color_from_string (gchar *string)
|
read_color_from_string (const gchar *string)
|
||||||
{
|
{
|
||||||
GdkColor *color;
|
GdkColor *color;
|
||||||
gint32 rgb;
|
gint32 rgb;
|
||||||
|
@ -780,6 +417,21 @@ read_color_from_string (gchar *string)
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GdkColor *
|
||||||
|
bonobo_color_to_gdk (const Bonobo_Config_Color *color)
|
||||||
|
{
|
||||||
|
GdkColor *ret;
|
||||||
|
|
||||||
|
g_return_val_if_fail (color != NULL, NULL);
|
||||||
|
|
||||||
|
ret = g_new0 (GdkColor, 1);
|
||||||
|
ret->red = color->r * 65535;
|
||||||
|
ret->green = color->g * 65535;
|
||||||
|
ret->blue = color->b * 65535;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* It'd be nice if we could just get the pixbuf the applier uses, for
|
/* It'd be nice if we could just get the pixbuf the applier uses, for
|
||||||
* efficiency's sake */
|
* efficiency's sake */
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -823,3 +475,51 @@ preferences_need_color_opts (Preferences *prefs, GdkPixbuf *wallpaper_pixbuf)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gulong
|
||||||
|
local_bonobo_property_bag_client_get_value_gulong (Bonobo_PropertyBag pb,
|
||||||
|
const gchar *propname,
|
||||||
|
CORBA_Environment *ev)
|
||||||
|
{
|
||||||
|
BonoboArg *arg;
|
||||||
|
gulong retval;
|
||||||
|
|
||||||
|
arg = bonobo_property_bag_client_get_value_any (pb, propname, ev);
|
||||||
|
if (BONOBO_EX (ev)) return 0;
|
||||||
|
retval = BONOBO_ARG_GET_GENERAL (arg, TC_ulong, CORBA_long, ev);
|
||||||
|
bonobo_arg_release (arg);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GdkColor *
|
||||||
|
local_bonobo_property_bag_client_get_value_color (Bonobo_PropertyBag pb,
|
||||||
|
const gchar *propname,
|
||||||
|
CORBA_Environment *ev)
|
||||||
|
{
|
||||||
|
BonoboArg *arg;
|
||||||
|
GdkColor *retval;
|
||||||
|
|
||||||
|
arg = bonobo_property_bag_client_get_value_any (pb, propname, ev);
|
||||||
|
if (BONOBO_EX (ev)) return 0;
|
||||||
|
retval = bonobo_color_to_gdk ((Bonobo_Config_Color *) arg->_value);
|
||||||
|
bonobo_arg_release (arg);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
local_bonobo_property_bag_client_get_value_filename (Bonobo_PropertyBag pb,
|
||||||
|
const gchar *propname,
|
||||||
|
CORBA_Environment *ev)
|
||||||
|
{
|
||||||
|
BonoboArg *arg;
|
||||||
|
gchar *retval;
|
||||||
|
|
||||||
|
arg = bonobo_property_bag_client_get_value_any (pb, propname, ev);
|
||||||
|
if (BONOBO_EX (ev)) return 0;
|
||||||
|
retval = g_strdup (((CORBA_char **) arg->_value)[0]);
|
||||||
|
bonobo_arg_release (arg);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
|
@ -80,47 +80,27 @@ struct _PreferencesClass
|
||||||
GtkObjectClass klass;
|
GtkObjectClass klass;
|
||||||
};
|
};
|
||||||
|
|
||||||
guint preferences_get_type (void);
|
guint preferences_get_type (void);
|
||||||
|
|
||||||
GtkObject *preferences_new (void);
|
GtkObject *preferences_new (void);
|
||||||
GtkObject *preferences_clone (const Preferences *prefs);
|
GtkObject *preferences_clone (const Preferences *prefs);
|
||||||
|
|
||||||
void preferences_destroy (GtkObject *object);
|
gboolean preferences_need_color_opts (Preferences *prefs,
|
||||||
|
|
||||||
gboolean preferences_need_color_opts (Preferences *prefs,
|
|
||||||
GdkPixbuf *wallpaper_pixbuf);
|
GdkPixbuf *wallpaper_pixbuf);
|
||||||
|
|
||||||
#ifdef BONOBO_CONF_ENABLE
|
GtkObject *preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb,
|
||||||
|
CORBA_Environment *ev);
|
||||||
GtkObject *preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb,
|
GtkObject *preferences_new_from_bonobo_db (Bonobo_ConfigDatabase db,
|
||||||
CORBA_Environment *ev);
|
CORBA_Environment *ev);
|
||||||
GtkObject *preferences_new_from_bonobo_db (Bonobo_ConfigDatabase db,
|
|
||||||
CORBA_Environment *ev);
|
|
||||||
void preferences_load_from_bonobo_pbag (Preferences *prefs,
|
void preferences_load_from_bonobo_pbag (Preferences *prefs,
|
||||||
Bonobo_ConfigDatabase db,
|
Bonobo_ConfigDatabase db,
|
||||||
CORBA_Environment *ev);
|
CORBA_Environment *ev);
|
||||||
void preferences_load_from_bonobo_db (Preferences *prefs,
|
void preferences_load_from_bonobo_db (Preferences *prefs,
|
||||||
Bonobo_ConfigDatabase db,
|
Bonobo_ConfigDatabase db,
|
||||||
CORBA_Environment *ev);
|
CORBA_Environment *ev);
|
||||||
|
|
||||||
void preferences_apply_event (Preferences *prefs,
|
void preferences_apply_event (Preferences *prefs,
|
||||||
const gchar *event_name,
|
const gchar *event_name,
|
||||||
const CORBA_any *value);
|
const CORBA_any *value);
|
||||||
|
|
||||||
#else /* !BONOBO_CONF_ENABLE */
|
|
||||||
|
|
||||||
void preferences_load (Preferences *prefs);
|
|
||||||
void preferences_save (Preferences *prefs);
|
|
||||||
void preferences_changed (Preferences *prefs);
|
|
||||||
void preferences_apply_now (Preferences *prefs);
|
|
||||||
void preferences_apply_preview (Preferences *prefs);
|
|
||||||
|
|
||||||
void preferences_freeze (Preferences *prefs);
|
|
||||||
void preferences_thaw (Preferences *prefs);
|
|
||||||
|
|
||||||
Preferences *preferences_read_xml (xmlDocPtr xml_doc);
|
|
||||||
xmlDocPtr preferences_write_xml (Preferences *prefs);
|
|
||||||
|
|
||||||
#endif /* BONOBO_CONF_ENABLE */
|
|
||||||
|
|
||||||
#endif /* __PREFERENCES_H */
|
#endif /* __PREFERENCES_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue