datetime: Return FALSE when we fail to find a timezone

This commit is contained in:
Bastien Nocera 2011-03-15 00:49:00 +00:00
parent 9ab02da28b
commit cb3c0af71d
2 changed files with 10 additions and 4 deletions

View file

@ -636,17 +636,19 @@ cc_timezone_map_new (void)
return g_object_new (CC_TYPE_TIMEZONE_MAP, NULL); return g_object_new (CC_TYPE_TIMEZONE_MAP, NULL);
} }
void gboolean
cc_timezone_map_set_timezone (CcTimezoneMap *map, cc_timezone_map_set_timezone (CcTimezoneMap *map,
const gchar *timezone) const gchar *timezone)
{ {
GPtrArray *locations; GPtrArray *locations;
guint i; guint i;
char *real_tz; char *real_tz;
gboolean ret;
real_tz = g_hash_table_lookup (map->priv->alias_db, timezone); real_tz = g_hash_table_lookup (map->priv->alias_db, timezone);
locations = tz_get_locations (map->priv->tzdb); locations = tz_get_locations (map->priv->tzdb);
ret = FALSE;
for (i = 0; i < locations->len; i++) for (i = 0; i < locations->len; i++)
{ {
@ -655,11 +657,15 @@ cc_timezone_map_set_timezone (CcTimezoneMap *map,
if (!g_strcmp0 (loc->zone, real_tz ? real_tz : timezone)) if (!g_strcmp0 (loc->zone, real_tz ? real_tz : timezone))
{ {
set_location (map, loc); set_location (map, loc);
ret = TRUE;
break; break;
} }
} }
gtk_widget_queue_draw (GTK_WIDGET (map)); if (ret)
gtk_widget_queue_draw (GTK_WIDGET (map));
return ret;
} }
TzLocation * TzLocation *

View file

@ -70,8 +70,8 @@ GType cc_timezone_map_get_type (void) G_GNUC_CONST;
CcTimezoneMap *cc_timezone_map_new (void); CcTimezoneMap *cc_timezone_map_new (void);
void cc_timezone_map_set_timezone (CcTimezoneMap *map, gboolean cc_timezone_map_set_timezone (CcTimezoneMap *map,
const gchar *timezone); const gchar *timezone);
TzLocation * cc_timezone_map_get_location (CcTimezoneMap *map); TzLocation * cc_timezone_map_get_location (CcTimezoneMap *map);
G_END_DECLS G_END_DECLS