diff options
author | Vratislav Podzimek <vpodzime@redhat.com> | 2012-11-01 13:23:13 +0100 |
---|---|---|
committer | Vratislav Podzimek <vpodzime@redhat.com> | 2012-11-06 10:18:43 +0100 |
commit | 4a53beafb8a1a4264844d98445d385b5cd4cd9ea (patch) | |
tree | 32fa1bd6dfccbb08e3c549116c3b76f919771f81 /widgets | |
parent | 14171a872a4a68142be27769a3da7a99a4d61c7a (diff) | |
download | anaconda-4a53beafb8a1a4264844d98445d385b5cd4cd9ea.tar.gz anaconda-4a53beafb8a1a4264844d98445d385b5cd4cd9ea.tar.xz anaconda-4a53beafb8a1a4264844d98445d385b5cd4cd9ea.zip |
TimezoneMap should handle "" timezone
This is needed for displaying UTC and GMT-X timezones. Setting
timezone to "" graphically sets "Europe/London", but doesn't add
the pin.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/src/TimezoneMap.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/widgets/src/TimezoneMap.c b/widgets/src/TimezoneMap.c index 10713909e..a494e7032 100644 --- a/widgets/src/TimezoneMap.c +++ b/widgets/src/TimezoneMap.c @@ -436,18 +436,24 @@ sort_locations (TzLocation *a, static void set_location (AnacondaTimezoneMap *map, - TzLocation *location) { + TzLocation *location, + gboolean no_city) { AnacondaTimezoneMapPrivate *priv = map->priv; TzInfo *info; - priv->location = location; + info = tz_info_from_location (location); - info = tz_info_from_location (priv->location); - - priv->selected_offset = tz_location_get_utc_offset (priv->location) + priv->selected_offset = tz_location_get_utc_offset (location) / (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0); - g_signal_emit (map, signals[TIMEZONE_CHANGED], 0, priv->location->zone); + if (no_city) { + priv->location = NULL; + g_signal_emit (map, signals[TIMEZONE_CHANGED], 0, ""); + } + else { + priv->location = location; + g_signal_emit (map, signals[TIMEZONE_CHANGED], 0, priv->location->zone); + } tz_info_free (info); } @@ -514,7 +520,7 @@ button_press_event (GtkWidget *widget, distances = g_list_sort (distances, (GCompareFunc) sort_locations); - set_location (ANACONDA_TIMEZONE_MAP (widget), (TzLocation*) distances->data); + set_location (ANACONDA_TIMEZONE_MAP (widget), (TzLocation*) distances->data, FALSE); g_list_free (distances); @@ -572,6 +578,14 @@ anaconda_timezone_map_set_timezone (AnacondaTimezoneMap *map, guint i; char *real_tz; gboolean ret; + gboolean no_city = FALSE; + + /* "" means reset to default -- Europe/London timezone without + * a pin (no_city) */ + if (!g_strcmp0 (timezone, "")) { + timezone = "Europe/London"; + no_city = TRUE; + } real_tz = tz_info_get_clean_name (map->priv->tzdb, timezone); @@ -582,7 +596,7 @@ anaconda_timezone_map_set_timezone (AnacondaTimezoneMap *map, TzLocation *loc = locations->pdata[i]; if (!g_strcmp0 (loc->zone, real_tz ? real_tz : timezone)) { - set_location (map, loc); + set_location (map, loc, no_city); ret = TRUE; break; } @@ -604,5 +618,8 @@ anaconda_timezone_map_set_timezone (AnacondaTimezoneMap *map, */ gchar * anaconda_timezone_map_get_timezone (AnacondaTimezoneMap *map) { - return map->priv->location->zone; + if (map->priv->location) + return map->priv->location->zone; + else + return ""; } |