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.
This commit is contained in:
parent
1358fd4ef5
commit
7173f6e3d8
2 changed files with 22 additions and 10 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
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>
|
2006-08-21 Rodney Dawes <dobey@novell.com>
|
||||||
|
|
||||||
* preferences.c (bg_preferences_load): Revert previous leak fix from
|
* 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 void bg_preferences_finalize (GObject *object);
|
||||||
|
|
||||||
static GdkColor *read_color_from_string (const gchar *string);
|
static GdkColor *read_color_from_string (const gchar *string);
|
||||||
static orientation_t read_orientation_from_string (gchar *string);
|
static orientation_t read_orientation_from_string (const gchar *string);
|
||||||
static wallpaper_type_t read_wptype_from_string (gchar *string);
|
static wallpaper_type_t read_wptype_from_string (const gchar *string);
|
||||||
|
|
||||||
static GEnumValue _bg_wptype_values[] = {
|
static GEnumValue _bg_wptype_values[] = {
|
||||||
{ WPTYPE_TILED, "WPTYPE_TILED", "wallpaper"},
|
{ WPTYPE_TILED, "WPTYPE_TILED", "wallpaper"},
|
||||||
|
@ -272,13 +272,18 @@ bg_preferences_load (BGPreferences *prefs)
|
||||||
if (prefs->opacity >= 100 || prefs->opacity < 0)
|
if (prefs->opacity >= 100 || prefs->opacity < 0)
|
||||||
prefs->adjust_opacity = FALSE;
|
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)
|
if (prefs->orientation == ORIENTATION_SOLID)
|
||||||
prefs->gradient_enabled = FALSE;
|
prefs->gradient_enabled = FALSE;
|
||||||
else
|
else
|
||||||
prefs->gradient_enabled = TRUE;
|
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) {
|
if (prefs->wallpaper_type == WPTYPE_UNSET) {
|
||||||
prefs->wallpaper_enabled = FALSE;
|
prefs->wallpaper_enabled = FALSE;
|
||||||
|
@ -305,7 +310,7 @@ bg_preferences_merge_entry (BGPreferences *prefs,
|
||||||
g_return_if_fail (IS_BG_PREFERENCES (prefs));
|
g_return_if_fail (IS_BG_PREFERENCES (prefs));
|
||||||
|
|
||||||
if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_OPTIONS)) {
|
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) {
|
if (wallpaper_type == WPTYPE_UNSET) {
|
||||||
prefs->wallpaper_enabled = FALSE;
|
prefs->wallpaper_enabled = FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -350,7 +355,7 @@ bg_preferences_merge_entry (BGPreferences *prefs,
|
||||||
prefs->adjust_opacity = FALSE;
|
prefs->adjust_opacity = FALSE;
|
||||||
}
|
}
|
||||||
else if (!strcmp (entry->key, BG_PREFERENCES_COLOR_SHADING_TYPE)) {
|
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)
|
if (prefs->orientation == ORIENTATION_SOLID)
|
||||||
prefs->gradient_enabled = FALSE;
|
prefs->gradient_enabled = FALSE;
|
||||||
|
@ -371,7 +376,7 @@ bg_preferences_merge_entry (BGPreferences *prefs,
|
||||||
}
|
}
|
||||||
|
|
||||||
static wallpaper_type_t
|
static wallpaper_type_t
|
||||||
read_wptype_from_string (gchar *string)
|
read_wptype_from_string (const gchar *string)
|
||||||
{
|
{
|
||||||
wallpaper_type_t type = WPTYPE_UNSET;
|
wallpaper_type_t type = WPTYPE_UNSET;
|
||||||
|
|
||||||
|
@ -387,14 +392,13 @@ read_wptype_from_string (gchar *string)
|
||||||
} else if (!strncmp (string, "zoom", sizeof ("zoom"))) {
|
} else if (!strncmp (string, "zoom", sizeof ("zoom"))) {
|
||||||
type = WPTYPE_ZOOM;
|
type = WPTYPE_ZOOM;
|
||||||
}
|
}
|
||||||
g_free (string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static orientation_t
|
static orientation_t
|
||||||
read_orientation_from_string (gchar *string)
|
read_orientation_from_string (const gchar *string)
|
||||||
{
|
{
|
||||||
orientation_t type = ORIENTATION_SOLID;
|
orientation_t type = ORIENTATION_SOLID;
|
||||||
|
|
||||||
|
@ -404,7 +408,6 @@ read_orientation_from_string (gchar *string)
|
||||||
} else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) {
|
} else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) {
|
||||||
type = ORIENTATION_HORIZ;
|
type = ORIENTATION_HORIZ;
|
||||||
}
|
}
|
||||||
g_free (string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue