[gnome-applets] gweather: port to the new libgweather



commit 8a413573e7ec34f19e7724737183caa25dc709eb
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed Dec 14 18:51:26 2011 +0100

    gweather: port to the new libgweather
    
    libgweather API was broken to add introspection support, and to
    remove the old dependency on GConf. Update accordingly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678977

 configure.in                                       |    5 +-
 gweather/Makefile.am                               |   10 +
 gweather/gweather-applet.c                         |   91 ++---
 gweather/gweather-dialog.c                         |  185 +++-------
 gweather/gweather-pref.c                           |  394 ++++++--------------
 gweather/gweather.h                                |   14 +-
 gweather/main.c                                    |   11 +-
 ....gnome.applets.GWeatherApplet.gschema.xml.in.in |   29 ++
 8 files changed, 250 insertions(+), 489 deletions(-)
---
diff --git a/configure.in b/configure.in
index 9eb94d4..7c1c8fc 100644
--- a/configure.in
+++ b/configure.in
@@ -28,7 +28,7 @@ DBUS_GLIB_REQUIRED=0.74
 PYGOBJECT_REQUIRED=2.26
 GNOME_ICON_THEME_REQUIRED=2.15.91
 LIBXML_REQUIRED=2.5.0
-GWEATHER_REQUIRED=2.91.0
+GWEATHER_REQUIRED=3.5.0
 GUCHARMAP3_REQUIRED=2.33.0
 POLKIT_REQUIRED=0.92
 NETWORKMANAGER_REQUIRED=0.7
@@ -258,6 +258,9 @@ AC_SUBST(LIBGWEATHER_CFLAGS)
 AC_SUBST(LIBGWEATHER_LIBS)
 AM_CONDITIONAL(BUILD_LIBGWEATHER_APPLETS, $build_libgweather_applets)
 
+dnl -- check for GSettings (required for gweather applet)
+GLIB_GSETTINGS
+
 dnl -- check for NetworkManager -----------------------------------------------
 AC_ARG_ENABLE([networkmanager],
 	AC_HELP_STRING([--enable-networkmanager],
diff --git a/gweather/Makefile.am b/gweather/Makefile.am
index 1537b29..13ddb2b 100644
--- a/gweather/Makefile.am
+++ b/gweather/Makefile.am
@@ -57,10 +57,20 @@ org.gnome.panel.applet.GWeatherAppletFactory.service: $(service_in_files)
             -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
             $< > $@
 
+%.gschema.xml.in: %.gschema.xml.in.in
+	$(AM_V_GEN)sed -e "s|\ GETTEXT_PACKAGE\@|$(GETTEXT_PACKAGE)|" $< > $@
+
+ INTLTOOL_XML_NOMERGE_RULE@
+
+ GSETTINGS_RULES@
+
+gsettings_SCHEMAS = $(builddir)/org.gnome.applets.GWeatherApplet.gschema.xml
+
 CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA)
 
 EXTRA_DIST = \
 	org.gnome.applets.GWeatherApplet.panel-applet.in.in	\
+	org.gnome.applets.GWeatherApplet.gschema.xml		\
 	$(service_in_files)					\
 	$(ui_DATA)
 
diff --git a/gweather/gweather-applet.c b/gweather/gweather-applet.c
index c906eef..02b15b1 100644
--- a/gweather/gweather-applet.c
+++ b/gweather/gweather-applet.c
@@ -150,7 +150,7 @@ static void place_widgets (GWeatherApplet *gw_applet)
     }
 
     /* Create the weather icon */
-    icon_name = weather_info_get_icon_name (gw_applet->gweather_info);
+    icon_name = gweather_info_get_icon_name (gw_applet->gweather_info);
     gw_applet->image = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_BUTTON); 
 
     if (icon_name != NULL) {
@@ -165,7 +165,7 @@ static void place_widgets (GWeatherApplet *gw_applet)
     gw_applet->label = gtk_label_new("--");
     
     /* Update temperature text */
-    temp = weather_info_get_temp_summary(gw_applet->gweather_info);
+    temp = gweather_info_get_temp_summary(gw_applet->gweather_info);
     if (temp) 
         gtk_label_set_text(GTK_LABEL(gw_applet->label), temp);
 
@@ -294,11 +294,10 @@ applet_destroy (GtkWidget *widget, GWeatherApplet *gw_applet)
        gw_applet->suncalc_timeout_tag = 0;
     }
 	
-    if (gw_applet->gconf) {
-       gweather_gconf_free (gw_applet->gconf);
-    }
+    g_clear_object (&gw_applet->lib_settings);
+    g_clear_object (&gw_applet->applet_settings);
 
-    weather_info_abort (gw_applet->gweather_info);
+    gweather_info_abort (gw_applet->gweather_info);
 }
 
 #ifdef HAVE_NETWORKMANAGER
@@ -311,16 +310,6 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
     gchar          *ui_path;
     AtkObject      *atk_obj;
 
-    gw_applet->gweather_pref.location = NULL;
-    gw_applet->gweather_pref.update_interval = 1800;
-    gw_applet->gweather_pref.update_enabled = TRUE;
-    gw_applet->gweather_pref.detailed = FALSE;
-    gw_applet->gweather_pref.radar_enabled = TRUE;
-    gw_applet->gweather_pref.temperature_unit = TEMP_UNIT_INVALID;
-    gw_applet->gweather_pref.speed_unit = SPEED_UNIT_INVALID;
-    gw_applet->gweather_pref.pressure_unit = PRESSURE_UNIT_INVALID;
-    gw_applet->gweather_pref.distance_unit = DISTANCE_UNIT_INVALID;
-    
     panel_applet_set_flags (gw_applet->applet, PANEL_APPLET_EXPAND_MINOR);
 
     panel_applet_set_background_widget(gw_applet->applet,
@@ -389,7 +378,7 @@ gint timeout_cb (gpointer data)
 }
 
 static void
