[Xfce4-commits] <xfce4-weather-plugin:master> * description

Colin Leroy noreply at xfce.org
Wed Nov 16 22:34:09 CET 2011


Updating branch refs/heads/master
         to 697443279ec734d61601a115da9f2f575f0f569e (commit)
       from caff57be41f6eca3e1e075811a5cda220028d5c0 (commit)

commit 697443279ec734d61601a115da9f2f575f0f569e
Author: Colin Leroy <colin at colino.net>
Date:   Wed Nov 16 21:54:21 2011 +0100

    * description

 panel-plugin/weather-config.c    |    2 +-
 panel-plugin/weather-parsers.c   |    1 +
 panel-plugin/weather-parsers.h   |    1 +
 panel-plugin/weather-translate.c |   40 ++++++++++++++++++++++++++++++++++++-
 panel-plugin/weather.c           |    2 +-
 5 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 59ed6ba..eb00f22 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -30,7 +30,7 @@
 #include "weather-search.h"
 #include "weather-scrollbox.h"
 
-#define OPTIONS_N 11
+#define OPTIONS_N 12
 #define BORDER    8
 
 static const labeloption labeloptions[OPTIONS_N] = {
diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
index 18ef180..202985a 100644
--- a/panel-plugin/weather-parsers.c
+++ b/panel-plugin/weather-parsers.c
@@ -252,6 +252,7 @@ void parse_location (xmlNode * cur_node, xml_location *loc)
 		if (NODE_IS_TYPE (child_node, "symbol")) {
 			g_free(loc->symbol);
 			loc->symbol = PROP(child_node, "id");
+			loc->symbol_id = strtol(PROP(child_node, "number"), NULL, 10);
 		}
 	}
 }
diff --git a/panel-plugin/weather-parsers.h b/panel-plugin/weather-parsers.h
index ccfd5cf..b461f90 100644
--- a/panel-plugin/weather-parsers.h
+++ b/panel-plugin/weather-parsers.h
@@ -58,6 +58,7 @@ typedef struct
 	gchar *precipitation_value;
 	gchar *precipitation_unit;
 
+	gint   symbol_id;
 	gchar *symbol;
 }
 xml_location;
diff --git a/panel-plugin/weather-translate.c b/panel-plugin/weather-translate.c
index 4649c46..7147eb1 100644
--- a/panel-plugin/weather-translate.c
+++ b/panel-plugin/weather-translate.c
@@ -272,12 +272,48 @@ translate_risk (const gchar *risk)
   return translate_str (risk_strings, risk);
 }
 
-
+typedef struct {
+	gint id;
+	gchar *symbol;
+	gchar *desc;
+} SymbolToDesc;
+static const SymbolToDesc symbol_to_desc[] = {
+	{ 1, "SUN",		N_("Sunny") },
+	{ 2, "LIGHTCLOUD",	N_("Lightly cloudy") },
+	{ 3, "PARTLYCLOUD",	N_("Partly cloudy") },
+	{ 4, "CLOUD",		N_("Cloudy") },
+	{ 5, "LIGHTRAINSUN",	N_("Sunny, rain showers") },
+	{ 6, "LIGHTRAINTHUNDERSUN",
+				N_("Sunny, rain showers with thunder") },
+	{ 7, "SLEETSUN",	N_("Sunny, Sleet") },
+	{ 8, "SNOWSUN",		N_("Sunny, Snow") },
+	{ 9, "LIGHTRAIN",	N_("Rain showers") },
+	{ 10,"RAIN",		N_("Rain") },
+	{ 11,"RAINTHUNDER",	N_("Rain with thunder") },
+	{ 12,"SLEET",		N_("Sleet") },
+	{ 13,"SNOW",		N_("Snow") },
+	{ 14,"SNOWTHUNDER",	N_("Snow with thunder") },
+	{ 15,"FOG",		N_("Fog") },
+	{ 16,"SUN",		N_("Sunny") },
+	{ 17,"LIGHTCLOUD",	N_("Lightly cloudy") },
+	{ 18,"LIGHTRAINSUN",	N_("Sunny, rain showers") },
+	{ 19,"SNOWSUN",		N_("Sunny, Snow") },
+	{ 20,"SLEETSUNTHUNDER",	N_("Sunny, Sleet and thunder") },
+	{ 21,"SNOWSUNTHUNDER",	N_("Sunny, Snow and thunder") },
+	{ 22,"LIGHTRAINTHUNDER",N_("Rain showers with thunder") },
+	{ 23,"SLEETTHUNDER",	N_("Sleet and thunder") },
+};
+#define NUM_SYMBOLS (sizeof(symbol_to_desc)/sizeof(symbol_to_desc[0]))
 
 const gchar *
 translate_desc (const gchar *desc)
 {
-  return translate_str (desc_strings, desc);
+  int i;
+  for (i = 0; i < NUM_SYMBOLS; i++) {
+    if (!strcmp(desc, symbol_to_desc[i].symbol))
+	return _(symbol_to_desc[i].desc);
+  }
+  return desc;
 }
 
 
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 497bf7b..c11583c 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -295,7 +295,7 @@ set_icon_current (xfceweather_data *data)
 
 #if !GTK_CHECK_VERSION(2,12,0)
   gtk_tooltips_set_tip (data->tooltips, data->tooltipbox,
-                        translate_desc (get_data (data->weatherdata, TRANS)),
+                        translate_desc (get_data (data->weatherdata, SYMBOL)),
                         NULL);
 #endif
 }


More information about the Xfce4-commits mailing list