I tried to do only minimum changes to the widget.
Vratislav Podzimek (2): TimezoneMap should handle "" timezone Add UTC and GMT-X timezones (#863199)
pyanaconda/timezone.py | 14 +++++++++++- pyanaconda/ui/gui/spokes/datetime_spoke.py | 35 ++++++++++++++++++++++++------ widgets/src/TimezoneMap.c | 35 ++++++++++++++++++++++-------- 3 files changed, 67 insertions(+), 17 deletions(-)
This is needed for displaying UTC and GMT-X timezones. Setting timezone to "" graphically sets "Europe/London", but doesn't add the pin.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- widgets/src/TimezoneMap.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/widgets/src/TimezoneMap.c b/widgets/src/TimezoneMap.c index 1071390..a494e70 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 ""; }
It makes sense to set timezone to UTC or GMT-XX. Please mind that "Etc" category doesn't come from my mind, that's how these timezones are defined in the /usr/share/zoneinfo tree.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- pyanaconda/timezone.py | 14 +++++++++++- pyanaconda/ui/gui/spokes/datetime_spoke.py | 35 ++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/pyanaconda/timezone.py b/pyanaconda/timezone.py index 61f7e75..f08f0c4 100644 --- a/pyanaconda/timezone.py +++ b/pyanaconda/timezone.py @@ -34,6 +34,15 @@ from pyanaconda import iutil import logging log = logging.getLogger("anaconda")
+# The following zones are not in pytz.common_timezones and +# Etc category in pytz.all_timezones includes some more, +# however confusing ones (like UCT, GMT+0, GMT-0,...) +ETC_ZONES = ['GMT+1', 'GMT+2', 'GMT+3', 'GMT+4', 'GMT+5', 'GMT+6', 'GMT+7', + 'GMT+8', 'GMT+9', 'GMT+10', 'GMT+11', 'GMT+12', + 'GMT-1', 'GMT-2', 'GMT-3', 'GMT-4', 'GMT-5', 'GMT-6', 'GMT-7', + 'GMT-8', 'GMT-9', 'GMT-10', 'GMT-11', 'GMT-12', 'GMT-13', + 'GMT-14', 'UTC', 'GMT'] + class TimezoneConfigError(Exception): """Exception class for timezone configuration related problems""" pass @@ -163,6 +172,7 @@ def get_all_regions_and_timezones(): result[parts[0]] = set() result[parts[0]].add(parts[1])
+ result["Etc"] = set(ETC_ZONES) return result
def is_valid_timezone(timezone): @@ -174,5 +184,7 @@ def is_valid_timezone(timezone):
"""
- return timezone in pytz.common_timezones + etc_zones = ["Etc/" + zone for zone in ETC_ZONES] + + return timezone in pytz.common_timezones + etc_zones
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py index f3249bb..aae574c 100644 --- a/pyanaconda/ui/gui/spokes/datetime_spoke.py +++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py @@ -366,7 +366,16 @@ class DatetimeSpoke(NormalSpoke): GLib.source_remove(self._update_datetime_timer_id) self._update_datetime_timer_id = None
- self.data.timezone.timezone = self._tzmap.get_timezone() + new_tz = self._tzmap.get_timezone() + + # get_timezone() may return "" if Etc/XXXXX is selected + if not new_tz: + # get selected "Etc/XXXXXX" zone + region = self._get_active_region() + city = self._get_active_city() + new_tz = region + "/" + city + + self.data.timezone.timezone = new_tz
if self._ntpSwitch.get_active(): # turned ON @@ -719,7 +728,16 @@ class DatetimeSpoke(NormalSpoke): if city and region: timezone = region + "/" + city
- if timezone and (self._tzmap.get_timezone() != timezone): + if timezone is not None and region == "Etc": + # Etc timezones cannot be displayed on the map, so let's set the map + # to "" which sets it to "Europe/London" (UTC) without a city pin + self._tzmap.set_timezone("") + + # Change to Etc/XXXXX emits timezone-changed with "" as timezone, + # so let's help it a bit. + self._tzmap.emit("timezone-changed", timezone) + + elif timezone and (self._tzmap.get_timezone() != timezone): self._tzmap.set_timezone(timezone)
def on_month_changed(self, *args): @@ -736,13 +754,16 @@ class DatetimeSpoke(NormalSpoke): def on_timezone_changed(self, tz_map, timezone): fields = timezone.split("/", 1) if len(fields) == 1: - #initial "" + # timezone may be "" return - else: - region, city = fields
- self._set_combo_selection(self._regionCombo, region) - self._set_combo_selection(self._cityCombo, city) + region, city = fields + if region != "Etc": + # If region is "Etc", TimezoneMap returns "" from get_timezone + # and changing comboboxes here would create an endless loop. + self._set_combo_selection(self._regionCombo, region) + self._set_combo_selection(self._cityCombo, city) + os.environ["TZ"] = timezone self._update_datetime()
I tried to do only minimum changes to the widget.
Vratislav Podzimek (2): TimezoneMap should handle "" timezone Add UTC and GMT-X timezones (#863199)
pyanaconda/timezone.py | 14 +++++++++++- pyanaconda/ui/gui/spokes/datetime_spoke.py | 35 ++++++++++++++++++++++++------ widgets/src/TimezoneMap.c | 35 ++++++++++++++++++++++-------- 3 files changed, 67 insertions(+), 17 deletions(-)
I think this is fine.
- Chris
anaconda-patches@lists.fedorahosted.org