-update_finish (WeatherInfo *info, gpointer data)
+update_finish (GWeatherInfo *info, gpointer data)
 {
     static int gw_fault_counter = 0;
 #ifdef HAVE_LIBNOTIFY
@@ -403,33 +392,32 @@ update_finish (WeatherInfo *info, gpointer data)
     /* Update timer */
     if (gw_applet->timeout_tag > 0)
         g_source_remove(gw_applet->timeout_tag);
-    if (gw_applet->gweather_pref.update_enabled)
+    if (g_settings_get_boolean (gw_applet->applet_settings, "auto-update"))
     {
 	gw_applet->timeout_tag =
-		g_timeout_add_seconds (
-                       gw_applet->gweather_pref.update_interval,
-                        timeout_cb, gw_applet);
+	  g_timeout_add_seconds (g_settings_get_int (gw_applet->applet_settings, "auto-update-interval"),
+				 timeout_cb, gw_applet);
 
-        nxtSunEvent = weather_info_next_sun_event(gw_applet->gweather_info);
+        nxtSunEvent = gweather_info_next_sun_event(gw_applet->gweather_info);
         if (nxtSunEvent >= 0)
             gw_applet->suncalc_timeout_tag =
                         g_timeout_add_seconds (nxtSunEvent,
                                 suncalc_timeout_cb, gw_applet);
     }
 
-    if ((TRUE == weather_info_is_valid (info)) ||
+    if ((TRUE == gweather_info_is_valid (info)) ||
 	     (gw_fault_counter >= MAX_CONSECUTIVE_FAULTS))
     {
 	    gw_fault_counter = 0;
-            icon_name = weather_info_get_icon_name (gw_applet->gweather_info);
+            icon_name = gweather_info_get_icon_name (gw_applet->gweather_info);
             gtk_image_set_from_icon_name (GTK_IMAGE(gw_applet->image), 
                                           icon_name, GTK_ICON_SIZE_BUTTON);
 	      
 	    gtk_label_set_text (GTK_LABEL (gw_applet->label), 
-	        		weather_info_get_temp_summary(
+				gweather_info_get_temp_summary(
 					gw_applet->gweather_info));
 	    
-	    s = weather_info_get_weather_summary (gw_applet->gweather_info);
+	    s = gweather_info_get_weather_summary (gw_applet->gweather_info);
 	    gtk_widget_set_tooltip_text (GTK_WIDGET (gw_applet->applet), s);
 	    g_free (s);
 
@@ -442,8 +430,7 @@ update_finish (WeatherInfo *info, gpointer data)
 	    place_widgets(gw_applet);
 
 #ifdef HAVE_LIBNOTIFY
-	    if (panel_applet_gconf_get_bool (gw_applet->applet,
-				    "show_notifications", NULL))
+	    if (g_settings_get_boolean (gw_applet->applet_settings, "show-notifications"))
 	    {
 		    NotifyNotification *n;
 	            
@@ -458,15 +445,15 @@ update_finish (WeatherInfo *info, gpointer data)
 			 
 	           	 /* Show notification */
 	           	 message = g_strdup_printf ("%s: %s",
-					 weather_info_get_location_name (info),
-					 weather_info_get_sky (info));
+					 gweather_info_get_location_name (info),
+					 gweather_info_get_sky (info));
 	           	 detail = g_strdup_printf (
 					 _("City: %s\nSky: %s\nTemperature: %s"),
-					 weather_info_get_location_name (info),
-					 weather_info_get_sky (info),
-					 weather_info_get_temp_summary (info));
+					 gweather_info_get_location_name (info),
+					 gweather_info_get_sky (info),
+					 gweather_info_get_temp_summary (info));
 
-			 icon = weather_info_get_icon_name (gw_applet->gweather_info);
+			 icon = gweather_info_get_icon_name (gw_applet->gweather_info);
 			 if (icon == NULL)
 				 icon = "stock-unknown";
 	           	 
@@ -496,7 +483,7 @@ update_finish (WeatherInfo *info, gpointer data)
 
 gint suncalc_timeout_cb (gpointer data)
 {
-    WeatherInfo *info = ((GWeatherApplet *)data)->gweather_info;
+    GWeatherInfo *info = ((GWeatherApplet *)data)->gweather_info;
     update_finish(info, data);
     return 0;  /* Do not repeat timeout (will be re-set by update_finish) */
 }
@@ -504,41 +491,23 @@ gint suncalc_timeout_cb (gpointer data)
 
 void gweather_update (GWeatherApplet *gw_applet)
 {
-    WeatherPrefs prefs;
     const gchar *icon_name;
+    GWeatherForecastType type;
 
-    icon_name = weather_info_get_icon_name(gw_applet->gweather_info);
+    icon_name = gweather_info_get_icon_name(gw_applet->gweather_info);
     gtk_image_set_from_icon_name (GTK_IMAGE (gw_applet->image), 
     			          icon_name, GTK_ICON_SIZE_BUTTON); 
     gtk_widget_set_tooltip_text (GTK_WIDGET(gw_applet->applet),  _("Updating..."));
 
     /* Set preferred forecast type */
-    prefs.type = gw_applet->gweather_pref.detailed ? FORECAST_ZONE : FORECAST_STATE;
-
-    /* Set radar map retrieval option */
-    prefs.radar = gw_applet->gweather_pref.radar_enabled;
-    prefs.radar_custom_url = (gw_applet->gweather_pref.use_custom_radar_url &&
-    				gw_applet->gweather_pref.radar) ?
-				gw_applet->gweather_pref.radar : NULL;
-
-    /* Set the units */
-    prefs.temperature_unit = gw_applet->gweather_pref.temperature_unit;
-    prefs.speed_unit = gw_applet->gweather_pref.speed_unit;
-    prefs.pressure_unit = gw_applet->gweather_pref.pressure_unit;
-    prefs.distance_unit = gw_applet->gweather_pref.distance_unit;
+    type = g_settings_get_boolean (gw_applet->applet_settings, "detailed") ?
+      GWEATHER_FORECAST_ZONE : GWEATHER_FORECAST_STATE;
 
     /* Update current conditions */
-    if (gw_applet->gweather_info && 
-    	weather_location_equal(weather_info_get_location(gw_applet->gweather_info),
-    			       gw_applet->gweather_pref.location)) {
-	weather_info_update(gw_applet->gweather_info, &prefs,
-			    update_finish, gw_applet);
-    } else {
-        weather_info_free(gw_applet->gweather_info);
-        gw_applet->gweather_info = weather_info_new(gw_applet->gweather_pref.location,
-						    &prefs,
-						    update_finish, gw_applet);
-    }
+    g_object_unref(gw_applet->gweather_info);
+    gw_applet->gweather_info = gweather_info_new(NULL, /* default location */
+						 type);
+    g_signal_connect(gw_applet->gweather_info, "updated", G_CALLBACK (update_finish), gw_applet);
 }
 
 #ifdef HAVE_NETWORKMANAGER
diff --git a/gweather/gweather-dialog.c b/gweather/gweather-dialog.c
index 94ab4bf..4912b0e 100644
--- a/gweather/gweather-dialog.c
+++ b/gweather/gweather-dialog.c
@@ -61,64 +61,6 @@ G_DEFINE_TYPE (GWeatherDialog, gweather_dialog, GTK_TYPE_DIALOG);
 #define MONOSPACE_FONT_KEY MONOSPACE_FONT_DIR "/monospace_font_name"
 
 static void
-gweather_dialog_save_geometry (GWeatherDialog *dialog)
-{
-	GWeatherGConf *gconf;
-	int w, h, x, y;
-
-	gconf = dialog->priv->applet->gconf;
-
-	gtk_window_get_position (GTK_WINDOW (dialog), &x, &y);
-	gtk_window_get_size (GTK_WINDOW (dialog), &w, &h);
-
-	gweather_gconf_set_int (gconf, "dialog_width", w, NULL);
-	gweather_gconf_set_int (gconf, "dialog_height", h, NULL);
-	gweather_gconf_set_int (gconf, "dialog_x", x, NULL);
-	gweather_gconf_set_int (gconf, "dialog_y", y, NULL);
-}
-
-static void
-gweather_dialog_load_geometry (GWeatherDialog *dialog)
-{
-	GWeatherGConf *gconf;
-	int w, h, x, y;
-	GError *error;
-
-	gconf = dialog->priv->applet->gconf;
-	error = NULL;
-
-	w = gweather_gconf_get_int (gconf, "dialog_width", &error);
-	if (error) {
-		g_message ("gweather: no spatial information available");
-		g_error_free (error);
-		return;
-	}
-	h = gweather_gconf_get_int (gconf, "dialog_height", &error);
-	if (error) {
-		g_message ("gweather: no spatial information available");
-		g_error_free (error);
-		return;
-	}
-	x = gweather_gconf_get_int (gconf, "dialog_x", &error);
-	if (error) {
-		g_message ("gweather: no spatial information available");
-		g_error_free (error);
-		return;
-	}
-	y = gweather_gconf_get_int (gconf, "dialog_y", &error);
-	if (error) {
-		g_message ("gweather: no spatial information available");
-		g_error_free (error);
-		return;
-	}
-	
-	if (w > 0 && h > 0) {
-		gtk_window_resize (GTK_WINDOW (dialog), w, h);
-	}
-	gtk_window_move (GTK_WINDOW (dialog), x, y);
-}
-
-static void
 response_cb (GWeatherDialog *dialog,
              gint id,
              gpointer data)
@@ -220,14 +162,13 @@ gweather_dialog_create (GWeatherDialog *dialog)
   gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
   gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
 
-  if (gw_applet->gweather_pref.radar_enabled)
+  if (g_settings_get_boolean (gw_applet->applet_settings, "enable-radar-map"))
       gtk_window_set_default_size (GTK_WINDOW (dialog), 570,440);
   else
       gtk_window_set_default_size (GTK_WINDOW (dialog), 590, 340);
 
   gtk_window_set_screen (GTK_WINDOW (dialog),
 			 gtk_widget_get_screen (GTK_WIDGET (gw_applet->applet)));
-  gweather_dialog_load_geometry (dialog);
 
   /* Must come after load geometry, otherwise it will get reset. */
   gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
@@ -486,36 +427,32 @@ gweather_dialog_create (GWeatherDialog *dialog)
   gtk_widget_show (current_note_lbl);
   gtk_notebook_set_tab_label (GTK_NOTEBOOK (weather_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (weather_notebook), 0), current_note_lbl);
 
-  if (gw_applet->gweather_pref.location->zone_valid) {
-
-      forecast_hbox = gtk_hbox_new(FALSE, 0);
-      gtk_container_set_border_width (GTK_CONTAINER (forecast_hbox), 12);
-      gtk_widget_show (forecast_hbox);
+  forecast_hbox = gtk_hbox_new(FALSE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (forecast_hbox), 12);
+  gtk_widget_show (forecast_hbox);
 
-      scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
-                                      GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-      gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
-                                           GTK_SHADOW_ETCHED_IN);
+  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+				       GTK_SHADOW_ETCHED_IN);
 
-      priv->forecast_text = gtk_text_view_new ();
-      set_access_namedesc (priv->forecast_text, _("Forecast Report"), _("See the ForeCast Details"));
-      gtk_container_add (GTK_CONTAINER (scrolled_window), priv->forecast_text);
-      gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->forecast_text), FALSE);
-      gtk_text_view_set_left_margin (GTK_TEXT_VIEW (priv->forecast_text), 6);
-      gtk_widget_show (priv->forecast_text);
-      gtk_widget_show (scrolled_window);
-      gtk_box_pack_start (GTK_BOX (forecast_hbox), scrolled_window, TRUE, TRUE, 0);
+  priv->forecast_text = gtk_text_view_new ();
+  set_access_namedesc (priv->forecast_text, _("Forecast Report"), _("See the ForeCast Details"));
+  gtk_container_add (GTK_CONTAINER (scrolled_window), priv->forecast_text);
+  gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->forecast_text), FALSE);
+  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (priv->forecast_text), 6);
+  gtk_widget_show (priv->forecast_text);
+  gtk_widget_show (scrolled_window);
+  gtk_box_pack_start (GTK_BOX (forecast_hbox), scrolled_window, TRUE, TRUE, 0);
 
