Committed new schemas patch.
2002-03-14 Richard Hestilow <hestilow@ximian.com> * Committed new schemas patch.
This commit is contained in:
parent
e89410ab87
commit
c10c6c06ce
7 changed files with 629 additions and 110 deletions
|
@ -1,3 +1,9 @@
|
|||
2002-03-14 Richard Hestilow <hestilow@ximian.com>
|
||||
|
||||
* background-properties-capplet.c (setup_dialog): Use new enum
|
||||
peditors, and convert to using the #defined gconf keys from
|
||||
preferences.h.
|
||||
|
||||
2002-03-09 Richard Hestilow <hestilow@ximian.com>
|
||||
|
||||
* background-properties-capplet.c (setup_dialog): Hook up
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "gconf-property-editor.h"
|
||||
#include "applier.h"
|
||||
#include "preview-file-selection.h"
|
||||
#include "activate-settings-daemon.h"
|
||||
|
||||
/* Retrieve legacy gnome_config settings and store them in the GConf
|
||||
* database. This involves some translation of the settings' meanings.
|
||||
|
@ -49,42 +50,52 @@ get_legacy_settings (void)
|
|||
gboolean val_boolean;
|
||||
gboolean def;
|
||||
gchar *val_filename;
|
||||
gchar *path;
|
||||
gchar *prefix;
|
||||
|
||||
GConfClient *client;
|
||||
|
||||
/* gnome_config needs to be told to use the Gnome1 prefix */
|
||||
path = g_build_filename (g_get_home_dir (), ".gnome", "Background", NULL);
|
||||
prefix = g_strconcat ("=", path, "=", "/Default/", NULL);
|
||||
gnome_config_push_prefix (prefix);
|
||||
g_free (prefix);
|
||||
g_free (path);
|
||||
|
||||
client = gconf_client_get_default ();
|
||||
|
||||
gconf_client_set_bool (client, "/desktop/gnome/background/enabled",
|
||||
gnome_config_get_bool ("/Background/Default/Enabled=true"), NULL);
|
||||
gconf_client_set_bool (client, BG_PREFERENCES_DRAW_BACKGROUND,
|
||||
gnome_config_get_bool ("Enabled=true"), NULL);
|
||||
|
||||
val_filename = gnome_config_get_string ("/Background/Default/wallpaper=(none)");
|
||||
gconf_client_set_string (client, "/desktop/gnome/background/wallpaper-filename",
|
||||
val_filename, NULL);
|
||||
val_filename = gnome_config_get_string ("wallpaper=(none)");
|
||||
|
||||
if (val_filename != NULL && strcmp (val_filename, "(none)"))
|
||||
gconf_client_set_bool (client, "/desktop/gnome/background/wallpaper-enabled", TRUE, NULL);
|
||||
{
|
||||
gconf_client_set_string (client, BG_PREFERENCES_PICTURE_FILENAME,
|
||||
val_filename, NULL);
|
||||
gconf_client_set_string (client, BG_PREFERENCES_PICTURE_OPTIONS,
|
||||
bg_preferences_get_wptype_as_string (gnome_config_get_int ("wallpaperAlign=0")), NULL);
|
||||
}
|
||||
else
|
||||
gconf_client_set_bool (client, "/desktop/gnome/background/wallpaper-enabled", FALSE, NULL);
|
||||
gconf_client_set_string (client, BG_PREFERENCES_PICTURE_OPTIONS, "none", NULL);
|
||||
|
||||
g_free (val_filename);
|
||||
|
||||
gconf_client_set_int (client, "/desktop/gnome/background/wallpaper-type",
|
||||
gnome_config_get_int ("/Background/Default/wallpaperAlign=0"), NULL);
|
||||
|
||||
gconf_client_set_string (client, "/desktop/gnome/background/color1",
|
||||
gnome_config_get_string ("/Background/Default/color1"), NULL);
|
||||
gconf_client_set_string (client, "/desktop/gnome/background/color2",
|
||||
gnome_config_get_string ("/Background/Default/color2"), NULL);
|
||||
gconf_client_set_string (client, BG_PREFERENCES_PRIMARY_COLOR,
|
||||
gnome_config_get_string ("color1"), NULL);
|
||||
gconf_client_set_string (client, BG_PREFERENCES_SECONDARY_COLOR,
|
||||
gnome_config_get_string ("color2"), NULL);
|
||||
|
||||
/* Code to deal with new enum - messy */
|
||||
val_int = -1;
|
||||
val_string = gnome_config_get_string_with_default ("/Background/Default/simple=solid", &def);
|
||||
val_string = gnome_config_get_string_with_default ("simple=solid", &def);
|
||||
if (!def) {
|
||||
if (!strcmp (val_string, "solid")) {
|
||||
val_int = ORIENTATION_SOLID;
|
||||
} else {
|
||||
g_free (val_string);
|
||||
val_string = gnome_config_get_string_with_default ("/Background/Default/gradient=vertical", &def);
|
||||
val_string = gnome_config_get_string_with_default ("gradient=vertical", &def);
|
||||
if (!def)
|
||||
val_int = (!strcmp (val_string, "vertical")) ? ORIENTATION_VERT : ORIENTATION_HORIZ;
|
||||
}
|
||||
|
@ -93,13 +104,17 @@ get_legacy_settings (void)
|
|||
g_free (val_string);
|
||||
|
||||
if (val_int != -1)
|
||||
gconf_client_set_int (client, "/desktop/gnome/background/orientation", val_int, NULL);
|
||||
gconf_client_set_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, bg_preferences_get_orientation_as_string (val_int), NULL);
|
||||
|
||||
val_boolean = gnome_config_get_bool_with_default ("/Background/Default/adjustOpacity=true", &def);
|
||||
val_boolean = gnome_config_get_bool_with_default ("adjustOpacity=true", &def);
|
||||
|
||||
if (!def && val_boolean)
|
||||
gconf_client_set_int (client, "/desktop/gnome/background/opacity",
|
||||
gnome_config_get_int ("/Background/Default/opacity=100"), NULL);
|
||||
gconf_client_set_int (client, BG_PREFERENCES_PICTURE_OPACITY,
|
||||
gnome_config_get_int ("opacity=100"), NULL);
|
||||
else
|
||||
gconf_client_set_int (client, BG_PREFERENCES_PICTURE_OPACITY, 100, NULL);
|
||||
|
||||
gnome_config_pop_prefix ();
|
||||
}
|
||||
|
||||
/* Initial apply to the preview, and setting of the color frame's sensitivity.
|
||||
|
@ -169,15 +184,22 @@ peditor_value_changed (GConfPropertyEditor *peditor, const gchar *key, const GCo
|
|||
if (GTK_WIDGET_REALIZED (bg_applier_get_preview_widget (bg_applier)))
|
||||
bg_applier_apply_prefs (bg_applier, BG_PREFERENCES (prefs));
|
||||
|
||||
if (!strcmp (key, "/desktop/gnome/background/wallpaper-enabled") ||
|
||||
!strcmp (key, "/desktop/gnome/background/wallpaper-filename") ||
|
||||
!strcmp (key, "/desktop/gnome/background/wallpaper-type"))
|
||||
if (!strcmp (key, BG_PREFERENCES_PICTURE_FILENAME) ||
|
||||
!strcmp (key, BG_PREFERENCES_PICTURE_OPTIONS))
|
||||
{
|
||||
color_frame = g_object_get_data (G_OBJECT (prefs), "color-frame");
|
||||
gtk_widget_set_sensitive (color_frame, bg_applier_render_color_p (bg_applier, prefs));
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the wallpaper enum set before we disabled it */
|
||||
static int
|
||||
get_val_true_cb (GConfPropertyEditor *peditor, gpointer data)
|
||||
{
|
||||
BGPreferences *prefs = (BGPreferences*) data;
|
||||
return prefs->wallpaper_type;
|
||||
}
|
||||
|
||||
/* Set up the property editors in the dialog. This also loads the preferences
|
||||
* and sets up the callbacks.
|
||||
*/
|
||||
|
@ -191,7 +213,7 @@ setup_dialog (GladeXML *dialog, GConfChangeSet *changeset, BGApplier *bg_applier
|
|||
|
||||
/* Override the enabled setting to make sure background is enabled */
|
||||
client = gconf_client_get_default ();
|
||||
gconf_client_set_bool (client, "/desktop/gnome/background/enabled", TRUE, NULL);
|
||||
gconf_client_set_bool (client, BG_PREFERENCES_DRAW_BACKGROUND, TRUE, NULL);
|
||||
|
||||
/* Load preferences */
|
||||
prefs = bg_preferences_new ();
|
||||
|
@ -202,28 +224,28 @@ setup_dialog (GladeXML *dialog, GConfChangeSet *changeset, BGApplier *bg_applier
|
|||
g_object_set_data (prefs, "color-frame", WID ("color_frame"));
|
||||
g_object_set_data (prefs, "applier", bg_applier);
|
||||
|
||||
peditor = gconf_peditor_new_select_menu
|
||||
(changeset, "/desktop/gnome/background/orientation", WID ("color_option"), NULL);
|
||||
peditor = gconf_peditor_new_select_menu_with_enum
|
||||
(changeset, BG_PREFERENCES_COLOR_SHADING_TYPE, WID ("color_option"), bg_preferences_orientation_get_type (), NULL);
|
||||
g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs);
|
||||
|
||||
peditor = gconf_peditor_new_color
|
||||
(changeset, "/desktop/gnome/background/color1", WID ("colorpicker1"), NULL);
|
||||
(changeset, BG_PREFERENCES_PRIMARY_COLOR, WID ("colorpicker1"), NULL);
|
||||
g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs);
|
||||
|
||||
peditor = gconf_peditor_new_color
|
||||
(changeset, "/desktop/gnome/background/color2", WID ("colorpicker2"), NULL);
|
||||
(changeset, BG_PREFERENCES_SECONDARY_COLOR, WID ("colorpicker2"), NULL);
|
||||
g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs);
|
||||
|
||||
peditor = gconf_peditor_new_filename
|
||||
(changeset, "/desktop/gnome/background/wallpaper-filename", WID ("image_fileentry"), NULL);
|
||||
(changeset, BG_PREFERENCES_PICTURE_FILENAME, WID ("image_fileentry"), NULL);
|
||||
g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs);
|
||||
|
||||
peditor = gconf_peditor_new_select_menu
|
||||
(changeset, "/desktop/gnome/background/wallpaper-type", WID ("image_option"), NULL);
|
||||
peditor = gconf_peditor_new_select_menu_with_enum
|
||||
(changeset, BG_PREFERENCES_PICTURE_OPTIONS, WID ("image_option"), bg_preferences_wptype_get_type (), NULL);
|
||||
g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs);
|
||||
|
||||
peditor = gconf_peditor_new_boolean
|
||||
(changeset, "/desktop/gnome/background/wallpaper-enabled", WID ("picture_enabled_check"), NULL);
|
||||
peditor = gconf_peditor_new_enum_toggle
|
||||
(changeset, BG_PREFERENCES_PICTURE_OPTIONS, WID ("picture_enabled_check"), bg_preferences_wptype_get_type (), get_val_true_cb, WPTYPE_NONE, prefs, NULL);
|
||||
g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs);
|
||||
|
||||
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("picture_frame"));
|
||||
|
@ -301,6 +323,8 @@ main (int argc, char **argv)
|
|||
GNOME_PARAM_POPT_TABLE, cap_options,
|
||||
NULL);
|
||||
|
||||
activate_settings_daemon ();
|
||||
|
||||
client = gconf_client_get_default ();
|
||||
gconf_client_add_dir (client, "/desktop/gnome/background", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
||||
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
2002-03-14 Richard Hestilow <hestilow@ximian.com>
|
||||
|
||||
* gconf-property-editor.c:
|
||||
(gconf_property_editor_new_option_menu_with_enum):
|
||||
(gconf_property_editor_new_enum_toggle): Added.
|
||||
(gconf_property_editor_new): Accept custom arguments from the
|
||||
editor "subclass".
|
||||
(gconf_property_editor_class_init): Add arguments "data"
|
||||
and "data-free-cb", for custom "subclass" data.
|
||||
(gconf_property_editor_finalize): Free custom data.
|
||||
(*_new): Add NULL at the end of gconf_property_editor_new.
|
||||
(guard_value_changed, peditor_widget_set_guard): Use the
|
||||
enum->boolean mapping if the gconf value is a string.
|
||||
|
||||
2002-03-10 Seth Nickell <snickell@stanford.edu>
|
||||
|
||||
* Makefile.am:
|
||||
|
|
|
@ -43,9 +43,13 @@ enum {
|
|||
PROP_CHANGESET,
|
||||
PROP_CONV_TO_WIDGET_CB,
|
||||
PROP_CONV_FROM_WIDGET_CB,
|
||||
PROP_UI_CONTROL
|
||||
PROP_UI_CONTROL,
|
||||
PROP_DATA,
|
||||
PROP_DATA_FREE_CB
|
||||
};
|
||||
|
||||
typedef void (*GConfPropertyEditorDataFreeCb) (gpointer data);
|
||||
|
||||
struct _GConfPropertyEditorPrivate
|
||||
{
|
||||
gchar *key;
|
||||
|
@ -56,8 +60,19 @@ struct _GConfPropertyEditorPrivate
|
|||
GConfPEditorValueConvFn conv_from_widget_cb;
|
||||
GConfClientNotifyFunc callback;
|
||||
gboolean inited;
|
||||
|
||||
gpointer data;
|
||||
GConfPropertyEditorDataFreeCb data_free_cb;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GType enum_type;
|
||||
GConfPEditorGetValueFn enum_val_true_fn;
|
||||
gpointer enum_val_true_fn_data;
|
||||
guint enum_val_false;
|
||||
} GConfPropertyEditorEnumData;
|
||||
|
||||
static guint peditor_signals[LAST_SIGNAL];
|
||||
|
||||
static GObjectClass *parent_class;
|
||||
|
@ -83,7 +98,9 @@ static GObject *gconf_peditor_new (gchar *key,
|
|||
GConfChangeSet *changeset,
|
||||
GObject *ui_control,
|
||||
const gchar *first_prop_name,
|
||||
va_list var_args);
|
||||
va_list var_args,
|
||||
const gchar *first_custom,
|
||||
...);
|
||||
|
||||
GType
|
||||
gconf_property_editor_get_type (void)
|
||||
|
@ -113,13 +130,20 @@ gconf_property_editor_get_type (void)
|
|||
return gconf_property_editor_type;
|
||||
}
|
||||
|
||||
static GConfValue*
|
||||
gconf_property_editor_conv_default (GConfPropertyEditor *peditor,
|
||||
const GConfValue *value)
|
||||
{
|
||||
return gconf_value_copy (value);
|
||||
}
|
||||
|
||||
static void
|
||||
gconf_property_editor_init (GConfPropertyEditor *gconf_property_editor,
|
||||
GConfPropertyEditorClass *class)
|
||||
{
|
||||
gconf_property_editor->p = g_new0 (GConfPropertyEditorPrivate, 1);
|
||||
gconf_property_editor->p->conv_to_widget_cb = gconf_value_copy;
|
||||
gconf_property_editor->p->conv_from_widget_cb = gconf_value_copy;
|
||||
gconf_property_editor->p->conv_to_widget_cb = gconf_property_editor_conv_default;
|
||||
gconf_property_editor->p->conv_from_widget_cb = gconf_property_editor_conv_default;
|
||||
gconf_property_editor->p->inited = FALSE;
|
||||
}
|
||||
|
||||
|
@ -186,6 +210,20 @@ gconf_property_editor_class_init (GConfPropertyEditorClass *class)
|
|||
(GSignalCMarshaller) gconf_property_editor_marshal_VOID__STRING_POINTER,
|
||||
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER);
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DATA,
|
||||
g_param_spec_pointer ("data",
|
||||
_("Property editor object data"),
|
||||
_("Custom data required by the specific property editor"),
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DATA_FREE_CB,
|
||||
g_param_spec_pointer ("data-free-cb",
|
||||
_("Property editor data freeing callback"),
|
||||
_("Callback to be issued when property editor object data is to be freed"),
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
parent_class = G_OBJECT_CLASS
|
||||
(g_type_class_ref (G_TYPE_OBJECT));
|
||||
}
|
||||
|
@ -236,7 +274,12 @@ gconf_property_editor_set_prop (GObject *object,
|
|||
peditor->p->ui_control = g_value_get_object (value);
|
||||
g_object_weak_ref (peditor->p->ui_control, (GWeakNotify) g_object_unref, object);
|
||||
break;
|
||||
|
||||
case PROP_DATA:
|
||||
peditor->p->data = g_value_get_pointer (value);
|
||||
break;
|
||||
case PROP_DATA_FREE_CB:
|
||||
peditor->p->data_free_cb = g_value_get_pointer (value);
|
||||
break;
|
||||
default:
|
||||
g_warning ("Bad argument set");
|
||||
break;
|
||||
|
@ -281,6 +324,9 @@ gconf_property_editor_finalize (GObject *object)
|
|||
|
||||
gconf_property_editor = GCONF_PROPERTY_EDITOR (object);
|
||||
|
||||
if (gconf_property_editor->p->data_free_cb)
|
||||
gconf_property_editor->p->data_free_cb (gconf_property_editor->p->data);
|
||||
|
||||
g_free (gconf_property_editor->p);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
|
@ -292,7 +338,9 @@ gconf_peditor_new (gchar *key,
|
|||
GConfChangeSet *changeset,
|
||||
GObject *ui_control,
|
||||
const gchar *first_prop_name,
|
||||
va_list var_args)
|
||||
va_list var_args,
|
||||
const gchar *first_custom,
|
||||
...)
|
||||
{
|
||||
GObject *obj;
|
||||
GConfClient *client;
|
||||
|
@ -310,6 +358,14 @@ gconf_peditor_new (gchar *key,
|
|||
|
||||
g_object_set_valist (obj, first_prop_name, var_args);
|
||||
|
||||
if (first_custom)
|
||||
{
|
||||
va_list custom_args;
|
||||
va_start (custom_args, first_custom);
|
||||
g_object_set_valist (obj, first_custom, custom_args);
|
||||
va_end (custom_args);
|
||||
}
|
||||
|
||||
client = gconf_client_get_default ();
|
||||
gconf_entry = gconf_client_get_entry (client, GCONF_PROPERTY_EDITOR (obj)->p->key, NULL, TRUE, NULL);
|
||||
GCONF_PROPERTY_EDITOR (obj)->p->callback (client, 0, gconf_entry, obj);
|
||||
|
@ -349,7 +405,7 @@ peditor_boolean_value_changed (GConfClient *client,
|
|||
value = gconf_entry_get_value (entry);
|
||||
|
||||
if (value != NULL) {
|
||||
value_wid = peditor->p->conv_to_widget_cb (value);
|
||||
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (peditor->p->ui_control), gconf_value_get_bool (value_wid));
|
||||
gconf_value_free (value_wid);
|
||||
}
|
||||
|
@ -364,7 +420,7 @@ peditor_boolean_widget_changed (GConfPropertyEditor *peditor,
|
|||
if (!peditor->p->inited) return;
|
||||
value_wid = gconf_value_new (GCONF_VALUE_BOOL);
|
||||
gconf_value_set_bool (value_wid, gtk_toggle_button_get_active (tb));
|
||||
value = peditor->p->conv_from_widget_cb (value_wid);
|
||||
value = peditor->p->conv_from_widget_cb (peditor, value_wid);
|
||||
peditor_set_gconf_value (peditor, peditor->p->key, value);
|
||||
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
|
||||
gconf_value_free (value_wid);
|
||||
|
@ -393,7 +449,8 @@ gconf_peditor_new_boolean (GConfChangeSet *changeset,
|
|||
changeset,
|
||||
G_OBJECT (checkbox),
|
||||
first_property_name,
|
||||
var_args);
|
||||
var_args,
|
||||
NULL);
|
||||
|
||||
va_end (var_args);
|
||||
|
||||
|
@ -418,7 +475,7 @@ peditor_string_value_changed (GConfClient *client,
|
|||
value = gconf_entry_get_value (entry);
|
||||
|
||||
if (value != NULL) {
|
||||
value_wid = peditor->p->conv_to_widget_cb (value);
|
||||
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
|
||||
entry_current_text = gtk_entry_get_text (GTK_ENTRY (peditor->p->ui_control));
|
||||
if (strcmp (entry_current_text, gconf_value_get_string (value)) != 0) {
|
||||
gtk_entry_set_text (GTK_ENTRY (peditor->p->ui_control), gconf_value_get_string (value_wid));
|
||||
|
@ -438,7 +495,7 @@ peditor_string_widget_changed (GConfPropertyEditor *peditor,
|
|||
value_wid = gconf_value_new (GCONF_VALUE_STRING);
|
||||
|
||||
gconf_value_set_string (value_wid, gtk_entry_get_text (entry));
|
||||
value = peditor->p->conv_from_widget_cb (value_wid);
|
||||
value = peditor->p->conv_from_widget_cb (peditor, value_wid);
|
||||
|
||||
peditor_set_gconf_value (peditor, peditor->p->key, value);
|
||||
|
||||
|
@ -462,7 +519,7 @@ gconf_peditor_new_string_valist (GConfChangeSet *changeset,
|
|||
changeset,
|
||||
G_OBJECT (entry),
|
||||
first_property_name,
|
||||
var_args);
|
||||
var_args, NULL);
|
||||
|
||||
g_signal_connect_swapped (G_OBJECT (entry), "changed",
|
||||
(GCallback) peditor_string_widget_changed, peditor);
|
||||
|
@ -536,7 +593,7 @@ peditor_color_value_changed (GConfClient *client,
|
|||
value = gconf_entry_get_value (entry);
|
||||
|
||||
if (value != NULL) {
|
||||
value_wid = peditor->p->conv_to_widget_cb (value);
|
||||
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
|
||||
gdk_color_parse (gconf_value_get_string (value_wid), &color);
|
||||
gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (peditor->p->ui_control), color.red, color.green, color.blue, 65535);
|
||||
gconf_value_free (value_wid);
|
||||
|
@ -561,7 +618,7 @@ peditor_color_widget_changed (GConfPropertyEditor *peditor,
|
|||
gconf_value_set_string (value_wid, str);
|
||||
g_free (str);
|
||||
|
||||
value = peditor->p->conv_from_widget_cb (value_wid);
|
||||
value = peditor->p->conv_from_widget_cb (peditor, value_wid);
|
||||
|
||||
peditor_set_gconf_value (peditor, peditor->p->key, value);
|
||||
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
|
||||
|
@ -592,7 +649,7 @@ gconf_peditor_new_color (GConfChangeSet *changeset,
|
|||
changeset,
|
||||
G_OBJECT (cp),
|
||||
first_property_name,
|
||||
var_args);
|
||||
var_args, NULL);
|
||||
|
||||
va_end (var_args);
|
||||
|
||||
|
@ -602,6 +659,88 @@ gconf_peditor_new_color (GConfChangeSet *changeset,
|
|||
return peditor;
|
||||
}
|
||||
|
||||
static int
|
||||
peditor_enum_int_from_string (GType type, const gchar *str)
|
||||
{
|
||||
GEnumClass *klass;
|
||||
GEnumValue *val;
|
||||
int ret = -1;
|
||||
|
||||
klass = g_type_class_ref (type);
|
||||
val = g_enum_get_value_by_name (klass, str);
|
||||
if (!val)
|
||||
val = g_enum_get_value_by_nick (klass, str);
|
||||
if (val)
|
||||
ret = val->value;
|
||||
|
||||
g_type_class_unref (klass);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
peditor_enum_string_from_int (GType type, const int index)
|
||||
{
|
||||
GEnumClass *klass;
|
||||
GEnumValue *val;
|
||||
gchar *ret = NULL;
|
||||
|
||||
klass = g_type_class_ref (type);
|
||||
val = g_enum_get_value (klass, index);
|
||||
if (val)
|
||||
{
|
||||
if (val->value_name)
|
||||
ret = g_strdup (val->value_name);
|
||||
else
|
||||
ret = g_strdup (val->value_nick);
|
||||
}
|
||||
|
||||
g_type_class_unref (klass);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GConfValue*
|
||||
peditor_enum_conv_to_widget (GConfPropertyEditor *peditor,
|
||||
const GConfValue *value)
|
||||
{
|
||||
GConfValue *ret;
|
||||
GConfPropertyEditorEnumData *data = peditor->p->data;
|
||||
int index;
|
||||
|
||||
if (value->type == GCONF_VALUE_INT)
|
||||
return gconf_value_copy (value);
|
||||
|
||||
ret = gconf_value_new (GCONF_VALUE_INT);
|
||||
|
||||
index = peditor_enum_int_from_string (data->enum_type,
|
||||
gconf_value_get_string (value));
|
||||
|
||||
gconf_value_set_int (ret, index);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GConfValue*
|
||||
peditor_enum_conv_from_widget (GConfPropertyEditor *peditor,
|
||||
const GConfValue *value)
|
||||
{
|
||||
GConfValue *ret;
|
||||
GConfPropertyEditorEnumData *data = peditor->p->data;
|
||||
gchar *str;
|
||||
|
||||
if (value->type == GCONF_VALUE_STRING)
|
||||
return gconf_value_copy (value);
|
||||
|
||||
ret = gconf_value_new (GCONF_VALUE_STRING);
|
||||
str = peditor_enum_string_from_int (data->enum_type,
|
||||
gconf_value_get_int (value));
|
||||
gconf_value_set_string (ret, str);
|
||||
g_free (str);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
peditor_select_menu_value_changed (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
|
@ -616,7 +755,7 @@ peditor_select_menu_value_changed (GConfClient *client,
|
|||
value = gconf_entry_get_value (entry);
|
||||
|
||||
if (value != NULL) {
|
||||
value_wid = peditor->p->conv_to_widget_cb (value);
|
||||
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
|
||||
gtk_option_menu_set_history (GTK_OPTION_MENU (peditor->p->ui_control), gconf_value_get_int (value_wid));
|
||||
gconf_value_free (value_wid);
|
||||
}
|
||||
|
@ -631,7 +770,7 @@ peditor_select_menu_widget_changed (GConfPropertyEditor *peditor,
|
|||
if (!peditor->p->inited) return;
|
||||
value_wid = gconf_value_new (GCONF_VALUE_INT);
|
||||
gconf_value_set_int (value_wid, gtk_option_menu_get_history (option_menu));
|
||||
value = peditor->p->conv_from_widget_cb (value_wid);
|
||||
value = peditor->p->conv_from_widget_cb (peditor, value_wid);
|
||||
peditor_set_gconf_value (peditor, peditor->p->key, value);
|
||||
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
|
||||
gconf_value_free (value_wid);
|
||||
|
@ -660,7 +799,7 @@ gconf_peditor_new_select_menu (GConfChangeSet *changeset,
|
|||
changeset,
|
||||
G_OBJECT (option_menu),
|
||||
first_property_name,
|
||||
var_args);
|
||||
var_args, NULL);
|
||||
|
||||
va_end (var_args);
|
||||
|
||||
|
@ -670,6 +809,55 @@ gconf_peditor_new_select_menu (GConfChangeSet *changeset,
|
|||
return peditor;
|
||||
}
|
||||
|
||||
GObject *
|
||||
gconf_peditor_new_select_menu_with_enum (GConfChangeSet *changeset,
|
||||
gchar *key,
|
||||
GtkWidget *option_menu,
|
||||
GType enum_type,
|
||||
gchar *first_property_name,
|
||||
...)
|
||||
{
|
||||
GConfPropertyEditor *peditor;
|
||||
GConfPropertyEditorEnumData *data;
|
||||
va_list var_args;
|
||||
|
||||
g_return_val_if_fail (key != NULL, NULL);
|
||||
g_return_val_if_fail (option_menu != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_OPTION_MENU (option_menu), NULL);
|
||||
g_return_val_if_fail (enum_type != G_TYPE_NONE, NULL);
|
||||
|
||||
data = g_new0 (GConfPropertyEditorEnumData, 1);
|
||||
data->enum_type = enum_type;
|
||||
|
||||
va_start (var_args, first_property_name);
|
||||
|
||||
peditor = GCONF_PROPERTY_EDITOR (
|
||||
gconf_peditor_new
|
||||
(key,
|
||||
(GConfClientNotifyFunc) peditor_select_menu_value_changed,
|
||||
changeset,
|
||||
G_OBJECT (option_menu),
|
||||
first_property_name,
|
||||
var_args,
|
||||
"conv-to-widget-cb",
|
||||
peditor_enum_conv_to_widget,
|
||||
"conv-from-widget-cb",
|
||||
peditor_enum_conv_from_widget,
|
||||
"data",
|
||||
data,
|
||||
"data-free-cb",
|
||||
g_free,
|
||||
NULL
|
||||
));
|
||||
|
||||
va_end (var_args);
|
||||
|
||||
g_signal_connect_swapped (G_OBJECT (option_menu), "changed",
|
||||
(GCallback) peditor_select_menu_widget_changed, peditor);
|
||||
|
||||
return G_OBJECT (peditor);
|
||||
}
|
||||
|
||||
static void
|
||||
peditor_select_radio_value_changed (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
|
@ -685,7 +873,7 @@ peditor_select_radio_value_changed (GConfClient *client,
|
|||
value = gconf_entry_get_value (entry);
|
||||
|
||||
if (value != NULL) {
|
||||
value_wid = peditor->p->conv_to_widget_cb (value);
|
||||
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
|
||||
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (peditor->p->ui_control));
|
||||
group = g_slist_nth (group, gconf_value_get_int (value_wid));
|
||||
if (group && group->data)
|
||||
|
@ -707,7 +895,7 @@ peditor_select_radio_widget_changed (GConfPropertyEditor *peditor,
|
|||
value_wid = gconf_value_new (GCONF_VALUE_INT);
|
||||
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (peditor->p->ui_control));
|
||||
gconf_value_set_int (value_wid, g_slist_index (group, tb));
|
||||
value = peditor->p->conv_from_widget_cb (value_wid);
|
||||
value = peditor->p->conv_from_widget_cb (peditor, value_wid);
|
||||
|
||||
peditor_set_gconf_value (peditor, peditor->p->key, value);
|
||||
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
|
||||
|
@ -743,7 +931,7 @@ gconf_peditor_new_select_radio (GConfChangeSet *changeset,
|
|||
changeset,
|
||||
G_OBJECT (first_button),
|
||||
first_property_name,
|
||||
var_args);
|
||||
var_args, NULL);
|
||||
|
||||
va_end (var_args);
|
||||
|
||||
|
@ -768,7 +956,7 @@ peditor_numeric_range_value_changed (GConfClient *client,
|
|||
value = gconf_entry_get_value (entry);
|
||||
|
||||
if (value != NULL) {
|
||||
value_wid = peditor->p->conv_to_widget_cb (value);
|
||||
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (peditor->p->ui_control), gconf_value_get_float (value_wid));
|
||||
gconf_value_free (value_wid);
|
||||
}
|
||||
|
@ -783,7 +971,7 @@ peditor_numeric_range_widget_changed (GConfPropertyEditor *peditor,
|
|||
if (!peditor->p->inited) return;
|
||||
value_wid = gconf_value_new (GCONF_VALUE_FLOAT);
|
||||
gconf_value_set_float (value_wid, gtk_adjustment_get_value (adjustment));
|
||||
value = peditor->p->conv_from_widget_cb (value_wid);
|
||||
value = peditor->p->conv_from_widget_cb (peditor, value_wid);
|
||||
peditor_set_gconf_value (peditor, peditor->p->key, value);
|
||||
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
|
||||
gconf_value_free (value_wid);
|
||||
|
@ -815,7 +1003,7 @@ gconf_peditor_new_numeric_range (GConfChangeSet *changeset,
|
|||
changeset,
|
||||
G_OBJECT (adjustment),
|
||||
first_property_name,
|
||||
var_args);
|
||||
var_args, NULL);
|
||||
|
||||
va_end (var_args);
|
||||
|
||||
|
@ -825,13 +1013,26 @@ gconf_peditor_new_numeric_range (GConfChangeSet *changeset,
|
|||
return peditor;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
guard_get_bool (GConfPropertyEditor *peditor, const GConfValue *value)
|
||||
{
|
||||
if (value->type == GCONF_VALUE_BOOL)
|
||||
return gconf_value_get_bool (value);
|
||||
else
|
||||
{
|
||||
GConfPropertyEditorEnumData *data = peditor->p->data;
|
||||
int index = peditor_enum_int_from_string (data->enum_type, gconf_value_get_string (value));
|
||||
return (index != data->enum_val_false);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
guard_value_changed (GConfPropertyEditor *peditor,
|
||||
const gchar *key,
|
||||
const GConfValue *value,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
gtk_widget_set_sensitive (widget, gconf_value_get_bool (value));
|
||||
gtk_widget_set_sensitive (widget, guard_get_bool (peditor, value));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -839,6 +1040,7 @@ gconf_peditor_widget_set_guard (GConfPropertyEditor *peditor,
|
|||
GtkWidget *widget)
|
||||
{
|
||||
GConfClient *client;
|
||||
GConfValue *value;
|
||||
|
||||
g_return_if_fail (peditor != NULL);
|
||||
g_return_if_fail (IS_GCONF_PROPERTY_EDITOR (peditor));
|
||||
|
@ -846,7 +1048,10 @@ gconf_peditor_widget_set_guard (GConfPropertyEditor *peditor,
|
|||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
client = gconf_client_get_default ();
|
||||
gtk_widget_set_sensitive (widget, gconf_client_get_bool (client, peditor->p->key, NULL));
|
||||
|
||||
value = gconf_client_get (client, peditor->p->key, NULL);
|
||||
gtk_widget_set_sensitive (widget, guard_get_bool (peditor, value));
|
||||
gconf_value_free (value);
|
||||
|
||||
g_signal_connect (G_OBJECT (peditor), "value-changed", (GCallback) guard_value_changed, widget);
|
||||
}
|
||||
|
@ -902,7 +1107,7 @@ peditor_font_value_changed (GConfClient *client,
|
|||
if (value != NULL) {
|
||||
const gchar *font_name;
|
||||
|
||||
value_wid = peditor->p->conv_to_widget_cb (value);
|
||||
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
|
||||
font_name = gconf_value_get_string (value_wid);
|
||||
g_object_set (G_OBJECT (peditor->p->ui_control),
|
||||
"font_name", font_name,
|
||||
|
@ -927,7 +1132,7 @@ peditor_font_widget_changed (GConfPropertyEditor *peditor,
|
|||
|
||||
value_wid = gconf_value_new (GCONF_VALUE_STRING);
|
||||
gconf_value_set_string (value_wid, font_name);
|
||||
value = peditor->p->conv_from_widget_cb (value_wid);
|
||||
value = peditor->p->conv_from_widget_cb (peditor, value_wid);
|
||||
|
||||
peditor_set_gconf_value (peditor, peditor->p->key, value);
|
||||
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
|
||||
|
@ -958,7 +1163,7 @@ gconf_peditor_new_font (GConfChangeSet *changeset,
|
|||
changeset,
|
||||
G_OBJECT (font_picker),
|
||||
first_property_name,
|
||||
var_args);
|
||||
var_args, NULL);
|
||||
|
||||
va_end (var_args);
|
||||
|
||||
|
@ -968,3 +1173,101 @@ gconf_peditor_new_font (GConfChangeSet *changeset,
|
|||
return peditor;
|
||||
}
|
||||
|
||||
static GConfValue*
|
||||
peditor_enum_toggle_conv_to_widget (GConfPropertyEditor *peditor,
|
||||
const GConfValue *value)
|
||||
{
|
||||
GConfValue *ret;
|
||||
GConfPropertyEditorEnumData *data = peditor->p->data;
|
||||
int index;
|
||||
|
||||
if (value->type == GCONF_VALUE_BOOL)
|
||||
return gconf_value_copy (value);
|
||||
|
||||
ret = gconf_value_new (GCONF_VALUE_BOOL);
|
||||
|
||||
index = peditor_enum_int_from_string (data->enum_type,
|
||||
gconf_value_get_string (value));
|
||||
gconf_value_set_bool (ret, (index != data->enum_val_false));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GConfValue*
|
||||
peditor_enum_toggle_conv_from_widget (GConfPropertyEditor *peditor,
|
||||
const GConfValue *value)
|
||||
{
|
||||
GConfValue *ret;
|
||||
GConfPropertyEditorEnumData *data = peditor->p->data;
|
||||
gchar *str;
|
||||
int index;
|
||||
|
||||
if (value->type == GCONF_VALUE_STRING)
|
||||
return gconf_value_copy (value);
|
||||
|
||||
ret = gconf_value_new (GCONF_VALUE_STRING);
|
||||
if (gconf_value_get_bool (value))
|
||||
index = data->enum_val_true_fn (peditor, data->enum_val_true_fn_data);
|
||||
else
|
||||
index = data->enum_val_false;
|
||||
|
||||
str = peditor_enum_string_from_int (data->enum_type, index);
|
||||
gconf_value_set_string (ret, str);
|
||||
g_free (str);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
GObject *
|
||||
gconf_peditor_new_enum_toggle (GConfChangeSet *changeset,
|
||||
gchar *key,
|
||||
GtkWidget *checkbox,
|
||||
GType enum_type,
|
||||
GConfPEditorGetValueFn val_true_fn,
|
||||
guint val_false,
|
||||
gpointer data,
|
||||
gchar *first_property_name,
|
||||
...)
|
||||
{
|
||||
GConfPropertyEditor *peditor;
|
||||
GConfPropertyEditorEnumData *enum_data;
|
||||
va_list var_args;
|
||||
|
||||
g_return_val_if_fail (key != NULL, NULL);
|
||||
g_return_val_if_fail (checkbox != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (checkbox), NULL);
|
||||
|
||||
enum_data = g_new0 (GConfPropertyEditorEnumData, 1);
|
||||
enum_data->enum_type = enum_type;
|
||||
enum_data->enum_val_true_fn = val_true_fn;
|
||||
enum_data->enum_val_true_fn_data = data;
|
||||
enum_data->enum_val_false = val_false;
|
||||
|
||||
va_start (var_args, first_property_name);
|
||||
|
||||
peditor = GCONF_PROPERTY_EDITOR (
|
||||
gconf_peditor_new
|
||||
(key,
|
||||
(GConfClientNotifyFunc) peditor_boolean_value_changed,
|
||||
changeset,
|
||||
G_OBJECT (checkbox),
|
||||
first_property_name,
|
||||
var_args,
|
||||
"conv-to-widget-cb",
|
||||
peditor_enum_toggle_conv_to_widget,
|
||||
"conv-from-widget-cb",
|
||||
peditor_enum_toggle_conv_from_widget,
|
||||
"data",
|
||||
enum_data,
|
||||
"data-free-cb",
|
||||
g_free,
|
||||
NULL));
|
||||
|
||||
va_end (var_args);
|
||||
|
||||
g_signal_connect_swapped (G_OBJECT (checkbox), "toggled",
|
||||
(GCallback) peditor_boolean_widget_changed, peditor);
|
||||
|
||||
return G_OBJECT (peditor);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ typedef struct _GConfPropertyEditor GConfPropertyEditor;
|
|||
typedef struct _GConfPropertyEditorClass GConfPropertyEditorClass;
|
||||
typedef struct _GConfPropertyEditorPrivate GConfPropertyEditorPrivate;
|
||||
|
||||
typedef GConfValue *(*GConfPEditorValueConvFn) (const GConfValue *);
|
||||
typedef GConfValue *(*GConfPEditorValueConvFn) (GConfPropertyEditor *peditor, const GConfValue *);
|
||||
typedef int (*GConfPEditorGetValueFn) (GConfPropertyEditor *peditor, gpointer data);
|
||||
|
||||
struct _GConfPropertyEditor
|
||||
{
|
||||
|
@ -63,6 +64,17 @@ GObject *gconf_peditor_new_boolean (GConfChangeSet *changeset,
|
|||
GtkWidget *checkbox,
|
||||
gchar *first_property_name,
|
||||
...);
|
||||
|
||||
GObject *gconf_peditor_new_enum_toggle (GConfChangeSet *changeset,
|
||||
gchar *key,
|
||||
GtkWidget *checkbox,
|
||||
GType enum_type,
|
||||
GConfPEditorGetValueFn val_true_fn,
|
||||
guint val_false,
|
||||
gpointer data,
|
||||
gchar *first_property_name,
|
||||
...);
|
||||
|
||||
GObject *gconf_peditor_new_string (GConfChangeSet *changeset,
|
||||
gchar *key,
|
||||
GtkWidget *entry,
|
||||
|
@ -78,11 +90,21 @@ GObject *gconf_peditor_new_color (GConfChangeSet *changeset,
|
|||
GtkWidget *color_entry,
|
||||
gchar *first_property_name,
|
||||
...);
|
||||
GObject *gconf_peditor_new_select_menu (GConfChangeSet *changeset,
|
||||
gchar *key,
|
||||
GtkWidget *option_menu,
|
||||
gchar *first_property_name,
|
||||
|
||||
GObject *gconf_peditor_new_select_menu (GConfChangeSet *changeset,
|
||||
gchar *key,
|
||||
GtkWidget *option_menu,
|
||||
gchar *first_property_name,
|
||||
...);
|
||||
|
||||
|
||||
GObject *gconf_peditor_new_select_menu_with_enum (GConfChangeSet *changeset,
|
||||
gchar *key,
|
||||
GtkWidget *option_menu,
|
||||
GType enum_type,
|
||||
gchar *first_property_name,
|
||||
...);
|
||||
|
||||
GObject *gconf_peditor_new_select_radio (GConfChangeSet *changeset,
|
||||
gchar *key,
|
||||
GSList *radio_group,
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gnome.h>
|
||||
|
@ -42,6 +41,53 @@ static void bg_preferences_class_init (BGPreferencesClass *class);
|
|||
static void bg_preferences_finalize (GObject *object);
|
||||
|
||||
static GdkColor *read_color_from_string (const gchar *string);
|
||||
static orientation_t read_orientation_from_string (gchar *string);
|
||||
static wallpaper_type_t read_wptype_from_string (gchar *string);
|
||||
|
||||
static GEnumValue _bg_wptype_values[] = {
|
||||
{ WPTYPE_TILED, "wallpaper", N_("Tiled") },
|
||||
{ WPTYPE_CENTERED, "centered", N_("Centered") },
|
||||
{ WPTYPE_SCALED, "scaled", N_("Scaled") },
|
||||
{ WPTYPE_STRETCHED, "stretched", N_("Stretched") },
|
||||
{ WPTYPE_EMBOSSED, "embossed", N_("Embossed") },
|
||||
{ WPTYPE_NONE, "none", N_("None") },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GEnumValue _bg_orientation_values[] = {
|
||||
{ ORIENTATION_SOLID, "solid", N_("Solid") },
|
||||
{ ORIENTATION_HORIZ, "horizontal-gradient", N_("Horizontal Gradient") },
|
||||
{ ORIENTATION_VERT, "vertical-gradient", N_("Vertical Gradient") },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
GType
|
||||
bg_preferences_wptype_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
type = g_enum_register_static ("BgPreferencesWptype",
|
||||
_bg_wptype_values);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
bg_preferences_orientation_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
type = g_enum_register_static ("BgPreferencesOrientation",
|
||||
_bg_orientation_values);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
bg_preferences_get_type (void)
|
||||
|
@ -86,7 +132,7 @@ bg_preferences_init (BGPreferences *prefs,
|
|||
prefs->wallpaper_sel_path = g_strdup (g_get_home_dir ());
|
||||
prefs->auto_apply = TRUE;
|
||||
prefs->wallpapers = NULL;
|
||||
prefs->adjust_opacity = FALSE;
|
||||
prefs->adjust_opacity = TRUE;
|
||||
prefs->opacity = 255;
|
||||
}
|
||||
|
||||
|
@ -174,22 +220,30 @@ bg_preferences_load (BGPreferences *prefs)
|
|||
|
||||
client = gconf_client_get_default ();
|
||||
|
||||
prefs->enabled = gconf_client_get_bool (client, "/desktop/gnome/background/enabled", &error);
|
||||
prefs->wallpaper_type = gconf_client_get_int (client, "/desktop/gnome/background/wallpaper-type", &error);
|
||||
prefs->wallpaper_filename = gconf_client_get_string (client, "/desktop/gnome/background/wallpaper-filename", &error);
|
||||
prefs->wallpaper_enabled = gconf_client_get_bool (client, "/desktop/gnome/background/wallpaper-enabled", &error);
|
||||
prefs->color1 = read_color_from_string (gconf_client_get_string (client, "/desktop/gnome/background/color1", &error));
|
||||
prefs->color2 = read_color_from_string (gconf_client_get_string (client, "/desktop/gnome/background/color2", &error));
|
||||
prefs->opacity = gconf_client_get_int (client, "/desktop/gnome/background/opacity", &error);
|
||||
prefs->enabled = gconf_client_get_bool (client, BG_PREFERENCES_DRAW_BACKGROUND, &error);
|
||||
prefs->wallpaper_filename = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_FILENAME, &error);
|
||||
|
||||
prefs->color1 = read_color_from_string (gconf_client_get_string (client, BG_PREFERENCES_PRIMARY_COLOR, &error));
|
||||
prefs->color2 = read_color_from_string (gconf_client_get_string (client, BG_PREFERENCES_SECONDARY_COLOR, &error));
|
||||
|
||||
prefs->opacity = gconf_client_get_int (client, BG_PREFERENCES_PICTURE_OPACITY, &error);
|
||||
if (prefs->opacity >= 100 || prefs->opacity < 0)
|
||||
prefs->adjust_opacity = FALSE;
|
||||
|
||||
prefs->orientation = gconf_client_get_int (client, "/desktop/gnome/background/orientation", &error);
|
||||
|
||||
prefs->orientation = read_orientation_from_string (gconf_client_get_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, &error));
|
||||
if (prefs->orientation == ORIENTATION_SOLID)
|
||||
prefs->gradient_enabled = FALSE;
|
||||
else
|
||||
prefs->gradient_enabled = TRUE;
|
||||
|
||||
prefs->wallpaper_type = read_wptype_from_string (gconf_client_get_string (client, BG_PREFERENCES_PICTURE_OPTIONS, &error));
|
||||
|
||||
if (prefs->wallpaper_type == -1) {
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
prefs->wallpaper_type = WPTYPE_CENTERED;
|
||||
} else {
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse the event name given (the event being notification of a property having
|
||||
|
@ -206,10 +260,17 @@ bg_preferences_merge_entry (BGPreferences *prefs,
|
|||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_BG_PREFERENCES (prefs));
|
||||
|
||||
if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper_type")) {
|
||||
prefs->wallpaper_type = gconf_value_get_int (value);
|
||||
if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_OPTIONS)) {
|
||||
wallpaper_type_t wallpaper_type = read_wptype_from_string (g_strdup (gconf_value_get_string (value)));
|
||||
if (wallpaper_type == -1) {
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
} else {
|
||||
prefs->wallpaper_type = wallpaper_type;
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
else if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper-filename")) {
|
||||
else if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_FILENAME)) {
|
||||
prefs->wallpaper_filename = g_strdup (gconf_value_get_string (value));
|
||||
|
||||
if (prefs->wallpaper_filename != NULL &&
|
||||
|
@ -219,42 +280,76 @@ bg_preferences_merge_entry (BGPreferences *prefs,
|
|||
else
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
}
|
||||
else if (!strcmp (entry->key, "/desktop/gnome/background/color1")) {
|
||||
else if (!strcmp (entry->key, BG_PREFERENCES_PRIMARY_COLOR)) {
|
||||
prefs->color1 = read_color_from_string (gconf_value_get_string (value));
|
||||
}
|
||||
else if (!strcmp (entry->key, "/desktop/gnome/background/color2")) {
|
||||
else if (!strcmp (entry->key, BG_PREFERENCES_SECONDARY_COLOR)) {
|
||||
prefs->color2 = read_color_from_string (gconf_value_get_string (value));
|
||||
}
|
||||
else if (!strcmp (entry->key, "/desktop/gnome/background/opacity")) {
|
||||
else if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_OPACITY)) {
|
||||
prefs->opacity = gconf_value_get_int (value);
|
||||
|
||||
if (prefs->opacity >= 100)
|
||||
prefs->adjust_opacity = FALSE;
|
||||
}
|
||||
else if (!strcmp (entry->key, "/desktop/gnome/background/orientation")) {
|
||||
prefs->orientation = gconf_value_get_int (value);
|
||||
else if (!strcmp (entry->key, BG_PREFERENCES_COLOR_SHADING_TYPE)) {
|
||||
prefs->orientation = read_orientation_from_string (g_strdup (gconf_value_get_string (value)));
|
||||
|
||||
if (prefs->orientation == ORIENTATION_SOLID)
|
||||
prefs->gradient_enabled = FALSE;
|
||||
else
|
||||
prefs->gradient_enabled = TRUE;
|
||||
}
|
||||
else if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper-enabled")) {
|
||||
if (gconf_value_get_bool (value) &&
|
||||
(prefs->wallpaper_filename != NULL) &&
|
||||
strcmp (prefs->wallpaper_filename, "") != 0 &&
|
||||
strcmp (prefs->wallpaper_filename, "(none)") != 0)
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
else if (!strcmp (entry->key, BG_PREFERENCES_DRAW_BACKGROUND)) {
|
||||
if (gconf_value_get_bool (value))
|
||||
prefs->enabled = TRUE;
|
||||
else
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
}
|
||||
else if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper-type")) {
|
||||
prefs->wallpaper_type = gconf_value_get_int (value);
|
||||
prefs->enabled = FALSE;
|
||||
} else {
|
||||
g_warning ("%s: Unknown property: %s", G_GNUC_FUNCTION, entry->key);
|
||||
g_warning ("%s: Unknown property: %s", __FUNCTION__, entry->key);
|
||||
}
|
||||
}
|
||||
|
||||
static wallpaper_type_t
|
||||
read_wptype_from_string (gchar *string)
|
||||
{
|
||||
wallpaper_type_t type = -1;
|
||||
|
||||
if (string) {
|
||||
if (!strncmp (string, "wallpaper", sizeof ("wallpaper"))) {
|
||||
type = WPTYPE_TILED;
|
||||
} else if (!strncmp (string, "centered", sizeof ("centered"))) {
|
||||
type = WPTYPE_CENTERED;
|
||||
} else if (!strncmp (string, "scaled", sizeof ("scaled"))) {
|
||||
type = WPTYPE_SCALED;
|
||||
} else if (!strncmp (string, "stretched", sizeof ("stretched"))) {
|
||||
type = WPTYPE_STRETCHED;
|
||||
} else if (!strncmp (string, "embossed", sizeof ("embossed"))) {
|
||||
type = WPTYPE_EMBOSSED;
|
||||
}
|
||||
g_free (string);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static orientation_t
|
||||
read_orientation_from_string (gchar *string)
|
||||
{
|
||||
orientation_t type = ORIENTATION_SOLID;
|
||||
|
||||
if (string) {
|
||||
if (!strncmp (string, "vertical-gradient", sizeof ("vertical-gradient"))) {
|
||||
type = ORIENTATION_VERT;
|
||||
} else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) {
|
||||
type = ORIENTATION_HORIZ;
|
||||
}
|
||||
g_free (string);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static GdkColor *
|
||||
read_color_from_string (const gchar *string)
|
||||
{
|
||||
|
@ -269,16 +364,51 @@ read_color_from_string (const gchar *string)
|
|||
((color->green >> 8) << 8) ||
|
||||
(color->blue >> 8);
|
||||
#if 0
|
||||
/* fixme: I am not sure, but this can be accomplished otherwise */
|
||||
color->pixel = gdk_rgb_xpixel_from_rgb (rgb);
|
||||
#else
|
||||
gdk_rgb_find_color (gdk_rgb_get_colormap (), color);
|
||||
#endif
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
#define DGB "/desktop/gnome/background/"
|
||||
const gchar*
|
||||
bg_preferences_get_wptype_as_string (wallpaper_type_t wp)
|
||||
{
|
||||
switch (wp)
|
||||
{
|
||||
case WPTYPE_TILED:
|
||||
return "wallpaper";
|
||||
case WPTYPE_CENTERED:
|
||||
return "centered";
|
||||
case WPTYPE_SCALED:
|
||||
return "scaled";
|
||||
case WPTYPE_STRETCHED:
|
||||
return "stretched";
|
||||
case WPTYPE_EMBOSSED:
|
||||
return "embossed";
|
||||
case WPTYPE_NONE:
|
||||
return "none";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const gchar*
|
||||
bg_preferences_get_orientation_as_string (orientation_t o)
|
||||
{
|
||||
switch (o)
|
||||
{
|
||||
case ORIENTATION_SOLID:
|
||||
return "solid";
|
||||
case ORIENTATION_HORIZ:
|
||||
return "horizontal-gradient";
|
||||
case ORIENTATION_VERT:
|
||||
return "vertical-gradient";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
bg_preferences_save (BGPreferences *prefs)
|
||||
|
@ -290,29 +420,32 @@ bg_preferences_save (BGPreferences *prefs)
|
|||
g_return_if_fail (IS_BG_PREFERENCES (prefs));
|
||||
|
||||
cs = gconf_change_set_new ();
|
||||
gconf_change_set_set_bool (cs, DGB "enabled", prefs->enabled);
|
||||
gconf_change_set_set_bool (cs, DGB "wallpaper-enabled", prefs->wallpaper_enabled);
|
||||
gconf_change_set_set_int (cs, DGB "wallpaper-type", prefs->wallpaper_type);
|
||||
gconf_change_set_set_string (cs, DGB "wallpaper-filename", prefs->wallpaper_filename);
|
||||
gconf_change_set_set_bool (cs, BG_PREFERENCES_DRAW_BACKGROUND, prefs->enabled);
|
||||
if (prefs->wallpaper_enabled)
|
||||
gconf_change_set_set_string (cs, BG_PREFERENCES_PICTURE_OPTIONS, bg_preferences_get_wptype_as_string (prefs->wallpaper_type));
|
||||
else
|
||||
gconf_change_set_set_string (cs, BG_PREFERENCES_PICTURE_OPTIONS, "none");
|
||||
|
||||
gconf_change_set_set_string (cs, BG_PREFERENCES_PICTURE_FILENAME, prefs->wallpaper_filename);
|
||||
|
||||
tmp = g_strdup_printf ("#%02x%02x%02x",
|
||||
prefs->color1->red >> 8,
|
||||
prefs->color1->green >> 8,
|
||||
prefs->color1->blue >> 8);
|
||||
gconf_change_set_set_string (cs, DGB "color1", tmp);
|
||||
gconf_change_set_set_string (cs, BG_PREFERENCES_PRIMARY_COLOR, tmp);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = g_strdup_printf ("#%02x%02x%02x",
|
||||
prefs->color2->red >> 8,
|
||||
prefs->color2->green >> 8,
|
||||
prefs->color2->blue >> 8);
|
||||
gconf_change_set_set_string (cs, DGB "color2", tmp);
|
||||
gconf_change_set_set_string (cs, BG_PREFERENCES_SECONDARY_COLOR, tmp);
|
||||
g_free (tmp);
|
||||
|
||||
gconf_change_set_set_int (cs, DGB "orientation", prefs->orientation);
|
||||
gconf_change_set_set_string (cs, BG_PREFERENCES_COLOR_SHADING_TYPE, bg_preferences_get_orientation_as_string (prefs->orientation));
|
||||
|
||||
gconf_client_commit_change_set (gconf_client_get_default (), cs, TRUE, NULL);
|
||||
gconf_change_set_unref (cs);
|
||||
}
|
||||
|
||||
#undef DGB
|
||||
|
||||
|
|
|
@ -32,16 +32,27 @@
|
|||
#define BG_PREFERENCES_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, bg_preferences_get_type (), BGPreferencesClass)
|
||||
#define IS_BG_PREFERENCES(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, bg_preferences_get_type ())
|
||||
|
||||
#define BG_PREFERENCES_DRAW_BACKGROUND "/desktop/gnome/background/draw_background"
|
||||
#define BG_PREFERENCES_PRIMARY_COLOR "/desktop/gnome/background/primary_color"
|
||||
#define BG_PREFERENCES_SECONDARY_COLOR "/desktop/gnome/background/secondary_color"
|
||||
#define BG_PREFERENCES_COLOR_SHADING_TYPE "/desktop/gnome/background/color_shading_type"
|
||||
#define BG_PREFERENCES_PICTURE_OPTIONS "/desktop/gnome/background/picture_options"
|
||||
#define BG_PREFERENCES_PICTURE_OPACITY "/desktop/gnome/background/picture_opacity"
|
||||
#define BG_PREFERENCES_PICTURE_FILENAME "/desktop/gnome/background/picture_filename"
|
||||
|
||||
|
||||
typedef struct _BGPreferences BGPreferences;
|
||||
typedef struct _BGPreferencesClass BGPreferencesClass;
|
||||
|
||||
typedef enum _orientation_t {
|
||||
ORIENTATION_SOLID, ORIENTATION_HORIZ, ORIENTATION_VERT
|
||||
ORIENTATION_SOLID = 0,
|
||||
ORIENTATION_HORIZ,
|
||||
ORIENTATION_VERT
|
||||
} orientation_t;
|
||||
|
||||
typedef enum _wallpaper_type_t {
|
||||
WPTYPE_TILED, WPTYPE_CENTERED, WPTYPE_SCALED,
|
||||
WPTYPE_STRETCHED, WPTYPE_EMBOSSED
|
||||
WPTYPE_TILED = 0, WPTYPE_CENTERED, WPTYPE_SCALED,
|
||||
WPTYPE_STRETCHED, WPTYPE_EMBOSSED, WPTYPE_NONE
|
||||
} wallpaper_type_t;
|
||||
|
||||
struct _BGPreferences
|
||||
|
@ -87,4 +98,10 @@ void bg_preferences_merge_entry (BGPreferences *prefs,
|
|||
|
||||
void bg_preferences_save (BGPreferences *prefs);
|
||||
|
||||
const gchar *bg_preferences_get_wptype_as_string (wallpaper_type_t wp);
|
||||
const gchar *bg_preferences_get_orientation_as_string (orientation_t o);
|
||||
GType bg_preferences_wptype_get_type (void);
|
||||
GType bg_preferences_orientation_get_type (void);
|
||||
|
||||
|
||||
#endif /* __PREFERENCES_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue