Add an enum type for specifying that we don't know the type (i.e. the key

2002-03-15  Seth Nickell  <snickell@stanford.edu>

	* preferences.c: (bg_preferences_load),
	(bg_preferences_merge_entry), (read_wptype_from_string),
	(read_color_from_string), (bg_preferences_get_wptype_as_string):
	* preferences.h:

	Add an enum type for specifying that we don't know the type (i.e. the
	key was not available, or set to something invalid). Currently it
	was using -1, which barfs with some compilers that set enums
	to be uint.
This commit is contained in:
Seth Nickell 2002-03-15 09:23:45 +00:00 committed by Seth Nickell
parent c10c6c06ce
commit 8e834c8342
2 changed files with 23 additions and 10 deletions

View file

@ -1,3 +1,15 @@
2002-03-15 Seth Nickell <snickell@stanford.edu>
* preferences.c: (bg_preferences_load),
(bg_preferences_merge_entry), (read_wptype_from_string),
(read_color_from_string), (bg_preferences_get_wptype_as_string):
* preferences.h:
Add an enum type for specifying that we don't know the type (i.e. the
key was not available, or set to something invalid). Currently it
was using -1, which barfs with some compilers that set enums
to be uint.
2002-03-09 Richard Hestilow <hestilow@ximian.com>
* preview-file-selection.[ch]: Added.

View file

@ -238,7 +238,7 @@ bg_preferences_load (BGPreferences *prefs)
prefs->wallpaper_type = read_wptype_from_string (gconf_client_get_string (client, BG_PREFERENCES_PICTURE_OPTIONS, &error));
if (prefs->wallpaper_type == -1) {
if (prefs->wallpaper_type == WPTYPE_UNSET) {
prefs->wallpaper_enabled = FALSE;
prefs->wallpaper_type = WPTYPE_CENTERED;
} else {
@ -262,13 +262,12 @@ bg_preferences_merge_entry (BGPreferences *prefs,
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) {
if (wallpaper_type == WPTYPE_UNSET) {
prefs->wallpaper_enabled = FALSE;
} else {
prefs->wallpaper_type = wallpaper_type;
prefs->wallpaper_enabled = TRUE;
}
}
else if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_FILENAME)) {
prefs->wallpaper_filename = g_strdup (gconf_value_get_string (value));
@ -301,8 +300,11 @@ bg_preferences_merge_entry (BGPreferences *prefs,
prefs->gradient_enabled = TRUE;
}
else if (!strcmp (entry->key, BG_PREFERENCES_DRAW_BACKGROUND)) {
if (gconf_value_get_bool (value))
prefs->enabled = TRUE;
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
prefs->enabled = FALSE;
} else {
@ -313,7 +315,7 @@ bg_preferences_merge_entry (BGPreferences *prefs,
static wallpaper_type_t
read_wptype_from_string (gchar *string)
{
wallpaper_type_t type = -1;
wallpaper_type_t type = WPTYPE_UNSET;
if (string) {
if (!strncmp (string, "wallpaper", sizeof ("wallpaper"))) {
@ -363,10 +365,7 @@ read_color_from_string (const gchar *string)
rgb = ((color->red >> 8) << 16) ||
((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);
#endif
gdk_rgb_find_color (gdk_rgb_get_colormap (), color);
}
return color;
@ -389,6 +388,8 @@ bg_preferences_get_wptype_as_string (wallpaper_type_t wp)
return "embossed";
case WPTYPE_NONE:
return "none";
case WPTYPE_UNSET:
return NULL;
}
return NULL;