-      gtk_container_add (GTK_CONTAINER (weather_notebook), forecast_hbox);
+  gtk_container_add (GTK_CONTAINER (weather_notebook), forecast_hbox);
 
-      forecast_note_lbl = gtk_label_new (_("Forecast"));
-      gtk_widget_show (forecast_note_lbl);
-      gtk_notebook_set_tab_label (GTK_NOTEBOOK (weather_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (weather_notebook), 1), forecast_note_lbl);
-
-  }
+  forecast_note_lbl = gtk_label_new (_("Forecast"));
+  gtk_widget_show (forecast_note_lbl);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (weather_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (weather_notebook), 1), forecast_note_lbl);
 
-  if (gw_applet->gweather_pref.radar_enabled) {
+  if (g_settings_get_boolean (gw_applet->applet_settings, "enable-radar-map")) {
 
       radar_note_lbl = gtk_label_new_with_mnemonic (_("Radar Map"));
       gtk_widget_show (radar_note_lbl);
@@ -548,12 +485,12 @@ gweather_dialog_create (GWeatherDialog *dialog)
       gtk_widget_show (radar_link_alignment);
       gtk_box_pack_start (GTK_BOX (radar_vbox), radar_link_alignment, FALSE, FALSE, 0);
 
+      /* XXX: weather.com? is this an advert? */
       radar_link_btn = gtk_button_new_with_mnemonic (_("_Visit Weather.com"));
       set_access_namedesc (radar_link_btn, _("Visit Weather.com"), _("Click to Enter Weather.com"));
       gtk_widget_set_size_request (radar_link_btn, 450, -2);
       gtk_widget_show (radar_link_btn);
-      if (!gweather_gconf_get_bool (gw_applet->gconf, "use_custom_radar_url", NULL))
-          gtk_container_add (GTK_CONTAINER (radar_link_alignment), radar_link_btn);
+      gtk_container_add (GTK_CONTAINER (radar_link_alignment), radar_link_btn);
 
       g_signal_connect (G_OBJECT (radar_link_btn), "clicked",
                         G_CALLBACK (link_cb), NULL);
@@ -600,49 +537,47 @@ void gweather_dialog_update (GWeatherDialog *dialog)
     	return;
 
     /* Update icon */
-    icon_name = weather_info_get_icon_name (gw_applet->gweather_info);
+    icon_name = gweather_info_get_icon_name (gw_applet->gweather_info);
     gtk_image_set_from_icon_name (GTK_IMAGE (priv->cond_image), 
                                   icon_name, GTK_ICON_SIZE_DIALOG);
 
     /* Update current condition fields and forecast */
-    gtk_label_set_text(GTK_LABEL(priv->cond_location), weather_info_get_location_name(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_update), weather_info_get_update(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_cond), weather_info_get_conditions(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_sky), weather_info_get_sky(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_temp), weather_info_get_temp(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_apparent), weather_info_get_apparent(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_dew), weather_info_get_dew(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_humidity), weather_info_get_humidity(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_wind), weather_info_get_wind(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_pressure), weather_info_get_pressure(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_vis), weather_info_get_visibility(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_sunrise), weather_info_get_sunrise(gw_applet->gweather_info));
-    gtk_label_set_text(GTK_LABEL(priv->cond_sunset), weather_info_get_sunset(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_location), gweather_info_get_location_name(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_update), gweather_info_get_update(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_cond), gweather_info_get_conditions(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_sky), gweather_info_get_sky(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_temp), gweather_info_get_temp(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_apparent), gweather_info_get_apparent(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_dew), gweather_info_get_dew(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_humidity), gweather_info_get_humidity(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_wind), gweather_info_get_wind(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_pressure), gweather_info_get_pressure(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_vis), gweather_info_get_visibility(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_sunrise), gweather_info_get_sunrise(gw_applet->gweather_info));
+    gtk_label_set_text(GTK_LABEL(priv->cond_sunset), gweather_info_get_sunset(gw_applet->gweather_info));
 
     /* Update forecast */
-    if (gw_applet->gweather_pref.location->zone_valid) {
-	font_desc = get_system_monospace_font ();
-	if (font_desc) {
-            gtk_widget_modify_font (priv->forecast_text, font_desc);
-            pango_font_description_free (font_desc);
-	}
+    font_desc = get_system_monospace_font ();
+    if (font_desc) {
+      gtk_widget_modify_font (priv->forecast_text, font_desc);
+      pango_font_description_free (font_desc);
+    }
 	
-        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->forecast_text));
-        forecast = g_strdup(weather_info_get_forecast(gw_applet->gweather_info));
-        if (forecast) {
-            forecast = g_strstrip(replace_multiple_new_lines(forecast));
-            gtk_text_buffer_set_text(buffer, forecast, -1);
-            g_free(forecast);
-        } else {
-            gtk_text_buffer_set_text(buffer, _("Forecast not currently available for this location."), -1);
-        }
+    buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->forecast_text));
+    forecast = g_strdup(gweather_info_get_forecast(gw_applet->gweather_info));
+    if (forecast) {
+      forecast = g_strstrip(replace_multiple_new_lines(forecast));
+      gtk_text_buffer_set_text(buffer, forecast, -1);
+      g_free(forecast);
+    } else {
+      gtk_text_buffer_set_text(buffer, _("Forecast not currently available for this location."), -1);
     }
 
     /* Update radar map */
