gnome-panel r10920 - trunk/applets/clock



Author: vuntz
Date: Mon Mar  3 21:26:16 2008
New Revision: 10920
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=10920&view=rev

Log:
2008-03-03  Vincent Untz  <vuntz gnome org>

	Display sunrise/sunset in local (to the location) time.
	Fix bug #518106. Patch by Matthias Clasen <mclasen redhat com>

	* clock-location-tile.[ch]: (weather_info_setup_tooltip): hack to
	display the sunrise/sunset in local time
	(weather_tooltip): update
	* clock.c: (weather_tooltip): update


Modified:
   trunk/applets/clock/ChangeLog
   trunk/applets/clock/clock-location-tile.c
   trunk/applets/clock/clock-location-tile.h
   trunk/applets/clock/clock.c

Modified: trunk/applets/clock/clock-location-tile.c
==============================================================================
--- trunk/applets/clock/clock-location-tile.c	(original)
+++ trunk/applets/clock/clock-location-tile.c	Mon Mar  3 21:26:16 2008
@@ -565,13 +565,14 @@
 }
 
 void
-weather_info_setup_tooltip (WeatherInfo *info, GtkTooltip *tooltip)
+weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkTooltip *tooltip)
 {
         GdkPixbuf *pixbuf = NULL;
         GtkIconTheme *theme = NULL;
 	const gchar *conditions, *temp, *apparent, *wind;
 	gchar *line1, *line2, *line3, *line4, *tip;
 	const gchar *icon_name;
+	const gchar *sys_timezone;
 
        	icon_name = weather_info_get_icon_name (info);
         theme = gtk_icon_theme_get_default ();
@@ -602,9 +603,20 @@
 	else
 		line3 = g_strdup ("");
 
+	/* FIXME: we need libgweather to give us the time,
+	 * not just a formatted string
+	 */
+	sys_timezone = getenv ("TZ");
+	setenv ("TZ", clock_location_get_timezone (location), 1);
+	tzset ();
 	line4 = g_strdup_printf (_("Sunrise: %s / Sunset: %s"),
 				 weather_info_get_sunrise (info),
 				 weather_info_get_sunset (info));
+	if (sys_timezone)
+		setenv ("TZ", sys_timezone, 1);
+	else
+		unsetenv ("TZ");
+	tzset ();
 
 	tip = g_strdup_printf ("<b>%s</b>\n%s\n%s%s", line1, line2, line3, line4);
 	gtk_tooltip_set_markup (tooltip, tip);
@@ -632,7 +644,7 @@
 	if (!info || !weather_info_is_valid (info))
 		return FALSE;
 
-	weather_info_setup_tooltip (info, tooltip);
+	weather_info_setup_tooltip (info, priv->location, tooltip);
 
 	return TRUE;
 }

Modified: trunk/applets/clock/clock-location-tile.h
==============================================================================
--- trunk/applets/clock/clock-location-tile.h	(original)
+++ trunk/applets/clock/clock-location-tile.h	Mon Mar  3 21:26:16 2008
@@ -37,7 +37,7 @@
 
 ClockLocation *clock_location_tile_get_location (ClockLocationTile *this);
 
-void weather_info_setup_tooltip (WeatherInfo *info, GtkTooltip *tip);
+void weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkTooltip *tip);
 
 void clock_location_tile_refresh (ClockLocationTile *this,
                                   gboolean           force_refresh);

Modified: trunk/applets/clock/clock.c
==============================================================================
--- trunk/applets/clock/clock.c	(original)
+++ trunk/applets/clock/clock.c	Mon Mar  3 21:26:16 2008
@@ -1341,12 +1341,13 @@
         locations = cd->locations;
 
         for (l = locations; l; l = l->next) {
-                if (clock_location_is_current (l->data)) {
-                        info = clock_location_get_weather_info (l->data);
+		ClockLocation *location = l->data;
+                if (clock_location_is_current (location)) {
+                        info = clock_location_get_weather_info (location);
                         if (!info || !weather_info_is_valid (info))
                                 continue;
 
-                        weather_info_setup_tooltip (info, tooltip);
+                        weather_info_setup_tooltip (info, location, tooltip);
 
                         return TRUE;
                 }



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