[Xfce4-commits] <xfce4-weather-plugin:master> Refactor symbol definitions and make them public.

Harald Judt noreply at xfce.org
Mon Jan 14 18:08:03 CET 2013


Updating branch refs/heads/master
         to cd743dd183588997bcec972cac4f48d679550cb6 (commit)
       from bf1a0b446846d3238069110a6dfcc9f393b1bbe8 (commit)

commit cd743dd183588997bcec972cac4f48d679550cb6
Author: Harald Judt <h.judt at gmx.at>
Date:   Sun Jan 13 19:54:54 2013 +0100

    Refactor symbol definitions and make them public.

 panel-plugin/weather-data.c |   63 +-----------------------------------------
 panel-plugin/weather-icon.h |   55 +++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 61 deletions(-)

diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index e217fb4..6087343 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -56,33 +56,6 @@
     comb->location->var = g_strdup(end->location->var);
 
 
-enum {
-    SYMBOL_NODATA = 0,
-    SYMBOL_SUN,
-    SYMBOL_LIGHTCLOUD,
-    SYMBOL_PARTLYCLOUD,
-    SYMBOL_CLOUD,
-    SYMBOL_LIGHTRAINSUN,
-    SYMBOL_LIGHTRAINTHUNDERSUN,
-    SYMBOL_SLEETSUN,
-    SYMBOL_SNOWSUN,
-    SYMBOL_LIGHTRAIN,
-    SYMBOL_RAIN,
-    SYMBOL_RAINTHUNDER,
-    SYMBOL_SLEET,
-    SYMBOL_SNOW,
-    SYMBOL_SNOWTHUNDER,
-    SYMBOL_FOG,
-    SYMBOL_SUN_POLAR,
-    SYMBOL_LIGHTCLOUD_POLAR,
-    SYMBOL_LIGHTRAINSUN_POLAR,
-    SYMBOL_SNOWSUN_POLAR,
-    SYMBOL_SLEETSUNTHUNDER,
-    SYMBOL_SNOWSUNTHUNDER,
-    SYMBOL_LIGHTRAINTHUNDER,
-    SYMBOL_SLEETTHUNDER
-};
-
 /* struct to store results from searches for point data */
 typedef struct {
     GArray *before;
@@ -404,7 +377,7 @@ get_data(const xml_time *timeslice,
         if (loc->symbol_id == SYMBOL_SNOWSUN ||
             loc->symbol_id == SYMBOL_SNOW ||
             loc->symbol_id == SYMBOL_SNOWTHUNDER ||
-            loc->symbol_id == SYMBOL_SNOWSUN_POLAR ||
+            loc->symbol_id == SYMBOL_SNOWSUNPOLAR ||
             loc->symbol_id == SYMBOL_SNOWSUNTHUNDER) {
             temp = string_to_double(loc->temperature_value, 0);
             if (temp < -11.1111)      /* below 12 °F, low snow density */
@@ -574,38 +547,6 @@ wind_dir_name_by_deg(gchar *degrees, gboolean long_name)
 }
 
 
-static const gchar *
-symbol_by_id(const gint symbol_id)
-{
-    switch (symbol_id) {
-    case SYMBOL_SUN:                  return "SUN";
-    case SYMBOL_LIGHTCLOUD:           return "LIGHTCLOUD";
-    case SYMBOL_PARTLYCLOUD:          return "PARTLYCLOUD";
-    case SYMBOL_CLOUD:                return "CLOUD";
-    case SYMBOL_LIGHTRAINSUN:         return "LIGHTRAINSUN";
-    case SYMBOL_LIGHTRAINTHUNDERSUN:  return "LIGHTRAINTHUNDERSUN";
-    case SYMBOL_SLEETSUN:             return "SLEETSUN";
-    case SYMBOL_SNOWSUN:              return "SNOWSUN";
-    case SYMBOL_LIGHTRAIN:            return "LIGHTRAIN";
-    case SYMBOL_RAIN:                 return "RAIN";
-    case SYMBOL_RAINTHUNDER:          return "RAINTHUNDER";
-    case SYMBOL_SLEET:                return "SLEET";
-    case SYMBOL_SNOW:                 return "SNOW";
-    case SYMBOL_SNOWTHUNDER:          return "SNOWTHUNDER";
-    case SYMBOL_FOG:                  return "FOG";
-    case SYMBOL_SUN_POLAR:            return "SUN";
-    case SYMBOL_LIGHTCLOUD_POLAR:     return "LIGHTCLOUD";
-    case SYMBOL_LIGHTRAINSUN_POLAR:   return "LIGHTRAINSUN";
-    case SYMBOL_SNOWSUN_POLAR:        return "SNOWSUN";
-    case SYMBOL_SLEETSUNTHUNDER:      return "SLEETSUNTHUNDER";
-    case SYMBOL_SNOWSUNTHUNDER:       return "SLEETSUNTHUNDER";
-    case SYMBOL_LIGHTRAINTHUNDER:     return "LIGHTRAINTHUNDER";
-    case SYMBOL_SLEETTHUNDER:         return "SLEETTHUNDER";
-    default:                          return "";
-    }
-}
-
-
 static void
 calculate_symbol(xml_time *timeslice)
 {
@@ -637,7 +578,7 @@ calculate_symbol(xml_time *timeslice)
 
     /* update symbol name */
     g_free(loc->symbol);
-    loc->symbol = g_strdup(symbol_by_id(loc->symbol_id));
+    loc->symbol = g_strdup(symbol_names[loc->symbol_id]);
 }
 
 
diff --git a/panel-plugin/weather-icon.h b/panel-plugin/weather-icon.h
index 98dc571..4178b85 100644
--- a/panel-plugin/weather-icon.h
+++ b/panel-plugin/weather-icon.h
@@ -21,6 +21,61 @@
 
 G_BEGIN_DECLS
 
+typedef enum {
+    SYMBOL_NODATA = 0,
+    SYMBOL_SUN,
+    SYMBOL_LIGHTCLOUD,
+    SYMBOL_PARTLYCLOUD,
+    SYMBOL_CLOUD,
+    SYMBOL_LIGHTRAINSUN,
+    SYMBOL_LIGHTRAINTHUNDERSUN,
+    SYMBOL_SLEETSUN,
+    SYMBOL_SNOWSUN,
+    SYMBOL_LIGHTRAIN,
+    SYMBOL_RAIN,
+    SYMBOL_RAINTHUNDER,
+    SYMBOL_SLEET,
+    SYMBOL_SNOW,
+    SYMBOL_SNOWTHUNDER,
+    SYMBOL_FOG,
+    SYMBOL_SUNPOLAR,
+    SYMBOL_LIGHTCLOUDPOLAR,
+    SYMBOL_LIGHTRAINSUNPOLAR,
+    SYMBOL_SNOWSUNPOLAR,
+    SYMBOL_SLEETSUNTHUNDER,
+    SYMBOL_SNOWSUNTHUNDER,
+    SYMBOL_LIGHTRAINTHUNDER,
+    SYMBOL_SLEETTHUNDER,
+    SYMBOL_COUNT
+} symbol_ids;
+
+static const gchar *symbol_names[] = {
+    "NODATA",
+    "SUN",
+    "LIGHTCLOUD",
+    "PARTLYCLOUD",
+    "CLOUD",
+    "LIGHTRAINSUN",
+    "LIGHTRAINTHUNDERSUN",
+    "SLEETSUN",
+    "SNOWSUN",
+    "LIGHTRAIN",
+    "RAIN",
+    "RAINTHUNDER",
+    "SLEET",
+    "SNOW",
+    "SNOWTHUNDER",
+    "FOG",
+    "SUN",
+    "LIGHTCLOUD",
+    "LIGHTRAINSUN",
+    "SNOWSUN",
+    "SLEETSUNTHUNDER",
+    "SNOWSUNTHUNDER",
+    "LIGHTRAINTHUNDER",
+    "SLEETTHUNDER"
+};
+
 typedef struct {
     gchar *dir;
     gchar *name;


More information about the Xfce4-commits mailing list