diff options
author | David Trowbridge <trowbrds@cs.colorado.edu> | 2005-01-12 15:22:49 +0800 |
---|---|---|
committer | David Trowbridge <trowbrds@src.gnome.org> | 2005-01-12 15:22:49 +0800 |
commit | a7fe81b508b9119ba60301fc5670bf98b9b8b8c7 (patch) | |
tree | 399e994cb40c1a0cb43c0f3fbd96ae05a7472d2f | |
parent | 06091a255ef2fdbdf44629078b93c11b02e1aa31 (diff) | |
download | gsoc2013-evolution-a7fe81b508b9119ba60301fc5670bf98b9b8b8c7.tar.gz gsoc2013-evolution-a7fe81b508b9119ba60301fc5670bf98b9b8b8c7.tar.zst gsoc2013-evolution-a7fe81b508b9119ba60301fc5670bf98b9b8b8c7.zip |
use a single setting for metric/imperial rather than separate temperature
2005-01-12 David Trowbridge <trowbrds@cs.colorado.edu>
* 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
-rw-r--r-- | plugins/calendar-weather/ChangeLog | 6 | ||||
-rw-r--r-- | plugins/calendar-weather/calendar-weather.c | 126 | ||||
-rw-r--r-- | plugins/calendar-weather/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 <trowbrds@cs.colorado.edu> + + * 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 <rodrigo@novell.com> * 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"/> <item type="item_table" - path="00.general/00.source/50.tempFormat" + path="00.general/00.source/50.units" factory="e_calendar_weather_temperature"/> <item type="item_table" - path="00.general/00.source/60.snowfallFormat" - factory="e_calendar_weather_snowfall"/> - <item - type="item_table" - path="00.general/00.source/70.refresh" + path="00.general/00.source/60.refresh" factory="e_calendar_weather_refresh"/> </group> </hook> |