summaryrefslogtreecommitdiffstats
path: root/widgets/src/tz.c
diff options
context:
space:
mode:
authorVratislav Podzimek <vpodzime@redhat.com>2012-05-24 15:32:13 +0200
committerVratislav Podzimek <vpodzime@redhat.com>2012-05-24 16:48:09 +0200
commit6176b2386b8ebcc73c22a66425e349bef6d05d68 (patch)
tree2ef651d0bd82f5f0e3b64f6f33055c32662fc1ee /widgets/src/tz.c
parent4d4d803d672488abcc08c840a3e295368de1de2b (diff)
downloadanaconda-6176b2386b8ebcc73c22a66425e349bef6d05d68.tar.gz
anaconda-6176b2386b8ebcc73c22a66425e349bef6d05d68.tar.xz
anaconda-6176b2386b8ebcc73c22a66425e349bef6d05d68.zip
Make TimezoneMap suitable for testing
When testing we, need to set the location of the bitmaps our TimezoneMap is using, so let it try to get the location from the environment.
Diffstat (limited to 'widgets/src/tz.c')
-rw-r--r--widgets/src/tz.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/widgets/src/tz.c b/widgets/src/tz.c
index 5173808e0..54c0da51c 100644
--- a/widgets/src/tz.c
+++ b/widgets/src/tz.c
@@ -41,6 +41,20 @@ static void sort_locations_by_country (GPtrArray *locations);
static gchar * tz_data_file_get (void);
static void load_backward_tz (TzDB *tz_db);
+/* Returns path to anaconda widgets data directory using the value of the
+ * environment variable ANACONDA_WIDGETS_DATA or WIDGETS_DATADIR macro
+ * (defined in Makefile.am) if the environment variable is not defined.
+ */
+gchar *get_widgets_datadir() {
+ gchar *env_value;
+
+ env_value = getenv("ANACONDA_WIDGETS_DATA");
+ if (env_value == NULL)
+ return WIDGETS_DATADIR;
+ else
+ return env_value;
+}
+
/* ---------------- *
* Public interface *
* ---------------- */
@@ -381,13 +395,17 @@ load_backward_tz (TzDB *tz_db)
GError *error = NULL;
char **lines, *contents;
guint i;
+ gchar *file;
tz_db->backward = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- if (g_file_get_contents (BACKWARDDIR "timezones_backward", &contents, NULL, &error) == FALSE) {
+ file = g_strdup_printf ("%s/" TZMAP_DATADIR "/timezones_backward", get_widgets_datadir());
+ if (g_file_get_contents (file, &contents, NULL, &error) == FALSE) {
g_warning ("Failed to load 'backward' file: %s", error->message);
return;
}
+ g_free(file);
+
lines = g_strsplit (contents, "\n", -1);
g_free (contents);
for (i = 0; lines[i] != NULL; i++) {