[gnome-control-center] background: Use g_settings_get/_set_enum for background options and shading



commit 7cc99ddc874d7c28db4823a416615f2fd36b6b00
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Thu Oct 14 13:30:29 2010 +0200

    background: Use g_settings_get/_set_enum for background options and shading

 panels/background/background.ui         |   74 +++++++++++++++----------------
 panels/background/cc-background-panel.c |   16 +++----
 panels/background/gnome-wp-item.h       |    5 +-
 3 files changed, 46 insertions(+), 49 deletions(-)
---
diff --git a/panels/background/background.ui b/panels/background/background.ui
index 457aafb..22f13f4 100644
--- a/panels/background/background.ui
+++ b/panels/background/background.ui
@@ -1,41 +1,7 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
-  <object class="GtkListStore" id="style-liststore">
-    <columns>
-      <!-- column-name name -->
-      <column type="gchararray"/>
-      <!-- column-name value -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">Tile</col>
-        <col id="1">wallpaper</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Zoom</col>
-        <col id="1">zoom</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Center</col>
-        <col id="1">centered</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Scale</col>
-        <col id="1">scaled</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Fill</col>
-        <col id="1">stretched</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Span</col>
-        <col id="1">spanned</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkListStore" id="backgrounds-liststore">
     <columns>
       <!-- column-name pixbuf -->
@@ -64,7 +30,6 @@
     <child>
       <object class="GtkVBox" id="vbox2">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
         <property name="spacing">6</property>
         <child>
           <object class="GtkComboBox" id="sources-combobox">
@@ -120,7 +85,6 @@
     <child>
       <object class="GtkVBox" id="vbox3">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
         <child>
           <object class="GtkDrawingArea" id="preview-area">
             <property name="visible">True</property>
@@ -197,8 +161,42 @@
   <object class="GtkSizeGroup" id="sizegroup">
     <property name="mode">vertical</property>
     <widgets>
-      <widget name="background-label"/>
       <widget name="edit-hbox"/>
+      <widget name="background-label"/>
     </widgets>
   </object>
+  <object class="GtkListStore" id="style-liststore">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+      <!-- column-name value -->
+      <column type="gint"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Tile</col>
+        <col id="1">1</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Zoom</col>
+        <col id="1">5</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Center</col>
+        <col id="1">2</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Scale</col>
+        <col id="1">3</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Fill</col>
+        <col id="1">4</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Span</col>
+        <col id="1">6</col>
+      </row>
+    </data>
+  </object>
 </interface>
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 55d49b2..e8e6311 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -369,7 +369,7 @@ backgrounds_changed_cb (GtkIconView       *icon_view,
 
   if (!g_strcmp0 (item->filename, "(none)"))
     {
-      g_settings_set_string (priv->settings, WP_OPTIONS_KEY, "none");
+      g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, G_DESKTOP_BACKGROUND_STYLE_NONE);
       g_settings_set_string (priv->settings, WP_FILE_KEY, "");
     }
   else if (item->source_url)
@@ -420,7 +420,7 @@ backgrounds_changed_cb (GtkIconView       *icon_view,
                          copy_finished_cb, panel);
 
       g_settings_set_string (priv->settings, WP_FILE_KEY, cache_path);
-      g_settings_set_string (priv->settings, WP_OPTIONS_KEY, wp_item_option_to_string (item->options));
+      g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, item->options);
       g_free (item->filename);
       item->filename = cache_path;
 
@@ -447,11 +447,10 @@ backgrounds_changed_cb (GtkIconView       *icon_view,
            g_free (uri);
          }
 
-       g_settings_set_string (priv->settings, WP_OPTIONS_KEY, wp_item_option_to_string (item->options));
+       g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, item->options);
     }
 
-  g_settings_set_string (priv->settings, WP_SHADING_KEY,
-			 wp_item_shading_to_string (item->shade_type));
+  g_settings_set_enum (priv->settings, WP_SHADING_KEY, item->shade_type);
 
   pcolor = gdk_color_to_string (item->pcolor);
   scolor = gdk_color_to_string (item->scolor);
@@ -460,6 +459,7 @@ backgrounds_changed_cb (GtkIconView       *icon_view,
   g_free (pcolor);
   g_free (scolor);
 
+  /* Apply all changes */
   g_settings_apply (priv->settings);
 
   /* update the preview information */
@@ -544,7 +544,7 @@ style_changed_cb (GtkComboBox       *box,
   CcBackgroundPanelPrivate *priv = panel->priv;
   GtkTreeModel *model;
   GtkTreeIter iter;
-  gchar *value;
+  gint value;
 
   gtk_combo_box_get_active_iter (box, &iter);
 
@@ -552,9 +552,7 @@ style_changed_cb (GtkComboBox       *box,
 
   gtk_tree_model_get (model, &iter, 1, &value, -1);
 
-  g_settings_set_string (priv->settings, WP_OPTIONS_KEY, value);
-
-  g_free (value);
+  g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, value);
 
   if (priv->current_background)
     priv->current_background->options = gtk_combo_box_get_active (box);
diff --git a/panels/background/gnome-wp-item.h b/panels/background/gnome-wp-item.h
index f069d99..86fa958 100644
--- a/panels/background/gnome-wp-item.h
+++ b/panels/background/gnome-wp-item.h
@@ -23,6 +23,7 @@
 #include <gtk/gtk.h>
 #include <libgnomeui/gnome-desktop-thumbnail.h>
 #include <libgnomeui/gnome-bg.h>
+#include <gsettings-desktop-schemas/gdesktop-enums.h>
 
 #include "gnome-wp-info.h"
 
@@ -44,8 +45,8 @@ struct _GnomeWPItem {
   gchar * name;
   gchar * filename;
   gchar * description;
-  GnomeBGPlacement options;
-  GnomeBGColorType shade_type;
+  GDesktopBackgroundStyle options;
+  GDesktopBackgroundShading shade_type;
 
   gchar * source_url;
 



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