-    if (gw_applet->gweather_pref.radar_enabled) {
+    if (g_settings_get_boolean (gw_applet->applet_settings, "enable-radar-map")) {
         GdkPixbufAnimation *radar;
 	
-	radar = weather_info_get_radar (gw_applet->gweather_info);
+	radar = gweather_info_get_radar (gw_applet->gweather_info);
         if (radar) {
             gtk_image_set_from_animation (GTK_IMAGE (priv->radar_image), radar);
         }
@@ -716,30 +651,16 @@ gweather_dialog_new (GWeatherApplet *applet)
 			 NULL);
 }
 
-
-static void
-gweather_dialog_unrealize (GtkWidget *widget)
-{
-    GWeatherDialog *self = GWEATHER_DIALOG (widget);
-
-    gweather_dialog_save_geometry (self);
-
-    GTK_WIDGET_CLASS (gweather_dialog_parent_class)->unrealize (widget);
-}
-
-
 static void
 gweather_dialog_class_init (GWeatherDialogClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
-    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
     gweather_dialog_parent_class = g_type_class_peek_parent (klass);
 
     object_class->set_property = gweather_dialog_set_property;
     object_class->get_property = gweather_dialog_get_property;
     object_class->constructor = gweather_dialog_constructor;
-    widget_class->unrealize = gweather_dialog_unrealize;
 
     /* This becomes an OBJECT property when GWeatherApplet is redone */
     g_object_class_install_property (object_class,
diff --git a/gweather/gweather-pref.c b/gweather/gweather-pref.c
index 7327373..0424adc 100644
--- a/gweather/gweather-pref.c
+++ b/gweather/gweather-pref.c
@@ -70,47 +70,6 @@ enum
 G_DEFINE_TYPE (GWeatherPref, gweather_pref, GTK_TYPE_DIALOG);
 #define GWEATHER_PREF_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GWEATHER_TYPE_PREF, GWeatherPrefPrivate))
 
-
-/* set sensitive and setup NEVER_SENSITIVE appropriately */
-static void
-hard_set_sensitive (GtkWidget *w, gboolean sensitivity)
-{
-	gtk_widget_set_sensitive (w, sensitivity);
-	g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE,
-			   GINT_TO_POINTER ( ! sensitivity));
-}
-
-
-/* set sensitive, but always insensitive if NEVER_SENSITIVE is set */
-static void
-soft_set_sensitive (GtkWidget *w, gboolean sensitivity)
-{
-	if (g_object_get_data (G_OBJECT (w), NEVER_SENSITIVE))
-		gtk_widget_set_sensitive (w, FALSE);
-	else
-		gtk_widget_set_sensitive (w, sensitivity);
-}
-
-
-static gboolean
-key_writable (GWeatherPref *pref, const char *key)
-{
-        GWeatherApplet *applet = pref->priv->applet;
-	gboolean writable;
-	char *fullkey;
-	static GConfClient *client = NULL;
-	if (client == NULL)
-		client = gconf_client_get_default ();
-
-	fullkey = gweather_gconf_get_full_key (applet->gconf, key);
-
-	writable = gconf_client_key_is_writable (client, fullkey, NULL);
-
-	g_free (fullkey);
-
-	return writable;
-}
-
 /* sets up ATK Relation between the widgets */
 
 static void
@@ -174,65 +133,75 @@ static void gweather_pref_set_accessibility (GWeatherPref *pref)
 
 }
 
+static gboolean
+bind_update_interval_get (GValue   *value,
+			  GVariant *variant,
+			  gpointer  user_data)
+{
+  g_value_set_double (value, g_variant_get_int32 (variant) / 60);
+  return TRUE;
+}
+
+static GVariant*
+bind_update_interval_set (const GValue       *value,
+			  const GVariantType *variant,
+			  gpointer            user_data)
+{
+  return g_variant_new_int32 (g_value_get_double (value) * 60);
+}
 
 /* Update pref dialog from gweather_pref */
 static gboolean update_dialog (GWeatherPref *pref)
 {
     GWeatherApplet *gw_applet = pref->priv->applet;
+    gchar *radar_url;
+    gboolean has_radar, has_custom_radar;
 
-    g_return_val_if_fail(gw_applet->gweather_pref.location != NULL, FALSE);
+    g_settings_bind_with_mapping (gw_applet->applet_settings, "auto-update-interval",
+				  pref->priv->basic_update_spin, "value",
+				  G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_NO_SENSITIVITY,
+				  bind_update_interval_get,
+				  bind_update_interval_set,
+				  NULL, NULL);
 
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(pref->priv->basic_update_spin), 
-    			      gw_applet->gweather_pref.update_interval / 60);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pref->priv->basic_update_btn), 
-    				 gw_applet->gweather_pref.update_enabled);
-    soft_set_sensitive(pref->priv->basic_update_spin, 
-    			     gw_applet->gweather_pref.update_enabled);
+    g_settings_bind (gw_applet->applet_settings, "auto-update",
+		     pref->priv->basic_update_btn, "active",
+		     G_SETTINGS_BIND_DEFAULT);
 
-    if ( gw_applet->gweather_pref.use_temperature_default) {
-        gtk_combo_box_set_active (GTK_COMBO_BOX(pref->priv->basic_temp_combo), 0);
-    } else {
-        gtk_combo_box_set_active (GTK_COMBO_BOX(pref->priv->basic_temp_combo), 
-				  gw_applet->gweather_pref.temperature_unit -1);
-    }
-	
-    if ( gw_applet->gweather_pref.use_speed_default) {
-        gtk_combo_box_set_active (GTK_COMBO_BOX(pref->priv->basic_speed_combo), 0);
-    } else {
-        gtk_combo_box_set_active (GTK_COMBO_BOX(pref->priv->basic_speed_combo), 
-				  gw_applet->gweather_pref.speed_unit -1);
-    }
-	
-    if ( gw_applet->gweather_pref.use_pressure_default) {
-        gtk_combo_box_set_active (GTK_COMBO_BOX(pref->priv->basic_pres_combo), 0);
-    } else {
-        gtk_combo_box_set_active (GTK_COMBO_BOX(pref->priv->basic_pres_combo), 
-				  gw_applet->gweather_pref.pressure_unit -1);
-    }
-    if ( gw_applet->gweather_pref.use_distance_default) {
-        gtk_combo_box_set_active (GTK_COMBO_BOX(pref->priv->basic_dist_combo), 0);
-    } else {
-        gtk_combo_box_set_active (GTK_COMBO_BOX(pref->priv->basic_dist_combo), 
-				  gw_applet->gweather_pref.distance_unit -1);
-    }
+    gtk_widget_set_sensitive(pref->priv->basic_update_spin,
+			      g_settings_get_boolean (gw_applet->applet_settings, "auto-update"));
+
+    g_settings_bind (gw_applet->lib_settings, "temperature-unit",
+		     pref->priv->basic_temp_combo, "active",
+		     G_SETTINGS_BIND_DEFAULT);
+
+    g_settings_bind (gw_applet->lib_settings, "speed-unit",
+		     pref->priv->basic_speed_combo, "active",
+		     G_SETTINGS_BIND_DEFAULT);
+
+    g_settings_bind (gw_applet->lib_settings, "pressure-unit",
+		     pref->priv->basic_pres_combo, "active",
+		     G_SETTINGS_BIND_DEFAULT);
+
+    g_settings_bind (gw_applet->lib_settings, "distance-unit",
+		     pref->priv->basic_dist_combo, "active",
+		     G_SETTINGS_BIND_DEFAULT);
 
