[Xfce4-commits] <xfce4-weather-plugin:master> Rename "Measurement unit" to "System of Measurement".

Harald Judt noreply at xfce.org
Fri Jul 13 16:50:13 CEST 2012


Updating branch refs/heads/master
         to 28061e3f51c503709ee4e014416ddfe346ab207e (commit)
       from b19a7542f00ad783666a9efe9d1985d7d82fa62b (commit)

commit 28061e3f51c503709ee4e014416ddfe346ab207e
Author: Harald Judt <h.judt at gmx.at>
Date:   Wed Jul 11 16:20:57 2012 +0200

    Rename "Measurement unit" to "System of Measurement".
    
    We're switching between systems of units, make this description
    more clear and exact.
    
    Rename all variables and texts accordingly.

 panel-plugin/weather-config.c    |   20 ++++++++++----------
 panel-plugin/weather-config.h    |    2 +-
 panel-plugin/weather-data.c      |   32 ++++++++++++++++----------------
 panel-plugin/weather-data.h      |    6 +++---
 panel-plugin/weather-summary.c   |   37 ++++++++++++++++++-------------------
 panel-plugin/weather-translate.c |    6 +++---
 panel-plugin/weather-translate.h |    4 ++--
 panel-plugin/weather.c           |   22 +++++++++++-----------
 panel-plugin/weather.h           |    2 +-
 9 files changed, 65 insertions(+), 66 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 72641c3..53b6052 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -168,12 +168,12 @@ apply_options (xfceweather_dialog *dialog)
 
   xfceweather_data *data = (xfceweather_data *) dialog->wd;
 
-  history = gtk_option_menu_get_history (GTK_OPTION_MENU (dialog->opt_unit));
+  history = gtk_option_menu_get_history (GTK_OPTION_MENU (dialog->opt_unit_system));
 
   if (history == 0)
-    data->unit = IMPERIAL;
+    data->unit_system = IMPERIAL;
   else
-    data->unit = METRIC;
+    data->unit_system = METRIC;
 
   if (data->lat)
     g_free (data->lat);
@@ -375,26 +375,26 @@ create_config_dialog (xfceweather_data *data,
   dialog->wd = (xfceweather_data *) data;
   dialog->dialog = gtk_widget_get_toplevel (vbox);
 
-  label = gtk_label_new (_("Measurement unit:"));
+  label = gtk_label_new (_("System of Measurement:"));
   gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
   menu = gtk_menu_new ();
-  dialog->opt_unit = gtk_option_menu_new ();
+  dialog->opt_unit_system = gtk_option_menu_new ();
 
   gtk_menu_shell_append ((GtkMenuShell *) (GTK_MENU (menu)),
                          (gtk_menu_item_new_with_label (_("Imperial"))));
   gtk_menu_shell_append ((GtkMenuShell *) (GTK_MENU (menu)),
                          (gtk_menu_item_new_with_label (_("Metric"))));
-  gtk_option_menu_set_menu (GTK_OPTION_MENU (dialog->opt_unit), menu);
+  gtk_option_menu_set_menu (GTK_OPTION_MENU (dialog->opt_unit_system), menu);
 
-  if (dialog->wd->unit == IMPERIAL)
-    gtk_option_menu_set_history (GTK_OPTION_MENU (dialog->opt_unit), 0);
+  if (dialog->wd->unit_system == IMPERIAL)
+    gtk_option_menu_set_history (GTK_OPTION_MENU (dialog->opt_unit_system), 0);
   else
-    gtk_option_menu_set_history (GTK_OPTION_MENU (dialog->opt_unit), 1);
+    gtk_option_menu_set_history (GTK_OPTION_MENU (dialog->opt_unit_system), 1);
   gtk_size_group_add_widget (sg, label);
 
   hbox = gtk_hbox_new (FALSE, BORDER);
   gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (hbox), dialog->opt_unit, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), dialog->opt_unit_system, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
 
diff --git a/panel-plugin/weather-config.h b/panel-plugin/weather-config.h
index b5b3f16..a7eaf9f 100644
--- a/panel-plugin/weather-config.h
+++ b/panel-plugin/weather-config.h
@@ -30,7 +30,7 @@ labeloption;
 typedef struct
 {
   GtkWidget        *dialog;
-  GtkWidget        *opt_unit;
+  GtkWidget        *opt_unit_system;
   GtkWidget        *txt_lat;
   GtkWidget        *txt_lon;
   GtkWidget        *txt_loc_name;
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index e34b1cf..ed99b0f 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -40,7 +40,7 @@ gboolean has_timeslice(xml_weather *data, time_t start_t, time_t end_t)
 }
 
 gchar *
