Merge lp:~mterry/indicator-datetime/avoid-duplicate-geonames into lp:indicator-datetime/0.3

Proposed by Michael Terry
Status: Merged
Merged at revision: 77
Proposed branch: lp:~mterry/indicator-datetime/avoid-duplicate-geonames
Merge into: lp:indicator-datetime/0.3
Diff against target: 62 lines (+28/-10)
1 file modified
src/timezone-completion.c (+28/-10)
To merge this branch: bzr merge lp:~mterry/indicator-datetime/avoid-duplicate-geonames
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+54515@code.launchpad.net
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/timezone-completion.c'
2--- src/timezone-completion.c 2011-02-24 16:41:37 +0000
3+++ src/timezone-completion.c 2011-03-23 13:17:15 +0000
4@@ -74,6 +74,9 @@
5 TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);
6 TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion);
7 GError * error = NULL;
8+ const gchar * prev_name = NULL;
9+ const gchar * prev_admin1 = NULL;
10+ const gchar * prev_country = NULL;
11
12 json_parser_load_from_stream_finish (JSON_PARSER (object), res, &error);
13
14@@ -112,6 +115,7 @@
15 const gchar * country = NULL;
16 const gchar * longitude = NULL;
17 const gchar * latitude = NULL;
18+ gboolean skip = FALSE;
19 if (json_reader_read_member (reader, "name")) {
20 name = json_reader_get_string_value (reader);
21 json_reader_end_member (reader);
22@@ -133,16 +137,30 @@
23 json_reader_end_member (reader);
24 }
25
26- GtkTreeIter iter;
27- gtk_list_store_append (store, &iter);
28- gtk_list_store_set (store, &iter,
29- TIMEZONE_COMPLETION_ZONE, NULL,
30- TIMEZONE_COMPLETION_NAME, name,
31- TIMEZONE_COMPLETION_ADMIN1, admin1,
32- TIMEZONE_COMPLETION_COUNTRY, country,
33- TIMEZONE_COMPLETION_LONGITUDE, longitude,
34- TIMEZONE_COMPLETION_LATITUDE, latitude,
35- -1);
36+ if (g_strcmp0(name, prev_name) == 0 &&
37+ g_strcmp0(admin1, prev_admin1) == 0 &&
38+ g_strcmp0(country, prev_country) == 0) {
39+ // Sometimes the data will have duplicate entries that only differ
40+ // in longitude and latitude. e.g. "rio de janeiro", "wellington"
41+ skip = TRUE;
42+ }
43+
44+ if (!skip) {
45+ GtkTreeIter iter;
46+ gtk_list_store_append (store, &iter);
47+ gtk_list_store_set (store, &iter,
48+ TIMEZONE_COMPLETION_ZONE, NULL,
49+ TIMEZONE_COMPLETION_NAME, name,
50+ TIMEZONE_COMPLETION_ADMIN1, admin1,
51+ TIMEZONE_COMPLETION_COUNTRY, country,
52+ TIMEZONE_COMPLETION_LONGITUDE, longitude,
53+ TIMEZONE_COMPLETION_LATITUDE, latitude,
54+ -1);
55+ }
56+
57+ prev_name = name;
58+ prev_admin1 = admin1;
59+ prev_country = country;
60 }
61
62 json_reader_end_element (reader);

Subscribers

People subscribed via source and target branches