-#if 0
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pref->priv->basic_detailed_btn), 
-    				 gw_applet->gweather_pref.detailed);
-#endif
 #ifdef RADARMAP
+    has_radar = g_settings_get_boolean (gw_applet->applet_settings, "enable-radar-map");
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pref->priv->basic_radar_btn),
-    				 gw_applet->gweather_pref.radar_enabled);
+				 has_radar);
+
+    radar_url = g_settings_get_string (gw_applet->lib_settings, "radar");
+    has_custom_radar = radar_url && *radar_url;
     				 
-    soft_set_sensitive (pref->priv->basic_radar_url_btn, 
-    			      gw_applet->gweather_pref.radar_enabled);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pref->priv->basic_radar_url_btn),
-    				 gw_applet->gweather_pref.use_custom_radar_url);
-    soft_set_sensitive (pref->priv->basic_radar_url_hbox, 
-    			      gw_applet->gweather_pref.radar_enabled);
-    if (gw_applet->gweather_pref.radar)
+    gtk_widget_set_sensitive (pref->priv->basic_radar_url_btn, has_radar);
+    gtk_widget_set_sensitive (pref->priv->basic_radar_url_hbox, has_radar && has_custom_radar);
+    if (radar_url)
     	gtk_entry_set_text (GTK_ENTRY (pref->priv->basic_radar_url_entry),
-    			    gw_applet->gweather_pref.radar);
+			    radar_url);
+
+    g_free(radar_url);
 #endif /* RADARMAP */
     
     
@@ -243,27 +212,31 @@ static void row_selected_cb (GtkTreeSelection *selection, GWeatherPref *pref)
 {
     GWeatherApplet *gw_applet = pref->priv->applet;
     GtkTreeModel *model;
-    WeatherLocation *loc = NULL;
     GtkTreeIter iter;
+    gchar *name, *code;
+    gboolean has_latlon;
+    gdouble latitude, longitude;
     
     if (!gtk_tree_selection_get_selected (selection, &model, &iter))
     	return;
     	
-    gtk_tree_model_get (model, &iter, GWEATHER_XML_COL_POINTER, &loc, -1);
+    gtk_tree_model_get (model, &iter, GWEATHER_XML_COL_METAR_CODE, &code, -1);
     
-    if (!loc)
+    if (!code)
     	return;
 
-    gweather_gconf_set_string(gw_applet->gconf, "location1", loc->code, NULL);
-    gweather_gconf_set_string(gw_applet->gconf, "location2", loc->zone, NULL);
-    gweather_gconf_set_string(gw_applet->gconf, "location3", loc->radar, NULL);
-    gweather_gconf_set_string(gw_applet->gconf, "location4", loc->name, NULL);
-    gweather_gconf_set_string(gw_applet->gconf, "coordinates", loc->coordinates, NULL);
-    
-    if (gw_applet->gweather_pref.location) {
-       weather_location_free (gw_applet->gweather_pref.location);
-    }
-    gw_applet->gweather_pref.location = gweather_gconf_get_location (gw_applet->gconf);
+    gtk_tree_model_get (model, &iter,
+			GWEATHER_XML_COL_LOCATION_NAME, &name,
+			GWEATHER_XML_COL_LATLON_VALID, &has_latlon,
+			GWEATHER_XML_COL_LATITUDE, &latitude,
+			GWEATHER_XML_COL_LONGITUDE, &longitude,
+			-1);
+
+    g_settings_set (gw_applet->lib_settings, "default-location", "(ssm(dd))",
+		    name, code, has_latlon, latitude, longitude);
+
+    g_free (name);
+    g_free (code);
     
     gweather_update (gw_applet);
 } 
@@ -275,21 +248,31 @@ compare_location (GtkTreeModel *model,
                   gpointer      user_data)
 {
     GWeatherPref *pref = user_data;
-    WeatherLocation *loc;
     GtkTreeView *view;
+    gchar *name = NULL;
+    gchar *default_loc = NULL;
+    gboolean retval = FALSE;
 
-    gtk_tree_model_get (model, iter, GWEATHER_XML_COL_POINTER, &loc, -1);
-    if (!loc)
-	return FALSE;
+    gtk_tree_model_get (model, iter, GWEATHER_XML_COL_LOCATION_NAME, &name, -1);
+    if (!name)
+	retval = FALSE;
 
-    if (!weather_location_equal (loc, pref->priv->applet->gweather_pref.location))
-	return FALSE;
+    g_settings_get (pref->priv->applet->lib_settings, "default-location", "(ssm(dd))",
+		    &default_loc, NULL, NULL);
 
-    view = GTK_TREE_VIEW (pref->priv->tree);
-    gtk_tree_view_expand_to_path (view, path);
-    gtk_tree_view_set_cursor (view, path, NULL, FALSE);
-    gtk_tree_view_scroll_to_cell (view, path, NULL, TRUE, 0.5, 0.5);
-    return TRUE;
+    if (strcmp(name, default_loc))
+	retval = FALSE;
+
+    if (retval) {
+      view = GTK_TREE_VIEW (pref->priv->tree);
+      gtk_tree_view_expand_to_path (view, path);
+      gtk_tree_view_set_cursor (view, path, NULL, FALSE);
+      gtk_tree_view_scroll_to_cell (view, path, NULL, TRUE, 0.5, 0.5);
+    }
+
+    g_free(name);
+    g_free(default_loc);
+    return retval;
 }
 
 static void load_locations (GWeatherPref *pref)
@@ -301,7 +284,7 @@ static void load_locations (GWeatherPref *pref)
     /* Add a colum for the locations */
     cell_renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes ("not used", cell_renderer,
-						       "text", GWEATHER_XML_COL_LOC, NULL);
+						       "text", GWEATHER_XML_COL_LOCATION_NAME, NULL);
     gtk_tree_view_append_column (tree, column);
     gtk_tree_view_set_expander_column (GTK_TREE_VIEW (tree), column);
     
@@ -320,10 +303,8 @@ static void load_locations (GWeatherPref *pref)
     }
     gtk_tree_view_set_model (tree, pref->priv->model);
 
-    if (pref->priv->applet->gweather_pref.location) {
-	/* Select the current (default) location */
-	gtk_tree_model_foreach (GTK_TREE_MODEL (pref->priv->model), compare_location, pref);
-    }
+    /* Select the current (default) location */
+    gtk_tree_model_foreach (GTK_TREE_MODEL (pref->priv->model), compare_location, pref);
 }
 
 static void
@@ -334,18 +315,15 @@ auto_update_toggled (GtkToggleButton *button, GWeatherPref *pref)
     gint nxtSunEvent;
 
     toggled = gtk_toggle_button_get_active(button);
-    gw_applet->gweather_pref.update_enabled = toggled;
-    soft_set_sensitive (pref->priv->basic_update_spin, toggled);
-    gweather_gconf_set_bool(gw_applet->gconf, "auto_update", toggled, NULL);
+    gtk_widget_set_sensitive (pref->priv->basic_update_spin, toggled);
     if (gw_applet->timeout_tag > 0)
         g_source_remove(gw_applet->timeout_tag);
     if (gw_applet->suncalc_timeout_tag > 0)
         g_source_remove(gw_applet->suncalc_timeout_tag);
