Merge lp:~jjardon/indicator-datetime/update_map into lp:indicator-datetime/0.3
- update_map
- Merge into trunk
Proposed by
Javier Jardón
Status: | Rejected |
---|---|
Rejected by: | Charles Kerr |
Proposed branch: | lp:~jjardon/indicator-datetime/update_map |
Merge into: | lp:indicator-datetime/0.3 |
Diff against target: |
853 lines (+343/-228) 6 files modified
libmap/Makefile.am (+3/-1) libmap/cc-timezone-map.c (+44/-89) libmap/cc-timezone-map.h (+2/-4) libmap/test-timezone.c (+94/-49) libmap/tz.c (+196/-84) libmap/tz.h (+4/-1) |
To merge this branch: | bzr merge lp:~jjardon/indicator-datetime/update_map |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Disapprove | ||
Review via email: mp+76144@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 140. By Javier Jardón
-
Handle GMT offsets as timezones
Unmerged revisions
- 140. By Javier Jardón
-
Handle GMT offsets as timezones
- 139. By Javier Jardón
-
libmap/Makefile.am: Add two missing timezone files
- 138. By Javier Jardón
-
libmap: Use GtkStyleContext instead deprecated GtkStyle
- 137. By Javier Jardón
-
libmap: sync cc-timezone-map code against upstream
- 136. By Javier Jardón
-
libmap: Update tz utilities
- 135. By Javier Jardón
-
libmap: Update maps with upstream
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libmap/Makefile.am' | |||
2 | --- libmap/Makefile.am 2011-02-23 18:28:53 +0000 | |||
3 | +++ libmap/Makefile.am 2011-09-21 00:00:29 +0000 | |||
4 | @@ -16,6 +16,7 @@ | |||
5 | 16 | data/timezone_12.png \ | 16 | data/timezone_12.png \ |
6 | 17 | data/timezone_12.75.png \ | 17 | data/timezone_12.75.png \ |
7 | 18 | data/timezone_13.png \ | 18 | data/timezone_13.png \ |
8 | 19 | data/timezone_14.png \ | ||
9 | 19 | data/timezone_-2.png \ | 20 | data/timezone_-2.png \ |
10 | 20 | data/timezone_2.png \ | 21 | data/timezone_2.png \ |
11 | 21 | data/timezone_-3.png \ | 22 | data/timezone_-3.png \ |
12 | @@ -38,6 +39,7 @@ | |||
13 | 38 | data/timezone_7.png \ | 39 | data/timezone_7.png \ |
14 | 39 | data/timezone_-8.png \ | 40 | data/timezone_-8.png \ |
15 | 40 | data/timezone_8.png \ | 41 | data/timezone_8.png \ |
16 | 42 | data/timezone_8.75.png \ | ||
17 | 41 | data/timezone_-9.png \ | 43 | data/timezone_-9.png \ |
18 | 42 | data/timezone_9.png \ | 44 | data/timezone_9.png \ |
19 | 43 | data/timezone_-9.5.png \ | 45 | data/timezone_-9.5.png \ |
20 | @@ -55,7 +57,7 @@ | |||
21 | 55 | 57 | ||
22 | 56 | noinst_PROGRAMS = test-timezone | 58 | noinst_PROGRAMS = test-timezone |
23 | 57 | 59 | ||
25 | 58 | test_timezone_SOURCES = test-timezone.c tz.c tz.h | 60 | test_timezone_SOURCES = test-timezone.c tz.c tz.h cc-timezone-map.h cc-timezone-map.c |
26 | 59 | test_timezone_LDADD = $(LIBMAP_LIBS) | 61 | test_timezone_LDADD = $(LIBMAP_LIBS) |
27 | 60 | test_timezone_CFLAGS = $(LIBMAP_CFLAGS) | 62 | test_timezone_CFLAGS = $(LIBMAP_CFLAGS) |
28 | 61 | 63 | ||
29 | 62 | 64 | ||
30 | === modified file 'libmap/cc-timezone-map.c' | |||
31 | --- libmap/cc-timezone-map.c 2011-06-29 13:10:25 +0000 | |||
32 | +++ libmap/cc-timezone-map.c 2011-09-21 00:00:29 +0000 | |||
33 | @@ -25,6 +25,7 @@ | |||
34 | 25 | 25 | ||
35 | 26 | #include "cc-timezone-map.h" | 26 | #include "cc-timezone-map.h" |
36 | 27 | #include <math.h> | 27 | #include <math.h> |
37 | 28 | #include <string.h> | ||
38 | 28 | #include "tz.h" | 29 | #include "tz.h" |
39 | 29 | 30 | ||
40 | 30 | G_DEFINE_TYPE (CcTimezoneMap, cc_timezone_map, GTK_TYPE_WIDGET) | 31 | G_DEFINE_TYPE (CcTimezoneMap, cc_timezone_map, GTK_TYPE_WIDGET) |
41 | @@ -50,10 +51,10 @@ | |||
42 | 50 | GdkPixbuf *background; | 51 | GdkPixbuf *background; |
43 | 51 | GdkPixbuf *color_map; | 52 | GdkPixbuf *color_map; |
44 | 52 | GdkPixbuf *olsen_map; | 53 | GdkPixbuf *olsen_map; |
46 | 53 | 54 | ||
47 | 54 | guchar *visible_map_pixels; | 55 | guchar *visible_map_pixels; |
48 | 55 | gint visible_map_rowstride; | 56 | gint visible_map_rowstride; |
50 | 56 | 57 | ||
51 | 57 | gint olsen_map_channels; | 58 | gint olsen_map_channels; |
52 | 58 | guchar *olsen_map_pixels; | 59 | guchar *olsen_map_pixels; |
53 | 59 | gint olsen_map_rowstride; | 60 | gint olsen_map_rowstride; |
54 | @@ -64,7 +65,6 @@ | |||
55 | 64 | 65 | ||
56 | 65 | TzDB *tzdb; | 66 | TzDB *tzdb; |
57 | 66 | TzLocation *location; | 67 | TzLocation *location; |
58 | 67 | GHashTable *alias_db; | ||
59 | 68 | }; | 68 | }; |
60 | 69 | 69 | ||
61 | 70 | enum | 70 | enum |
62 | @@ -570,12 +570,6 @@ | |||
63 | 570 | priv->visible_map_rowstride = 0; | 570 | priv->visible_map_rowstride = 0; |
64 | 571 | } | 571 | } |
65 | 572 | 572 | ||
66 | 573 | if (priv->alias_db) | ||
67 | 574 | { | ||
68 | 575 | g_hash_table_destroy (priv->alias_db); | ||
69 | 576 | priv->alias_db = NULL; | ||
70 | 577 | } | ||
71 | 578 | |||
72 | 579 | if (priv->watermark) | 573 | if (priv->watermark) |
73 | 580 | { | 574 | { |
74 | 581 | g_free (priv->watermark); | 575 | g_free (priv->watermark); |
75 | @@ -686,11 +680,10 @@ | |||
76 | 686 | window = gdk_window_new (gtk_widget_get_parent_window (widget), &attr, | 680 | window = gdk_window_new (gtk_widget_get_parent_window (widget), &attr, |
77 | 687 | GDK_WA_X | GDK_WA_Y); | 681 | GDK_WA_X | GDK_WA_Y); |
78 | 688 | 682 | ||
79 | 689 | gdk_window_set_user_data (window, widget); | ||
80 | 690 | |||
81 | 691 | cursor = gdk_cursor_new (GDK_HAND2); | 683 | cursor = gdk_cursor_new (GDK_HAND2); |
82 | 692 | gdk_window_set_cursor (window, cursor); | 684 | gdk_window_set_cursor (window, cursor); |
83 | 693 | 685 | ||
84 | 686 | gdk_window_set_user_data (window, widget); | ||
85 | 694 | gtk_widget_set_window (widget, window); | 687 | gtk_widget_set_window (widget, window); |
86 | 695 | } | 688 | } |
87 | 696 | 689 | ||
88 | @@ -739,23 +732,26 @@ | |||
89 | 739 | CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv; | 732 | CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv; |
90 | 740 | GdkPixbuf *hilight, *orig_hilight, *pin; | 733 | GdkPixbuf *hilight, *orig_hilight, *pin; |
91 | 741 | GtkAllocation alloc; | 734 | GtkAllocation alloc; |
92 | 735 | GtkStateFlags state; | ||
93 | 736 | GtkStyleContext *context; | ||
94 | 737 | GdkRGBA rgba; | ||
95 | 742 | gchar *file; | 738 | gchar *file; |
96 | 743 | GError *err = NULL; | 739 | GError *err = NULL; |
97 | 744 | gdouble pointx, pointy; | 740 | gdouble pointx, pointy; |
98 | 745 | gdouble alpha = 1.0; | 741 | gdouble alpha = 1.0; |
99 | 746 | GtkStyle *style; | ||
100 | 747 | char buf[16]; | 742 | char buf[16]; |
101 | 748 | 743 | ||
102 | 749 | gtk_widget_get_allocation (widget, &alloc); | 744 | gtk_widget_get_allocation (widget, &alloc); |
103 | 750 | 745 | ||
105 | 751 | style = gtk_widget_get_style (widget); | 746 | state = gtk_widget_get_state_flags (widget); |
106 | 752 | 747 | ||
107 | 753 | /* Check if insensitive */ | 748 | /* Check if insensitive */ |
109 | 754 | if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE) | 749 | if (state & GTK_STATE_FLAG_INSENSITIVE) |
110 | 755 | alpha = 0.5; | 750 | alpha = 0.5; |
111 | 756 | 751 | ||
112 | 757 | /* paint background */ | 752 | /* paint background */ |
114 | 758 | gdk_cairo_set_source_color (cr, &style->bg[gtk_widget_get_state (widget)]); | 753 | gtk_style_context_get_color (context, state, &rgba); |
115 | 754 | gdk_cairo_set_source_rgba (cr, &rgba); | ||
116 | 759 | cairo_paint (cr); | 755 | cairo_paint (cr); |
117 | 760 | gdk_cairo_set_source_pixbuf (cr, priv->background, 0, 0); | 756 | gdk_cairo_set_source_pixbuf (cr, priv->background, 0, 0); |
118 | 761 | cairo_paint_with_alpha (cr, alpha); | 757 | cairo_paint_with_alpha (cr, alpha); |
119 | @@ -773,10 +769,6 @@ | |||
120 | 773 | cairo_stroke(cr); | 769 | cairo_stroke(cr); |
121 | 774 | } | 770 | } |
122 | 775 | 771 | ||
123 | 776 | if (!priv->location) { | ||
124 | 777 | return TRUE; | ||
125 | 778 | } | ||
126 | 779 | |||
127 | 780 | /* paint hilight */ | 772 | /* paint hilight */ |
128 | 781 | file = g_strdup_printf (DATADIR "/timezone_%s.png", | 773 | file = g_strdup_printf (DATADIR "/timezone_%s.png", |
129 | 782 | g_ascii_formatd (buf, sizeof (buf), | 774 | g_ascii_formatd (buf, sizeof (buf), |
130 | @@ -804,6 +796,13 @@ | |||
131 | 804 | g_object_unref (orig_hilight); | 796 | g_object_unref (orig_hilight); |
132 | 805 | } | 797 | } |
133 | 806 | 798 | ||
134 | 799 | /* Don't draw the pin for non-geographical locations */ | ||
135 | 800 | if (priv->location && | ||
136 | 801 | g_str_has_prefix (priv->location->zone, "Etc/")) | ||
137 | 802 | { | ||
138 | 803 | return TRUE; | ||
139 | 804 | } | ||
140 | 805 | |||
141 | 807 | /* load pin icon */ | 806 | /* load pin icon */ |
142 | 808 | pin = gdk_pixbuf_new_from_file (DATADIR "/pin.png", &err); | 807 | pin = gdk_pixbuf_new_from_file (DATADIR "/pin.png", &err); |
143 | 809 | 808 | ||
144 | @@ -813,16 +812,23 @@ | |||
145 | 813 | g_clear_error (&err); | 812 | g_clear_error (&err); |
146 | 814 | } | 813 | } |
147 | 815 | 814 | ||
153 | 816 | pointx = convert_longtitude_to_x (priv->location->longitude, alloc.width); | 815 | if (priv->location) |
154 | 817 | pointy = convert_latitude_to_y (priv->location->latitude, alloc.height); | 816 | { |
155 | 818 | 817 | pointx = convert_longtitude_to_x (priv->location->longitude, alloc.width); | |
156 | 819 | if (pointy > alloc.height) | 818 | pointy = convert_latitude_to_y (priv->location->latitude, alloc.height); |
157 | 820 | pointy = alloc.height; | 819 | |
158 | 820 | if (pointy > alloc.height) | ||
159 | 821 | pointy = alloc.height; | ||
160 | 822 | |||
161 | 823 | if (pin) | ||
162 | 824 | { | ||
163 | 825 | gdk_cairo_set_source_pixbuf (cr, pin, pointx - 8, pointy - 14); | ||
164 | 826 | cairo_paint_with_alpha (cr, alpha); | ||
165 | 827 | } | ||
166 | 828 | } | ||
167 | 821 | 829 | ||
168 | 822 | if (pin) | 830 | if (pin) |
169 | 823 | { | 831 | { |
170 | 824 | gdk_cairo_set_source_pixbuf (cr, pin, pointx - 8, pointy - 14); | ||
171 | 825 | cairo_paint_with_alpha (cr, alpha); | ||
172 | 826 | g_object_unref (pin); | 832 | g_object_unref (pin); |
173 | 827 | } | 833 | } |
174 | 828 | 834 | ||
175 | @@ -964,6 +970,7 @@ | |||
176 | 964 | { | 970 | { |
177 | 965 | TzLocation * loc = get_loc_for_xy (widget, event->x, event->y); | 971 | TzLocation * loc = get_loc_for_xy (widget, event->x, event->y); |
178 | 966 | set_location (CC_TIMEZONE_MAP (widget), loc); | 972 | set_location (CC_TIMEZONE_MAP (widget), loc); |
179 | 973 | |||
180 | 967 | return TRUE; | 974 | return TRUE; |
181 | 968 | } | 975 | } |
182 | 969 | 976 | ||
183 | @@ -975,57 +982,6 @@ | |||
184 | 975 | } | 982 | } |
185 | 976 | 983 | ||
186 | 977 | static void | 984 | static void |
187 | 978 | load_backward_tz (CcTimezoneMap *self) | ||
188 | 979 | { | ||
189 | 980 | GError *error = NULL; | ||
190 | 981 | char **lines, *contents; | ||
191 | 982 | guint i; | ||
192 | 983 | |||
193 | 984 | self->priv->alias_db = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); | ||
194 | 985 | |||
195 | 986 | if (g_file_get_contents (GNOMECC_DATA_DIR "/datetime/backward", &contents, NULL, &error) == FALSE) | ||
196 | 987 | { | ||
197 | 988 | g_warning ("Failed to load 'backward' file: %s", error->message); | ||
198 | 989 | return; | ||
199 | 990 | } | ||
200 | 991 | lines = g_strsplit (contents, "\n", -1); | ||
201 | 992 | g_free (contents); | ||
202 | 993 | for (i = 0; lines[i] != NULL; i++) | ||
203 | 994 | { | ||
204 | 995 | char **items; | ||
205 | 996 | guint j; | ||
206 | 997 | char *real, *alias; | ||
207 | 998 | |||
208 | 999 | if (g_ascii_strncasecmp (lines[i], "Link\t", 5) != 0) | ||
209 | 1000 | continue; | ||
210 | 1001 | |||
211 | 1002 | items = g_strsplit (lines[i], "\t", -1); | ||
212 | 1003 | real = NULL; | ||
213 | 1004 | alias = NULL; | ||
214 | 1005 | /* Skip the "Link<tab>" part */ | ||
215 | 1006 | for (j = 1; items[j] != NULL; j++) | ||
216 | 1007 | { | ||
217 | 1008 | if (items[j][0] == '\0') | ||
218 | 1009 | continue; | ||
219 | 1010 | if (real == NULL) | ||
220 | 1011 | { | ||
221 | 1012 | real = items[j]; | ||
222 | 1013 | continue; | ||
223 | 1014 | } | ||
224 | 1015 | alias = items[j]; | ||
225 | 1016 | break; | ||
226 | 1017 | } | ||
227 | 1018 | |||
228 | 1019 | if (real == NULL || alias == NULL) | ||
229 | 1020 | g_warning ("Could not parse line: %s", lines[i]); | ||
230 | 1021 | |||
231 | 1022 | g_hash_table_insert (self->priv->alias_db, g_strdup (alias), g_strdup (real)); | ||
232 | 1023 | g_strfreev (items); | ||
233 | 1024 | } | ||
234 | 1025 | g_strfreev (lines); | ||
235 | 1026 | } | ||
236 | 1027 | |||
237 | 1028 | static void | ||
238 | 1029 | cc_timezone_map_init (CcTimezoneMap *self) | 985 | cc_timezone_map_init (CcTimezoneMap *self) |
239 | 1030 | { | 986 | { |
240 | 1031 | CcTimezoneMapPrivate *priv; | 987 | CcTimezoneMapPrivate *priv; |
241 | @@ -1070,8 +1026,6 @@ | |||
242 | 1070 | NULL); | 1026 | NULL); |
243 | 1071 | g_signal_connect (self, "state-flags-changed", G_CALLBACK (state_flags_changed), | 1027 | g_signal_connect (self, "state-flags-changed", G_CALLBACK (state_flags_changed), |
244 | 1072 | NULL); | 1028 | NULL); |
245 | 1073 | |||
246 | 1074 | load_backward_tz (self); | ||
247 | 1075 | } | 1029 | } |
248 | 1076 | 1030 | ||
249 | 1077 | CcTimezoneMap * | 1031 | CcTimezoneMap * |
250 | @@ -1080,17 +1034,19 @@ | |||
251 | 1080 | return g_object_new (CC_TYPE_TIMEZONE_MAP, NULL); | 1034 | return g_object_new (CC_TYPE_TIMEZONE_MAP, NULL); |
252 | 1081 | } | 1035 | } |
253 | 1082 | 1036 | ||
255 | 1083 | void | 1037 | gboolean |
256 | 1084 | cc_timezone_map_set_timezone (CcTimezoneMap *map, | 1038 | cc_timezone_map_set_timezone (CcTimezoneMap *map, |
257 | 1085 | const gchar *timezone) | 1039 | const gchar *timezone) |
258 | 1086 | { | 1040 | { |
259 | 1087 | GPtrArray *locations; | 1041 | GPtrArray *locations; |
260 | 1088 | guint i; | 1042 | guint i; |
261 | 1089 | char *real_tz; | 1043 | char *real_tz; |
262 | 1044 | gboolean ret; | ||
263 | 1090 | 1045 | ||
265 | 1091 | real_tz = g_hash_table_lookup (map->priv->alias_db, timezone); | 1046 | real_tz = tz_info_get_clean_name (map->priv->tzdb, timezone); |
266 | 1092 | 1047 | ||
267 | 1093 | locations = tz_get_locations (map->priv->tzdb); | 1048 | locations = tz_get_locations (map->priv->tzdb); |
268 | 1049 | ret = FALSE; | ||
269 | 1094 | 1050 | ||
270 | 1095 | for (i = 0; i < locations->len; i++) | 1051 | for (i = 0; i < locations->len; i++) |
271 | 1096 | { | 1052 | { |
272 | @@ -1099,18 +1055,17 @@ | |||
273 | 1099 | if (!g_strcmp0 (loc->zone, real_tz ? real_tz : timezone)) | 1055 | if (!g_strcmp0 (loc->zone, real_tz ? real_tz : timezone)) |
274 | 1100 | { | 1056 | { |
275 | 1101 | set_location (map, loc); | 1057 | set_location (map, loc); |
276 | 1058 | ret = TRUE; | ||
277 | 1102 | break; | 1059 | break; |
278 | 1103 | } | 1060 | } |
279 | 1104 | } | 1061 | } |
280 | 1105 | 1062 | ||
289 | 1106 | gtk_widget_queue_draw (GTK_WIDGET (map)); | 1063 | if (ret) |
290 | 1107 | } | 1064 | gtk_widget_queue_draw (GTK_WIDGET (map)); |
291 | 1108 | 1065 | ||
292 | 1109 | void | 1066 | g_free (real_tz); |
293 | 1110 | cc_timezone_map_set_coords (CcTimezoneMap *map, gdouble lon, gdouble lat) | 1067 | |
294 | 1111 | { | 1068 | return ret; |
287 | 1112 | const gchar * zone = cc_timezone_map_get_timezone_at_coords (map, lon, lat); | ||
288 | 1113 | cc_timezone_map_set_timezone (map, zone); | ||
295 | 1114 | } | 1069 | } |
296 | 1115 | 1070 | ||
297 | 1116 | const gchar * | 1071 | const gchar * |
298 | 1117 | 1072 | ||
299 | === modified file 'libmap/cc-timezone-map.h' | |||
300 | --- libmap/cc-timezone-map.h 2011-02-23 21:26:49 +0000 | |||
301 | +++ libmap/cc-timezone-map.h 2011-09-21 00:00:29 +0000 | |||
302 | @@ -72,10 +72,8 @@ | |||
303 | 72 | 72 | ||
304 | 73 | void cc_timezone_map_set_watermark (CcTimezoneMap * map, | 73 | void cc_timezone_map_set_watermark (CcTimezoneMap * map, |
305 | 74 | const gchar * watermark); | 74 | const gchar * watermark); |
310 | 75 | void cc_timezone_map_set_timezone (CcTimezoneMap *map, | 75 | gboolean cc_timezone_map_set_timezone (CcTimezoneMap *map, |
311 | 76 | const gchar *timezone); | 76 | const gchar *timezone); |
308 | 77 | void cc_timezone_map_set_coords (CcTimezoneMap *map, | ||
309 | 78 | gdouble lon, gdouble lat); | ||
312 | 79 | const gchar * cc_timezone_map_get_timezone_at_coords (CcTimezoneMap *map, | 77 | const gchar * cc_timezone_map_get_timezone_at_coords (CcTimezoneMap *map, |
313 | 80 | gdouble lon, gdouble lat); | 78 | gdouble lon, gdouble lat); |
314 | 81 | TzLocation * cc_timezone_map_get_location (CcTimezoneMap *map); | 79 | TzLocation * cc_timezone_map_get_location (CcTimezoneMap *map); |
315 | 82 | 80 | ||
316 | === modified file 'libmap/data/cc.png' | |||
317 | 83 | Binary files libmap/data/cc.png 2011-02-22 16:20:34 +0000 and libmap/data/cc.png 2011-09-21 00:00:29 +0000 differ | 81 | Binary files libmap/data/cc.png 2011-02-22 16:20:34 +0000 and libmap/data/cc.png 2011-09-21 00:00:29 +0000 differ |
318 | === modified file 'libmap/data/timezone_-11.png' | |||
319 | 84 | Binary files libmap/data/timezone_-11.png 2011-02-22 16:20:34 +0000 and libmap/data/timezone_-11.png 2011-09-21 00:00:29 +0000 differ | 82 | Binary files libmap/data/timezone_-11.png 2011-02-22 16:20:34 +0000 and libmap/data/timezone_-11.png 2011-09-21 00:00:29 +0000 differ |
320 | === modified file 'libmap/data/timezone_8.png' | |||
321 | 85 | Binary files libmap/data/timezone_8.png 2011-02-22 16:20:34 +0000 and libmap/data/timezone_8.png 2011-09-21 00:00:29 +0000 differ | 83 | Binary files libmap/data/timezone_8.png 2011-02-22 16:20:34 +0000 and libmap/data/timezone_8.png 2011-09-21 00:00:29 +0000 differ |
322 | === modified file 'libmap/test-timezone.c' | |||
323 | --- libmap/test-timezone.c 2011-02-25 16:41:56 +0000 | |||
324 | +++ libmap/test-timezone.c 2011-09-21 00:00:29 +0000 | |||
325 | @@ -1,56 +1,101 @@ | |||
330 | 1 | #include <config.h> | 1 | #include <gtk/gtk.h> |
331 | 2 | #include <locale.h> | 2 | #include "cc-timezone-map.h" |
332 | 3 | 3 | ||
333 | 4 | #include "tz.h" | 4 | #define TZ_DIR "/usr/share/zoneinfo/" |
334 | 5 | |||
335 | 6 | static GList * | ||
336 | 7 | get_timezone_list (GList *tzs, | ||
337 | 8 | const char *top_path, | ||
338 | 9 | const char *subpath) | ||
339 | 10 | { | ||
340 | 11 | GDir *dir; | ||
341 | 12 | char *fullpath; | ||
342 | 13 | const char *name; | ||
343 | 14 | |||
344 | 15 | if (subpath == NULL) | ||
345 | 16 | fullpath = g_strdup (top_path); | ||
346 | 17 | else | ||
347 | 18 | fullpath = g_build_filename (top_path, subpath, NULL); | ||
348 | 19 | dir = g_dir_open (fullpath, 0, NULL); | ||
349 | 20 | if (dir == NULL) { | ||
350 | 21 | g_warning ("Could not open %s", fullpath); | ||
351 | 22 | return NULL; | ||
352 | 23 | } | ||
353 | 24 | while ((name = g_dir_read_name (dir)) != NULL) { | ||
354 | 25 | char *path; | ||
355 | 26 | |||
356 | 27 | if (g_str_has_suffix (name, ".tab")) | ||
357 | 28 | continue; | ||
358 | 29 | |||
359 | 30 | if (subpath != NULL) | ||
360 | 31 | path = g_build_filename (top_path, subpath, name, NULL); | ||
361 | 32 | else | ||
362 | 33 | path = g_build_filename (top_path, name, NULL); | ||
363 | 34 | if (g_file_test (path, G_FILE_TEST_IS_DIR)) { | ||
364 | 35 | if (subpath == NULL) { | ||
365 | 36 | tzs = get_timezone_list (tzs, top_path, name); | ||
366 | 37 | } else { | ||
367 | 38 | char *new_subpath; | ||
368 | 39 | new_subpath = g_strdup_printf ("%s/%s", subpath, name); | ||
369 | 40 | tzs = get_timezone_list (tzs, top_path, new_subpath); | ||
370 | 41 | g_free (new_subpath); | ||
371 | 42 | } | ||
372 | 43 | } else if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) { | ||
373 | 44 | if (subpath == NULL) | ||
374 | 45 | tzs = g_list_prepend (tzs, g_strdup (name)); | ||
375 | 46 | else { | ||
376 | 47 | char *tz; | ||
377 | 48 | tz = g_strdup_printf ("%s/%s", subpath, name); | ||
378 | 49 | tzs = g_list_prepend (tzs, tz); | ||
379 | 50 | } | ||
380 | 51 | } | ||
381 | 52 | g_free (path); | ||
382 | 53 | } | ||
383 | 54 | g_dir_close (dir); | ||
384 | 55 | |||
385 | 56 | return tzs; | ||
386 | 57 | } | ||
387 | 5 | 58 | ||
388 | 6 | int main (int argc, char **argv) | 59 | int main (int argc, char **argv) |
389 | 7 | { | 60 | { |
428 | 8 | TzDB *db; | 61 | CcTimezoneMap *map; |
429 | 9 | GPtrArray *locs; | 62 | TzDB *tz_db; |
430 | 10 | guint i; | 63 | GList *tzs, *l; |
431 | 11 | char *pixmap_dir; | 64 | GHashTable *ht; |
432 | 12 | int retval = 0; | 65 | int ret = 0; |
433 | 13 | 66 | ||
434 | 14 | setlocale (LC_ALL, ""); | 67 | gtk_init (&argc, &argv); |
435 | 15 | 68 | ||
436 | 16 | if (argc == 2) { | 69 | ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); |
437 | 17 | pixmap_dir = g_strdup (argv[1]); | 70 | map = cc_timezone_map_new (); |
438 | 18 | } else if (argc == 1) { | 71 | tz_db = tz_load_db (); |
439 | 19 | pixmap_dir = g_strdup ("data/"); | 72 | tzs = get_timezone_list (NULL, TZ_DIR, NULL); |
440 | 20 | } else { | 73 | for (l = tzs; l != NULL; l = l->next) { |
441 | 21 | g_message ("Usage: %s [PIXMAP DIRECTORY]", argv[0]); | 74 | char *timezone = l->data; |
442 | 22 | return 1; | 75 | char *clean_tz; |
443 | 23 | } | 76 | |
444 | 24 | 77 | clean_tz = tz_info_get_clean_name (tz_db, timezone); | |
445 | 25 | db = tz_load_db (); | 78 | |
446 | 26 | locs = tz_get_locations (db); | 79 | if (cc_timezone_map_set_timezone (map, clean_tz) == FALSE) { |
447 | 27 | for (i = 0; i < locs->len ; i++) { | 80 | if (g_hash_table_lookup (ht, clean_tz) == NULL) { |
448 | 28 | TzLocation *loc = locs->pdata[i]; | 81 | if (g_strcmp0 (clean_tz, timezone) == 0) |
449 | 29 | TzInfo *info; | 82 | g_print ("Failed to locate timezone '%s'\n", timezone); |
450 | 30 | char *filename, *path; | 83 | else |
451 | 31 | gdouble selected_offset; | 84 | g_print ("Failed to locate timezone '%s' (original name: '%s')\n", clean_tz, timezone); |
452 | 32 | char buf[16]; | 85 | g_hash_table_insert (ht, g_strdup (clean_tz), GINT_TO_POINTER (TRUE)); |
453 | 33 | 86 | } | |
454 | 34 | info = tz_info_from_location (loc); | 87 | /* We don't warn for those two, we'll just fallback |
455 | 35 | selected_offset = tz_location_get_utc_offset (loc) | 88 | * in the panel code */ |
456 | 36 | / (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0); | 89 | if (!g_str_equal (clean_tz, "posixrules") && |
457 | 37 | 90 | !g_str_equal (clean_tz, "Factory")) | |
458 | 38 | filename = g_strdup_printf ("timezone_%s.png", | 91 | ret = 1; |
421 | 39 | g_ascii_formatd (buf, sizeof (buf), | ||
422 | 40 | "%g", selected_offset)); | ||
423 | 41 | path = g_build_filename (pixmap_dir, filename, NULL); | ||
424 | 42 | |||
425 | 43 | if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) { | ||
426 | 44 | g_message ("File '%s' missing for zone '%s'", filename, loc->zone); | ||
427 | 45 | retval = 1; | ||
459 | 46 | } | 92 | } |
464 | 47 | 93 | g_free (timezone); | |
465 | 48 | g_free (filename); | 94 | g_free (clean_tz); |
462 | 49 | g_free (path); | ||
463 | 50 | tz_info_free (info); | ||
466 | 51 | } | 95 | } |
469 | 52 | tz_db_free (db); | 96 | g_list_free (tzs); |
470 | 53 | g_free (pixmap_dir); | 97 | tz_db_free (tz_db); |
471 | 98 | g_hash_table_destroy (ht); | ||
472 | 54 | 99 | ||
474 | 55 | return retval; | 100 | return ret; |
475 | 56 | } | 101 | } |
476 | 57 | 102 | ||
477 | === modified file 'libmap/tz.c' | |||
478 | --- libmap/tz.c 2011-02-23 18:28:53 +0000 | |||
479 | +++ libmap/tz.c 2011-09-21 00:00:29 +0000 | |||
480 | @@ -39,7 +39,7 @@ | |||
481 | 39 | static int compare_country_names (const void *a, const void *b); | 39 | static int compare_country_names (const void *a, const void *b); |
482 | 40 | static void sort_locations_by_country (GPtrArray *locations); | 40 | static void sort_locations_by_country (GPtrArray *locations); |
483 | 41 | static gchar * tz_data_file_get (void); | 41 | static gchar * tz_data_file_get (void); |
485 | 42 | 42 | static void load_backward_tz (TzDB *tz_db); | |
486 | 43 | 43 | ||
487 | 44 | /* ---------------- * | 44 | /* ---------------- * |
488 | 45 | * Public interface * | 45 | * Public interface * |
489 | @@ -51,6 +51,7 @@ | |||
490 | 51 | TzDB *tz_db; | 51 | TzDB *tz_db; |
491 | 52 | FILE *tzfile; | 52 | FILE *tzfile; |
492 | 53 | char buf[4096]; | 53 | char buf[4096]; |
493 | 54 | gint i; | ||
494 | 54 | 55 | ||
495 | 55 | tz_data_file = tz_data_file_get (); | 56 | tz_data_file = tz_data_file_get (); |
496 | 56 | if (!tz_data_file) { | 57 | if (!tz_data_file) { |
497 | @@ -119,14 +120,45 @@ | |||
498 | 119 | } | 120 | } |
499 | 120 | 121 | ||
500 | 121 | fclose (tzfile); | 122 | fclose (tzfile); |
502 | 122 | 123 | ||
503 | 124 | /* Add the Etc/GMT offsets, except Etc/GMT+12, which | ||
504 | 125 | * is not inhabited, see: | ||
505 | 126 | * http://en.wikipedia.org/wiki/GMT-12 | ||
506 | 127 | * | ||
507 | 128 | * Are you confused about the above? So was I. | ||
508 | 129 | * | ||
509 | 130 | * From tzdata | ||
510 | 131 | * We use POSIX-style signs in the Zone names and the output abbreviations, | ||
511 | 132 | * even though this is the opposite of what many people expect. | ||
512 | 133 | * POSIX has positive signs west of Greenwich, but many people expect | ||
513 | 134 | * positive signs east of Greenwich. | ||
514 | 135 | * etc. | ||
515 | 136 | */ | ||
516 | 137 | for (i = -14; i <= 12; i++) { | ||
517 | 138 | TzLocation *loc; | ||
518 | 139 | |||
519 | 140 | if (i == 12) | ||
520 | 141 | continue; | ||
521 | 142 | |||
522 | 143 | loc = g_new0 (TzLocation, 1); | ||
523 | 144 | if (i != 0) | ||
524 | 145 | loc->zone = g_strdup_printf ("Etc/GMT%c%d", i < 0 ? '-' : '+', abs(i)); | ||
525 | 146 | else | ||
526 | 147 | loc->zone = g_strdup ("Etc/GMT"); | ||
527 | 148 | loc->country = g_strdup ("XX"); | ||
528 | 149 | g_ptr_array_add (tz_db->locations, (gpointer) loc); | ||
529 | 150 | } | ||
530 | 151 | |||
531 | 123 | /* now sort by country */ | 152 | /* now sort by country */ |
532 | 124 | sort_locations_by_country (tz_db->locations); | 153 | sort_locations_by_country (tz_db->locations); |
533 | 125 | 154 | ||
534 | 126 | g_free (tz_data_file); | 155 | g_free (tz_data_file); |
536 | 127 | 156 | ||
537 | 157 | /* Load up the hashtable of backward links */ | ||
538 | 158 | load_backward_tz (tz_db); | ||
539 | 159 | |||
540 | 128 | return tz_db; | 160 | return tz_db; |
542 | 129 | } | 161 | } |
543 | 130 | 162 | ||
544 | 131 | static void | 163 | static void |
545 | 132 | tz_location_free (TzLocation *loc) | 164 | tz_location_free (TzLocation *loc) |
546 | @@ -143,58 +175,10 @@ | |||
547 | 143 | { | 175 | { |
548 | 144 | g_ptr_array_foreach (db->locations, (GFunc) tz_location_free, NULL); | 176 | g_ptr_array_foreach (db->locations, (GFunc) tz_location_free, NULL); |
549 | 145 | g_ptr_array_free (db->locations, TRUE); | 177 | g_ptr_array_free (db->locations, TRUE); |
550 | 178 | g_hash_table_destroy (db->backward); | ||
551 | 146 | g_free (db); | 179 | g_free (db); |
552 | 147 | } | 180 | } |
553 | 148 | 181 | ||
554 | 149 | static gint | ||
555 | 150 | sort_locations (TzLocation *a, | ||
556 | 151 | TzLocation *b) | ||
557 | 152 | { | ||
558 | 153 | if (a->dist > b->dist) | ||
559 | 154 | return 1; | ||
560 | 155 | |||
561 | 156 | if (a->dist < b->dist) | ||
562 | 157 | return -1; | ||
563 | 158 | |||
564 | 159 | return 0; | ||
565 | 160 | } | ||
566 | 161 | |||
567 | 162 | static gdouble | ||
568 | 163 | convert_longtitude_to_x (gdouble longitude, gint map_width) | ||
569 | 164 | { | ||
570 | 165 | const gdouble xdeg_offset = -6; | ||
571 | 166 | gdouble x; | ||
572 | 167 | |||
573 | 168 | x = (map_width * (180.0 + longitude) / 360.0) | ||
574 | 169 | + (map_width * xdeg_offset / 180.0); | ||
575 | 170 | |||
576 | 171 | return x; | ||
577 | 172 | } | ||
578 | 173 | |||
579 | 174 | static gdouble | ||
580 | 175 | radians (gdouble degrees) | ||
581 | 176 | { | ||
582 | 177 | return (degrees / 360.0) * G_PI * 2; | ||
583 | 178 | } | ||
584 | 179 | |||
585 | 180 | static gdouble | ||
586 | 181 | convert_latitude_to_y (gdouble latitude, gdouble map_height) | ||
587 | 182 | { | ||
588 | 183 | gdouble bottom_lat = -59; | ||
589 | 184 | gdouble top_lat = 81; | ||
590 | 185 | gdouble top_per, y, full_range, top_offset, map_range; | ||
591 | 186 | |||
592 | 187 | top_per = top_lat / 180.0; | ||
593 | 188 | y = 1.25 * log (tan (G_PI_4 + 0.4 * radians (latitude))); | ||
594 | 189 | full_range = 4.6068250867599998; | ||
595 | 190 | top_offset = full_range * top_per; | ||
596 | 191 | map_range = fabs (1.25 * log (tan (G_PI_4 + 0.4 * radians (bottom_lat))) - top_offset); | ||
597 | 192 | y = fabs (y - top_offset); | ||
598 | 193 | y = y / map_range; | ||
599 | 194 | y = y * map_height; | ||
600 | 195 | return y; | ||
601 | 196 | } | ||
602 | 197 | |||
603 | 198 | GPtrArray * | 182 | GPtrArray * |
604 | 199 | tz_get_locations (TzDB *db) | 183 | tz_get_locations (TzDB *db) |
605 | 200 | { | 184 | { |
606 | @@ -242,47 +226,18 @@ | |||
607 | 242 | return offset; | 226 | return offset; |
608 | 243 | } | 227 | } |
609 | 244 | 228 | ||
610 | 245 | gint | ||
611 | 246 | tz_location_set_locally (TzLocation *loc) | ||
612 | 247 | { | ||
613 | 248 | time_t curtime; | ||
614 | 249 | struct tm *curzone; | ||
615 | 250 | gboolean is_dst = FALSE; | ||
616 | 251 | gint correction = 0; | ||
617 | 252 | |||
618 | 253 | g_return_val_if_fail (loc != NULL, 0); | ||
619 | 254 | g_return_val_if_fail (loc->zone != NULL, 0); | ||
620 | 255 | |||
621 | 256 | curtime = time (NULL); | ||
622 | 257 | curzone = localtime (&curtime); | ||
623 | 258 | is_dst = curzone->tm_isdst; | ||
624 | 259 | |||
625 | 260 | setenv ("TZ", loc->zone, 1); | ||
626 | 261 | #if 0 | ||
627 | 262 | curtime = time (NULL); | ||
628 | 263 | curzone = localtime (&curtime); | ||
629 | 264 | |||
630 | 265 | if (!is_dst && curzone->tm_isdst) { | ||
631 | 266 | correction = (60 * 60); | ||
632 | 267 | } | ||
633 | 268 | else if (is_dst && !curzone->tm_isdst) { | ||
634 | 269 | correction = 0; | ||
635 | 270 | } | ||
636 | 271 | #endif | ||
637 | 272 | |||
638 | 273 | return correction; | ||
639 | 274 | } | ||
640 | 275 | |||
641 | 276 | TzInfo * | 229 | TzInfo * |
642 | 277 | tz_info_from_location (TzLocation *loc) | 230 | tz_info_from_location (TzLocation *loc) |
643 | 278 | { | 231 | { |
644 | 279 | TzInfo *tzinfo; | 232 | TzInfo *tzinfo; |
645 | 280 | time_t curtime; | 233 | time_t curtime; |
646 | 281 | struct tm *curzone; | 234 | struct tm *curzone; |
647 | 235 | gchar *tz_env_value; | ||
648 | 282 | 236 | ||
649 | 283 | g_return_val_if_fail (loc != NULL, NULL); | 237 | g_return_val_if_fail (loc != NULL, NULL); |
650 | 284 | g_return_val_if_fail (loc->zone != NULL, NULL); | 238 | g_return_val_if_fail (loc->zone != NULL, NULL); |
651 | 285 | 239 | ||
652 | 240 | tz_env_value = g_strdup (getenv ("TZ")); | ||
653 | 286 | setenv ("TZ", loc->zone, 1); | 241 | setenv ("TZ", loc->zone, 1); |
654 | 287 | 242 | ||
655 | 288 | #if 0 | 243 | #if 0 |
656 | @@ -311,6 +266,13 @@ | |||
657 | 311 | #endif | 266 | #endif |
658 | 312 | 267 | ||
659 | 313 | tzinfo->daylight = curzone->tm_isdst; | 268 | tzinfo->daylight = curzone->tm_isdst; |
660 | 269 | |||
661 | 270 | if (tz_env_value) | ||
662 | 271 | setenv ("TZ", tz_env_value, 1); | ||
663 | 272 | else | ||
664 | 273 | unsetenv ("TZ"); | ||
665 | 274 | |||
666 | 275 | g_free (tz_env_value); | ||
667 | 314 | 276 | ||
668 | 315 | return tzinfo; | 277 | return tzinfo; |
669 | 316 | } | 278 | } |
670 | @@ -326,6 +288,99 @@ | |||
671 | 326 | g_free (tzinfo); | 288 | g_free (tzinfo); |
672 | 327 | } | 289 | } |
673 | 328 | 290 | ||
674 | 291 | struct { | ||
675 | 292 | const char *orig; | ||
676 | 293 | const char *dest; | ||
677 | 294 | } aliases[] = { | ||
678 | 295 | { "Asia/Istanbul", "Europe/Istanbul" }, /* Istanbul is in both Europe and Asia */ | ||
679 | 296 | { "Europe/Nicosia", "Asia/Nicosia" }, /* Ditto */ | ||
680 | 297 | { "EET", "Europe/Istanbul" }, /* Same tz as the 2 above */ | ||
681 | 298 | { "HST", "Pacific/Honolulu" }, | ||
682 | 299 | { "WET", "Europe/Brussels" }, /* Other name for the mainland Europe tz */ | ||
683 | 300 | { "CET", "Europe/Brussels" }, /* ditto */ | ||
684 | 301 | { "MET", "Europe/Brussels" }, | ||
685 | 302 | { "Etc/Zulu", "Etc/GMT" }, | ||
686 | 303 | { "Etc/UTC", "Etc/GMT" }, | ||
687 | 304 | { "GMT", "Etc/GMT" }, | ||
688 | 305 | { "Greenwich", "Etc/GMT" }, | ||
689 | 306 | { "Etc/UCT", "Etc/GMT" }, | ||
690 | 307 | { "Etc/GMT0", "Etc/GMT" }, | ||
691 | 308 | { "Etc/GMT+0", "Etc/GMT" }, | ||
692 | 309 | { "Etc/GMT-0", "Etc/GMT" }, | ||
693 | 310 | { "Etc/Universal", "Etc/GMT" }, | ||
694 | 311 | { "PST8PDT", "America/Los_Angeles" }, /* Other name for the Atlantic tz */ | ||
695 | 312 | { "EST", "America/New_York" }, /* Other name for the Eastern tz */ | ||
696 | 313 | { "EST5EDT", "America/New_York" }, /* ditto */ | ||
697 | 314 | { "CST6CDT", "America/Chicago" }, /* Other name for the Central tz */ | ||
698 | 315 | { "MST", "America/Denver" }, /* Other name for the mountain tz */ | ||
699 | 316 | { "MST7MDT", "America/Denver" }, /* ditto */ | ||
700 | 317 | }; | ||
701 | 318 | |||
702 | 319 | static gboolean | ||
703 | 320 | compare_timezones (const char *a, | ||
704 | 321 | const char *b) | ||
705 | 322 | { | ||
706 | 323 | if (g_str_equal (a, b)) | ||
707 | 324 | return TRUE; | ||
708 | 325 | if (strchr (b, '/') == NULL) { | ||
709 | 326 | char *prefixed; | ||
710 | 327 | |||
711 | 328 | prefixed = g_strdup_printf ("/%s", b); | ||
712 | 329 | if (g_str_has_suffix (a, prefixed)) { | ||
713 | 330 | g_free (prefixed); | ||
714 | 331 | return TRUE; | ||
715 | 332 | } | ||
716 | 333 | g_free (prefixed); | ||
717 | 334 | } | ||
718 | 335 | |||
719 | 336 | return FALSE; | ||
720 | 337 | } | ||
721 | 338 | |||
722 | 339 | char * | ||
723 | 340 | tz_info_get_clean_name (TzDB *tz_db, | ||
724 | 341 | const char *tz) | ||
725 | 342 | { | ||
726 | 343 | char *ret; | ||
727 | 344 | const char *timezone; | ||
728 | 345 | guint i; | ||
729 | 346 | gboolean replaced; | ||
730 | 347 | |||
731 | 348 | /* Remove useless prefixes */ | ||
732 | 349 | if (g_str_has_prefix (tz, "right/")) | ||
733 | 350 | tz = tz + strlen ("right/"); | ||
734 | 351 | else if (g_str_has_prefix (tz, "posix/")) | ||
735 | 352 | tz = tz + strlen ("posix/"); | ||
736 | 353 | |||
737 | 354 | /* Here start the crazies */ | ||
738 | 355 | replaced = FALSE; | ||
739 | 356 | |||
740 | 357 | for (i = 0; i < G_N_ELEMENTS (aliases); i++) { | ||
741 | 358 | if (compare_timezones (tz, aliases[i].orig)) { | ||
742 | 359 | replaced = TRUE; | ||
743 | 360 | timezone = aliases[i].dest; | ||
744 | 361 | break; | ||
745 | 362 | } | ||
746 | 363 | } | ||
747 | 364 | |||
748 | 365 | /* Try again! */ | ||
749 | 366 | if (!replaced) { | ||
750 | 367 | /* Ignore crazy solar times from the '80s */ | ||
751 | 368 | if (g_str_has_prefix (tz, "Asia/Riyadh") || | ||
752 | 369 | g_str_has_prefix (tz, "Mideast/Riyadh")) { | ||
753 | 370 | timezone = "Asia/Riyadh"; | ||
754 | 371 | replaced = TRUE; | ||
755 | 372 | } | ||
756 | 373 | } | ||
757 | 374 | |||
758 | 375 | if (!replaced) | ||
759 | 376 | timezone = tz; | ||
760 | 377 | |||
761 | 378 | ret = g_hash_table_lookup (tz_db->backward, timezone); | ||
762 | 379 | if (ret == NULL) | ||
763 | 380 | return g_strdup (timezone); | ||
764 | 381 | return g_strdup (ret); | ||
765 | 382 | } | ||
766 | 383 | |||
767 | 329 | /* ----------------- * | 384 | /* ----------------- * |
768 | 330 | * Private functions * | 385 | * Private functions * |
769 | 331 | * ----------------- */ | 386 | * ----------------- */ |
770 | @@ -397,3 +452,60 @@ | |||
771 | 397 | qsort (locations->pdata, locations->len, sizeof (gpointer), | 452 | qsort (locations->pdata, locations->len, sizeof (gpointer), |
772 | 398 | compare_country_names); | 453 | compare_country_names); |
773 | 399 | } | 454 | } |
774 | 455 | |||
775 | 456 | static void | ||
776 | 457 | load_backward_tz (TzDB *tz_db) | ||
777 | 458 | { | ||
778 | 459 | GError *error = NULL; | ||
779 | 460 | char **lines, *contents; | ||
780 | 461 | guint i; | ||
781 | 462 | |||
782 | 463 | tz_db->backward = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); | ||
783 | 464 | |||
784 | 465 | if (g_file_get_contents (GNOMECC_DATA_DIR "/datetime/backward", &contents, NULL, &error) == FALSE) | ||
785 | 466 | { | ||
786 | 467 | g_warning ("Failed to load 'backward' file: %s", error->message); | ||
787 | 468 | return; | ||
788 | 469 | } | ||
789 | 470 | lines = g_strsplit (contents, "\n", -1); | ||
790 | 471 | g_free (contents); | ||
791 | 472 | for (i = 0; lines[i] != NULL; i++) | ||
792 | 473 | { | ||
793 | 474 | char **items; | ||
794 | 475 | guint j; | ||
795 | 476 | char *real, *alias; | ||
796 | 477 | |||
797 | 478 | if (g_ascii_strncasecmp (lines[i], "Link\t", 5) != 0) | ||
798 | 479 | continue; | ||
799 | 480 | |||
800 | 481 | items = g_strsplit (lines[i], "\t", -1); | ||
801 | 482 | real = NULL; | ||
802 | 483 | alias = NULL; | ||
803 | 484 | /* Skip the "Link<tab>" part */ | ||
804 | 485 | for (j = 1; items[j] != NULL; j++) | ||
805 | 486 | { | ||
806 | 487 | if (items[j][0] == '\0') | ||
807 | 488 | continue; | ||
808 | 489 | if (real == NULL) | ||
809 | 490 | { | ||
810 | 491 | real = items[j]; | ||
811 | 492 | continue; | ||
812 | 493 | } | ||
813 | 494 | alias = items[j]; | ||
814 | 495 | break; | ||
815 | 496 | } | ||
816 | 497 | |||
817 | 498 | if (real == NULL || alias == NULL) | ||
818 | 499 | g_warning ("Could not parse line: %s", lines[i]); | ||
819 | 500 | |||
820 | 501 | /* We don't need more than one name for it */ | ||
821 | 502 | if (g_str_equal (real, "Etc/UTC") || | ||
822 | 503 | g_str_equal (real, "Etc/UCT")) | ||
823 | 504 | real = "Etc/GMT"; | ||
824 | 505 | |||
825 | 506 | g_hash_table_insert (tz_db->backward, g_strdup (alias), g_strdup (real)); | ||
826 | 507 | g_strfreev (items); | ||
827 | 508 | } | ||
828 | 509 | g_strfreev (lines); | ||
829 | 510 | } | ||
830 | 511 | |||
831 | 400 | 512 | ||
832 | === modified file 'libmap/tz.h' | |||
833 | --- libmap/tz.h 2011-02-22 16:20:34 +0000 | |||
834 | +++ libmap/tz.h 2011-09-21 00:00:29 +0000 | |||
835 | @@ -41,7 +41,8 @@ | |||
836 | 41 | 41 | ||
837 | 42 | struct _TzDB | 42 | struct _TzDB |
838 | 43 | { | 43 | { |
840 | 44 | GPtrArray *locations; | 44 | GPtrArray *locations; |
841 | 45 | GHashTable *backward; | ||
842 | 45 | }; | 46 | }; |
843 | 46 | 47 | ||
844 | 47 | struct _TzLocation | 48 | struct _TzLocation |
845 | @@ -72,6 +73,8 @@ | |||
846 | 72 | 73 | ||
847 | 73 | TzDB *tz_load_db (void); | 74 | TzDB *tz_load_db (void); |
848 | 74 | void tz_db_free (TzDB *db); | 75 | void tz_db_free (TzDB *db); |
849 | 76 | char * tz_info_get_clean_name (TzDB *tz_db, | ||
850 | 77 | const char *tz); | ||
851 | 75 | GPtrArray *tz_get_locations (TzDB *db); | 78 | GPtrArray *tz_get_locations (TzDB *db); |
852 | 76 | void tz_location_get_position (TzLocation *loc, | 79 | void tz_location_get_position (TzLocation *loc, |
853 | 77 | double *longitude, double *latitude); | 80 | double *longitude, double *latitude); |
indicator-datetime uses an external dependency for this now (libtimezonemap), so we're no longer bundling libmap.
I appreciate you taking the time to make this patch. I think the code reviewers need to do a better job of handling these reviews in a timely manner so that conflicting patches like this have less chance of occurring.
The patch looks fine, but since it's now moot I'm going to pass on it.