From a7fe81b508b9119ba60301fc5670bf98b9b8b8c7 Mon Sep 17 00:00:00 2001 From: David Trowbridge Date: Wed, 12 Jan 2005 07:22:49 +0000 Subject: use a single setting for metric/imperial rather than separate temperature 2005-01-12 David Trowbridge * plugins/calendar-weather/(calendar-weather.c, org-gnome-calendar-weather.eplug.in): use a single setting for metric/imperial rather than separate temperature and snowfall settings svn path=/trunk/; revision=28369 --- plugins/calendar-weather/ChangeLog | 6 + plugins/calendar-weather/calendar-weather.c | 126 +++++---------------- .../org-gnome-calendar-weather.eplug.in | 8 +- 3 files changed, 38 insertions(+), 102 deletions(-) diff --git a/plugins/calendar-weather/ChangeLog b/plugins/calendar-weather/ChangeLog index bc2073c6d1..3f8a1044d5 100644 --- a/plugins/calendar-weather/ChangeLog +++ b/plugins/calendar-weather/ChangeLog @@ -1,3 +1,9 @@ +2005-01-12 David Trowbridge + + * calendar-weather.c, org-gnome-calendar-weather.eplug.in: use + a single setting for metric/imperial rather than separate + temperature and snowfall settings + 2005-01-10 Rodrigo Moya * calendar-weather.c (create_source_selected): use HIG-compliant diff --git a/plugins/calendar-weather/calendar-weather.c b/plugins/calendar-weather/calendar-weather.c index 6579b1f470..5009ee5484 100644 --- a/plugins/calendar-weather/calendar-weather.c +++ b/plugins/calendar-weather/calendar-weather.c @@ -34,8 +34,7 @@ GtkWidget *e_calendar_weather_location (EPlugin *epl, EConfigHookItemFactoryData *data); GtkWidget *e_calendar_weather_refresh (EPlugin *epl, EConfigHookItemFactoryData *data); -GtkWidget *e_calendar_weather_temperature (EPlugin *epl, EConfigHookItemFactoryData *data); -GtkWidget *e_calendar_weather_snowfall (EPlugin *epl, EConfigHookItemFactoryData *data); +GtkWidget *e_calendar_weather_units (EPlugin *epl, EConfigHookItemFactoryData *data); gboolean e_calendar_weather_check (EPlugin *epl, EConfigHookPageCheckData *data); void e_calendar_weather_migrate (EPlugin *epl, ECalEventTargetComponent *data); int e_plugin_lib_enable (EPluginLib *epl, int enable); @@ -587,107 +586,42 @@ e_calendar_weather_refresh (EPlugin *epl, EConfigHookItemFactoryData *data) } static void -set_temperature_units (ESource *source, GtkWidget *option) +set_units (ESource *source, GtkWidget *option) { - const char *format = e_source_get_property (source, "temperature"); - if (format == NULL) - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); - else if (strcmp (format, "fahrenheit") == 0) - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 1); - else - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); -} - -static void -temperature_units_changed (GtkOptionMenu *option, ECalConfigTargetSource *t) -{ - int choice = gtk_option_menu_get_history (GTK_OPTION_MENU (option)); - if (choice == 0) - e_source_set_property (t->source, "temperature", "celcius"); - else - e_source_set_property (t->source, "temperature", "fahrenheit"); -} - -GtkWidget * -e_calendar_weather_temperature (EPlugin *epl, EConfigHookItemFactoryData *data) -{ - static GtkWidget *label; - GtkWidget *option, *menu, *parent; - GtkWidget *formats[2]; - int row, i; - ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target; - ESource *source = t->source; - EUri *uri; - char *uri_text; - static GtkWidget *hidden = NULL; - - if (!hidden) - hidden = gtk_label_new (""); - - if (data->old) - gtk_widget_destroy (label); - - uri_text = e_source_get_uri (t->source); - uri = e_uri_new (uri_text); - g_free (uri_text); - if (strcmp (uri->protocol, "weather")) { - e_uri_free (uri); - return hidden; - } - e_uri_free (uri); - - parent = data->parent; - - row = ((GtkTable*)parent)->nrows; - - label = gtk_label_new_with_mnemonic (_("_Temperature Units:")); - gtk_widget_show (label); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0); - - option = gtk_option_menu_new (); - gtk_widget_show (option); - formats[0] = gtk_menu_item_new_with_label (_("Celcius")); - formats[1] = gtk_menu_item_new_with_label (_("Fahrenheit")); - menu = gtk_menu_new (); - gtk_widget_show (menu); - for (i = 0; i < 2; i++) { - gtk_widget_show (formats[i]); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), formats[i]); + const char *format = e_source_get_property (source, "units"); + if (format == NULL) { + format = e_source_get_property (source, "temperature"); + if (format == NULL) { + e_source_set_property (source, "units", "metric"); + gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); + } else if (strcmp (format, "fahrenheit") == 0) { + /* old format, convert */ + e_source_set_property (source, "units", "imperial"); + gtk_option_menu_set_history (GTK_OPTION_MENU (option), 1); + } else { + e_source_set_property (source, "units", "metric"); + gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); + } + } else { + if (strcmp (format, "metric") == 0) + gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); + else + gtk_option_menu_set_history (GTK_OPTION_MENU (option), 1); } - gtk_option_menu_set_menu (GTK_OPTION_MENU (option), menu); - set_temperature_units (source, option); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), option); - g_signal_connect (G_OBJECT (option), "changed", G_CALLBACK (temperature_units_changed), t); - gtk_table_attach (GTK_TABLE (parent), option, 1, 2, row, row+1, GTK_FILL, 0, 0, 0); - - return option; -} - -static void -set_snowfall_units (ESource *source, GtkWidget *option) -{ - const char *format = e_source_get_property (source, "snowfall"); - if (format == NULL) - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); - else if (strcmp (format, "inches") == 0) - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 1); - else - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); } static void -snowfall_units_changed (GtkOptionMenu *option, ECalConfigTargetSource *t) +units_changed (GtkOptionMenu *option, ECalConfigTargetSource *t) { int choice = gtk_option_menu_get_history (GTK_OPTION_MENU (option)); if (choice == 0) - e_source_set_property (t->source, "snowfall", "centimeters"); + e_source_set_property (t->source, "units", "metric"); else - e_source_set_property (t->source, "snowfall", "inches"); + e_source_set_property (t->source, "units", "imperial"); } GtkWidget * -e_calendar_weather_snowfall (EPlugin *epl, EConfigHookItemFactoryData *data) +e_calendar_weather_units (EPlugin *epl, EConfigHookItemFactoryData *data) { static GtkWidget *label; GtkWidget *option, *menu, *parent; @@ -718,15 +652,15 @@ e_calendar_weather_snowfall (EPlugin *epl, EConfigHookItemFactoryData *data) row = ((GtkTable*)parent)->nrows; - label = gtk_label_new_with_mnemonic (_("_Snowfall Units:")); + label = gtk_label_new_with_mnemonic (_("_Units:")); gtk_widget_show (label); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0); option = gtk_option_menu_new (); gtk_widget_show (option); - formats[0] = gtk_menu_item_new_with_label (_("Centimeters")); - formats[1] = gtk_menu_item_new_with_label (_("Inches")); + formats[0] = gtk_menu_item_new_with_label (_("Metric (celcius, cm, etc)")); + formats[1] = gtk_menu_item_new_with_label (_("Imperial (fahrenheit, inches, etc)")); menu = gtk_menu_new (); gtk_widget_show (menu); for (i = 0; i < 2; i++) { @@ -734,9 +668,9 @@ e_calendar_weather_snowfall (EPlugin *epl, EConfigHookItemFactoryData *data) gtk_menu_shell_append (GTK_MENU_SHELL (menu), formats[i]); } gtk_option_menu_set_menu (GTK_OPTION_MENU (option), menu); - set_snowfall_units (source, option); + set_units (source, option); gtk_label_set_mnemonic_widget (GTK_LABEL (label), option); - g_signal_connect (G_OBJECT (option), "changed", G_CALLBACK (snowfall_units_changed), t); + g_signal_connect (G_OBJECT (option), "changed", G_CALLBACK (units_changed), t); gtk_table_attach (GTK_TABLE (parent), option, 1, 2, row, row+1, GTK_FILL, 0, 0, 0); return option; diff --git a/plugins/calendar-weather/org-gnome-calendar-weather.eplug.in b/plugins/calendar-weather/org-gnome-calendar-weather.eplug.in index 9a9357d0b9..977630ad15 100644 --- a/plugins/calendar-weather/org-gnome-calendar-weather.eplug.in +++ b/plugins/calendar-weather/org-gnome-calendar-weather.eplug.in @@ -18,15 +18,11 @@ factory="e_calendar_weather_location"/> - -- cgit v1.2.3