-    if (gw_applet->gweather_pref.update_enabled) {
-        gw_applet->timeout_tag = g_timeout_add_seconds (
-				gw_applet->gweather_pref.update_interval,
-				timeout_cb, gw_applet);
-	nxtSunEvent = weather_info_next_sun_event(gw_applet->gweather_info);
+    if (toggled) {
+      gw_applet->timeout_tag = g_timeout_add_seconds (g_settings_get_int (gw_applet->applet_settings, "auto-update-interval"),
+						      timeout_cb, gw_applet);
+	nxtSunEvent = gweather_info_next_sun_event(gw_applet->gweather_info);
 	if (nxtSunEvent >= 0)
 	    gw_applet->suncalc_timeout_tag = g_timeout_add_seconds (
 	    						nxtSunEvent,
@@ -371,29 +349,9 @@ detailed_toggled (GtkToggleButton *button, GWeatherPref *pref)
 static void temp_combo_changed_cb (GtkComboBox *combo, GWeatherPref *pref)
 {
     GWeatherApplet *gw_applet = pref->priv->applet;
-    TempUnit       new_unit, old_unit;
-
-    g_return_if_fail(gw_applet != NULL);
-
-    new_unit = gtk_combo_box_get_active(combo) + 1;
-
-    if (gw_applet->gweather_pref.use_temperature_default)
-        old_unit = TEMP_UNIT_DEFAULT;
-    else
-        old_unit = gw_applet->gweather_pref.temperature_unit;	
-
-    if (new_unit == old_unit)
-        return;
-
-    gw_applet->gweather_pref.use_temperature_default = new_unit == TEMP_UNIT_DEFAULT;
-    gw_applet->gweather_pref.temperature_unit = new_unit;
-
-    gweather_gconf_set_string(gw_applet->gconf, GCONF_TEMP_UNIT,
-                              gweather_prefs_temp_enum_to_string (new_unit),
-                                  NULL);
 
     gtk_label_set_text(GTK_LABEL(gw_applet->label), 
-                       weather_info_get_temp_summary(gw_applet->gweather_info));
+                       gweather_info_get_temp_summary(gw_applet->gweather_info));
 
     if (gw_applet->details_dialog)
         gweather_dialog_update (GWEATHER_DIALOG (gw_applet->details_dialog));
@@ -402,26 +360,6 @@ static void temp_combo_changed_cb (GtkComboBox *combo, GWeatherPref *pref)
 static void speed_combo_changed_cb (GtkComboBox *combo, GWeatherPref *pref)
 {
     GWeatherApplet *gw_applet = pref->priv->applet;
-    SpeedUnit      new_unit, old_unit;
-
-	g_return_if_fail(gw_applet != NULL);
-
-    new_unit = gtk_combo_box_get_active(combo) + 1;
-
-    if (gw_applet->gweather_pref.use_speed_default)
-        old_unit = SPEED_UNIT_DEFAULT;
-    else
-        old_unit = gw_applet->gweather_pref.speed_unit;	
-
-    if (new_unit == old_unit)
-        return;
-
-    gw_applet->gweather_pref.use_speed_default = new_unit == SPEED_UNIT_DEFAULT;
-    gw_applet->gweather_pref.speed_unit = new_unit;
-
-    gweather_gconf_set_string(gw_applet->gconf, GCONF_SPEED_UNIT,
-                              gweather_prefs_speed_enum_to_string (new_unit),
-                                  NULL);
 
     if (gw_applet->details_dialog)
         gweather_dialog_update (GWEATHER_DIALOG (gw_applet->details_dialog));
@@ -430,26 +368,6 @@ static void speed_combo_changed_cb (GtkComboBox *combo, GWeatherPref *pref)
 static void pres_combo_changed_cb (GtkComboBox *combo, GWeatherPref *pref)
 {
     GWeatherApplet *gw_applet = pref->priv->applet;
-    PressureUnit   new_unit, old_unit;
-
-    g_return_if_fail(gw_applet != NULL);
-
-    new_unit = gtk_combo_box_get_active(combo) + 1;
-
-    if (gw_applet->gweather_pref.use_pressure_default)
-        old_unit = PRESSURE_UNIT_DEFAULT;
-    else
-        old_unit = gw_applet->gweather_pref.pressure_unit;	
-
-    if (new_unit == old_unit)
-        return;
-
-    gw_applet->gweather_pref.use_pressure_default = new_unit == PRESSURE_UNIT_DEFAULT;
-    gw_applet->gweather_pref.pressure_unit = new_unit;
-
-    gweather_gconf_set_string(gw_applet->gconf, GCONF_PRESSURE_UNIT,
-                              gweather_prefs_pressure_enum_to_string (new_unit),
-                                  NULL);
 
     if (gw_applet->details_dialog)
         gweather_dialog_update (GWEATHER_DIALOG (gw_applet->details_dialog));
@@ -458,26 +376,6 @@ static void pres_combo_changed_cb (GtkComboBox *combo, GWeatherPref *pref)
 static void dist_combo_changed_cb (GtkComboBox *combo, GWeatherPref *pref)
 {
     GWeatherApplet *gw_applet = pref->priv->applet;
-    DistanceUnit   new_unit, old_unit;
-
-    g_return_if_fail(gw_applet != NULL);
-
-    new_unit = gtk_combo_box_get_active(combo) + 1;
-
-    if (gw_applet->gweather_pref.use_distance_default)
-        old_unit = DISTANCE_UNIT_DEFAULT;
-    else
-        old_unit = gw_applet->gweather_pref.distance_unit;	
-
-    if (new_unit == old_unit)
-        return;
-
-    gw_applet->gweather_pref.use_distance_default = new_unit == DISTANCE_UNIT_DEFAULT;
-    gw_applet->gweather_pref.distance_unit = new_unit;
-
-    gweather_gconf_set_string(gw_applet->gconf, GCONF_DISTANCE_UNIT,
-                              gweather_prefs_distance_enum_to_string (new_unit),
-                                  NULL);
 
     if (gw_applet->details_dialog)
         gweather_dialog_update (GWEATHER_DIALOG (gw_applet->details_dialog));
@@ -490,11 +388,12 @@ radar_toggled (GtkToggleButton *button, GWeatherPref *pref)
     gboolean toggled;
     
     toggled = gtk_toggle_button_get_active(button);
-    gw_applet->gweather_pref.radar_enabled = toggled;
-    gweather_gconf_set_bool(gw_applet->gconf, "enable_radar_map", toggled, NULL);
-    soft_set_sensitive (pref->priv->basic_radar_url_btn, toggled);
+
+    if (toggled)
+      g_settings_set_boolean (gw_applet->applet_settings, "enable-radar-map", toggled);
+    gtk_widget_set_sensitive (pref->priv->basic_radar_url_btn, toggled);
     if (toggled == FALSE || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (pref->priv->basic_radar_url_btn)) == TRUE)
-            soft_set_sensitive (pref->priv->basic_radar_url_hbox, toggled);
+            gtk_widget_set_sensitive (pref->priv->basic_radar_url_hbox, toggled);
 }
 
 static void
@@ -504,9 +403,10 @@ use_radar_url_toggled (GtkToggleButton *button, GWeatherPref *pref)
     gboolean toggled;
     
     toggled = gtk_toggle_button_get_active(button);
-    gw_applet->gweather_pref.use_custom_radar_url = toggled;
-    gweather_gconf_set_bool(gw_applet->gconf, "use_custom_radar_url", toggled, NULL);
-    soft_set_sensitive (pref->priv->basic_radar_url_hbox, toggled);
+
+    if (!toggled)
+      g_settings_set_string (gw_applet->lib_settings, "radar", "");
+    gtk_widget_set_sensitive (pref->priv->basic_radar_url_hbox, toggled);
 }
 
 static gboolean
@@ -517,18 +417,7 @@ radar_url_changed (GtkWidget *widget, GdkEventFocus *event, GWeatherPref *pref)
     
     text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
     
-    if (gw_applet->gweather_pref.radar)
-        g_free (gw_applet->gweather_pref.radar);
-        
-    if (text) {
-    	gw_applet->gweather_pref.radar = g_strdup (text);
-    	g_free (text);
-    }
-    else
-    	gw_applet->gweather_pref.radar = NULL;
-    	
-    gweather_gconf_set_string (gw_applet->gconf, "radar", 
-    				   gw_applet->gweather_pref.radar, NULL);
+    g_settings_set_string (gw_applet->lib_settings, "radar", text);
     				   
     return FALSE;
     				   
@@ -539,32 +428,14 @@ update_interval_changed (GtkSpinButton *button, GWeatherPref *pref)
 {
     GWeatherApplet *gw_applet = pref->priv->applet;
     
-    gw_applet->gweather_pref.update_interval = gtk_spin_button_get_value_as_int(button)*60;
-    gweather_gconf_set_int(gw_applet->gconf, "auto_update_interval", 
-    		               gw_applet->gweather_pref.update_interval, NULL);
     if (gw_applet->timeout_tag > 0)
         g_source_remove(gw_applet->timeout_tag);
-    if (gw_applet->gweather_pref.update_enabled)
+    if (g_settings_get_boolean (gw_applet->applet_settings, "auto-update"))
         gw_applet->timeout_tag =  
-        	g_timeout_add_seconds (gw_applet->gweather_pref.update_interval,
+	  g_timeout_add_seconds (g_settings_get_int (gw_applet->applet_settings, "auto-update-interval"),
                                  timeout_cb, gw_applet);
 }
 
-static gboolean
-free_data (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
-{
-   WeatherLocation *location;
-   
-   gtk_tree_model_get (model, iter, GWEATHER_XML_COL_POINTER, &location, -1);
-   if (!location)
-   	return FALSE;
-
-   weather_location_free (location);
-   
-   return FALSE;
-}
-
-
 static GtkWidget *
 create_hig_catagory (GtkWidget *main_box, gchar *title)
 {
@@ -611,7 +482,7 @@ find_location (GtkTreeModel *model, GtkTreeIter *iter, const gchar *location, gb
 	
 	do {
 		
-		gtk_tree_model_get (model, iter, GWEATHER_XML_COL_LOC, &aux_loc, -1);
+	  gtk_tree_model_get (model, iter, GWEATHER_XML_COL_LOCATION_NAME, &aux_loc, -1);
 
 		if (g_ascii_strncasecmp (aux_loc, location, len) == 0) {
 			g_free (aux_loc);
@@ -838,8 +709,6 @@ gweather_pref_create (GWeatherPref *pref)
     gtk_container_add (GTK_CONTAINER (pref_basic_update_alignment), pref->priv->basic_update_btn);
     g_signal_connect (G_OBJECT (pref->priv->basic_update_btn), "toggled",
     		      G_CALLBACK (auto_update_toggled), pref);
-    if ( ! key_writable (pref, "auto_update"))
-	    hard_set_sensitive (pref->priv->basic_update_btn, FALSE);
 
   /*
    * Units settings page.
@@ -855,15 +724,11 @@ gweather_pref_create (GWeatherPref *pref)
     temp_combo = gtk_combo_box_text_new ();
 	pref->priv->basic_temp_combo = temp_combo;
     gtk_label_set_mnemonic_widget (GTK_LABEL (temp_label), temp_combo);
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (temp_combo), _("Default"));
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (temp_combo), _("Kelvin"));
     /* TRANSLATORS: Celsius is sometimes referred Centigrade */
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (temp_combo), _("Celsius"));
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (temp_combo), _("Fahrenheit"));
 	gtk_widget_show (temp_combo);
-		
-    if ( ! key_writable (pref, GCONF_TEMP_UNIT))
-        hard_set_sensitive (pref->priv->basic_temp_combo, FALSE);
 	
     /* Speed Unit */
     speed_label = gtk_label_new_with_mnemonic (_("_Wind speed unit:"));
@@ -875,7 +740,6 @@ gweather_pref_create (GWeatherPref *pref)
     speed_combo = gtk_combo_box_text_new ();
     pref->priv->basic_speed_combo = speed_combo;
     gtk_label_set_mnemonic_widget (GTK_LABEL (speed_label), speed_combo);
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (speed_combo), _("Default"));
     /* TRANSLATOR: The wind speed unit "meters per second" */    
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (speed_combo), _("m/s"));
     /* TRANSLATOR: The wind speed unit "kilometers per hour" */
@@ -888,9 +752,6 @@ gweather_pref_create (GWeatherPref *pref)
 		    _("Beaufort scale"));
 	gtk_widget_show (speed_combo);
 
-    if ( ! key_writable (pref, GCONF_SPEED_UNIT))
-        hard_set_sensitive (pref->priv->basic_speed_combo, FALSE);
-
     /* Pressure Unit */
     pres_label = gtk_label_new_with_mnemonic (_("_Pressure unit:"));
     gtk_label_set_use_markup (GTK_LABEL (pres_label), TRUE);
@@ -901,7 +762,6 @@ gweather_pref_create (GWeatherPref *pref)
     pres_combo = gtk_combo_box_text_new ();
 	pref->priv->basic_pres_combo = pres_combo;
     gtk_label_set_mnemonic_widget (GTK_LABEL (pres_label), pres_combo);
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pres_combo), _("Default"));
     /* TRANSLATOR: The pressure unit "kiloPascals" */
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pres_combo), _("kPa"));
     /* TRANSLATOR: The pressure unit "hectoPascals" */
