Merge lp:~laney/timezonemap/more-data-whitespace into lp:timezonemap

Proposed by Iain Lane
Status: Merged
Merged at revision: 32
Proposed branch: lp:~laney/timezonemap/more-data-whitespace
Merge into: lp:timezonemap
Prerequisite: lp:~laney/timezonemap/more-data
Diff against target: 1354 lines (+550/-488)
4 files modified
src/cc-timezone-map.c (+49/-48)
src/test-timezone.c (+52/-49)
src/timezone-completion.c (+326/-270)
src/tz.c (+123/-121)
To merge this branch: bzr merge lp:~laney/timezonemap/more-data-whitespace
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Pending
Review via email: mp+193907@code.launchpad.net

Commit message

Make whitespace & indentation consistent

Description of the change

There's a mix of tabs and spaces, and indentation styles. Try to unify these.

Also wrap lines to 80 columns.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/cc-timezone-map.c'
2--- src/cc-timezone-map.c 2012-11-06 17:14:04 +0000
3+++ src/cc-timezone-map.c 2013-11-05 11:33:58 +0000
4@@ -974,40 +974,41 @@
5 width = alloc.width;
6 height = alloc.height;
7
8- if (x == priv->previous_x && y == priv->previous_y) {
9- priv->distances = g_list_next (priv->distances);
10- location = (CcTimezoneLocation*) priv->distances->data;
11- } else {
12- g_list_free (priv->distances);
13- priv->distances = NULL;
14- for (i = 0; i < array->len; i++)
15- {
16- gdouble pointx, pointy, dx, dy;
17- CcTimezoneLocation *loc = array->pdata[i];
18-
19- g_object_get_property(G_OBJECT (loc), "longitude", &glon);
20- g_object_get_property(G_OBJECT (loc), "latitude", &glat);
21- pointx = convert_longtitude_to_x (g_value_get_double(&glon), width);
22- pointy = convert_latitude_to_y (g_value_get_double(&glat), height);
23-
24- dx = pointx - x;
25- dy = pointy - y;
26-
27- g_value_set_double(&gdist, (gdouble) dx * dx + dy * dy);
28- g_object_set_property(G_OBJECT (loc), "dist", &gdist);
29- priv->distances = g_list_prepend (priv->distances, loc);
30- }
31- priv->distances = g_list_sort (priv->distances, (GCompareFunc) sort_locations);
32- location = (CcTimezoneLocation*) priv->distances->data;
33- priv->previous_x = x;
34- priv->previous_y = y;
35- }
36-
37- g_value_unset (&glon);
38- g_value_unset (&glat);
39- g_value_unset (&gdist);
40-
41- return location;
42+ if (x == priv->previous_x && y == priv->previous_y)
43+ {
44+ priv->distances = g_list_next (priv->distances);
45+ location = (CcTimezoneLocation*) priv->distances->data;
46+ } else {
47+ g_list_free (priv->distances);
48+ priv->distances = NULL;
49+ for (i = 0; i < array->len; i++)
50+ {
51+ gdouble pointx, pointy, dx, dy;
52+ CcTimezoneLocation *loc = array->pdata[i];
53+
54+ g_object_get_property(G_OBJECT (loc), "longitude", &glon);
55+ g_object_get_property(G_OBJECT (loc), "latitude", &glat);
56+ pointx = convert_longtitude_to_x (g_value_get_double(&glon), width);
57+ pointy = convert_latitude_to_y (g_value_get_double(&glat), height);
58+
59+ dx = pointx - x;
60+ dy = pointy - y;
61+
62+ g_value_set_double(&gdist, (gdouble) dx * dx + dy * dy);
63+ g_object_set_property(G_OBJECT (loc), "dist", &gdist);
64+ priv->distances = g_list_prepend (priv->distances, loc);
65+ }
66+ priv->distances = g_list_sort (priv->distances, (GCompareFunc) sort_locations);
67+ location = (CcTimezoneLocation*) priv->distances->data;
68+ priv->previous_x = x;
69+ priv->previous_y = y;
70+ }
71+
72+ g_value_unset (&glon);
73+ g_value_unset (&glat);
74+ g_value_unset (&gdist);
75+
76+ return location;
77 }
78
79 static gboolean
80@@ -1199,20 +1200,20 @@
81 if (zone < G_N_ELEMENTS(olsen_map_timezones))
82 city = olsen_map_timezones[zone];
83
84- if (city != NULL) {
85- return city;
86- }
87- else {
88- GtkAllocation alloc;
89- GValue val_zone = {0};
90- g_value_init (&val_zone, G_TYPE_STRING);
91- gtk_widget_get_allocation (GTK_WIDGET (map), &alloc);
92- x = convert_longtitude_to_x(lon, alloc.width);
93- y = convert_latitude_to_y(lat, alloc.height);
94- CcTimezoneLocation * loc = get_loc_for_xy(GTK_WIDGET (map), x, y);
95- g_value_unset (&val_zone);
96- return g_value_get_string(&val_zone);
97- }
98+ if (city != NULL)
99+ {
100+ return city;
101+ } else {
102+ GtkAllocation alloc;
103+ GValue val_zone = {0};
104+ g_value_init (&val_zone, G_TYPE_STRING);
105+ gtk_widget_get_allocation (GTK_WIDGET (map), &alloc);
106+ x = convert_longtitude_to_x(lon, alloc.width);
107+ y = convert_latitude_to_y(lat, alloc.height);
108+ CcTimezoneLocation * loc = get_loc_for_xy(GTK_WIDGET (map), x, y);
109+ g_value_unset (&val_zone);
110+ return g_value_get_string(&val_zone);
111+ }
112 }
113
114 void
115
116=== modified file 'src/test-timezone.c'
117--- src/test-timezone.c 2011-08-01 16:37:54 +0000
118+++ src/test-timezone.c 2013-11-05 11:33:58 +0000
119@@ -5,58 +5,61 @@
120
121 int main (int argc, char **argv)
122 {
123- TzDB *db;
124- GPtrArray *locs;
125- guint i;
126- char *pixmap_dir;
127- int retval = 0;
128+ TzDB *db;
129+ GPtrArray *locs;
130+ guint i;
131+ char *pixmap_dir;
132+ int retval = 0;
133
134 setlocale (LC_ALL, "");
135
136- if (argc == 2) {
137- pixmap_dir = g_strdup (argv[1]);
138- } else if (argc == 1) {
139- pixmap_dir = g_strdup ("data/");
140- } else {
141- g_message ("Usage: %s [PIXMAP DIRECTORY]", argv[0]);
142- return 1;
143- }
144-
145- g_type_init();
146- GValue zone = {0};
147- g_value_init(&zone, G_TYPE_STRING);
148-
149- db = tz_load_db ();
150- locs = tz_get_locations (db);
151- for (i = 0; i < locs->len ; i++) {
152- CcTimezoneLocation *loc = locs->pdata[i];
153-
154- TzInfo *info;
155- char *filename, *path;
156- gdouble selected_offset;
157- char buf[16];
158- g_object_get_property(G_OBJECT (loc), "zone", &zone);
159-
160- info = tz_info_from_location (loc);
161- selected_offset = tz_location_get_utc_offset (loc)
162- / (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0);
163-
164- filename = g_strdup_printf ("timezone_%s.png",
165+ if (argc == 2)
166+ {
167+ pixmap_dir = g_strdup (argv[1]);
168+ } else if (argc == 1) {
169+ pixmap_dir = g_strdup ("data/");
170+ } else {
171+ g_message ("Usage: %s [PIXMAP DIRECTORY]", argv[0]);
172+ return 1;
173+ }
174+
175+ g_type_init();
176+ GValue zone = {0};
177+ g_value_init(&zone, G_TYPE_STRING);
178+
179+ db = tz_load_db ();
180+ locs = tz_get_locations (db);
181+ for (i = 0; i < locs->len ; i++)
182+ {
183+ CcTimezoneLocation *loc = locs->pdata[i];
184+
185+ TzInfo *info;
186+ char *filename, *path;
187+ gdouble selected_offset;
188+ char buf[16];
189+ g_object_get_property(G_OBJECT (loc), "zone", &zone);
190+
191+ info = tz_info_from_location (loc);
192+ selected_offset = tz_location_get_utc_offset (loc)
193+ / (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0);
194+
195+ filename = g_strdup_printf ("timezone_%s.png",
196 g_ascii_formatd (buf, sizeof (buf),
197 "%g", selected_offset));
198- path = g_build_filename (pixmap_dir, filename, NULL);
199-
200- if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) {
201- g_message ("File '%s' missing for zone '%s'", filename, g_value_get_string(&zone));
202- retval = 1;
203- }
204-
205- g_free (filename);
206- g_free (path);
207- tz_info_free (info);
208- }
209- tz_db_free (db);
210- g_free (pixmap_dir);
211-
212- return retval;
213+ path = g_build_filename (pixmap_dir, filename, NULL);
214+
215+ if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE)
216+ {
217+ g_message ("File '%s' missing for zone '%s'", filename, g_value_get_string(&zone));
218+ retval = 1;
219+ }
220+
221+ g_free (filename);
222+ g_free (path);
223+ tz_info_free (info);
224+ }
225+ tz_db_free (db);
226+ g_free (pixmap_dir);
227+
228+ return retval;
229 }
230
231=== modified file 'src/timezone-completion.c'
232--- src/timezone-completion.c 2012-11-06 17:14:04 +0000
233+++ src/timezone-completion.c 2013-11-05 11:33:58 +0000
234@@ -138,13 +138,14 @@
235 g_cancellable_reset (priv->cancel);
236 }
237
238- if (error != NULL) {
239- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
240- save_and_use_model (completion, priv->initial_model);
241- g_warning ("Could not parse geoname JSON data: %s", error->message);
242- g_error_free (error);
243- return;
244- }
245+ if (error != NULL)
246+ {
247+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
248+ save_and_use_model (completion, priv->initial_model);
249+ g_warning ("Could not parse geoname JSON data: %s", error->message);
250+ g_error_free (error);
251+ return;
252+ }
253
254 GtkListStore * store = gtk_list_store_new (CC_TIMEZONE_COMPLETION_LAST,
255 G_TYPE_STRING,
256@@ -156,73 +157,85 @@
257
258 JsonReader * reader = json_reader_new (json_parser_get_root (JSON_PARSER (object)));
259
260- if (!json_reader_is_array (reader)) {
261- g_warning ("Could not parse geoname JSON data");
262- save_and_use_model (completion, priv->initial_model);
263- g_object_unref (G_OBJECT (reader));
264- return;
265- }
266+ if (!json_reader_is_array (reader))
267+ {
268+ g_warning ("Could not parse geoname JSON data");
269+ save_and_use_model (completion, priv->initial_model);
270+ g_object_unref (G_OBJECT (reader));
271+ return;
272+ }
273
274 gint i, count = json_reader_count_elements (reader);
275- for (i = 0; i < count; ++i) {
276- if (!json_reader_read_element (reader, i))
277- continue;
278+ for (i = 0; i < count; ++i)
279+ {
280+ if (!json_reader_read_element (reader, i))
281+ continue;
282
283- if (json_reader_is_object (reader)) {
284- const gchar * name = NULL;
285- const gchar * admin1 = NULL;
286- const gchar * country = NULL;
287- const gchar * longitude = NULL;
288- const gchar * latitude = NULL;
289- gboolean skip = FALSE;
290- if (json_reader_read_member (reader, "name")) {
291- name = json_reader_get_string_value (reader);
292- json_reader_end_member (reader);
293- }
294- if (json_reader_read_member (reader, "admin1")) {
295- admin1 = json_reader_get_string_value (reader);
296- json_reader_end_member (reader);
297- }
298- if (json_reader_read_member (reader, "country")) {
299- country = json_reader_get_string_value (reader);
300- json_reader_end_member (reader);
301- }
302- if (json_reader_read_member (reader, "longitude")) {
303- longitude = json_reader_get_string_value (reader);
304- json_reader_end_member (reader);
305- }
306- if (json_reader_read_member (reader, "latitude")) {
307- latitude = json_reader_get_string_value (reader);
308- json_reader_end_member (reader);
309- }
310+ if (json_reader_is_object (reader))
311+ {
312+ const gchar * name = NULL;
313+ const gchar * admin1 = NULL;
314+ const gchar * country = NULL;
315+ const gchar * longitude = NULL;
316+ const gchar * latitude = NULL;
317+ gboolean skip = FALSE;
318+ if (json_reader_read_member (reader, "name"))
319+ {
320+ name = json_reader_get_string_value (reader);
321+ json_reader_end_member (reader);
322+ }
323+ if (json_reader_read_member (reader, "admin1"))
324+ {
325+ admin1 = json_reader_get_string_value (reader);
326+ json_reader_end_member (reader);
327+ }
328+ if (json_reader_read_member (reader, "country"))
329+ {
330+ country = json_reader_get_string_value (reader);
331+ json_reader_end_member (reader);
332+ }
333+ if (json_reader_read_member (reader, "longitude"))
334+ {
335+ longitude = json_reader_get_string_value (reader);
336+ json_reader_end_member (reader);
337+ }
338+ if (json_reader_read_member (reader, "latitude"))
339+ {
340+ latitude = json_reader_get_string_value (reader);
341+ json_reader_end_member (reader);
342+ }
343
344 if (g_strcmp0(name, prev_name) == 0 &&
345 g_strcmp0(admin1, prev_admin1) == 0 &&
346- g_strcmp0(country, prev_country) == 0) {
347- // Sometimes the data will have duplicate entries that only differ
348- // in longitude and latitude. e.g. "rio de janeiro", "wellington"
349- skip = TRUE;
350- }
351+ g_strcmp0(country, prev_country) == 0)
352+ {
353+ // Sometimes the data will have duplicate entries that only differ
354+ // in longitude and latitude. e.g. "rio de janeiro", "wellington"
355+ skip = TRUE;
356+ }
357
358- if (!skip) {
359- GtkTreeIter iter;
360- gtk_list_store_append (store, &iter);
361- gtk_list_store_set (store, &iter,
362- CC_TIMEZONE_COMPLETION_ZONE, NULL,
363- CC_TIMEZONE_COMPLETION_NAME, name,
364- CC_TIMEZONE_COMPLETION_ADMIN1, admin1,
365- CC_TIMEZONE_COMPLETION_COUNTRY, country,
366- CC_TIMEZONE_COMPLETION_LONGITUDE, longitude,
367- CC_TIMEZONE_COMPLETION_LATITUDE, latitude,
368- -1);
369- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
370- CC_TIMEZONE_COMPLETION_NAME, sort_zone,
371- g_utf8_casefold(priv->request_text, -1),
372- g_free);
373- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
374- CC_TIMEZONE_COMPLETION_NAME,
375- GTK_SORT_ASCENDING);
376- }
377+ if (!skip)
378+ {
379+ GtkTreeIter iter;
380+ gtk_list_store_append (store, &iter);
381+ gtk_list_store_set (store, &iter,
382+ CC_TIMEZONE_COMPLETION_ZONE, NULL,
383+ CC_TIMEZONE_COMPLETION_NAME, name,
384+ CC_TIMEZONE_COMPLETION_ADMIN1, admin1,
385+ CC_TIMEZONE_COMPLETION_COUNTRY, country,
386+ CC_TIMEZONE_COMPLETION_LONGITUDE, longitude,
387+ CC_TIMEZONE_COMPLETION_LATITUDE, latitude,
388+ -1);
389+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
390+ CC_TIMEZONE_COMPLETION_NAME,
391+ sort_zone,
392+ g_utf8_casefold(priv->request_text,
393+ -1),
394+ g_free);
395+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
396+ CC_TIMEZONE_COMPLETION_NAME,
397+ GTK_SORT_ASCENDING);
398+ }
399
400 prev_name = name;
401 prev_admin1 = admin1;
402@@ -232,19 +245,21 @@
403 json_reader_end_element (reader);
404 }
405
406- if (strlen (priv->request_text) < 4) {
407- gchar * lower_text = g_ascii_strdown (priv->request_text, -1);
408- if (g_strcmp0 (lower_text, "ut") == 0 ||
409- g_strcmp0 (lower_text, "utc") == 0) {
410- GtkTreeIter iter;
411- gtk_list_store_append (store, &iter);
412- gtk_list_store_set (store, &iter,
413- CC_TIMEZONE_COMPLETION_ZONE, "UTC",
414- CC_TIMEZONE_COMPLETION_NAME, "UTC",
415- -1);
416+ if (strlen (priv->request_text) < 4)
417+ {
418+ gchar * lower_text = g_ascii_strdown (priv->request_text, -1);
419+ if (g_strcmp0 (lower_text, "ut") == 0 ||
420+ g_strcmp0 (lower_text, "utc") == 0)
421+ {
422+ GtkTreeIter iter;
423+ gtk_list_store_append (store, &iter);
424+ gtk_list_store_set (store, &iter,
425+ CC_TIMEZONE_COMPLETION_ZONE, "UTC",
426+ CC_TIMEZONE_COMPLETION_NAME, "UTC",
427+ -1);
428+ }
429+ g_free (lower_text);
430 }
431- g_free (lower_text);
432- }
433
434 save_and_use_model (completion, GTK_TREE_MODEL (store));
435 g_object_unref (G_OBJECT (reader));
436@@ -260,17 +275,20 @@
437
438 stream = g_file_read_finish (G_FILE (object), res, &error);
439
440- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && priv->cancel) {
441- g_cancellable_reset (priv->cancel);
442- }
443+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && priv->cancel)
444+ {
445+ g_cancellable_reset (priv->cancel);
446+ }
447
448- if (error != NULL) {
449- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
450- save_and_use_model (completion, priv->initial_model);
451- g_warning ("Could not connect to geoname lookup server: %s", error->message);
452- g_error_free (error);
453- return;
454- }
455+ if (error != NULL)
456+ {
457+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
458+ save_and_use_model (completion, priv->initial_model);
459+ g_warning ("Could not connect to geoname lookup server: %s",
460+ error->message);
461+ g_error_free (error);
462+ return;
463+ }
464
465 JsonParser * parser = json_parser_new ();
466 json_parser_load_from_stream_async (parser, G_INPUT_STREAM (stream), priv->cancel,
467@@ -286,11 +304,12 @@
468 const gchar *env = NULL;
469 gint i;
470
471- for (i = 0; env_names[i]; i++) {
472- env = g_getenv (env_names[i]);
473- if (env != NULL && env[0] != 0)
474- break;
475- }
476+ for (i = 0; env_names[i]; i++)
477+ {
478+ env = g_getenv (env_names[i]);
479+ if (env != NULL && env[0] != 0)
480+ break;
481+ }
482
483 if (env == NULL)
484 return NULL;
485@@ -301,10 +320,11 @@
486 if (split == NULL)
487 return NULL;
488
489- if (split[0] == NULL) {
490- g_strfreev (split);
491- return NULL;
492- }
493+ if (split[0] == NULL)
494+ {
495+ g_strfreev (split);
496+ return NULL;
497+ }
498
499 gchar *locale = g_strdup (split[0]);
500 g_strfreev (split);
501@@ -316,15 +336,16 @@
502 {
503 static gchar *version = NULL;
504
505- if (version == NULL) {
506- gchar *stdout = NULL;
507- g_spawn_command_line_sync ("lsb_release -rs", &stdout, NULL, NULL, NULL);
508+ if (version == NULL)
509+ {
510+ gchar *stdout = NULL;
511+ g_spawn_command_line_sync ("lsb_release -rs", &stdout, NULL, NULL, NULL);
512
513- if (stdout != NULL)
514- version = g_strstrip (stdout);
515- else
516- version = g_strdup("");
517- }
518+ if (stdout != NULL)
519+ version = g_strstrip (stdout);
520+ else
521+ version = g_strdup("");
522+ }
523
524 return version;
525 }
526@@ -336,15 +357,17 @@
527
528 priv->queued_request = 0;
529
530- if (priv->entry == NULL) {
531- return FALSE;
532- }
533+ if (priv->entry == NULL)
534+ {
535+ return FALSE;
536+ }
537
538 /* Cancel any ongoing request */
539- if (priv->cancel) {
540- g_cancellable_cancel (priv->cancel);
541- g_cancellable_reset (priv->cancel);
542- }
543+ if (priv->cancel)
544+ {
545+ g_cancellable_cancel (priv->cancel);
546+ g_cancellable_reset (priv->cancel);
547+ }
548 g_free (priv->request_text);
549
550 const gchar * text = gtk_entry_get_text (priv->entry);
551@@ -371,21 +394,26 @@
552 {
553 CcTimezoneCompletionPrivate * priv = completion->priv;
554
555- if (priv->queued_request) {
556- g_source_remove (priv->queued_request);
557- priv->queued_request = 0;
558- }
559+ if (priv->queued_request)
560+ {
561+ g_source_remove (priv->queued_request);
562+ priv->queued_request = 0;
563+ }
564
565 /* See if we've already got this one */
566 const gchar * text = gtk_entry_get_text (priv->entry);
567 gpointer data;
568- if (g_hash_table_lookup_extended (priv->request_table, text, NULL, &data)) {
569- gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), GTK_TREE_MODEL (data));
570- }
571- else {
572- priv->queued_request = g_timeout_add (300, (GSourceFunc)request_zones, completion);
573- gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), NULL);
574- }
575+ if (g_hash_table_lookup_extended (priv->request_table, text, NULL, &data))
576+ {
577+ gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion),
578+ GTK_TREE_MODEL (data));
579+ }
580+ else
581+ {
582+ priv->queued_request = g_timeout_add (300, (GSourceFunc)request_zones,
583+ completion);
584+ gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), NULL);
585+ }
586 gtk_entry_completion_complete (GTK_ENTRY_COMPLETION (completion));
587 }
588
589@@ -395,18 +423,21 @@
590 if (g_type_is_a (G_OBJECT_TYPE (parent), type))
591 return parent;
592
593- if (GTK_IS_CONTAINER (parent)) {
594- GList * children = gtk_container_get_children (GTK_CONTAINER (parent));
595- GList * iter;
596- for (iter = children; iter; iter = iter->next) {
597- GtkWidget * found = get_descendent (GTK_WIDGET (iter->data), type);
598- if (found) {
599- g_list_free (children);
600- return found;
601- }
602+ if (GTK_IS_CONTAINER (parent))
603+ {
604+ GList * children = gtk_container_get_children (GTK_CONTAINER (parent));
605+ GList * iter;
606+ for (iter = children; iter; iter = iter->next)
607+ {
608+ GtkWidget * found = get_descendent (GTK_WIDGET (iter->data), type);
609+ if (found)
610+ {
611+ g_list_free (children);
612+ return found;
613+ }
614+ }
615+ g_list_free (children);
616 }
617- g_list_free (children);
618- }
619
620 return NULL;
621 }
622@@ -429,20 +460,26 @@
623 GtkWindowGroup * group = gtk_window_get_group (GTK_WINDOW (toplevel));
624 GList * windows = gtk_window_group_list_windows (group);
625 GList * iter;
626- for (iter = windows; iter; iter = iter->next) {
627- if (iter->data == toplevel)
628- continue; // Skip our own window, we don't have it
629- GtkWidget * view = get_descendent (GTK_WIDGET (iter->data), GTK_TYPE_TREE_VIEW);
630- if (view != NULL) {
631- GtkTreeModel * tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
632- if (GTK_IS_TREE_MODEL_FILTER (tree_model))
633- tree_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (tree_model));
634- if (tree_model == model) {
635- g_list_free (windows);
636- return GTK_TREE_VIEW (view);
637- }
638+ for (iter = windows; iter; iter = iter->next)
639+ {
640+ if (iter->data == toplevel)
641+ continue; // Skip our own window, we don't have it
642+ GtkWidget * view = get_descendent (GTK_WIDGET (iter->data),
643+ GTK_TYPE_TREE_VIEW);
644+ if (view != NULL)
645+ {
646+ GtkTreeModel * tree_model =
647+ gtk_tree_view_get_model (GTK_TREE_VIEW (view));
648+ if (GTK_IS_TREE_MODEL_FILTER (tree_model))
649+ tree_model = gtk_tree_model_filter_get_model (
650+ GTK_TREE_MODEL_FILTER (tree_model));
651+ if (tree_model == model)
652+ {
653+ g_list_free (windows);
654+ return GTK_TREE_VIEW (view);
655+ }
656+ }
657 }
658- }
659 g_list_free (windows);
660
661 return NULL;
662@@ -453,26 +490,30 @@
663 {
664 if (event->keyval == GDK_KEY_ISO_Enter ||
665 event->keyval == GDK_KEY_KP_Enter ||
666- event->keyval == GDK_KEY_Return) {
667- /* Make sure that user has a selection to choose, otherwise ignore */
668- GtkTreeModel * model = gtk_entry_completion_get_model (GTK_ENTRY_COMPLETION (completion));
669- GtkTreeView * view = find_popup_treeview (GTK_WIDGET (entry), model);
670- if (view == NULL) {
671- // Just beep if popup hasn't appeared yet.
672- gtk_widget_error_bell (GTK_WIDGET (entry));
673- return TRUE;
674- }
675+ event->keyval == GDK_KEY_Return)
676+ {
677+ /* Make sure that user has a selection to choose, otherwise ignore */
678+ GtkTreeModel * model = gtk_entry_completion_get_model (
679+ GTK_ENTRY_COMPLETION (completion));
680+ GtkTreeView * view = find_popup_treeview (GTK_WIDGET (entry), model);
681+ if (view == NULL)
682+ {
683+ // Just beep if popup hasn't appeared yet.
684+ gtk_widget_error_bell (GTK_WIDGET (entry));
685+ return TRUE;
686+ }
687
688- GtkTreeSelection * sel = gtk_tree_view_get_selection (view);
689- GtkTreeModel * sel_model = NULL;
690- if (!gtk_tree_selection_get_selected (sel, &sel_model, NULL)) {
691- // No selection, we should help them out and select first item in list
692- GtkTreeIter iter;
693- if (gtk_tree_model_get_iter_first (sel_model, &iter))
694- gtk_tree_selection_select_iter (sel, &iter);
695- // And fall through to normal handler code
696+ GtkTreeSelection * sel = gtk_tree_view_get_selection (view);
697+ GtkTreeModel * sel_model = NULL;
698+ if (!gtk_tree_selection_get_selected (sel, &sel_model, NULL))
699+ {
700+ // No selection, we should help them out and select first item in list
701+ GtkTreeIter iter;
702+ if (gtk_tree_model_get_iter_first (sel_model, &iter))
703+ gtk_tree_selection_select_iter (sel, &iter);
704+ // And fall through to normal handler code
705+ }
706 }
707- }
708
709 return FALSE;
710 }
711@@ -482,32 +523,37 @@
712 {
713 CcTimezoneCompletionPrivate * priv = completion->priv;
714
715- if (priv->queued_request) {
716- g_source_remove (priv->queued_request);
717- priv->queued_request = 0;
718- }
719- if (priv->entry) {
720- g_signal_handler_disconnect (priv->entry, priv->changed_id);
721- priv->changed_id = 0;
722- g_signal_handler_disconnect (priv->entry, priv->keypress_id);
723- priv->keypress_id = 0;
724- g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *)&priv->entry);
725- gtk_entry_set_completion (priv->entry, NULL);
726- }
727+ if (priv->queued_request)
728+ {
729+ g_source_remove (priv->queued_request);
730+ priv->queued_request = 0;
731+ }
732+ if (priv->entry)
733+ {
734+ g_signal_handler_disconnect (priv->entry, priv->changed_id);
735+ priv->changed_id = 0;
736+ g_signal_handler_disconnect (priv->entry, priv->keypress_id);
737+ priv->keypress_id = 0;
738+ g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *)&priv->entry);
739+ gtk_entry_set_completion (priv->entry, NULL);
740+ }
741
742 priv->entry = entry;
743
744- if (entry) {
745- guint id = g_signal_connect (entry, "changed", G_CALLBACK (entry_changed), completion);
746- priv->changed_id = id;
747-
748- id = g_signal_connect (entry, "key-press-event", G_CALLBACK (entry_keypress), completion);
749- priv->keypress_id = id;
750-
751- g_object_add_weak_pointer (G_OBJECT (entry), (gpointer *)&priv->entry);
752-
753- gtk_entry_set_completion (entry, GTK_ENTRY_COMPLETION (completion));
754- }
755+ if (entry)
756+ {
757+ guint id = g_signal_connect (entry, "changed",
758+ G_CALLBACK (entry_changed), completion);
759+ priv->changed_id = id;
760+
761+ id = g_signal_connect (entry, "key-press-event",
762+ G_CALLBACK (entry_keypress), completion);
763+ priv->keypress_id = id;
764+
765+ g_object_add_weak_pointer (G_OBJECT (entry), (gpointer *)&priv->entry);
766+
767+ gtk_entry_set_completion (entry, GTK_ENTRY_COMPLETION (completion));
768+ }
769 }
770
771 static GtkListStore *
772@@ -525,37 +571,38 @@
773 G_TYPE_STRING);
774
775 gint i;
776- for (i = 0; i < locations->len; ++i) {
777- CcTimezoneLocation * loc = g_ptr_array_index (locations, i);
778- GtkTreeIter iter;
779- gtk_list_store_append (store, &iter);
780-
781- gchar * zone;
782- gchar * country;
783- gchar * en_name; // FIXME: need something better for non-English locales
784- gdouble longitude;
785- gdouble latitude;
786- g_object_get (loc, "zone", &zone, "country", &country, "en_name", &en_name,
787- "longitude", &longitude, "latitude", &latitude,
788- NULL);
789-
790- gchar * longitude_s = g_strdup_printf ("%f", longitude);
791- gchar * latitude_s= g_strdup_printf ("%f", latitude);
792-
793- gtk_list_store_set (store, &iter,
794- CC_TIMEZONE_COMPLETION_ZONE, NULL,
795- CC_TIMEZONE_COMPLETION_NAME, en_name,
796- CC_TIMEZONE_COMPLETION_COUNTRY, country,
797- CC_TIMEZONE_COMPLETION_LONGITUDE, longitude_s,
798- CC_TIMEZONE_COMPLETION_LATITUDE, latitude_s,
799- -1);
800-
801- g_free (latitude_s);
802- g_free (longitude_s);
803- g_free (en_name);
804- g_free (country);
805- g_free (zone);
806- }
807+ for (i = 0; i < locations->len; ++i)
808+ {
809+ CcTimezoneLocation * loc = g_ptr_array_index (locations, i);
810+ GtkTreeIter iter;
811+ gtk_list_store_append (store, &iter);
812+
813+ gchar * zone;
814+ gchar * country;
815+ gchar * en_name; // FIXME: need something better for non-English locales
816+ gdouble longitude;
817+ gdouble latitude;
818+ g_object_get (loc, "zone", &zone, "country", &country, "en_name", &en_name,
819+ "longitude", &longitude, "latitude", &latitude,
820+ NULL);
821+
822+ gchar * longitude_s = g_strdup_printf ("%f", longitude);
823+ gchar * latitude_s= g_strdup_printf ("%f", latitude);
824+
825+ gtk_list_store_set (store, &iter,
826+ CC_TIMEZONE_COMPLETION_ZONE, NULL,
827+ CC_TIMEZONE_COMPLETION_NAME, en_name,
828+ CC_TIMEZONE_COMPLETION_COUNTRY, country,
829+ CC_TIMEZONE_COMPLETION_LONGITUDE, longitude_s,
830+ CC_TIMEZONE_COMPLETION_LATITUDE, latitude_s,
831+ -1);
832+
833+ g_free (latitude_s);
834+ g_free (longitude_s);
835+ g_free (en_name);
836+ g_free (country);
837+ g_free (zone);
838+ }
839
840 GtkTreeIter iter;
841 gtk_list_store_append (store, &iter);
842@@ -581,13 +628,14 @@
843 -1);
844
845 gchar * user_name;
846- if (country == NULL || country[0] == 0) {
847- user_name = g_strdup (name);
848- } else if (admin1 == NULL || admin1[0] == 0) {
849- user_name = g_strdup_printf ("%s <small>(%s)</small>", name, country);
850- } else {
851- user_name = g_strdup_printf ("%s <small>(%s, %s)</small>", name, admin1, country);
852- }
853+ if (country == NULL || country[0] == 0)
854+ {
855+ user_name = g_strdup (name);
856+ } else if (admin1 == NULL || admin1[0] == 0) {
857+ user_name = g_strdup_printf ("%s <small>(%s)</small>", name, country);
858+ } else {
859+ user_name = g_strdup_printf ("%s <small>(%s, %s)</small>", name, admin1, country);
860+ }
861
862 g_object_set (G_OBJECT (cell), "markup", user_name, NULL);
863 }
864@@ -641,49 +689,57 @@
865 CcTimezoneCompletion * completion = CC_TIMEZONE_COMPLETION (object);
866 CcTimezoneCompletionPrivate * priv = completion->priv;
867
868- if (priv->changed_id) {
869- if (priv->entry)
870- g_signal_handler_disconnect (priv->entry, priv->changed_id);
871- priv->changed_id = 0;
872- }
873-
874- if (priv->keypress_id) {
875- if (priv->entry)
876- g_signal_handler_disconnect (priv->entry, priv->keypress_id);
877- priv->keypress_id = 0;
878- }
879-
880- if (priv->entry != NULL) {
881- gtk_entry_set_completion (priv->entry, NULL);
882- g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *)&priv->entry);
883- priv->entry = NULL;
884- }
885-
886- if (priv->initial_model != NULL) {
887- g_object_unref (G_OBJECT (priv->initial_model));
888- priv->initial_model = NULL;
889- }
890-
891- if (priv->queued_request) {
892- g_source_remove (priv->queued_request);
893- priv->queued_request = 0;
894- }
895-
896- if (priv->cancel != NULL) {
897- g_cancellable_cancel (priv->cancel);
898- g_object_unref (priv->cancel);
899- priv->cancel = NULL;
900- }
901-
902- if (priv->request_text != NULL) {
903- g_free (priv->request_text);
904- priv->request_text = NULL;
905- }
906-
907- if (priv->request_table != NULL) {
908- g_hash_table_destroy (priv->request_table);
909- priv->request_table = NULL;
910- }
911+ if (priv->changed_id)
912+ {
913+ if (priv->entry)
914+ g_signal_handler_disconnect (priv->entry, priv->changed_id);
915+ priv->changed_id = 0;
916+ }
917+
918+ if (priv->keypress_id)
919+ {
920+ if (priv->entry)
921+ g_signal_handler_disconnect (priv->entry, priv->keypress_id);
922+ priv->keypress_id = 0;
923+ }
924+
925+ if (priv->entry != NULL)
926+ {
927+ gtk_entry_set_completion (priv->entry, NULL);
928+ g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *)&priv->entry);
929+ priv->entry = NULL;
930+ }
931+
932+ if (priv->initial_model != NULL)
933+ {
934+ g_object_unref (G_OBJECT (priv->initial_model));
935+ priv->initial_model = NULL;
936+ }
937+
938+ if (priv->queued_request)
939+ {
940+ g_source_remove (priv->queued_request);
941+ priv->queued_request = 0;
942+ }
943+
944+ if (priv->cancel != NULL)
945+ {
946+ g_cancellable_cancel (priv->cancel);
947+ g_object_unref (priv->cancel);
948+ priv->cancel = NULL;
949+ }
950+
951+ if (priv->request_text != NULL)
952+ {
953+ g_free (priv->request_text);
954+ priv->request_text = NULL;
955+ }
956+
957+ if (priv->request_table != NULL)
958+ {
959+ g_hash_table_destroy (priv->request_table);
960+ priv->request_table = NULL;
961+ }
962
963 return;
964 }
965
966=== modified file 'src/tz.c'
967--- src/tz.c 2013-11-05 11:33:58 +0000
968+++ src/tz.c 2013-11-05 11:33:58 +0000
969@@ -50,16 +50,16 @@
970
971 struct _CcTimezoneLocationPrivate
972 {
973- gchar *country;
974- gchar *full_country;
975- gchar *en_name;
976- gchar *state;
977- gdouble latitude;
978- gdouble longitude;
979- gchar *zone;
980- gchar *comment;
981+ gchar *country;
982+ gchar *full_country;
983+ gchar *en_name;
984+ gchar *state;
985+ gdouble latitude;
986+ gdouble longitude;
987+ gchar *zone;
988+ gchar *comment;
989
990- gdouble dist; /* distance to clicked point for comparison */
991+ gdouble dist; /* distance to clicked point for comparison */
992 };
993
994 enum {
995@@ -82,8 +82,7 @@
996 GParamSpec *pspec)
997 {
998 CcTimezoneLocationPrivate *priv = CC_TIMEZONE_LOCATION (object)->priv;
999- switch (property_id)
1000- {
1001+ switch (property_id) {
1002 case PROP_COUNTRY:
1003 g_value_set_string (value, priv->country);
1004 break;
1005@@ -123,8 +122,7 @@
1006 GParamSpec *pspec)
1007 {
1008 CcTimezoneLocationPrivate *priv = CC_TIMEZONE_LOCATION (object)->priv;
1009- switch (property_id)
1010- {
1011+ switch (property_id) {
1012 case PROP_COUNTRY:
1013 priv->country = g_value_get_string(value);
1014 break;
1015@@ -162,31 +160,31 @@
1016 {
1017 CcTimezoneLocationPrivate *priv = CC_TIMEZONE_LOCATION (object)->priv;
1018
1019- if (priv->country)
1020+ if (priv->country)
1021 {
1022 g_free (priv->country);
1023 priv->country = NULL;
1024 }
1025
1026- if (priv->full_country)
1027+ if (priv->full_country)
1028 {
1029 g_free (priv->full_country);
1030 priv->full_country = NULL;
1031 }
1032
1033- if (priv->state)
1034+ if (priv->state)
1035 {
1036 g_free (priv->state);
1037 priv->state = NULL;
1038 }
1039
1040- if (priv->zone)
1041+ if (priv->zone)
1042 {
1043 g_free (priv->zone);
1044 priv->zone = NULL;
1045 }
1046
1047- if (priv->comment)
1048+ if (priv->comment)
1049 {
1050 g_free (priv->comment);
1051 priv->comment = NULL;
1052@@ -304,19 +302,20 @@
1053 FILE *fh = fopen (filename, "r");
1054 char buf[4096];
1055
1056- if (!fh) {
1057+ if (!fh)
1058+ {
1059 g_warning ("Could not open *%s*\n", filename);
1060 fclose (fh);
1061 return;
1062- }
1063+ }
1064
1065- while (fgets (buf, sizeof(buf), fh))
1066- {
1067+ while (fgets (buf, sizeof(buf), fh))
1068+ {
1069 if (*buf == '#') continue;
1070
1071 g_strchomp (buf);
1072 func (g_strsplit (buf,"\t", ncolumns), user_data);
1073- }
1074+ }
1075
1076 fclose (fh);
1077 }
1078@@ -438,22 +437,25 @@
1079 char buf[4096];
1080
1081 tz_data_file = tz_data_file_get ("TZ_DATA_FILE", TZ_DATA_FILE);
1082- if (!tz_data_file) {
1083+ if (!tz_data_file)
1084+ {
1085 g_warning ("Could not get the TimeZone data file name");
1086 return NULL;
1087- }
1088+ }
1089
1090 admin1_file = tz_data_file_get ("ADMIN1_FILE", ADMIN1_FILE);
1091- if (!admin1_file) {
1092+ if (!admin1_file)
1093+ {
1094 g_warning ("Could not get the admin1 data file name");
1095 return NULL;
1096- }
1097+ }
1098
1099 country_file = tz_data_file_get ("COUNTRY_FILE", COUNTRY_FILE);
1100- if (!country_file) {
1101+ if (!country_file)
1102+ {
1103 g_warning ("Could not get the country data file name");
1104 return NULL;
1105- }
1106+ }
1107
1108 GHashTable *stateHash = g_hash_table_new_full (g_str_hash,
1109 g_str_equal, g_free, g_free);
1110@@ -491,9 +493,9 @@
1111 void
1112 tz_db_free (TzDB *db)
1113 {
1114- g_ptr_array_foreach (db->locations, (GFunc) g_object_unref, NULL);
1115- g_ptr_array_free (db->locations, TRUE);
1116- g_free (db);
1117+ g_ptr_array_foreach (db->locations, (GFunc) g_object_unref, NULL);
1118+ g_ptr_array_free (db->locations, TRUE);
1119+ g_free (db);
1120 }
1121
1122 static gint
1123@@ -548,103 +550,103 @@
1124 GPtrArray *
1125 tz_get_locations (TzDB *db)
1126 {
1127- return db->locations;
1128+ return db->locations;
1129 }
1130
1131-glong
1132+ glong
1133 tz_location_get_utc_offset (CcTimezoneLocation *loc)
1134 {
1135- TzInfo *tz_info;
1136- glong offset;
1137+ TzInfo *tz_info;
1138+ glong offset;
1139
1140- tz_info = tz_info_from_location (loc);
1141- offset = tz_info->utc_offset;
1142- tz_info_free (tz_info);
1143- return offset;
1144+ tz_info = tz_info_from_location (loc);
1145+ offset = tz_info->utc_offset;
1146+ tz_info_free (tz_info);
1147+ return offset;
1148 }
1149
1150 gint
1151 tz_location_set_locally (CcTimezoneLocation *loc)
1152 {
1153- time_t curtime;
1154- struct tm *curzone;
1155- gboolean is_dst = FALSE;
1156- gint correction = 0;
1157-
1158- g_return_val_if_fail (loc != NULL, 0);
1159- g_return_val_if_fail (loc->priv->zone != NULL, 0);
1160-
1161- curtime = time (NULL);
1162- curzone = localtime (&curtime);
1163- is_dst = curzone->tm_isdst;
1164-
1165- setenv ("TZ", loc->priv->zone, 1);
1166+ time_t curtime;
1167+ struct tm *curzone;
1168+ gboolean is_dst = FALSE;
1169+ gint correction = 0;
1170+
1171+ g_return_val_if_fail (loc != NULL, 0);
1172+ g_return_val_if_fail (loc->priv->zone != NULL, 0);
1173+
1174+ curtime = time (NULL);
1175+ curzone = localtime (&curtime);
1176+ is_dst = curzone->tm_isdst;
1177+
1178+ setenv ("TZ", loc->priv->zone, 1);
1179 #if 0
1180- curtime = time (NULL);
1181- curzone = localtime (&curtime);
1182+ curtime = time (NULL);
1183+ curzone = localtime (&curtime);
1184
1185- if (!is_dst && curzone->tm_isdst) {
1186- correction = (60 * 60);
1187- }
1188- else if (is_dst && !curzone->tm_isdst) {
1189- correction = 0;
1190- }
1191+ if (!is_dst && curzone->tm_isdst) {
1192+ correction = (60 * 60);
1193+ }
1194+ else if (is_dst && !curzone->tm_isdst) {
1195+ correction = 0;
1196+ }
1197 #endif
1198
1199- return correction;
1200+ return correction;
1201 }
1202
1203-TzInfo *
1204+ TzInfo *
1205 tz_info_from_location (CcTimezoneLocation *loc)
1206 {
1207- TzInfo *tzinfo;
1208- time_t curtime;
1209- struct tm *curzone;
1210-
1211- g_return_val_if_fail (loc != NULL, NULL);
1212- g_return_val_if_fail (loc->priv->zone != NULL, NULL);
1213-
1214- setenv ("TZ", loc->priv->zone, 1);
1215-
1216+ TzInfo *tzinfo;
1217+ time_t curtime;
1218+ struct tm *curzone;
1219+
1220+ g_return_val_if_fail (loc != NULL, NULL);
1221+ g_return_val_if_fail (loc->priv->zone != NULL, NULL);
1222+
1223+ setenv ("TZ", loc->priv->zone, 1);
1224+
1225 #if 0
1226- tzset ();
1227+ tzset ();
1228 #endif
1229- tzinfo = g_new0 (TzInfo, 1);
1230+ tzinfo = g_new0 (TzInfo, 1);
1231
1232- curtime = time (NULL);
1233- curzone = localtime (&curtime);
1234+ curtime = time (NULL);
1235+ curzone = localtime (&curtime);
1236
1237 #ifndef __sun
1238- /* Currently this solution doesnt seem to work - I get that */
1239- /* America/Phoenix uses daylight savings, which is wrong */
1240- tzinfo->tzname_normal = g_strdup (curzone->tm_zone);
1241- if (curzone->tm_isdst)
1242- tzinfo->tzname_daylight =
1243- g_strdup (&curzone->tm_zone[curzone->tm_isdst]);
1244- else
1245- tzinfo->tzname_daylight = NULL;
1246+ /* Currently this solution doesnt seem to work - I get that */
1247+ /* America/Phoenix uses daylight savings, which is wrong */
1248+ tzinfo->tzname_normal = g_strdup (curzone->tm_zone);
1249+ if (curzone->tm_isdst)
1250+ tzinfo->tzname_daylight =
1251+ g_strdup (&curzone->tm_zone[curzone->tm_isdst]);
1252+ else
1253+ tzinfo->tzname_daylight = NULL;
1254
1255- tzinfo->utc_offset = curzone->tm_gmtoff;
1256+ tzinfo->utc_offset = curzone->tm_gmtoff;
1257 #else
1258- tzinfo->tzname_normal = NULL;
1259- tzinfo->tzname_daylight = NULL;
1260- tzinfo->utc_offset = 0;
1261+ tzinfo->tzname_normal = NULL;
1262+ tzinfo->tzname_daylight = NULL;
1263+ tzinfo->utc_offset = 0;
1264 #endif
1265
1266- tzinfo->daylight = curzone->tm_isdst;
1267-
1268- return tzinfo;
1269+ tzinfo->daylight = curzone->tm_isdst;
1270+
1271+ return tzinfo;
1272 }
1273
1274
1275-void
1276+ void
1277 tz_info_free (TzInfo *tzinfo)
1278 {
1279- g_return_if_fail (tzinfo != NULL);
1280-
1281- if (tzinfo->tzname_normal) g_free (tzinfo->tzname_normal);
1282- if (tzinfo->tzname_daylight) g_free (tzinfo->tzname_daylight);
1283- g_free (tzinfo);
1284+ g_return_if_fail (tzinfo != NULL);
1285+
1286+ if (tzinfo->tzname_normal) g_free (tzinfo->tzname_normal);
1287+ if (tzinfo->tzname_daylight) g_free (tzinfo->tzname_daylight);
1288+ g_free (tzinfo);
1289 }
1290
1291 /* ----------------- *
1292@@ -665,38 +667,38 @@
1293 static float
1294 convert_pos (gchar *pos, int digits)
1295 {
1296- gchar whole[10];
1297- gchar *fraction;
1298- gint i;
1299- float t1, t2;
1300-
1301- if (!pos || strlen(pos) < 4 || digits > 9) return 0.0;
1302-
1303- for (i = 0; i < digits + 1; i++) whole[i] = pos[i];
1304- whole[i] = '\0';
1305- fraction = pos + digits + 1;
1306-
1307- t1 = g_strtod (whole, NULL);
1308- t2 = g_strtod (fraction, NULL);
1309-
1310- if (t1 >= 0.0) return t1 + t2/pow (10.0, strlen(fraction));
1311- else return t1 - t2/pow (10.0, strlen(fraction));
1312+ gchar whole[10];
1313+ gchar *fraction;
1314+ gint i;
1315+ float t1, t2;
1316+
1317+ if (!pos || strlen(pos) < 4 || digits > 9) return 0.0;
1318+
1319+ for (i = 0; i < digits + 1; i++) whole[i] = pos[i];
1320+ whole[i] = '\0';
1321+ fraction = pos + digits + 1;
1322+
1323+ t1 = g_strtod (whole, NULL);
1324+ t2 = g_strtod (fraction, NULL);
1325+
1326+ if (t1 >= 0.0) return t1 + t2/pow (10.0, strlen(fraction));
1327+ else return t1 - t2/pow (10.0, strlen(fraction));
1328 }
1329 #endif
1330
1331-static int
1332+ static int
1333 compare_country_names (const void *a, const void *b)
1334 {
1335- const CcTimezoneLocation *tza = * (CcTimezoneLocation **) a;
1336- const CcTimezoneLocation *tzb = * (CcTimezoneLocation **) b;
1337-
1338- return strcmp (tza->priv->zone, tzb->priv->zone);
1339+ const CcTimezoneLocation *tza = * (CcTimezoneLocation **) a;
1340+ const CcTimezoneLocation *tzb = * (CcTimezoneLocation **) b;
1341+
1342+ return strcmp (tza->priv->zone, tzb->priv->zone);
1343 }
1344
1345
1346-static void
1347+ static void
1348 sort_locations_by_country (GPtrArray *locations)
1349 {
1350- qsort (locations->pdata, locations->len, sizeof (gpointer),
1351- compare_country_names);
1352+ qsort (locations->pdata, locations->len, sizeof (gpointer),
1353+ compare_country_names);
1354 }

Subscribers

People subscribed via source and target branches

to all changes: