[gnome-control-center] background: Use gdesktop-settings-schemas enums all over



commit bb26cd2e5150c195b2372054513c8d1fedc6278b
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Thu Oct 14 14:57:35 2010 +0200

    background: Use gdesktop-settings-schemas enums all over

 panels/background/bg-wallpapers-source.c |    4 +-
 panels/background/gnome-wp-item.c        |   37 +++++++++++++-----------------
 panels/background/gnome-wp-xml.c         |   14 +++--------
 panels/background/gnome-wp-xml.h         |    3 +-
 4 files changed, 23 insertions(+), 35 deletions(-)
---
diff --git a/panels/background/bg-wallpapers-source.c b/panels/background/bg-wallpapers-source.c
index f18d527..1d2dfc4 100644
--- a/panels/background/bg-wallpapers-source.c
+++ b/panels/background/bg-wallpapers-source.c
@@ -201,7 +201,7 @@ bg_wallpapers_source_init (BgWallpapersSource *self)
   /* set up wallpaper source */
   wp_xml = g_new0 (GnomeWpXml, 1);
   wp_xml->wp_hash = g_hash_table_new (g_str_hash, g_str_equal);
-  wp_xml->client = gconf_client_get_default ();
+  wp_xml->settings = g_settings_new (WP_PATH_ID);
   wp_xml->wp_model = bg_source_get_liststore (BG_SOURCE (self));
   wp_xml->thumb_width = THUMBNAIL_WIDTH;
   wp_xml->thumb_height = THUMBNAIL_HEIGHT;
@@ -213,7 +213,7 @@ bg_wallpapers_source_init (BgWallpapersSource *self)
                         self);
 
   g_hash_table_destroy (wp_xml->wp_hash);
-  g_object_unref (wp_xml->client);
+  g_object_unref (wp_xml->settings);
   g_free (wp_xml);
 }
 
diff --git a/panels/background/gnome-wp-item.c b/panels/background/gnome-wp-item.c
index 703b853..33685a3 100644
--- a/panels/background/gnome-wp-item.c
+++ b/panels/background/gnome-wp-item.c
@@ -26,19 +26,19 @@
 #include "gnome-wp-item.h"
 
 static GConfEnumStringPair options_lookup[] = {
-  { GNOME_BG_PLACEMENT_CENTERED, "centered" },
-  { GNOME_BG_PLACEMENT_FILL_SCREEN, "stretched" },
-  { GNOME_BG_PLACEMENT_SCALED, "scaled" },
-  { GNOME_BG_PLACEMENT_ZOOMED, "zoom" },
-  { GNOME_BG_PLACEMENT_TILED, "wallpaper" },
-  { GNOME_BG_PLACEMENT_SPANNED, "spanned" },
+  { G_DESKTOP_BACKGROUND_STYLE_CENTERED, "centered" },
+  { G_DESKTOP_BACKGROUND_STYLE_STRETCHED, "stretched" },
+  { G_DESKTOP_BACKGROUND_STYLE_SCALED, "scaled" },
+  { G_DESKTOP_BACKGROUND_STYLE_ZOOM, "zoom" },
+  { G_DESKTOP_BACKGROUND_STYLE_WALLPAPER, "wallpaper" },
+  { G_DESKTOP_BACKGROUND_STYLE_SPANNED, "spanned" },
   { 0, NULL }
 };
 
 static GConfEnumStringPair shade_lookup[] = {
-  { GNOME_BG_COLOR_SOLID, "solid" },
-  { GNOME_BG_COLOR_H_GRADIENT, "horizontal-gradient" },
-  { GNOME_BG_COLOR_V_GRADIENT, "vertical-gradient" },
+  { G_DESKTOP_BACKGROUND_SHADING_SOLID, "solid" },
+  { G_DESKTOP_BACKGROUND_SHADING_HORIZONTAL, "horizontal-gradient" },
+  { G_DESKTOP_BACKGROUND_SHADING_VERTICAL, "vertical-gradient" },
   { 0, NULL }
 };
 