@@ -916,9 +776,6 @@ gweather_pref_create (GWeatherPref *pref)
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pres_combo), _("atm"));
     gtk_widget_show (pres_combo);
 
-    if ( ! key_writable (pref, GCONF_PRESSURE_UNIT))
-        hard_set_sensitive (pref->priv->basic_pres_combo, FALSE);
-
     /* Distance Unit */
     dist_label = gtk_label_new_with_mnemonic (_("_Visibility unit:"));
     gtk_label_set_use_markup (GTK_LABEL (dist_label), TRUE);
@@ -929,7 +786,6 @@ gweather_pref_create (GWeatherPref *pref)
     dist_combo = gtk_combo_box_text_new ();
 	pref->priv->basic_dist_combo = dist_combo;
     gtk_label_set_mnemonic_widget (GTK_LABEL (dist_label), dist_combo);
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dist_combo), _("Default"));
     /* TRANSLATOR: The distance unit "meters" */
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dist_combo), _("meters"));
     /* TRANSLATOR: The distance unit "kilometers" */
@@ -938,9 +794,6 @@ gweather_pref_create (GWeatherPref *pref)
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dist_combo), _("miles"));
 	gtk_widget_show (dist_combo);
 
-    if ( ! key_writable (pref, GCONF_DISTANCE_UNIT))
-        hard_set_sensitive (pref->priv->basic_dist_combo, FALSE);
-	
 	unit_table = gtk_table_new(5, 2, FALSE);
 	gtk_table_set_row_spacings(GTK_TABLE(unit_table), 6);
 	gtk_table_set_col_spacings(GTK_TABLE(unit_table), 12);
