[gnome-panel/wip/applets/clock: 9/15] clock: update weather tooltip setup function
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/applets/clock: 9/15] clock: update weather tooltip setup function
- Date: Tue, 11 Nov 2014 11:37:48 +0000 (UTC)
commit 0c28af250b9d739e724a25cf94e0b4b1c3f1c3e3
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Nov 10 02:18:57 2014 +0200
clock: update weather tooltip setup function
applets/clock/clock-location-tile.c | 14 +++-----------
applets/clock/clock-location.c | 15 ++++++++++++---
applets/clock/clock-location.h | 7 +++----
applets/clock/clock.c | 13 +++++++------
4 files changed, 25 insertions(+), 24 deletions(-)
---
diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c
index 6ad6a8d..2df8d38 100644
--- a/applets/clock/clock-location-tile.c
+++ b/applets/clock/clock-location-tile.c
@@ -205,20 +205,12 @@ show_weather_tooltip (GtkWidget *widget,
gpointer user_data)
{
ClockLocationTile *tile;
- GWeatherInfo *info;
tile = CLOCK_LOCATION_TILE (user_data);
- info = clock_location_get_weather_info (tile->priv->location);
- if (!info || !gweather_info_is_valid (info))
- return FALSE;
-
- weather_info_setup_tooltip (info,
- tile->priv->location,
- tooltip,
- tile->priv->clock_format);
-
- return TRUE;
+ return clock_location_setup_weather_tooltip (tile->priv->location,
+ tooltip,
+ tile->priv->clock_format);
}
static void
diff --git a/applets/clock/clock-location.c b/applets/clock/clock-location.c
index 10f85a9..cf2968b 100644
--- a/applets/clock/clock-location.c
+++ b/applets/clock/clock-location.c
@@ -524,10 +524,12 @@ convert_time_to_str (time_t now, GDesktopClockFormat clock_format, const char *t
return ret;
}
-void
-weather_info_setup_tooltip (GWeatherInfo *info, ClockLocation *location, GtkTooltip *tooltip,
- GDesktopClockFormat clock_format)
+gboolean
+clock_location_setup_weather_tooltip (ClockLocation *location,
+ GtkTooltip *tooltip,
+ GDesktopClockFormat clock_format)
{
+ GWeatherInfo *info;
GdkPixbuf *pixbuf = NULL;
GtkIconTheme *theme = NULL;
gchar *conditions, *sky, *wind;
@@ -540,6 +542,11 @@ weather_info_setup_tooltip (GWeatherInfo *info, ClockLocation *location, GtkTool
gdouble unused;
GWeatherWindDirection unused2;
+ info = clock_location_get_weather_info (location);
+
+ if (!info || !gweather_info_is_valid (info))
+ return FALSE;
+
icon_name = gweather_info_get_icon_name (info);
theme = gtk_icon_theme_get_default ();
pixbuf = gtk_icon_theme_load_icon (theme, icon_name, 48,
@@ -596,4 +603,6 @@ weather_info_setup_tooltip (GWeatherInfo *info, ClockLocation *location, GtkTool
g_free (line3);
g_free (line4);
g_free (tip);
+
+ return TRUE;
}
diff --git a/applets/clock/clock-location.h b/applets/clock/clock-location.h
index 465151a..f2c06f7 100644
--- a/applets/clock/clock-location.h
+++ b/applets/clock/clock-location.h
@@ -63,10 +63,9 @@ GWeatherInfo *clock_location_get_weather_info (ClockLocation *loc);
glong clock_location_get_offset (ClockLocation *loc);
-void weather_info_setup_tooltip (GWeatherInfo *info,
- ClockLocation *location,
- GtkTooltip *tip,
- GDesktopClockFormat clock_format);
+gboolean clock_location_setup_weather_tooltip (ClockLocation *location,
+ GtkTooltip *tip,
+ GDesktopClockFormat clock_format);
G_END_DECLS
#endif /* __CLOCK_LOCATION_H__ */
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index 0014028..2f1c29b 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -858,19 +858,20 @@ weather_tooltip (GtkWidget *widget,
ClockData *cd)
{
GList *locations, *l;
- GWeatherInfo *info;
locations = cd->locations;
for (l = locations; l; l = l->next) {
ClockLocation *location = l->data;
if (clock_location_is_current (location)) {
- info = clock_location_get_weather_info (location);
- if (!info || !gweather_info_is_valid (info))
- continue;
+ gboolean ok;
- weather_info_setup_tooltip (info, location, tooltip,
- g_settings_get_enum (cd->clock_settings,
"clock-format"));
+ ok = clock_location_setup_weather_tooltip (location,
+ tooltip,
+ g_settings_get_enum (cd->clock_settings,
+ "clock-format"));
+ if (ok == FALSE)
+ continue;
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]