[Xfce4-commits] <xfce4-weather-plugin:master> Add night/day support for symbol descriptions.

Harald Judt noreply at xfce.org
Mon Jul 2 12:38:09 CEST 2012


Updating branch refs/heads/master
         to dcf6b950f5ee0c18ffd835def5c3f9da06a32cfe (commit)
       from 9f53cf03f769aa711896cf8fea84345f594ccebf (commit)

commit dcf6b950f5ee0c18ffd835def5c3f9da06a32cfe
Author: Harald Judt <h.judt at gmx.at>
Date:   Tue Jun 26 01:46:06 2012 +0200

    Add night/day support for symbol descriptions.
    
    Analogous to getting the right icon for day or night, we need
    to 'translate' the symbol descriptions (sunny, clear, partly cloudy)
    correctly for night and day. Good bye, "sunny night"!

 panel-plugin/weather-translate.c |   56 ++++++++++++++++++++-----------------
 panel-plugin/weather-translate.h |    2 +-
 panel-plugin/weather.c           |    4 +-
 3 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/panel-plugin/weather-translate.c b/panel-plugin/weather-translate.c
index da991c1..97a0ecf 100644
--- a/panel-plugin/weather-translate.c
+++ b/panel-plugin/weather-translate.c
@@ -276,42 +276,46 @@ typedef struct {
 	gint id;
 	gchar *symbol;
 	gchar *desc;
+	gchar *night_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") },
+	{ 1, "SUN",                 N_("Sunny"),                     N_("Clear")		},
+	{ 2, "LIGHTCLOUD",          N_("Lightly cloudy"),            N_("Lightly cloudy")	},
+	{ 3, "PARTLYCLOUD",         N_("Partly cloudy"),             N_("Partly cloudy")	},
+	{ 4, "CLOUD",               N_("Cloudy"),                    N_("Cloudy")		},
+	{ 5, "LIGHTRAINSUN",	    N_("Sunny, rain showers"),       N_("Clear, rain showers") },
+	{ 6, "LIGHTRAINTHUNDERSUN", N_("Sunny, rain showers with thunder"),
+	                            N_("Clear, rain showers with thunder") },
+	{ 7, "SLEETSUN",            N_("Sunny, Sleet"),              N_("Clear, Sleet") },
+	{ 8, "SNOWSUN",             N_("Sunny, Snow"),               N_("Clear, Snow") },
+	{ 9, "LIGHTRAIN",           N_("Rain showers"),              N_("Rain showers") },
+	{ 10,"RAIN",                N_("Rain"),                      N_("Rain") },
+	{ 11,"RAINTHUNDER",         N_("Rain with thunder"),         N_("Rain with thunder") },
+	{ 12,"SLEET",               N_("Sleet"),                     N_("Sleet") },
+	{ 13,"SNOW",                N_("Snow"),                      N_("Snow") },
+	{ 14,"SNOWTHUNDER",         N_("Snow with thunder"),         N_("Snow with thunder") },
+	{ 15,"FOG",                 N_("Fog"),                       N_("Fog") },
+	{ 16,"SUN",                 N_("Sunny"),                     N_("Clear") },
+	{ 17,"LIGHTCLOUD",          N_("Lightly cloudy"),            N_("Lightly cloudy") },
+	{ 18,"LIGHTRAINSUN",        N_("Sunny, rain showers"),       N_("Clear, rain showers") },
+	{ 19,"SNOWSUN",             N_("Sunny, Snow"),               N_("Clear, Snow") },
+	{ 20,"SLEETSUNTHUNDER",     N_("Sunny, Sleet and thunder"),  N_("Clear, sleet and thunder") },
+	{ 21,"SNOWSUNTHUNDER",      N_("Sunny, Snow and thunder"),   N_("Clear, snow and thunder") },
+	{ 22,"LIGHTRAINTHUNDER",    N_("Rain showers with thunder"), N_("Rain showers with thunder") },
+	{ 23,"SLEETTHUNDER",        N_("Sleet and thunder"),         N_("Sleet and thunder") },
 };
 #define NUM_SYMBOLS (sizeof(symbol_to_desc)/sizeof(symbol_to_desc[0]))
 
 const gchar *
-translate_desc (const gchar *desc)
+translate_desc (const gchar *desc, gboolean nighttime)
 {
   int i;
   for (i = 0; i < NUM_SYMBOLS; i++) {
     if (!strcmp(desc, symbol_to_desc[i].symbol))
-	return _(symbol_to_desc[i].desc);
+      if (nighttime)
+        return _(symbol_to_desc[i].night_desc);
+      else
+        return _(symbol_to_desc[i].desc);
   }
   return desc;
 }
diff --git a/panel-plugin/weather-translate.h b/panel-plugin/weather-translate.h
index 831f4f7..a8b1adf 100644
--- a/panel-plugin/weather-translate.h
+++ b/panel-plugin/weather-translate.h
@@ -23,7 +23,7 @@
 
 G_BEGIN_DECLS
 
-const gchar *translate_desc (const gchar *);
+const gchar *translate_desc (const gchar *, gboolean);
 
 const gchar *translate_bard (const gchar *);
 
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 85aa950..cedef93 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -304,7 +304,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 (timeslice, SYMBOL)),
+                        translate_desc (get_data (timeslice, SYMBOL), nighttime),
                         NULL);
 #endif
 }
@@ -778,7 +778,7 @@ static gboolean weather_get_tooltip_cb (GtkWidget        *widget,
   	  "<b>%s</b>\n"
 	  "%s",
 	  data->location_name,
-	  translate_desc (get_data (timeslice, SYMBOL))
+	  translate_desc (get_data (timeslice, SYMBOL), nighttime)
 	  );
     gtk_tooltip_set_markup (tooltip, markup_text);
     g_free(markup_text);


More information about the Xfce4-commits mailing list