-get_data (xml_time *timeslice, units unit, datas type)
+get_data (xml_time *timeslice, unit_systems unit_system, datas type)
 {
 	const xml_location *loc = NULL;
 	double val;
@@ -52,7 +52,7 @@ get_data (xml_time *timeslice, units unit, datas type)
 
 	switch(type) {
 	case ALTITUDE:
-		if (unit == METRIC)
+		if (unit_system == METRIC)
 			return LOCALE_DOUBLE(loc->altitude, "%.0f");
 		val = g_ascii_strtod(loc->altitude, NULL);
 		val /= 0.3048;
@@ -63,26 +63,26 @@ get_data (xml_time *timeslice, units unit, datas type)
 		return LOCALE_DOUBLE(loc->longitude, "%.4f");
 	case TEMPERATURE:
 		val = g_ascii_strtod(loc->temperature_value, NULL);
-		if (unit == IMPERIAL
+		if (unit_system == IMPERIAL
 			&& (strcmp(loc->temperature_unit, "celcius") == 0
 				|| strcmp(loc->temperature_unit, "celsius" == 0)))
 			val = val * 9.0 / 5.0 + 32.0;
-		else if (unit == METRIC
+		else if (unit_system == METRIC
 				 && strcmp(loc->temperature_unit, "fahrenheit") == 0)
 			val = (val - 32.0) * 5.0 / 9.0;
 		return g_strdup_printf ("%.1f", val);
 	case PRESSURE:
-		if (unit == METRIC)
+		if (unit_system == METRIC)
 			return LOCALE_DOUBLE(loc->pressure_value, "%.1f");
 		val = g_ascii_strtod(loc->pressure_value, NULL);
-		if (unit == IMPERIAL)
+		if (unit_system == IMPERIAL)
 			val *= 0.01450378911491;
 		return g_strdup_printf("%.1f", val);
 	case WIND_SPEED:
 		val = g_ascii_strtod(loc->wind_speed_mps, NULL);
-		if (unit == IMPERIAL)
+		if (unit_system == IMPERIAL)
 			val *= 2.2369362920544;
-		else if (unit == METRIC)
+		else if (unit_system == METRIC)
 			val *= 3.6;
 		return g_strdup_printf("%.1f", val);
 	case WIND_BEAUFORT:
@@ -104,10 +104,10 @@ get_data (xml_time *timeslice, units unit, datas type)
 	case FOG:
 		return LOCALE_DOUBLE(loc->fog_percent, "%.1f");
 	case PRECIPITATIONS:
-		if (unit == METRIC)
+		if (unit_system == METRIC)
 			return LOCALE_DOUBLE(loc->precipitation_value, "%.1f");
 		val = g_ascii_strtod(loc->precipitation_value, NULL);
-		if (unit == IMPERIAL)
+		if (unit_system == IMPERIAL)
 			val /= 25.4;
 		return g_strdup_printf("%.3f", val);
 	case SYMBOL:
@@ -117,7 +117,7 @@ get_data (xml_time *timeslice, units unit, datas type)
 }
 
 const gchar *
-get_unit (xml_time *timeslice, units unit, datas type)
+get_unit (xml_time *timeslice, unit_systems unit_system, datas type)
 {
 	const xml_location *loc = NULL;
 
@@ -128,13 +128,13 @@ get_unit (xml_time *timeslice, units unit, datas type)
 
 	switch(type) {
 	case ALTITUDE:
-		return (unit == IMPERIAL) ? _("ft") : _("m");
+		return (unit_system == IMPERIAL) ? _("ft") : _("m");
 	case TEMPERATURE:
-		return (unit == IMPERIAL) ? _("°F") : _("°C");
+		return (unit_system == IMPERIAL) ? _("°F") : _("°C");
 	case PRESSURE:
-		return (unit == IMPERIAL) ? _("psi") : _("hPa");
+		return (unit_system == IMPERIAL) ? _("psi") : _("hPa");
 	case WIND_SPEED:
-		return (unit == IMPERIAL) ? _("mph") : _("km/h");
+		return (unit_system == IMPERIAL) ? _("mph") : _("km/h");
 	case WIND_DIRECTION_DEG:
 	case LATITUDE:
 	case LONGITUDE:
@@ -147,7 +147,7 @@ get_unit (xml_time *timeslice, units unit, datas type)
 	case FOG:
 		return "%";
 	case PRECIPITATIONS:
-		return (unit == IMPERIAL) ? _("in") : _("mm");
+		return (unit_system == IMPERIAL) ? _("in") : _("mm");
 	case SYMBOL:
 	case WIND_BEAUFORT:
 	case WIND_DIRECTION:
diff --git a/panel-plugin/weather-data.h b/panel-plugin/weather-data.h
index 5223abc..d443458 100644
--- a/panel-plugin/weather-data.h
+++ b/panel-plugin/weather-data.h
@@ -43,7 +43,7 @@ typedef enum {
 typedef enum {
 	IMPERIAL,
 	METRIC
-} units;
+} unit_systems;
 
 typedef enum {
 	MORNING,
@@ -53,9 +53,9 @@ typedef enum {
 } daytime;
 
 gchar *
-get_data (xml_time *timeslice, units unit, datas type);
+get_data (xml_time *timeslice, unit_systems unit_system, datas type);
 const gchar *
-get_unit (xml_time *timeslice, units unit, datas type);
+get_unit (xml_time *timeslice, unit_systems unit_system, datas type);
 gboolean
 is_night_time();
 time_t
diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index 2906ecc..f3780a8 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -41,8 +41,8 @@ static gboolean lnk_clicked (GtkTextTag *tag, GObject *obj,
 #define APPEND_TEXT_ITEM_REAL(text)      gtk_text_buffer_insert(GTK_TEXT_BUFFER(buffer), \
                                                                 &iter, text, -1);\
                                          g_free (value);
-#define APPEND_TEXT_ITEM(text, item)     rawvalue = get_data(conditions, data->unit, item); \
-                                         unit = get_unit(conditions, data->unit, item); \
+#define APPEND_TEXT_ITEM(text, item)     rawvalue = get_data(conditions, data->unit_system, item); \
+                                         unit = get_unit(conditions, data->unit_system, item); \
                                          value = g_strdup_printf("\t%s%s%s%s%s\n", \
                                                                  text, text ? ": " : "", \
                                                                  rawvalue, \
@@ -306,22 +306,22 @@ create_summary_tab (xfceweather_data *data)
 
   /* Wind */
   APPEND_BTEXT (_("\nWind\n"));
-  rawvalue = get_data (conditions, data->unit, WIND_SPEED);
-  wind = translate_wind_speed (conditions, rawvalue, data->unit);
+  rawvalue = get_data (conditions, data->unit_system, WIND_SPEED);
+  wind = translate_wind_speed (conditions, rawvalue, data->unit_system);
   g_free (rawvalue);
-  rawvalue = get_data (conditions, data->unit, WIND_BEAUFORT);
+  rawvalue = get_data (conditions, data->unit_system, WIND_BEAUFORT);
   value = g_strdup_printf (_("\t%s: %s (%s on the Beaufort scale)\n"), _("Speed"), wind, rawvalue);
   g_free (rawvalue);
   g_free (wind);
   APPEND_TEXT_ITEM_REAL (value);
 
-  rawvalue = get_data (conditions, data->unit, WIND_DIRECTION);
+  rawvalue = get_data (conditions, data->unit_system, WIND_DIRECTION);
   wind = translate_wind_direction (rawvalue);
   g_free (rawvalue);
-  rawvalue = get_data (conditions, data->unit, WIND_DIRECTION_DEG);
+  rawvalue = get_data (conditions, data->unit_system, WIND_DIRECTION_DEG);
   value = g_strdup_printf ("\t%s: %s (%s%s)\n", _("Direction"),
                            wind, rawvalue,
-                           get_unit (conditions, data->unit, WIND_DIRECTION_DEG));
+                           get_unit (conditions, data->unit_system, WIND_DIRECTION_DEG));
   g_free (rawvalue);
   g_free (wind);
   APPEND_TEXT_ITEM_REAL (value);
@@ -399,8 +399,7 @@ add_forecast_header(gchar *text, gdouble angle, GdkColor *color)
 }
 
 static GtkWidget *
-make_forecast (xfceweather_data *data,
-               units     unit)
+make_forecast (xfceweather_data *data)
 {
     GtkWidget *table, *ebox, *box, *align;
     GtkWidget *forecast_box, *label, *image;
@@ -470,7 +469,7 @@ make_forecast (xfceweather_data *data,
             fcdata = make_forecast_data(data->weatherdata, i, daytime);
             if (fcdata != NULL) {
                 if (fcdata->location != NULL) {
-                    rawvalue = get_data(fcdata, data->unit, SYMBOL);
+                    rawvalue = get_data(fcdata, data->unit_system, SYMBOL);
                     icon = get_icon(rawvalue, 48, (daytime == NIGHT));
                     g_free(rawvalue);
                     image = gtk_image_new_from_pixbuf(icon);
@@ -479,7 +478,7 @@ make_forecast (xfceweather_data *data,
                     if (G_LIKELY (icon))
                         g_object_unref (G_OBJECT (icon));
 
-                    rawvalue = get_data(fcdata, data->unit, SYMBOL);
+                    rawvalue = get_data(fcdata, data->unit_system, SYMBOL);
                     value = g_strdup_printf("%s",
                                             translate_desc(rawvalue,
                                                            (daytime == NIGHT)));
@@ -491,10 +490,10 @@ make_forecast (xfceweather_data *data,
                                         TRUE, TRUE, 0);
                     g_free(value);
 
-                    rawvalue = get_data(fcdata, data->unit, TEMPERATURE);
+                    rawvalue = get_data(fcdata, data->unit_system, TEMPERATURE);
                     value = g_strdup_printf("%s %s",
                                             rawvalue,
-                                            get_unit(fcdata, data->unit, TEMPERATURE));
+                                            get_unit(fcdata, data->unit_system, TEMPERATURE));
                     g_free(rawvalue);
                     label = gtk_label_new(value);
                     gtk_widget_show(GTK_WIDGET(label));
@@ -502,12 +501,12 @@ make_forecast (xfceweather_data *data,
                                         TRUE, TRUE, 0);
                     g_free(value);
 
-                    rawvalue = get_data(fcdata, data->unit, WIND_DIRECTION);
-                    wind_speed = get_data(fcdata, data->unit, WIND_SPEED);
+                    rawvalue = get_data(fcdata, data->unit_system, WIND_DIRECTION);
+                    wind_speed = get_data(fcdata, data->unit_system, WIND_SPEED);
                     value = g_strdup_printf("%s %s %s",
                                             translate_wind_direction(rawvalue),
                                             wind_speed,
-                                            get_unit(fcdata, data->unit, WIND_SPEED));
+                                            get_unit(fcdata, data->unit_system, WIND_SPEED));
                     g_free(wind_speed);
                     g_free(rawvalue);
                     label = gtk_label_new(value);
@@ -537,7 +536,7 @@ create_forecast_tab (xfceweather_data *data)
   gtk_container_set_border_width (GTK_CONTAINER (align), 6);
   if (data->weatherdata)
     gtk_container_add(GTK_CONTAINER(align),
-                      GTK_WIDGET(make_forecast (data, data->unit)));
+                      GTK_WIDGET(make_forecast (data)));
   return align;
 }
 
@@ -579,7 +578,7 @@ create_summary_window (xfceweather_data *data)
 
   conditions = get_current_conditions(data->weatherdata);
 
-  rawvalue = get_data (conditions, data->unit, SYMBOL);
+  rawvalue = get_data (conditions, data->unit_system, SYMBOL);
   icon = get_icon (rawvalue, 48, is_night_time());
   g_free (rawvalue);
 
diff --git a/panel-plugin/weather-translate.c b/panel-plugin/weather-translate.c
index 97a0ecf..6b70efd 100644
--- a/panel-plugin/weather-translate.c
+++ b/panel-plugin/weather-translate.c
@@ -466,9 +466,9 @@ translate_wind_direction (const gchar *wdir)
 
 /* calm or a number */
 gchar *
-translate_wind_speed (xml_time *timeslice,
+translate_wind_speed (xml_time    *timeslice,
                       const gchar *wspeed,
-                      units        unit)
+                      unit_systems unit_system)
 {
   gchar *wspeed_loc;
 
@@ -478,7 +478,7 @@ translate_wind_speed (xml_time *timeslice,
     wspeed_loc = g_strdup (_("N/A"));
   else {
     wspeed_loc =
-      g_strdup_printf ("%s %s", wspeed, get_unit (timeslice, unit, WIND_SPEED));
+      g_strdup_printf ("%s %s", wspeed, get_unit (timeslice, unit_system, WIND_SPEED));
   }
 
   return wspeed_loc;
diff --git a/panel-plugin/weather-translate.h b/panel-plugin/weather-translate.h
index a8b1adf..5f24881 100644
--- a/panel-plugin/weather-translate.h
+++ b/panel-plugin/weather-translate.h
@@ -36,11 +36,11 @@ gchar *translate_day (gint);
 
 gchar *translate_wind_direction (const gchar *);
 
-gchar *translate_wind_speed (xml_time *, const gchar *, units);
+gchar *translate_wind_speed (xml_time *, const gchar *, unit_systems);
 
 gchar *translate_time (const gchar *);
 
-gchar *translate_visibility (const gchar *, units);
+gchar *translate_visibility (const gchar *, unit_systems);
 
 G_END_DECLS
 
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index e80afd8..700688d 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -164,7 +164,7 @@ make_label (xfceweather_data *data,
 
   /* get current weather conditions */
   conditions = get_current_conditions(data->weatherdata);
-  rawvalue = get_data(conditions, data->unit, opt);
+  rawvalue = get_data(conditions, data->unit_system, opt);
 
   switch (opt)
     {
@@ -172,7 +172,7 @@ make_label (xfceweather_data *data,
       value = translate_wind_direction (rawvalue);
       break;
     case WIND_SPEED:
-      value = translate_wind_speed (conditions, rawvalue, data->unit);
+      value = translate_wind_speed (conditions, rawvalue, data->unit_system);
       break;
     default:
       value = NULL;
@@ -189,7 +189,7 @@ make_label (xfceweather_data *data,
     else
       {
 	str = g_strdup_printf ("<span size=\"%s\">%s: %s %s</span>",
-                               txtsize, lbl, rawvalue, get_unit (conditions, data->unit, opt));
+                               txtsize, lbl, rawvalue, get_unit (conditions, data->unit_system, opt));
       }
   } else {
     if (value != NULL)
@@ -201,7 +201,7 @@ make_label (xfceweather_data *data,
     else
       {
 	str = g_strdup_printf ("<span size=\"%s\">%s %s</span>",
-                               txtsize, rawvalue, get_unit (conditions, data->unit, opt));
+                               txtsize, rawvalue, get_unit (conditions, data->unit_system, opt));
       }
   }
   g_free (rawvalue);
@@ -310,7 +310,7 @@ set_icon_current (xfceweather_data *data)
   conditions = get_current_conditions(data->weatherdata);
   nighttime = is_night_time();
 
-  str = get_data (conditions, data->unit, SYMBOL);
+  str = get_data (conditions, data->unit_system, SYMBOL);
   icon = get_icon (str, size, nighttime);
   g_free (str);
  
@@ -320,7 +320,7 @@ set_icon_current (xfceweather_data *data)
     g_object_unref (G_OBJECT (icon));
 
 #if !GTK_CHECK_VERSION(2,12,0)
-  str = get_data (conditions, data->unit, SYMBOL);
+  str = get_data (conditions, data->unit_system, SYMBOL);
   gtk_tooltips_set_tip (data->tooltips, data->tooltipbox,
                         translate_desc (str, nighttime),
                         NULL);
@@ -501,9 +501,9 @@ xfceweather_read_config (XfcePanelPlugin  *plugin,
     }
 
   if (xfce_rc_read_bool_entry (rc, "celcius", TRUE))
-    data->unit = METRIC;
+    data->unit_system = METRIC;
   else
-    data->unit = IMPERIAL;
+    data->unit_system = IMPERIAL;
 
   if (data->proxy_host)
     {
@@ -583,7 +583,7 @@ xfceweather_write_config (XfcePanelPlugin  *plugin,
   if (!rc)
     return;
 
-  xfce_rc_write_bool_entry (rc, "celcius", (data->unit == METRIC));
+  xfce_rc_write_bool_entry (rc, "celcius", (data->unit_system == METRIC));
 
   if (data->lat)
     xfce_rc_write_entry (rc, "lat", data->lat);
@@ -804,7 +804,7 @@ static gboolean weather_get_tooltip_cb (GtkWidget        *widget,
   if (data->weatherdata == NULL) {
     gtk_tooltip_set_text (tooltip, _("Cannot update weather data"));
   } else {
-    rawvalue = get_data (conditions, data->unit, SYMBOL);
+    rawvalue = get_data (conditions, data->unit_system, SYMBOL);
     markup_text = g_markup_printf_escaped(
   	  "<b>%s</b>\n"
 	  "%s",
@@ -816,7 +816,7 @@ static gboolean weather_get_tooltip_cb (GtkWidget        *widget,
     g_free(markup_text);
   }
 
-  rawvalue = get_data (conditions, data->unit, SYMBOL);
+  rawvalue = get_data (conditions, data->unit_system, SYMBOL);
   icon = get_icon (rawvalue, 32, nighttime);
   g_free (rawvalue);
   gtk_tooltip_set_icon (tooltip, icon);
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index 173b77d..fdffe48 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -55,7 +55,7 @@ typedef struct
   gchar           *lon;
   gchar		  *location_name;
   gchar           *location_name_short;
-  units            unit;
+  unit_systems     unit_system;
 
   xml_weather     *weatherdata;
 


More information about the Xfce4-commits mailing list