2
#include "cc-timezone-map.h"
4
#define TZ_DIR "/usr/share/zoneinfo/"
7
get_timezone_list (GList *tzs,
16
fullpath = g_strdup (top_path);
18
fullpath = g_build_filename (top_path, subpath, NULL);
19
dir = g_dir_open (fullpath, 0, NULL);
21
g_warning ("Could not open %s", fullpath);
24
while ((name = g_dir_read_name (dir)) != NULL) {
27
if (g_str_has_suffix (name, ".tab"))
31
path = g_build_filename (top_path, subpath, name, NULL);
33
path = g_build_filename (top_path, name, NULL);
34
if (g_file_test (path, G_FILE_TEST_IS_DIR)) {
35
if (subpath == NULL) {
36
tzs = get_timezone_list (tzs, top_path, name);
39
new_subpath = g_strdup_printf ("%s/%s", subpath, name);
40
tzs = get_timezone_list (tzs, top_path, new_subpath);
43
} else if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
45
tzs = g_list_prepend (tzs, g_strdup (name));
48
tz = g_strdup_printf ("%s/%s", subpath, name);
49
tzs = g_list_prepend (tzs, tz);
59
int main (int argc, char **argv)
67
gtk_init (&argc, &argv);
69
ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
70
map = cc_timezone_map_new ();
71
tz_db = tz_load_db ();
72
tzs = get_timezone_list (NULL, TZ_DIR, NULL);
73
for (l = tzs; l != NULL; l = l->next) {
74
char *timezone = l->data;
77
clean_tz = tz_info_get_clean_name (tz_db, timezone);
79
if (cc_timezone_map_set_timezone (map, clean_tz) == FALSE) {
80
if (g_hash_table_lookup (ht, clean_tz) == NULL) {
81
if (g_strcmp0 (clean_tz, timezone) == 0)
82
g_print ("Failed to locate timezone '%s'\n", timezone);
84
g_print ("Failed to locate timezone '%s' (original name: '%s')\n", clean_tz, timezone);
85
g_hash_table_insert (ht, g_strdup (clean_tz), GINT_TO_POINTER (TRUE));
87
/* We don't warn for those two, we'll just fallback
88
* in the panel code */
89
if (!g_str_equal (clean_tz, "posixrules") &&
90
!g_str_equal (clean_tz, "Factory"))
98
g_hash_table_destroy (ht);