Index: gweather-applet.c
===================================================================
RCS file: /cvs/gnome/gnome-applets/gweather/gweather-applet.c,v
retrieving revision 1.78
diff -p -u -u -r1.78 gweather-applet.c
--- gweather-applet.c	28 Apr 2004 13:29:46 -0000	1.78
+++ gweather-applet.c	30 Apr 2004 05:09:42 -0000
@@ -306,6 +306,10 @@ void gweather_applet_create (GWeatherApp
     gw_applet->gweather_pref.use_metric = FALSE;
     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);
     
Index: gweather-pref.c
===================================================================
RCS file: /cvs/gnome/gnome-applets/gweather/gweather-pref.c,v
retrieving revision 1.72
diff -p -u -u -r1.72 gweather-pref.c
--- gweather-pref.c	1 Feb 2004 17:14:14 -0000	1.72
+++ gweather-pref.c	30 Apr 2004 05:09:42 -0000
@@ -34,6 +34,13 @@
 
 #define NEVER_SENSITIVE		"never_sensitive"
 
+
+/* gconf keys */
+#define GCONF_TEMP_UNIT     "temperature_unit"
+#define GCONF_SPEED_UNIT    "speed_unit"
+#define GCONF_PRESSURE_UNIT "pressure_unit"
+#define GCONF_DISTANCE_UNIT "distance_unit"
+
 enum
 {
     COL_LOC = 0,
@@ -42,6 +49,40 @@ enum
 }; 
 
 
+static GConfEnumStringPair temp_unit_enum_map [] = {
+    { TEMP_UNIT_DEFAULT,     "Default" },
+    { TEMP_UNIT_FAHRENHEIT, "Fahrenheit" },
+    { TEMP_UNIT_CENTIGRADE, "Centigrade" },
+    { TEMP_UNIT_KELVIN,     "Kelvin" },
+    { 0, NULL }
+};	
+
+static GConfEnumStringPair speed_unit_enum_map [] = {
+    { SPEED_UNIT_DEFAULT, "Default" },
+    { SPEED_UNIT_MPH,    "mph" },
+    { SPEED_UNIT_KNOTS,  "knots" },
+    { SPEED_UNIT_KPH,    "kph" },
+    { SPEED_UNIT_MS,     "m/s" },
+	{ 0, NULL }
+};
+
+static GConfEnumStringPair pressure_unit_enum_map [] = {
+    { PRESSURE_UNIT_DEFAULT,  "Default" },
+	{ PRESSURE_UNIT_INCH_HG, "inHg" },
+    { PRESSURE_UNIT_MM_HG,   "mmHg" },
+	{ PRESSURE_UNIT_HPA,     "hPa"  },
+	{ PRESSURE_UNIT_MB,      "mb"   },
+    { 0, NULL }
+};
+
+static GConfEnumStringPair distance_unit_enum_map [] = {
+    { DISTANCE_UNIT_DEFAULT, "Default" },
+    { DISTANCE_UNIT_MILES,   "miles" },
+    { DISTANCE_UNIT_KM,      "kilometers" },
+    { DISTANCE_UNIT_METERS,  "meters" },
+    { 0, NULL }
+};
+
 static void gweather_pref_set_accessibility (GWeatherApplet *gw_applet);
 static void help_cb (GtkDialog *dialog);
 
@@ -171,8 +212,36 @@ static gboolean update_dialog (GWeatherA
     				 gw_applet->gweather_pref.update_enabled);
     soft_set_sensitive(gw_applet->pref_basic_update_spin, 
     			     gw_applet->gweather_pref.update_enabled);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gw_applet->pref_basic_metric_btn), 
-    				 gw_applet->gweather_pref.use_metric);
+/*    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gw_applet->pref_basic_metric_btn), 
+    				 gw_applet->gweather_pref.use_metric); */
+
+    if ( gw_applet->gweather_pref.use_temperature_default) {
+        gtk_combo_box_set_active (GTK_COMBO_BOX(gw_applet->pref_basic_temp_combo), 0);
+    } else {
+		gtk_combo_box_set_active (GTK_COMBO_BOX(gw_applet->pref_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(gw_applet->pref_basic_speed_combo), 0);
+    } else {
+        gtk_combo_box_set_active (GTK_COMBO_BOX(gw_applet->pref_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(gw_applet->pref_basic_pres_combo), 0);
+    } else {
+        gtk_combo_box_set_active (GTK_COMBO_BOX(gw_applet->pref_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(gw_applet->pref_basic_dist_combo), 0);
+    } else {
+        gtk_combo_box_set_active (GTK_COMBO_BOX(gw_applet->pref_basic_dist_combo), 
+	                 gw_applet->gweather_pref.distance_unit -1);
+    }
+
 #if 0
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gw_applet->pref_basic_detailed_btn), 
     				 gw_applet->gweather_pref.detailed);
@@ -419,7 +488,7 @@ metric_toggled (GtkToggleButton *button,
     }
     gtk_label_set_text(GTK_LABEL(gw_applet->label), 
     		       weather_info_get_temp_summary(gw_applet->gweather_info));
-    gweather_dialog_update (gw_applet); 
+    gweather_dialog_update (gw_applet);
 }
 
 static void
@@ -434,6 +503,211 @@ detailed_toggled (GtkToggleButton *butto
     				toggled, NULL);    
 }
 
