[Xfce4-commits] <xfce4-weather-plugin:master> Unit conversion: Prepare to use units in get_data().

Harald Judt noreply at xfce.org
Wed Jul 4 18:30:04 CEST 2012


Updating branch refs/heads/master
         to d0c0b1c93a3c20eb002b366fc331b1b574c41036 (commit)
       from 9467ce9f2b9adf7be98254494a414a26f4d64ca9 (commit)

commit d0c0b1c93a3c20eb002b366fc331b1b574c41036
Author: Harald Judt <h.judt at gmx.at>
Date:   Wed Jul 4 17:41:56 2012 +0200

    Unit conversion: Prepare to use units in get_data().
    
    get_data() will be the place to handle conversions from metric to
    imperial and vice-versa. Prepare this by adding units as a parameter
    similar to get_unit() and changing all function calls appropriately.

 panel-plugin/weather-data.c    |    2 +-
 panel-plugin/weather-data.h    |    2 +-
 panel-plugin/weather-summary.c |   22 +++++++++++-----------
 panel-plugin/weather.c         |   10 +++++-----
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index b67b4ca..09cae95 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, time_t end)
 }
 
 gchar *
-get_data (xml_time *timeslice, datas type)
+get_data (xml_time *timeslice, units unit, datas type)
 {
 	const xml_location *loc = NULL;
 
diff --git a/panel-plugin/weather-data.h b/panel-plugin/weather-data.h
index b43a3fb..70edc3a 100644
--- a/panel-plugin/weather-data.h
+++ b/panel-plugin/weather-data.h
@@ -53,7 +53,7 @@ typedef enum {
 } daytime;
 
 gchar *
-get_data (xml_time *timeslice, datas type);
+get_data (xml_time *timeslice, units unit, datas type);
 const gchar *
 get_unit (xml_time *timeslice, units unit, datas type);
 gboolean
diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index be14b0f..8d2e4b0 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -41,7 +41,7 @@ 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(timeslice, item); \
+#define APPEND_TEXT_ITEM(text, item)     rawvalue = get_data(timeslice, data->unit, item); \
                                          unit = get_unit(timeslice, data->unit, item); \
                                          value = g_strdup_printf("\t%s%s%s%s%s\n", \
                                                                  text, text ? ": " : "", \
@@ -295,19 +295,19 @@ create_summary_tab (xfceweather_data *data)
 
   /* Wind */
   APPEND_BTEXT (_("\nWind\n"));
-  rawvalue = get_data (timeslice, WIND_SPEED);
+  rawvalue = get_data (timeslice, data->unit, WIND_SPEED);
   wind = translate_wind_speed (timeslice, rawvalue, data->unit);
   g_free (rawvalue);
-  rawvalue = get_data (timeslice, WIND_BEAUFORT);
+  rawvalue = get_data (timeslice, data->unit, 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 (timeslice, WIND_DIRECTION);
+  rawvalue = get_data (timeslice, data->unit, WIND_DIRECTION);
   wind = translate_wind_direction (rawvalue);
   g_free (rawvalue);
-  rawvalue = get_data (timeslice, WIND_DIRECTION_DEG);
+  rawvalue = get_data (timeslice, data->unit, WIND_DIRECTION_DEG);
   value = g_strdup_printf ("\t%s: %s (%s%s)\n", _("Direction"),
                            wind, rawvalue,
                            get_unit (timeslice, data->unit, WIND_DIRECTION_DEG));
@@ -455,7 +455,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, SYMBOL);
+                    rawvalue = get_data(fcdata, data->unit, SYMBOL);
                     icon = get_icon(rawvalue, 48, (daytime == NIGHT));
                     g_free(rawvalue);
                     image = gtk_image_new_from_pixbuf(icon);
@@ -464,7 +464,7 @@ make_forecast (xfceweather_data *data,
                     if (G_LIKELY (icon))
                         g_object_unref (G_OBJECT (icon));
 
-                    rawvalue = get_data(fcdata, SYMBOL);
+                    rawvalue = get_data(fcdata, data->unit, SYMBOL);
                     value = g_strdup_printf("%s",
                                             translate_desc(rawvalue,
                                                            (daytime == NIGHT)));
@@ -476,7 +476,7 @@ make_forecast (xfceweather_data *data,
                                         TRUE, TRUE, 0);
                     g_free(value);
 
-                    rawvalue = get_data(fcdata, TEMPERATURE);
+                    rawvalue = get_data(fcdata, data->unit, TEMPERATURE);
                     value = g_strdup_printf("%s %s",
                                             rawvalue,
                                             get_unit(fcdata, data->unit, TEMPERATURE));
@@ -487,8 +487,8 @@ make_forecast (xfceweather_data *data,
                                         TRUE, TRUE, 0);
                     g_free(value);
 
-                    rawvalue = get_data(fcdata, WIND_DIRECTION);
-                    wind_speed = get_data(fcdata, WIND_SPEED);
+                    rawvalue = get_data(fcdata, data->unit, WIND_DIRECTION);
+                    wind_speed = get_data(fcdata, data->unit, WIND_SPEED);
                     value = g_strdup_printf("%s %s %s",
                                             translate_wind_direction(rawvalue),
                                             wind_speed,
@@ -564,7 +564,7 @@ create_summary_window (xfceweather_data *data)
 
   timeslice = get_current_timeslice(data->weatherdata, TRUE);
 
-  rawvalue = get_data (timeslice, SYMBOL);
+  rawvalue = get_data (timeslice, data->unit, SYMBOL);
   icon = get_icon (rawvalue, 48, is_night_time());
   g_free (rawvalue);
 
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 833956a..1d2d3f6 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -159,7 +159,7 @@ make_label (xml_weather    *weatherdata,
   /* get data from current timeslice */
   timeslice = get_current_timeslice(weatherdata,
                                     opt == PRECIPITATIONS || opt == SYMBOL);
-  rawvalue = get_data(timeslice, opt);
+  rawvalue = get_data(timeslice, unit, opt);
 
   switch (opt)
     {
@@ -317,7 +317,7 @@ set_icon_current (xfceweather_data *data)
   timeslice = get_current_timeslice(data->weatherdata, TRUE);
   nighttime = is_night_time();
 
-  str = get_data (timeslice, SYMBOL);
+  str = get_data (timeslice, data->unit, SYMBOL);
   icon = get_icon (str, size, nighttime);
   g_free (str);
  
@@ -327,7 +327,7 @@ set_icon_current (xfceweather_data *data)
     g_object_unref (G_OBJECT (icon));
 
 #if !GTK_CHECK_VERSION(2,12,0)
-  str = get_data (timeslice, SYMBOL);
+  str = get_data (timeslice, data->unit, SYMBOL);
   gtk_tooltips_set_tip (data->tooltips, data->tooltipbox,
                         translate_desc (str, nighttime),
                         NULL);
@@ -810,7 +810,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 (timeslice, SYMBOL);
+    rawvalue = get_data (timeslice, data->unit, SYMBOL);
     markup_text = g_markup_printf_escaped(
   	  "<b>%s</b>\n"
 	  "%s",
@@ -822,7 +822,7 @@ static gboolean weather_get_tooltip_cb (GtkWidget        *widget,
     g_free(markup_text);
   }
 
-  rawvalue = get_data (timeslice, SYMBOL);
+  rawvalue = get_data (timeslice, data->unit, SYMBOL);
   icon = get_icon (rawvalue, 32, nighttime);
   g_free (rawvalue);
   gtk_tooltip_set_icon (tooltip, icon);


More information about the Xfce4-commits mailing list