@@ -973,8 +826,6 @@ gweather_pref_create (GWeatherPref *pref)
     gtk_widget_show (pref->priv->basic_radar_btn);
     g_signal_connect (G_OBJECT (pref->priv->basic_radar_btn), "toggled",
     		      G_CALLBACK (radar_toggled), pref);
-    if ( ! key_writable (pref, "enable_radar_map"))
-	    hard_set_sensitive (pref->priv->basic_radar_btn, FALSE);
     
     radar_toggle_hbox = gtk_hbox_new (FALSE, 12);
     gtk_widget_show (radar_toggle_hbox);
@@ -989,8 +840,6 @@ gweather_pref_create (GWeatherPref *pref)
 
     g_signal_connect (G_OBJECT (pref->priv->basic_radar_url_btn), "toggled",
     		      G_CALLBACK (use_radar_url_toggled), pref);
-    if ( ! key_writable (pref, "use_custom_radar_url"))
-	    hard_set_sensitive (pref->priv->basic_radar_url_btn, FALSE);
     		      
     pref->priv->basic_radar_url_hbox = gtk_hbox_new (FALSE, 12);
     gtk_widget_show (pref->priv->basic_radar_url_hbox);
@@ -1010,8 +859,6 @@ gweather_pref_create (GWeatherPref *pref)
     			pref->priv->basic_radar_url_entry, TRUE, TRUE, 0);    
     g_signal_connect (G_OBJECT (pref->priv->basic_radar_url_entry), "focus_out_event",
     		      G_CALLBACK (radar_url_changed), pref);
-    if ( ! key_writable (pref, "radar"))
-	    hard_set_sensitive (pref->priv->basic_radar_url_entry, FALSE);
 #endif /* RADARMAP */
 
     frame = create_hig_catagory (pref_basic_vbox, _("Update"));
@@ -1040,10 +887,6 @@ gweather_pref_create (GWeatherPref *pref)
     
     pref_basic_update_sec_lbl = gtk_label_new (_("minutes"));
     gtk_widget_show (pref_basic_update_sec_lbl);
-    if ( ! key_writable (pref, "auto_update_interval")) {
-	    hard_set_sensitive (pref->priv->basic_update_spin, FALSE);
-	    hard_set_sensitive (pref_basic_update_sec_lbl, FALSE);
-    }
 
     value_hbox = gtk_hbox_new (FALSE, 6);
 
@@ -1132,10 +975,6 @@ gweather_pref_create (GWeatherPref *pref)
 
     gtk_box_pack_start (GTK_BOX (pref_loc_hbox), pref_find_hbox, FALSE, FALSE, 0);
     
-    if ( ! key_writable (pref, "location0")) {
-	    hard_set_sensitive (scrolled_window, FALSE);
-    }
-
     pref_loc_note_lbl = gtk_label_new (_("Location"));
     gtk_widget_show (pref_loc_note_lbl);
     gtk_notebook_set_tab_label (GTK_NOTEBOOK (pref_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (pref_notebook), 1), pref_loc_note_lbl);
@@ -1222,7 +1061,6 @@ gweather_pref_finalize (GObject *object)
 {
    GWeatherPref *self = GWEATHER_PREF (object);
 
-   gtk_tree_model_foreach (self->priv->model, free_data, NULL);
    g_object_unref (G_OBJECT (self->priv->model));
 
    G_OBJECT_CLASS (gweather_pref_parent_class)->finalize(object);
diff --git a/gweather/gweather.h b/gweather/gweather.h
index db4f8f8..5953b2f 100644
--- a/gweather/gweather.h
+++ b/gweather/gweather.h
@@ -12,11 +12,9 @@
  */
 #include <glib/gi18n.h>
 
-#include <panel-applet.h>
-
-#include <libgweather/gweather-gconf.h>
-#include <libgweather/gweather-prefs.h>
+#include <libgweather/gweather-weather.h>
 
+#include <panel-applet.h>
 
 /* Radar map on by default. */
 #define RADARMAP
@@ -28,9 +26,10 @@ typedef struct _GWeatherApplet GWeatherApplet;
 struct _GWeatherApplet
 {
 	PanelApplet *applet;
-	WeatherInfo *gweather_info;
+	GWeatherInfo *gweather_info;
 
-	GWeatherGConf *gconf;
+	GSettings *lib_settings;
+	GSettings *applet_settings;
 
 	GtkWidget *container;
 	GtkWidget *box;	
@@ -42,9 +41,6 @@ struct _GWeatherApplet
 	gint timeout_tag;
 	gint suncalc_timeout_tag;
 
-	/* preferences  */
-	GWeatherPrefs gweather_pref;
-
 	GtkWidget *pref_dialog;
 
 	/* dialog stuff */
diff --git a/gweather/main.c b/gweather/main.c
index 70d1b18..ba77cc4 100644
--- a/gweather/main.c
+++ b/gweather/main.c
@@ -14,12 +14,10 @@
 #include <config.h>
 #include <gtk/gtk.h>
 #include <panel-applet.h>
+#include <gio/gio.h>
 
 #define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 
-#include <libgweather/gweather-gconf.h>
-#include <libgweather/gweather-prefs.h>
-
 #include "gweather.h"
 #include "gweather-pref.h"
 #include "gweather-dialog.h"
@@ -33,18 +31,15 @@ gweather_applet_new(PanelApplet *applet, const gchar *iid, gpointer data)
 
 	char *prefs_key = panel_applet_get_preferences_key(applet);
 
-	panel_applet_add_preferences(applet, "/schemas/apps/gweather/prefs", NULL);
-	
 	gw_applet = g_new0(GWeatherApplet, 1);   
 	
 	gw_applet->applet = applet;
 	gw_applet->gweather_info = NULL;
-	gw_applet->gconf = gweather_gconf_new(prefs_key);
+	gw_applet->lib_settings = g_settings_new("org.gnome.GWeather");
+	gw_applet->applet_settings = panel_applet_settings_new(applet, "org.gnome.applets.GWeatherApplet");
 	g_free (prefs_key);
     	gweather_applet_create(gw_applet);
 
-    	gweather_prefs_load(&gw_applet->gweather_pref, gw_applet->gconf);
-    
     	gweather_update(gw_applet);
 
     	return TRUE;
diff --git a/gweather/org.gnome.applets.GWeatherApplet.gschema.xml.in.in b/gweather/org.gnome.applets.GWeatherApplet.gschema.xml.in.in
new file mode 100644
index 0000000..e4a312b
--- /dev/null
+++ b/gweather/org.gnome.applets.GWeatherApplet.gschema.xml.in.in
@@ -0,0 +1,29 @@
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+  <schema id="org.gnome.applets.GWeatherApplet">
+    <key name="auto-update" type="b">
+      <default>true</default>
+      <_summary>Update the data automatically</_summary>
+      <_description>Determines whether the applet automatically updates its weather statistics or not.</_description>
+    </key>
+    <key name="auto-update-interval" type="i">
+      <default>1800</default>
+      <_summary>Update interval</_summary>
+      <_description>The interval, in seconds, between automatic updates.</_description>
+    </key>
+    <key name="enable-radar-map" type="b">
+      <default>false</default>
+      <_summary>Display radar map</_summary>
+      <_description>Fetch a radar map on each update.</_description>
+    </key>
+    <key name="show-notifications" type="b">
+      <default>false</default>
+      <_summary>Show notification</_summary>
+      <_description>Show notifications for critical weather conditions</_description>
+    </key>
+    <key name="detailed" type="b">
+      <default>false</default>
+      <_summary>Show detailed forecast</_summary>
+      <_description>If true, additional details about weather will be downloaded and shown.</_description>
+    </key>
+  </schema>
+</schemalist>



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