Skip to content
Snippets Groups Projects
Commit 7173f6e3 authored by Kjartan Maraas's avatar Kjartan Maraas Committed by Kjartan Maraas
Browse files

Make read_orientation_from_string() and read_wptype_from_string() behave

2006-08-23  Kjartan Maraas  <kmaraas@gnome.org>

	* preferences.c: (bg_preferences_load),
	(bg_preferences_merge_entry), (read_wptype_from_string),
	(read_orientation_from_string): Make read_orientation_from_string()
	and read_wptype_from_string() behave like read_color_from_string()
	and adjust all callers. Avoids some excess strduping too I guess.
	Closes bug #352252.
parent 1358fd4e
No related branches found
No related tags found
No related merge requests found
2006-08-23 Kjartan Maraas <kmaraas@gnome.org>
* preferences.c: (bg_preferences_load),
(bg_preferences_merge_entry), (read_wptype_from_string),
(read_orientation_from_string): Make read_orientation_from_string()
and read_wptype_from_string() behave like read_color_from_string()
and adjust all callers. Avoids some excess strduping too I guess.
Closes bug #352252.
2006-08-21 Rodney Dawes <dobey@novell.com>
* preferences.c (bg_preferences_load): Revert previous leak fix from
......
......@@ -42,8 +42,8 @@ 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 orientation_t read_orientation_from_string (const gchar *string);
static wallpaper_type_t read_wptype_from_string (const gchar *string);
static GEnumValue _bg_wptype_values[] = {
{ WPTYPE_TILED, "WPTYPE_TILED", "wallpaper"},
......@@ -272,13 +272,18 @@ bg_preferences_load (BGPreferences *prefs)
if (prefs->opacity >= 100 || prefs->opacity < 0)
prefs->adjust_opacity = FALSE;
prefs->orientation = read_orientation_from_string (gconf_client_get_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, &error));
tmp = gconf_client_get_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, &error);
prefs->orientation = read_orientation_from_string (tmp);
g_free (tmp);
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));
tmp = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_OPTIONS, &error);
prefs->wallpaper_type = read_wptype_from_string (tmp);
g_free (tmp);
if (prefs->wallpaper_type == WPTYPE_UNSET) {
prefs->wallpaper_enabled = FALSE;
......@@ -305,7 +310,7 @@ bg_preferences_merge_entry (BGPreferences *prefs,
g_return_if_fail (IS_BG_PREFERENCES (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)));
wallpaper_type_t wallpaper_type = read_wptype_from_string (gconf_value_get_string (value));
if (wallpaper_type == WPTYPE_UNSET) {
prefs->wallpaper_enabled = FALSE;
} else {
......@@ -350,7 +355,7 @@ bg_preferences_merge_entry (BGPreferences *prefs,
prefs->adjust_opacity = FALSE;
}
else if (!strcmp (entry->key, BG_PREFERENCES_COLOR_SHADING_TYPE)) {
prefs->orientation = read_orientation_from_string (g_strdup (gconf_value_get_string (value)));
prefs->orientation = read_orientation_from_string (gconf_value_get_string (value));
if (prefs->orientation == ORIENTATION_SOLID)
prefs->gradient_enabled = FALSE;
......@@ -371,7 +376,7 @@ bg_preferences_merge_entry (BGPreferences *prefs,
}
static wallpaper_type_t
read_wptype_from_string (gchar *string)
read_wptype_from_string (const gchar *string)
{
wallpaper_type_t type = WPTYPE_UNSET;
......@@ -387,14 +392,13 @@ read_wptype_from_string (gchar *string)
} else if (!strncmp (string, "zoom", sizeof ("zoom"))) {
type = WPTYPE_ZOOM;
}
g_free (string);
}
return type;
}
static orientation_t
read_orientation_from_string (gchar *string)
read_orientation_from_string (const gchar *string)
{
orientation_t type = ORIENTATION_SOLID;
......@@ -404,7 +408,6 @@ read_orientation_from_string (gchar *string)
} else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) {
type = ORIENTATION_HORIZ;
}
g_free (string);
}
return type;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment