[libgweather] Add API for symbolic icon names



commit fa99b81c862b48e12b3f992367988779060ce481
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Feb 23 02:17:11 2013 +0100

    Add API for symbolic icon names
    
    For the new designs of the weather application, we want a symbolic
    icon.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695134

 libgweather/gweather-weather.h |    1 +
 libgweather/weather.c          |   89 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 0 deletions(-)
---
diff --git a/libgweather/gweather-weather.h b/libgweather/gweather-weather.h
index b5b473f..a597bf7 100644
--- a/libgweather/gweather-weather.h
+++ b/libgweather/gweather-weather.h
@@ -117,6 +117,7 @@ gchar *              gweather_info_get_temp_summary    (GWeatherInfo *info);
 gchar *                         gweather_info_get_weather_summary (GWeatherInfo *info);
 
 const gchar *           gweather_info_get_icon_name       (GWeatherInfo *info);
+const gchar *           gweather_info_get_symbolic_icon_name      (GWeatherInfo *info);
 gint                    gweather_info_next_sun_event      (GWeatherInfo *info);
 
 gboolean                 gweather_info_is_daytime          (GWeatherInfo *info);
diff --git a/libgweather/weather.c b/libgweather/weather.c
index 18f5899..b98fbe3 100644
--- a/libgweather/weather.c
+++ b/libgweather/weather.c
@@ -1180,6 +1180,95 @@ gweather_info_get_icon_name (GWeatherInfo *info)
     return icon_buffer;
 }
 
+const gchar *
+gweather_info_get_symbolic_icon_name (GWeatherInfo *info)
+{
+    GWeatherInfoPrivate *priv;
+    GWeatherConditions   cond;
+    GWeatherSky          sky;
+    gboolean             daytime;
+
+    g_return_val_if_fail (GWEATHER_IS_INFO (info), NULL);
+
+    priv = info->priv;
+
+    _gweather_info_ensure_sun (info);
+    _gweather_info_ensure_moon (info);
+
+    cond = priv->cond;
+    sky = priv->sky;
+
+    if (cond.significant) {
+       if (cond.phenomenon != GWEATHER_PHENOMENON_NONE &&
+           cond.qualifier == GWEATHER_QUALIFIER_THUNDERSTORM)
+            return "weather-storm-symbolic";
+
+        switch (cond.phenomenon) {
+       case GWEATHER_PHENOMENON_INVALID:
+       case GWEATHER_PHENOMENON_LAST:
+       case GWEATHER_PHENOMENON_NONE:
+           break;
+
+       case GWEATHER_PHENOMENON_DRIZZLE:
+       case GWEATHER_PHENOMENON_RAIN:
+       case GWEATHER_PHENOMENON_UNKNOWN_PRECIPITATION:
+       case GWEATHER_PHENOMENON_HAIL:
+       case GWEATHER_PHENOMENON_SMALL_HAIL:
+           return "weather-showers-symbolic";
+
+       case GWEATHER_PHENOMENON_SNOW:
+       case GWEATHER_PHENOMENON_SNOW_GRAINS:
+       case GWEATHER_PHENOMENON_ICE_PELLETS:
+       case GWEATHER_PHENOMENON_ICE_CRYSTALS:
+           return "weather-snow-symbolic";
+
+       case GWEATHER_PHENOMENON_TORNADO:
+       case GWEATHER_PHENOMENON_SQUALL:
+           return "weather-storm-symbolic";
+
+       case GWEATHER_PHENOMENON_MIST:
+       case GWEATHER_PHENOMENON_FOG:
+       case GWEATHER_PHENOMENON_SMOKE:
+       case GWEATHER_PHENOMENON_VOLCANIC_ASH:
+       case GWEATHER_PHENOMENON_SAND:
+       case GWEATHER_PHENOMENON_HAZE:
+       case GWEATHER_PHENOMENON_SPRAY:
+       case GWEATHER_PHENOMENON_DUST:
+       case GWEATHER_PHENOMENON_SANDSTORM:
+       case GWEATHER_PHENOMENON_DUSTSTORM:
+       case GWEATHER_PHENOMENON_FUNNEL_CLOUD:
+       case GWEATHER_PHENOMENON_DUST_WHIRLS:
+           return "weather-fog-symbolic";
+        }
+    }
+
+    daytime = gweather_info_is_daytime (info);
+
+    switch (sky) {
+    case GWEATHER_SKY_INVALID:
+    case GWEATHER_SKY_LAST:
+    case GWEATHER_SKY_CLEAR:
+       if (daytime)
+           return "weather-clear-symbolic";
+       else
+           return "weather-clear-night-symbolic";
+
+    case GWEATHER_SKY_BROKEN:
+    case GWEATHER_SKY_SCATTERED:
+    case GWEATHER_SKY_FEW:
+       if (daytime)
+           return "weather-few-clouds-symbolic";
+       else
+           return "weather-few-clouds-night-symbolic";
+
+    case GWEATHER_SKY_OVERCAST:
+       return "weather-overcast-symbolic";
+
+    default: /* unrecognized */
+       return NULL;
+    }
+}
+
 static gboolean
 temperature_value (gdouble temp_f,
                   GWeatherTemperatureUnit to_unit,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]