From 12c22f11565dd06b17f9501f7e7658d5e8449ccc Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Thu, 14 Oct 2010 15:24:00 +0200 Subject: [PATCH] background: Convert by hand the enum values to their strings --- panels/background/gnome-wp-item.c | 58 +++++++++++++++++++++++-------- panels/background/gnome-wp-item.h | 8 ++--- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/panels/background/gnome-wp-item.c b/panels/background/gnome-wp-item.c index 33685a396..40265c1e0 100644 --- a/panels/background/gnome-wp-item.c +++ b/panels/background/gnome-wp-item.c @@ -21,11 +21,13 @@ #include #include -#include #include #include "gnome-wp-item.h" -static GConfEnumStringPair options_lookup[] = { +static struct { + GDesktopBackgroundStyle value; + gchar *string; +} options_lookup[] = { { G_DESKTOP_BACKGROUND_STYLE_CENTERED, "centered" }, { G_DESKTOP_BACKGROUND_STYLE_STRETCHED, "stretched" }, { G_DESKTOP_BACKGROUND_STYLE_SCALED, "scaled" }, @@ -35,35 +37,61 @@ static GConfEnumStringPair options_lookup[] = { { 0, NULL } }; -static GConfEnumStringPair shade_lookup[] = { +static struct { + GDesktopBackgroundShading value; + gchar *string; +} shade_lookup[] = { { G_DESKTOP_BACKGROUND_SHADING_SOLID, "solid" }, { G_DESKTOP_BACKGROUND_SHADING_HORIZONTAL, "horizontal-gradient" }, { G_DESKTOP_BACKGROUND_SHADING_VERTICAL, "vertical-gradient" }, { 0, NULL } }; -const gchar *wp_item_option_to_string (GnomeBGPlacement type) +const gchar *wp_item_option_to_string (GDesktopBackgroundStyle type) { - return gconf_enum_to_string (options_lookup, type); + int i; + + for (i = 0; options_lookup[i].value != 0; i++) { + if (options_lookup[i].value == type) + return (const gchar *) options_lookup[i].string; + } + + return "scaled"; } -const gchar *wp_item_shading_to_string (GnomeBGColorType type) +const gchar *wp_item_shading_to_string (GDesktopBackgroundShading type) { - return gconf_enum_to_string (shade_lookup, type); + int i; + + for (i = 0; shade_lookup[i].value != 0; i++) { + if (shade_lookup[i].value == type) + return (const gchar *) shade_lookup[i].string; + } + + return "solid"; } -GnomeBGPlacement wp_item_string_to_option (const gchar *option) +GDesktopBackgroundStyle wp_item_string_to_option (const gchar *option) { - int i = GNOME_BG_PLACEMENT_SCALED; - gconf_string_to_enum (options_lookup, option, &i); - return i; + gint i; + + for (i = 0; options_lookup[i].value != 0; i++) { + if (g_str_equal (options_lookup[i].string, option)) + return options_lookup[i].value; + } + + return G_DESKTOP_BACKGROUND_STYLE_SCALED; } -GnomeBGColorType wp_item_string_to_shading (const gchar *shade_type) +GDesktopBackgroundShading wp_item_string_to_shading (const gchar *shade_type) { - int i = GNOME_BG_COLOR_SOLID; - gconf_string_to_enum (shade_lookup, shade_type, &i); - return i; + int i; + + for (i = 0; shade_lookup[i].value != 0; i++) { + if (g_str_equal (shade_lookup[i].string, shade_type)) + return options_lookup[i].value; + } + return G_DESKTOP_BACKGROUND_SHADING_SOLID; } static void set_bg_properties (GnomeWPItem *item) diff --git a/panels/background/gnome-wp-item.h b/panels/background/gnome-wp-item.h index 86fa95848..70f48c90e 100644 --- a/panels/background/gnome-wp-item.h +++ b/panels/background/gnome-wp-item.h @@ -85,9 +85,9 @@ void gnome_wp_item_update (GnomeWPItem *item); void gnome_wp_item_update_description (GnomeWPItem *item); void gnome_wp_item_ensure_gnome_bg (GnomeWPItem *item); -const gchar *wp_item_option_to_string (GnomeBGPlacement type); -const gchar *wp_item_shading_to_string (GnomeBGColorType type); -GnomeBGPlacement wp_item_string_to_option (const gchar *option); -GnomeBGColorType wp_item_string_to_shading (const gchar *shade_type); +const gchar *wp_item_option_to_string (GDesktopBackgroundStyle type); +const gchar *wp_item_shading_to_string (GDesktopBackgroundShading type); +GDesktopBackgroundStyle wp_item_string_to_option (const gchar *option); +GDesktopBackgroundShading wp_item_string_to_shading (const gchar *shade_type); #endif