@@ -90,33 +90,28 @@ void gnome_wp_item_ensure_gnome_bg (GnomeWPItem *item)
 }
 
 void gnome_wp_item_update (GnomeWPItem *item) {
-  GConfClient *client;
+  GSettings *settings;
   GdkColor color1 = { 0, 0, 0, 0 }, color2 = { 0, 0, 0, 0 };
   gchar *s;
 
-  client = gconf_client_get_default ();
+  settings = g_settings_new (WP_PATH_ID);
 
-  s = gconf_client_get_string (client, WP_OPTIONS_KEY, NULL);
-  item->options = wp_item_string_to_option (s);
-  g_free (s);
+  item->options = g_settings_get_enum (settings, WP_OPTIONS_KEY);
+  item->shade_type = g_settings_get_enum (settings,WP_SHADING_KEY);
 
-  s = gconf_client_get_string (client, WP_SHADING_KEY, NULL);
-  item->shade_type = wp_item_string_to_shading (s);
-  g_free (s);
-
-  s = gconf_client_get_string (client, WP_PCOLOR_KEY, NULL);
+  s = g_settings_get_string (settings, WP_PCOLOR_KEY);
   if (s != NULL) {
     gdk_color_parse (s, &color1);
     g_free (s);
   }
 
-  s = gconf_client_get_string (client, WP_SCOLOR_KEY, NULL);
+  s = g_settings_get_string (settings, WP_SCOLOR_KEY);
   if (s != NULL) {
     gdk_color_parse (s, &color2);
     g_free (s);
   }
 
-  g_object_unref (client);
+  g_object_unref (settings);
 
   if (item->pcolor != NULL)
     gdk_color_free (item->pcolor);
diff --git a/panels/background/gnome-wp-xml.c b/panels/background/gnome-wp-xml.c
index 1abe2e1..ec6537c 100644
--- a/panels/background/gnome-wp-xml.c
+++ b/panels/background/gnome-wp-xml.c
@@ -200,24 +200,18 @@ static void gnome_wp_xml_load_xml (GnomeWpXml *data,
 
       /* Verify the colors and alloc some GdkColors here */
       if (!have_scale) {
-        s = gconf_client_get_string (data->client, WP_OPTIONS_KEY, NULL);
-        wp->options = wp_item_string_to_option (s);
-        g_free (s);
+        wp->options = g_settings_get_enum (data->settings, WP_OPTIONS_KEY);
       }
 
       if (!have_shade) {
-        s = gconf_client_get_string (data->client, WP_SHADING_KEY, NULL);
-        wp->shade_type = wp_item_string_to_shading (s);
-        g_free (s);
+        wp->shade_type = g_settings_get_enum (data->settings, WP_SHADING_KEY);
       }
 
       if (pcolor == NULL) {
-	pcolor = gconf_client_get_string (data->client,
-					  WP_PCOLOR_KEY, NULL);
+	pcolor = g_settings_get_string (data->settings, WP_PCOLOR_KEY);
       }
       if (scolor == NULL) {
-	scolor = gconf_client_get_string (data->client,
-					  WP_SCOLOR_KEY, NULL);
+	scolor = g_settings_get_string (data->settings, WP_SCOLOR_KEY);
       }
       gdk_color_parse (pcolor, &color1);
       gdk_color_parse (scolor, &color2);
diff --git a/panels/background/gnome-wp-xml.h b/panels/background/gnome-wp-xml.h
index 2ea8c2a..a08f4c4 100644
--- a/panels/background/gnome-wp-xml.h
+++ b/panels/background/gnome-wp-xml.h
@@ -21,7 +21,6 @@
 #ifndef _GNOME_WP_XML_H_
 #define _GNOME_WP_XML_H_
 
-#include <gconf/gconf-client.h>
 #include <libgnomeui/gnome-desktop-thumbnail.h>
 
 typedef struct _GnomeWpXml GnomeWpXml;
@@ -30,7 +29,7 @@ struct _GnomeWpXml
 {
   GHashTable *wp_hash;
   GnomeDesktopThumbnailFactory *thumb_factory;
-  GConfClient *client;
+  GSettings *settings;
   gint thumb_height;
   gint thumb_width;
   GtkListStore *wp_model;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]