+static void parse_temp_string (const gchar *gconf_str, GWeatherPrefs *prefs)
+{
+    gint value = 0;
+	
+    prefs->use_temperature_default = TRUE;
+	
+    if ( gconf_str && gconf_string_to_enum (temp_unit_enum_map, gconf_str, &value) ) {
+        prefs->temperature_unit = value;
+		
+		if ((prefs->temperature_unit == TEMP_UNIT_DEFAULT) &&
+		    (gconf_string_to_enum (temp_unit_enum_map, _("DEFAULT_TEMP_UNIT"), &value)) ) {
+              prefs->temperature_unit = value;
+		} else {
+            prefs->use_temperature_default = FALSE;
+        }
+    }	
+    else {
+        /* TRANSLATOR: This is the default unit to use for temperature measurements. */
+        /* Valid values are: "Fahrenheit", "Centigrade" and "Kelvin" */
+        if (gconf_string_to_enum (temp_unit_enum_map, _("DEFAULT_TEMP_UNIT"), &value) ) {
+            prefs->temperature_unit = value;
+        }
+    }
+    if (!prefs->temperature_unit || prefs->temperature_unit == TEMP_UNIT_DEFAULT ) {
+        prefs->temperature_unit = TEMP_UNIT_FAHRENHEIT;
+    }
+}
+
+static void parse_speed_string (const gchar *gconf_str, GWeatherPrefs *prefs)
+{
+    gint value = 0;
+	
+    prefs->use_speed_default = TRUE;
+	
+    if ( gconf_str && gconf_string_to_enum (speed_unit_enum_map, gconf_str, &value) ) {
+        prefs->speed_unit = value;
+		if ((prefs->speed_unit == SPEED_UNIT_DEFAULT) &&
+			(gconf_string_to_enum (speed_unit_enum_map, _("DEFAULT_SPEED_UNIT"), &value)) ) {
+              prefs->speed_unit = value;
+		} else {
+            prefs->use_speed_default = FALSE;
+        }
+    }	
+    else {
+        /* TRANSLATOR: This is the default unit to use for wind speed. */
+        /* Valid values are: "mph" (miles per hour), "knots",  */
+		/* "kph" (kilometers per hour) and "m/s" (meters per second) */
+        if (gconf_string_to_enum (speed_unit_enum_map, _("DEFAULT_SPEED_UNIT"), &value) ) {
+            prefs->speed_unit = value;
+        }
+    }
+    if ( (!prefs->speed_unit) || prefs->speed_unit == SPEED_UNIT_DEFAULT ) {
+        prefs->speed_unit = SPEED_UNIT_KNOTS;
+    }
+}
+
+
+static void parse_pressure_string (const gchar *gconf_str, GWeatherPrefs *prefs)
+{
+    gint value = 0;
+	
+    prefs->use_pressure_default = TRUE;
+	
+    if ( gconf_str && gconf_string_to_enum (pressure_unit_enum_map, gconf_str, &value) ) {
+        prefs->pressure_unit = value;
+
+        if ((prefs->pressure_unit == PRESSURE_UNIT_DEFAULT) &&
+			(gconf_string_to_enum (pressure_unit_enum_map, _("DEFAULT_PRESSURE_UNIT"), &value)) ) {
+              prefs->pressure_unit = value;
+		} else {
+            prefs->use_pressure_default = FALSE;
+        }
+    }	
+    else {
+        /* TRANSLATOR: This is the default unit to use for atmospheric pressure. */
+        /* Valid values are: "inHg" (inches of mercury), "mmHg"  */
+		/* (millimeters of mercury), "hPa" (hecoPascals) and "mb" (millibars) */
+        if (gconf_string_to_enum (pressure_unit_enum_map, _("DEFAULT_PRESSURE_UNIT"), &value) ) {
+            prefs->pressure_unit = value;
+        }
+    }
+    if ( (!prefs->pressure_unit) || prefs->pressure_unit == PRESSURE_UNIT_DEFAULT ) {
+        prefs->pressure_unit = PRESSURE_UNIT_INCH_HG;
+    }	
+}
+
+static void parse_distance_string (const gchar *gconf_str, GWeatherPrefs *prefs)
+{
+    gint value = 0;
+	
+    prefs->use_distance_default = TRUE;
+    if ( gconf_str && gconf_string_to_enum (distance_unit_enum_map, gconf_str, &value) ) {
+        prefs->distance_unit = value;
+
+		if ((prefs->distance_unit == DISTANCE_UNIT_DEFAULT) &&
+			(gconf_string_to_enum (distance_unit_enum_map, _("DEFAULT_DISTANCE_UNIT"), &value)) ) {
+              prefs->distance_unit = value;
+		} else {
+            prefs->use_distance_default = FALSE;
+        }
+    }	
+    else {
+        /* TRANSLATOR: This is the default unit to use for visibility distance. */
+        /* Valid values are: "miles", "kilometers" and "meters",  */
+        if (gconf_string_to_enum (distance_unit_enum_map, _("DEFAULT_DISTANCE_UNIT"), &value) ) {
+            prefs->distance_unit = value;
+        }
+    }
+
+	if ((!prefs->distance_unit) || prefs->distance_unit == DISTANCE_UNIT_DEFAULT ) {
+        prefs->distance_unit = DISTANCE_UNIT_MILES;
+    }
+
+    return;
+}	
+static void temp_combo_changed (GtkComboBox *combo, gpointer data)
+{
+    GWeatherApplet *gw_applet = data;
+    TempUnit       new_unit, *old_unit;
+	
+	g_return_if_fail(gw_applet != NULL);
+    
+	old_unit = &gw_applet->gweather_pref.temperature_unit;	
+	new_unit = gtk_combo_box_get_active(combo) + 1;
+
+	if (new_unit == *old_unit)
+        return;
+
+    parse_temp_string (gconf_enum_to_string (temp_unit_enum_map, new_unit), &(gw_applet->gweather_pref));
+
+    panel_applet_gconf_set_string(gw_applet->applet, GCONF_TEMP_UNIT,
+                                  gconf_enum_to_string (temp_unit_enum_map, new_unit),
+                                  NULL);
+	
+    gtk_label_set_text(GTK_LABEL(gw_applet->label), 
+	                   weather_info_get_temp_summary(gw_applet->gweather_info));
+    gweather_dialog_update (gw_applet);
+}
+
+static void speed_combo_changed (GtkComboBox *combo, gpointer data)
+{
+    GWeatherApplet *gw_applet = data;
+    SpeedUnit      new_unit, *old_unit;
+	
+	g_return_if_fail(gw_applet != NULL);
+    
+	old_unit = &gw_applet->gweather_pref.speed_unit;	
+	new_unit = gtk_combo_box_get_active(combo) + 1;
+
+	if (new_unit == *old_unit)
+        return;
+
+    parse_speed_string (gconf_enum_to_string (speed_unit_enum_map, new_unit), &(gw_applet->gweather_pref));
+
+    panel_applet_gconf_set_string(gw_applet->applet, GCONF_SPEED_UNIT,
+                                  gconf_enum_to_string (speed_unit_enum_map, new_unit),
+                                  NULL);
+	
+    gweather_dialog_update (gw_applet);
+}
+
+static void pres_combo_changed (GtkComboBox *combo, gpointer data)
+{
+    GWeatherApplet *gw_applet = data;
+    PressureUnit   new_unit, *old_unit;
+	
+	g_return_if_fail(gw_applet != NULL);
+    
+	old_unit = &gw_applet->gweather_pref.pressure_unit;	
+	new_unit = gtk_combo_box_get_active(combo) + 1;
+
+	if (new_unit == *old_unit)
+        return;
+
+    parse_pressure_string (gconf_enum_to_string (pressure_unit_enum_map, new_unit), &(gw_applet->gweather_pref));
+
+    panel_applet_gconf_set_string(gw_applet->applet, GCONF_PRESSURE_UNIT,
+                                  gconf_enum_to_string (pressure_unit_enum_map, new_unit),
+                                  NULL);
+	
+    gweather_dialog_update (gw_applet);
+}
+
+static void dist_combo_changed (GtkComboBox *combo, gpointer data)
+{
+    GWeatherApplet *gw_applet = data;
+    DistanceUnit   new_unit, *old_unit;
+	
+	g_return_if_fail(gw_applet != NULL);
+    
+	old_unit = &gw_applet->gweather_pref.distance_unit;	
+	new_unit = gtk_combo_box_get_active(combo) + 1;
+
+	if (new_unit == *old_unit)
+        return;
+
+    parse_distance_string (gconf_enum_to_string (distance_unit_enum_map, new_unit), &(gw_applet->gweather_pref));
+
+    panel_applet_gconf_set_string(gw_applet->applet, GCONF_DISTANCE_UNIT,
+                                  gconf_enum_to_string (distance_unit_enum_map, new_unit),
+                                  NULL);
+	
+    gweather_dialog_update (gw_applet);
+}
+
 static void
 radar_toggled (GtkToggleButton *button, gpointer data)
 {
@@ -601,6 +875,15 @@ static void gweather_pref_create (GWeath
     GtkWidget *pref_basic_vbox;
     GtkWidget *vbox;
     GtkWidget *frame;
+    GtkWidget *temp_label;
+    GtkWidget *temp_combo;
+    GtkWidget *speed_label;
+    GtkWidget *speed_combo;	
+    GtkWidget *pres_label;
+    GtkWidget *pres_combo;
+    GtkWidget *dist_label;
+    GtkWidget *dist_combo;
+    GtkWidget *unit_table;	
     
     gw_applet->pref = gtk_dialog_new_with_buttons (_("Weather Preferences"), NULL,
 				      		   GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -610,7 +893,7 @@ static void gweather_pref_create (GWeath
     gtk_dialog_set_default_response (GTK_DIALOG (gw_applet->pref), GTK_RESPONSE_CLOSE);
     gtk_dialog_set_has_separator (GTK_DIALOG (gw_applet->pref), FALSE);
     gtk_container_set_border_width (GTK_CONTAINER (gw_applet->pref), 5);
-    gtk_window_set_default_size(GTK_WINDOW (gw_applet->pref), -1, 325);
+/*    gtk_window_set_default_size(GTK_WINDOW (gw_applet->pref), -1, 325); */
     gtk_window_set_policy (GTK_WINDOW (gw_applet->pref), TRUE, TRUE, FALSE);
     gtk_window_set_screen (GTK_WINDOW (gw_applet->pref),
 			   gtk_widget_get_screen (GTK_WIDGET (gw_applet->applet)));
@@ -643,13 +926,98 @@ static void gweather_pref_create (GWeath
     if ( ! key_writable (gw_applet->applet, "auto_update"))
 	    hard_set_sensitive (gw_applet->pref_basic_update_btn, FALSE);
 
-    gw_applet->pref_basic_metric_btn = gtk_check_button_new_with_mnemonic (_("Use _metric system units"));
+    /* Temperature Unit */
+    temp_label = gtk_label_new_with_mnemonic (_("_Temperature Unit:"));
+    gtk_label_set_use_markup (GTK_LABEL (temp_label), TRUE);
+    gtk_label_set_justify (GTK_LABEL (temp_label), GTK_JUSTIFY_LEFT);
+    gtk_misc_set_alignment (GTK_MISC (temp_label), 0, 0.5);
+    gtk_widget_show (temp_label);
+
+    temp_combo = gtk_combo_box_new_text ();
+	gw_applet->pref_basic_temp_combo = temp_combo;
+    gtk_label_set_mnemonic_widget (GTK_LABEL (temp_label), temp_combo);
+    gtk_combo_box_append_text (GTK_COMBO_BOX (temp_combo), _("Default"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (temp_combo), _("Fahrenheit"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (temp_combo), _("Centigrade"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (temp_combo), _("Kelvin"));
+	gtk_widget_show (temp_combo);
+		
+    /* Speed Unit */
+    speed_label = gtk_label_new_with_mnemonic (_("_Wind Speed Unit:"));
+    gtk_label_set_use_markup (GTK_LABEL (speed_label), TRUE);
+    gtk_label_set_justify (GTK_LABEL (speed_label), GTK_JUSTIFY_LEFT);
+    gtk_misc_set_alignment (GTK_MISC (speed_label), 0, 0.5);
+    gtk_widget_show (speed_label);
+
+    speed_combo = gtk_combo_box_new_text ();
+    gw_applet->pref_basic_speed_combo = speed_combo;
+    gtk_label_set_mnemonic_widget (GTK_LABEL (speed_label), speed_combo);
+    gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("Default"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("mph"));
+	gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("knots"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("kph"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("m/s"));
+	gtk_widget_show (speed_combo);
+
+    /* Pressure Unit */
+    pres_label = gtk_label_new_with_mnemonic (_("_Pressure Unit:"));
+    gtk_label_set_use_markup (GTK_LABEL (pres_label), TRUE);
+    gtk_label_set_justify (GTK_LABEL (pres_label), GTK_JUSTIFY_LEFT);
+    gtk_misc_set_alignment (GTK_MISC (pres_label), 0, 0.5);
+    gtk_widget_show (pres_label);
+
+    pres_combo = gtk_combo_box_new_text ();
+	gw_applet->pref_basic_pres_combo = pres_combo;
+    gtk_label_set_mnemonic_widget (GTK_LABEL (pres_label), pres_combo);
+    gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("Default"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("inHg"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("mmHg"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("hPa"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("mb"));
+    gtk_widget_show (pres_combo);
+
+    /* Distance Unit */
+    dist_label = gtk_label_new_with_mnemonic (_("_Visibility Unit:"));
+    gtk_label_set_use_markup (GTK_LABEL (dist_label), TRUE);
+    gtk_label_set_justify (GTK_LABEL (dist_label), GTK_JUSTIFY_LEFT);
+    gtk_misc_set_alignment (GTK_MISC (dist_label), 0, 0.5);
+    gtk_widget_show (dist_label);
+
+    dist_combo = gtk_combo_box_new_text ();
+	gw_applet->pref_basic_dist_combo = dist_combo;
+    gtk_label_set_mnemonic_widget (GTK_LABEL (dist_label), dist_combo);
+    gtk_combo_box_append_text (GTK_COMBO_BOX (dist_combo), _("Default"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (dist_combo), _("miles"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (dist_combo), _("km"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (dist_combo), _("meters"));
+	gtk_widget_show (dist_combo);
+	
+	unit_table = gtk_table_new(9, 3, FALSE);
+	gtk_table_set_row_spacings(GTK_TABLE(unit_table), 3);
+	gtk_table_attach_defaults(GTK_TABLE(unit_table), temp_label,  0, 1, 0, 1);
+	gtk_table_attach_defaults(GTK_TABLE(unit_table), temp_combo,  1, 2, 0, 1);
+	gtk_table_attach_defaults(GTK_TABLE(unit_table), speed_label, 0, 1, 2, 3);
+	gtk_table_attach_defaults(GTK_TABLE(unit_table), speed_combo, 1, 2, 2, 3);
+	gtk_table_attach_defaults(GTK_TABLE(unit_table), pres_label,  0, 1, 4, 5);
+	gtk_table_attach_defaults(GTK_TABLE(unit_table), pres_combo,  1, 2, 4, 5);
+	gtk_table_attach_defaults(GTK_TABLE(unit_table), dist_label,  0, 1, 6, 8);
+	gtk_table_attach_defaults(GTK_TABLE(unit_table), dist_combo,  1, 2, 6, 8);
+	gtk_widget_show(unit_table);
+	
+	g_signal_connect (temp_combo, "changed", G_CALLBACK (temp_combo_changed), gw_applet);
+	g_signal_connect (speed_combo, "changed", G_CALLBACK (speed_combo_changed), gw_applet);
+	g_signal_connect (dist_combo, "changed", G_CALLBACK (dist_combo_changed), gw_applet);
+	g_signal_connect (pres_combo, "changed", G_CALLBACK (pres_combo_changed), gw_applet);
+
+	/* 
+/*    gw_applet->pref_basic_metric_btn = gtk_check_button_new_with_mnemonic (_("Use _metric system units"));
     gtk_widget_show (gw_applet->pref_basic_metric_btn);
     g_signal_connect (G_OBJECT (gw_applet->pref_basic_metric_btn), "toggled",
     		      G_CALLBACK (metric_toggled), gw_applet);
     if ( ! key_writable (gw_applet->applet, "enable_metric"))
 	    hard_set_sensitive (gw_applet->pref_basic_metric_btn, FALSE);
-
+*/
+	
 #ifdef RADARMAP
     gw_applet->pref_basic_radar_btn = gtk_check_button_new_with_mnemonic (_("Enable _radar map"));
     gtk_widget_show (gw_applet->pref_basic_radar_btn);
@@ -665,7 +1033,7 @@ static void gweather_pref_create (GWeath
     gtk_widget_show (label);
     gtk_box_pack_start (GTK_BOX (radar_toggle_hbox), label, FALSE, FALSE, 0); 
 					      
-    gw_applet->pref_basic_radar_url_btn = gtk_check_button_new_with_mnemonic (_("Use cus_tom address for radar map"));
+    gw_applet->pref_basic_radar_url_btn = gtk_check_button_new_with_mnemonic (_("Use _custom address for radar map"));
     gtk_widget_show (gw_applet->pref_basic_radar_url_btn);
     gtk_box_pack_start (GTK_BOX (radar_toggle_hbox), gw_applet->pref_basic_radar_url_btn, FALSE, FALSE, 0);
 
@@ -740,7 +1108,9 @@ static void gweather_pref_create (GWeath
 
     vbox = gtk_vbox_new (FALSE, 6);
 
-    gtk_box_pack_start (GTK_BOX (vbox), gw_applet->pref_basic_metric_btn, TRUE, TRUE, 0);
+/*    gtk_box_pack_start (GTK_BOX (vbox), gw_applet->pref_basic_metric_btn, TRUE, TRUE, 0); */
+	gtk_box_pack_start (GTK_BOX (vbox), unit_table, TRUE, TRUE, 0);
+
 #ifdef RADARMAP
     gtk_box_pack_start (GTK_BOX (vbox), gw_applet->pref_basic_radar_btn, TRUE, TRUE, 0);
     gtk_box_pack_start (GTK_BOX (vbox), radar_toggle_hbox, TRUE, TRUE, 0);
@@ -810,11 +1180,18 @@ static void gweather_pref_create (GWeath
     gtk_widget_show_all (gw_applet->pref);
 }
 
-
 void gweather_pref_load (GWeatherApplet *gw_applet)
 {
     GError *error = NULL;
-
+	gchar  *gconf_str = NULL;
+	gint   value = 0;
+	GWeatherPrefs *prefs = &(gw_applet->gweather_pref);
+
+	/* Assume we use unit defaults */
+    prefs->use_speed_default = TRUE;
+    prefs->use_pressure_default = TRUE;
+    prefs->use_distance_default = TRUE;
+	
     gw_applet->gweather_pref.update_interval = 
     	panel_applet_gconf_get_int(gw_applet->applet, "auto_update_interval", &error);
     if (error) {
@@ -837,6 +1214,24 @@ void gweather_pref_load (GWeatherApplet 
     gw_applet->gweather_pref.radar = panel_applet_gconf_get_string (gw_applet->applet,
     								    "radar",
     								    NULL);
+    
+    gconf_str = panel_applet_gconf_get_string (gw_applet->applet, GCONF_TEMP_UNIT, NULL);
+    parse_temp_string(gconf_str, prefs);
+	g_free (gconf_str);
+    
+		
+    gconf_str = panel_applet_gconf_get_string (gw_applet->applet, GCONF_SPEED_UNIT, NULL);
+	parse_speed_string(gconf_str, prefs);
+	g_free (gconf_str);
+			
+    gconf_str = panel_applet_gconf_get_string (gw_applet->applet, GCONF_PRESSURE_UNIT, NULL);
+	parse_pressure_string(gconf_str, prefs);
+	g_free (gconf_str);
+
+    gconf_str = panel_applet_gconf_get_string (gw_applet->applet, GCONF_DISTANCE_UNIT, NULL);
+	parse_distance_string(gconf_str, prefs);
+	g_free (gconf_str);
+	
     return;
 }
 
@@ -869,4 +1264,3 @@ void gweather_pref_run (GWeatherApplet *
 
     
 }
-
Index: gweather.h
===================================================================
RCS file: /cvs/gnome/gnome-applets/gweather/gweather.h,v
retrieving revision 1.12
diff -p -u -u -r1.12 gweather.h
--- gweather.h	28 Feb 2004 06:26:51 -0000	1.12
+++ gweather.h	30 Apr 2004 05:09:42 -0000
@@ -26,15 +26,59 @@ typedef struct _GWeatherPrefs GWeatherPr
 typedef struct _WeatherInfo WeatherInfo;
 typedef struct _WeatherLocation WeatherLocation;
 
+typedef enum {
+    TEMP_UNIT_INVALID = 0,
+    TEMP_UNIT_DEFAULT,
+    TEMP_UNIT_FAHRENHEIT,
+    TEMP_UNIT_CENTIGRADE,
+    TEMP_UNIT_KELVIN
+} TempUnit;
+
+typedef enum {
+    SPEED_UNIT_INVALID = 0,
+    SPEED_UNIT_DEFAULT,
+    SPEED_UNIT_MPH,   /* miles per hour */
+    SPEED_UNIT_KNOTS, /* Knots */
+    SPEED_UNIT_KPH,   /* kilometres per hour */
+    SPEED_UNIT_MS     /* metres per second */
+} SpeedUnit;
+
+typedef enum {
+    PRESSURE_UNIT_INVALID = 0,
+    PRESSURE_UNIT_DEFAULT,
+	PRESSURE_UNIT_INCH_HG,
+    PRESSURE_UNIT_MM_HG,
+	PRESSURE_UNIT_HPA,   /* hectoPascal */
+	PRESSURE_UNIT_MB     /* 1 millibars = 1 hectoPascal */
+} PressureUnit;
+
+typedef enum {
+    DISTANCE_UNIT_INVALID = 0,
+    DISTANCE_UNIT_DEFAULT,
+    DISTANCE_UNIT_MILES,
+    DISTANCE_UNIT_KM,
+    DISTANCE_UNIT_METERS
+} DistanceUnit;
+
 struct _GWeatherPrefs {
     WeatherLocation *location;
     gint update_interval;  /* in seconds */
     gboolean update_enabled;
-    gboolean use_metric;
     gboolean detailed;
     gboolean radar_enabled;
     gboolean use_custom_radar_url;
     gchar *radar;
+	
+	TempUnit     temperature_unit;
+	gboolean     use_temperature_default;
+	SpeedUnit    speed_unit;
+	gboolean     use_speed_default;
+	PressureUnit pressure_unit;
+	gboolean     use_pressure_default;
+	DistanceUnit distance_unit;
+	gboolean     use_distance_default;
+	
+	gboolean use_metric;   /* no longer used */
 };
 
 struct _GWeatherApplet
@@ -61,6 +105,11 @@ struct _GWeatherApplet
 
 	GtkWidget *pref_basic_metric_btn;
 	GtkWidget *pref_basic_detailed_btn;
+	GtkWidget *pref_basic_temp_combo;
+    GtkWidget *pref_basic_speed_combo;
+    GtkWidget *pref_basic_dist_combo;
+    GtkWidget *pref_basic_pres_combo;
+	
 #ifdef RADARMAP
 	GtkWidget *pref_basic_radar_btn;
 	GtkWidget *pref_basic_radar_url_btn;
@@ -97,4 +146,3 @@ struct _GWeatherApplet
 G_END_DECLS
  
 #endif
-
Index: gweather.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-applets/gweather/gweather.schemas.in,v
retrieving revision 1.3
diff -p -u -u -r1.3 gweather.schemas.in
--- gweather.schemas.in	25 Jul 2003 01:28:54 -0000	1.3
+++ gweather.schemas.in	30 Apr 2004 05:09:42 -0000
@@ -32,6 +32,46 @@
 	</locale>
 </schema>
 <schema>
+	<key>/schemas/apps/gweather/prefs/distance_unit</key>
+	<owner>gweather-applet-2</owner>
+	<type>string</type>
+	<default>Default</default>
+	<locale name="C">
+		<short>Distance units</short>
+		<long>The unit to use for visibility.</long>
+	</locale>
+</schema>
+<schema>
+	<key>/schemas/apps/gweather/prefs/pressure_unit</key>
+	<owner>gweather-applet-2</owner>
+	<type>string</type>
+	<default>Default</default>
+	<locale name="C">
+		<short>Pressure units</short>
+		<long>The unit to use for pressure.</long>
+	</locale>
+</schema>
+<schema>
+	<key>/schemas/apps/gweather/prefs/speed_unit</key>
+	<owner>gweather-applet-2</owner>
+	<type>string</type>
+	<default>Default</default>
+	<locale name="C">
+		<short>Speed units</short>
+		<long>The unit to use for wind speed.</long>
+	</locale>
+</schema>
+<schema>
+	<key>/schemas/apps/gweather/prefs/temperature_unit</key>
+	<owner>gweather-applet-2</owner>
+	<type>string</type>
+	<default>Default</default>
+	<locale name="C">
+		<short>Temperature units</short>
+		<long>The temperature units to use.</long>
+	</locale>
+</schema>
+<schema>
 	<key>/schemas/apps/gweather/prefs/enable_detailed_forecast</key>
 	<owner>gweather-applet-2</owner>
 	<type>bool</type>
Index: weather.c
===================================================================
RCS file: /cvs/gnome/gnome-applets/gweather/weather.c,v
retrieving revision 1.75
diff -p -u -u -r1.75 weather.c
--- weather.c	25 Apr 2004 18:19:33 -0000	1.75
+++ weather.c	30 Apr 2004 05:09:43 -0000
@@ -50,19 +50,25 @@ static gboolean weather_radar = FALSE;
 /* Unit conversions and names */
 
 #define TEMP_F_TO_C(f)  (((f) - 32.0) * 0.555556)
+#define TEMP_F_TO_K(f)  (TEMP_F_TO_C(f) + 273.15)
 #define TEMP_C_TO_F(c)  (((c) * 1.8) + 32.0)
-#define TEMP_UNIT_STR(units)  (((units) == UNITS_IMPERIAL) ? "\302\260 F" : "\302\260 C")
+#define TEMP_UNIT_STR(units)  (((units) == UNITS_IMPERIAL) ? "\302\260F" : "\302\260 C")
 
 #define WINDSPEED_KNOTS_TO_KPH(knots)  ((knots) * 1.851965)
+#define WINDSPEED_KNOTS_TO_MPH(knots)  ((knots) * 1.150779)
+#define WINDSPEED_KNOTS_TO_MS(knots)   ((knots) * 0.514444)
 #define WINDSPEED_KPH_TO_KNOTS(kph)    ((kph) * 0.539967)
 #define WINDSPEED_UNIT_STR(units) (((units) == UNITS_IMPERIAL) ? _("knots") : _("kph"))
 
 #define PRESSURE_INCH_TO_HPA(inch)   ((inch) * 33.86)
+#define PRESSURE_INCH_TO_MM(inch)    ((inch) * 25.40005)
+#define PRESSURE_INCH_TO_MB(inch)    (PRESSURE_INCH_TO_HPA(inch))
 #define PRESSURE_HPA_TO_INCH(mm)     ((mm) / 33.86)
 #define PRESSURE_MBAR_TO_INCH(mbar) ((mbar) * 0.02963742)
 #define PRESSURE_UNIT_STR(units) (((units) == UNITS_IMPERIAL) ? _("inHg") : _("hPa"))
 
 #define VISIBILITY_SM_TO_KM(sm)  ((sm) * 1.609344)
+#define VISIBILITY_SM_TO_M(sm)   (VISIBILITY_SM_TO_KM(sm) * 1000)
 #define VISIBILITY_KM_TO_SM(km)  ((km) * 0.621371)
 #define VISIBILITY_UNIT_STR(units) (((units) == UNITS_IMPERIAL) ? _("miles") : _("kilometers"))
 
@@ -1965,42 +1971,139 @@ const gchar *weather_info_get_conditions
     return weather_conditions_string(info->cond);
 }
 
+static const gchar *temperature_string (gfloat far, TempUnit to_unit, gboolean round)
+{
+	static gchar buf[100];
+
+    switch (to_unit) {
+        case TEMP_UNIT_FAHRENHEIT:
+			if (!round) {
+                if ( strcmp (_("%.1f F"), "%.1f F") != 0 ) {
+                    /* TRANSLATOR: This is the temperature in degrees fahrenheit, use the degree */
+                    /* symbol Unicode 00B0 if possible */
+                    g_snprintf(buf, sizeof (buf), _("%.1f F"), far);
+                } else {
+                    g_snprintf(buf, sizeof (buf), "%.1f \302\260F", far);
+                }
+            } else {
+                if ( strcmp (_("%dF"), "%dF") != 0 ) {
+                    /* TRANSLATOR: This is the temperature in degrees fahrenheit, use the degree */
+                    /* symbol Unicode 00B0 if possible */
+                    g_snprintf(buf, sizeof (buf), _("%dF"), (int)floor(far + 0.5));
+                } else {
+                    g_snprintf(buf, sizeof (buf), "%d\302\260F", (int)floor(far + 0.5));
+                }
+            }
+            break;
+        case TEMP_UNIT_CENTIGRADE:
+            if (!round) {
+                if ( strcmp (_("%.1f C"), "%.1f C") != 0 ) {
+                    /* TRANSLATOR: This is the temperature in degrees centigrade , use the degree */
+                    /* symbol Unicode 00B0 if possible */
+                    g_snprintf (buf, sizeof (buf), _("%.1f C"), TEMP_F_TO_C(far));
+                } else { 
+                    g_snprintf (buf, sizeof (buf), "%.1f \302\260C", TEMP_F_TO_C(far));
+                }
+            } else {
+                if ( strcmp (_("%dC"), "%dC") != 0 ) {
+                    /* TRANSLATOR: This is the temperature in degrees centigrade , use the degree */
+                    /* symbol Unicode 00B0 if possible */
+                    g_snprintf (buf, sizeof (buf), _("%dC"), (int)floor(TEMP_F_TO_C(far) + 0.5));
+                } else { 
+                    g_snprintf (buf, sizeof (buf), "%d\302\260C", (int)floor(TEMP_F_TO_C(far) + 0.5));
+				}
+            }
+            break;
+        case TEMP_UNIT_KELVIN:
+            if (!round) {
+                /* TRANSLATOR: This is the temperature in Kelvin */
+                g_snprintf (buf, sizeof (buf), _("%.1f K"), TEMP_F_TO_K(far));
+            } else {
+                /* TRANSLATOR: This is the temperature in Kelvin */
+                g_snprintf (buf, sizeof (buf), _("%dK"), (int)floor(TEMP_F_TO_K(far)));
+            } 
+            break;
+
+        case TEMP_UNIT_INVALID:
+        case TEMP_UNIT_DEFAULT:
+        default:
+            g_warning("Conversion to illegal temperature unit: %d", to_unit);
+            return (_("Unknown"));
+            break;
+    }
+
+    return buf;
+}
+
 const gchar *weather_info_get_temp (WeatherInfo *info)
 {
-    static gchar buf[10];
     g_return_val_if_fail(info != NULL, NULL);
+
     if (!info->valid)
         return "-";
     if (info->temp < -500.0)
         return _("Unknown");
-    g_snprintf(buf, sizeof (buf), "%.1f%s", info->temp, TEMP_UNIT_STR(info->units));
-    return buf;
+    
+    return temperature_string (info->temp, info->applet->gweather_pref.temperature_unit, FALSE);
 }
 
 const gchar *weather_info_get_dew (WeatherInfo *info)
 {
-    static gchar buf[10];
     g_return_val_if_fail(info != NULL, NULL);
+
     if (!info->valid)
         return "-";
     if (info->dew < -500.0)
         return _("Unknown");
-    g_snprintf(buf, sizeof (buf), "%.1f%s", info->dew, TEMP_UNIT_STR(info->units));
-    return buf;
+
+    return temperature_string (info->dew, info->applet->gweather_pref.temperature_unit, FALSE);
 }
 
 const gchar *weather_info_get_humidity (WeatherInfo *info)
 {
-    static gchar buf[10];
+    static gchar buf[20];
     g_return_val_if_fail(info != NULL, NULL);
     if (!info->valid)
         return "-";
     if (info->humidity < 0.0)
         return _("Unknown");
-    g_snprintf(buf, sizeof (buf), "%d%%", info->humidity);
+
+    /* TRANSLATOR: This is the humidity in percent */
+    g_snprintf(buf, sizeof (buf), _("%d%%"), info->humidity);
     return buf;
 }
 
+static const gchar *windspeed_string (gfloat knots, SpeedUnit to_unit)
+{
+    static gchar buf[100];
+
+    switch (to_unit) {
+        case SPEED_UNIT_KNOTS:
+            /* TRANSLATOR: This is the wind speed in knots */
+            g_snprintf(buf, sizeof (buf), _("%0.1f knots"), knots);
+            break;
+        case SPEED_UNIT_MPH:
+            /* TRANSLATOR: This is the wind speed in miles per hour */
+            g_snprintf(buf, sizeof (buf), _("%.1f mph"), WINDSPEED_KNOTS_TO_MPH(knots));
+            break;
+        case SPEED_UNIT_KPH:
+            /* TRANSLATOR: This is the wind speed in kilometers per hour */
+            g_snprintf(buf, sizeof (buf), _("%.1f kph"), WINDSPEED_KNOTS_TO_KPH(knots));
+            break;
+        case SPEED_UNIT_MS:
+            /* TRANSLATOR: This is the wind speed in miles per hour */
+            g_snprintf(buf, sizeof (buf), _("%.1f m/s"), WINDSPEED_KNOTS_TO_MS(knots));
+            break;
+
+        case SPEED_UNIT_INVALID:
+        case SPEED_UNIT_DEFAULT:
+        default:
+            g_warning("Conversion to illegal speed unit: %d", to_unit);
+            return _("Unknown");
+    }
+
+    return buf;
+}
 const gchar *weather_info_get_wind (WeatherInfo *info)
 {
     static gchar buf[200];
@@ -2013,9 +2116,10 @@ const gchar *weather_info_get_wind (Weat
         strncpy(buf, _("Calm"), sizeof(buf));
 	buf[sizeof(buf)-1] = '\0';
     } else
-        g_snprintf(buf, sizeof(buf), "%s / %d %s",
+        /* TRANSLATOR: This is 'wind direction' / 'wind speed' */
+        g_snprintf(buf, sizeof(buf), _("%s / %s"),
 		   weather_wind_direction_string(info->wind),
-		   info->windspeed, WINDSPEED_UNIT_STR(info->units));
+		   windspeed_string(info->windspeed, info->applet->gweather_pref.speed_unit));
     return buf;
 }
 
@@ -2027,7 +2131,32 @@ const gchar *weather_info_get_pressure (
         return "-";
     if (info->pressure < 0.0)
         return _("Unknown");
-    g_snprintf(buf, sizeof (buf), "%.2f %s", info->pressure, PRESSURE_UNIT_STR(info->units));
+
+    switch (info->applet->gweather_pref.pressure_unit) {
+        case PRESSURE_UNIT_INCH_HG:
+            /* TRANSLATOR: This is pressure in inches of mercury */
+            g_snprintf (buf, sizeof (buf), _("%.2f inHg"), info->pressure);
+            break;
+        case PRESSURE_UNIT_MM_HG:
+            /* TRANSLATOR: This is pressure in millimeters of mercury */
+            g_snprintf (buf, sizeof (buf), _("%.1f mmHg"), PRESSURE_INCH_TO_MM(info->pressure));
+            break;
+        case PRESSURE_UNIT_HPA:
+            /* TRANSLATOR: This is pressure in hectoPascals */
+            g_snprintf (buf, sizeof (buf), _("%.2f hPa"), PRESSURE_INCH_TO_HPA(info->pressure));
+            break;
+        case PRESSURE_UNIT_MB:
+            /* TRANSLATOR: This is pressure in millibars */
+            g_snprintf (buf, sizeof (buf), _("%.2f mb"), PRESSURE_INCH_TO_MB(info->pressure));
+            break;
+
+        case PRESSURE_UNIT_INVALID:
+        case PRESSURE_UNIT_DEFAULT:
+        default:
+            g_warning("Conversion to illegal pressure unit: %d", info->applet->gweather_pref.pressure_unit);
+            return _("Unknown");
+    }
+
     return buf;
 }
 
@@ -2039,7 +2168,28 @@ const gchar *weather_info_get_visibility
         return "-";
     if (info->visibility < 0.0)
         return _("Unknown");
-    g_snprintf(buf, sizeof (buf), "%.1f %s", info->visibility, VISIBILITY_UNIT_STR(info->units));
+
+    switch (info->applet->gweather_pref.distance_unit) {
+        case DISTANCE_UNIT_MILES:
+            /* TRANSLATOR: This is the visibility in miles */
+            g_snprintf(buf, sizeof (buf), _("%.1f miles"), info->visibility);
+            break;
+        case DISTANCE_UNIT_KM:
+            /* TRANSLATOR: This is the visibility in kilometers */
+            g_snprintf(buf, sizeof (buf), _("%.1f km"), VISIBILITY_SM_TO_KM(info->visibility));
+            break;
+        case DISTANCE_UNIT_METERS:
+            /* TRANSLATOR: This is the visibility in meters */
+            g_snprintf(buf, sizeof (buf), _("%.0fm"), VISIBILITY_SM_TO_M(info->visibility));
+            break;
+
+        case DISTANCE_UNIT_INVALID:
+        case DISTANCE_UNIT_DEFAULT:
+        default:
+            g_warning("Conversion to illegal visibility unit: %d", info->applet->gweather_pref.pressure_unit);
+            return _("Unknown");
+    }
+
     return buf;
 }
 
@@ -2057,25 +2207,13 @@ GdkPixmap *weather_info_get_radar (Weath
 
 const gchar *weather_info_get_temp_summary (WeatherInfo *info)
 {
-    static gchar buf[10];
-    const gchar *degree="h";
-    
     if (!info)
         return NULL;
     if (!info->valid || info->temp < -500.0)
         return "--";
+          
+    return temperature_string (info->temp, info->applet->gweather_pref.temperature_unit, TRUE);
     
-    if (!info->applet)
-      degree = "F";
-    else if (info->applet->gweather_pref.use_metric)                                   
-      degree = "C";                                               
-    else                                                                    
-      degree = "F";
-      
-   g_snprintf(buf, sizeof (buf), "%d\302\260%s",
-	      (int)floor(info->temp + 0.5), degree);
-    
-    return buf;
 }
 
 gchar *weather_info_get_weather_summary (WeatherInfo *info)
@@ -2259,6 +2397,3 @@ void _weather_info_get_pixbuf (WeatherIn
 
     *pixbuf = pixbufs[idx];
 }
-
-
-
