[gnome-control-center] datetime: Add hacks to support more timezones



commit 31be5be9c7d1333bde7eedb98c938fc12c814bca
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 15 01:35:51 2011 +0000

    datetime: Add hacks to support more timezones
    
    Such as posix/Europe/London, and the likes.

 panels/datetime/cc-timezone-map.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/panels/datetime/cc-timezone-map.c b/panels/datetime/cc-timezone-map.c
index 4699841..7e0e585 100644
--- a/panels/datetime/cc-timezone-map.c
+++ b/panels/datetime/cc-timezone-map.c
@@ -24,6 +24,7 @@
 
 #include "cc-timezone-map.h"
 #include <math.h>
+#include <string.h>
 #include "tz.h"
 
 G_DEFINE_TYPE (CcTimezoneMap, cc_timezone_map, GTK_TYPE_WIDGET)
@@ -636,6 +637,26 @@ cc_timezone_map_new (void)
   return g_object_new (CC_TYPE_TIMEZONE_MAP, NULL);
 }
 
+static char *
+get_clean_tz (CcTimezoneMap *map,
+	      const char    *tz)
+{
+	char *ret;
+	const char *timezone;
+
+	if (g_str_has_prefix (tz, "right/"))
+		timezone = tz + strlen ("right/");
+	else if (g_str_has_prefix (tz, "posix/"))
+		timezone = tz + strlen ("posix/");
+	else
+		timezone = tz;
+
+	ret = g_hash_table_lookup (map->priv->alias_db, timezone);
+	if (ret == NULL)
+		return g_strdup (timezone);
+	return g_strdup (ret);
+}
+
 gboolean
 cc_timezone_map_set_timezone (CcTimezoneMap *map,
                               const gchar   *timezone)
@@ -645,7 +666,7 @@ cc_timezone_map_set_timezone (CcTimezoneMap *map,
   char *real_tz;
   gboolean ret;
 
-  real_tz = g_hash_table_lookup (map->priv->alias_db, timezone);
+  real_tz = get_clean_tz (map, timezone);
 
   locations = tz_get_locations (map->priv->tzdb);
   ret = FALSE;
@@ -665,6 +686,8 @@ cc_timezone_map_set_timezone (CcTimezoneMap *map,
   if (ret)
     gtk_widget_queue_draw (GTK_WIDGET (map));
 
+  g_free (real_tz);
+
   return ret;
 }
 



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