Merge lp:~mterry/indicator-datetime/remember-zone-name into lp:indicator-datetime/0.3

Proposed by Michael Terry
Status: Merged
Merged at revision: 93
Proposed branch: lp:~mterry/indicator-datetime/remember-zone-name
Merge into: lp:indicator-datetime/0.3
Diff against target: 125 lines (+53/-21)
3 files modified
data/com.canonical.indicator.datetime.gschema.xml (+7/-0)
src/datetime-prefs.c (+45/-21)
src/settings-shared.h (+1/-0)
To merge this branch: bzr merge lp:~mterry/indicator-datetime/remember-zone-name
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+55425@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
=== modified file 'data/com.canonical.indicator.datetime.gschema.xml'
--- data/com.canonical.indicator.datetime.gschema.xml 2011-03-03 18:51:26 +0000
+++ data/com.canonical.indicator.datetime.gschema.xml 2011-03-29 20:25:22 +0000
@@ -100,5 +100,12 @@
100 indicator-datetime menu.100 indicator-datetime menu.
101 </description>101 </description>
102 </key>102 </key>
103 <key name="timezone-name" type="s">
104 <default>''</default>
105 <summary>The name of the current timezone</summary>
106 <description>
107 Some timezones can be known by many different cities or names. This setting describes how the current zone prefers to be named. Format is "TIMEZONE NAME" (e.g. "America/New_York Boston" to name the New_York zone Boston).
108 </description>
109 </key>
103 </schema>110 </schema>
104</schemalist>111</schemalist>
105112
=== modified file 'src/datetime-prefs.c'
--- src/datetime-prefs.c 2011-03-29 19:28:49 +0000
+++ src/datetime-prefs.c 2011-03-29 20:25:22 +0000
@@ -184,10 +184,30 @@
184static void184static void
185sync_entry (const gchar * location)185sync_entry (const gchar * location)
186{186{
187 gchar * name;187 gchar * new_zone, * new_name;
188 split_settings_location (location, NULL, &name);188 gchar * old_zone, * old_name;
189 gtk_entry_set_text (GTK_ENTRY (tz_entry), name);189
190 g_free (name);190 split_settings_location (location, &new_zone, &new_name);
191
192 GSettings * conf = g_settings_new (SETTINGS_INTERFACE);
193 gchar * tz_name = g_settings_get_string (conf, SETTINGS_TIMEZONE_NAME_S);
194 split_settings_location (tz_name, &old_zone, &old_name);
195 g_free (tz_name);
196 g_object_unref (conf);
197
198 // new_name is always just a sanitized version of a timezone.
199 // old_name is potentially a saved "pretty" version of a timezone name from
200 // geonames. So we prefer to use it if available and the zones match.
201
202 if (g_strcmp0 (old_zone, new_zone) == 0)
203 gtk_entry_set_text (GTK_ENTRY (tz_entry), old_name);
204 else
205 gtk_entry_set_text (GTK_ENTRY (tz_entry), new_name);
206
207 g_free (new_zone);
208 g_free (old_zone);
209 g_free (new_name);
210 g_free (old_name);
191}211}
192212
193static void213static void
@@ -521,36 +541,40 @@
521timezone_selected (GtkEntryCompletion * widget, GtkTreeModel * model,541timezone_selected (GtkEntryCompletion * widget, GtkTreeModel * model,
522 GtkTreeIter * iter, gpointer user_data)542 GtkTreeIter * iter, gpointer user_data)
523{543{
524 GValue value = {0};544 const gchar * name, * zone;
525 const gchar * strval;545
526546 gtk_tree_model_get (model, iter,
527 gtk_tree_model_get_value (model, iter, TIMEZONE_COMPLETION_ZONE, &value);547 TIMEZONE_COMPLETION_NAME, &name,
528 strval = g_value_get_string (&value);548 TIMEZONE_COMPLETION_ZONE, &zone,
529549 -1);
530 if (strval != NULL && strval[0] != 0) {550
531 cc_timezone_map_set_timezone (tzmap, strval);551 if (zone == NULL || zone[0] == 0) {
532 }
533 else {
534 GValue lon_value = {0}, lat_value = {0};
535 const gchar * strlon, * strlat;552 const gchar * strlon, * strlat;
536 gdouble lon = 0.0, lat = 0.0;553 gdouble lon = 0.0, lat = 0.0;
537554
538 gtk_tree_model_get_value (model, iter, TIMEZONE_COMPLETION_LONGITUDE, &lon_value);555 gtk_tree_model_get (model, iter,
539 strlon = g_value_get_string (&lon_value);556 TIMEZONE_COMPLETION_LONGITUDE, &strlon,
557 TIMEZONE_COMPLETION_LATITUDE, &strlat,
558 -1);
559
540 if (strlon != NULL && strlon[0] != 0) {560 if (strlon != NULL && strlon[0] != 0) {
541 lon = strtod(strlon, NULL);561 lon = strtod(strlon, NULL);
542 }562 }
543563
544 gtk_tree_model_get_value (model, iter, TIMEZONE_COMPLETION_LATITUDE, &lat_value);
545 strlat = g_value_get_string (&lat_value);
546 if (strlat != NULL && strlat[0] != 0) {564 if (strlat != NULL && strlat[0] != 0) {
547 lat = strtod(strlat, NULL);565 lat = strtod(strlat, NULL);
548 }566 }
549567
550 cc_timezone_map_set_coords (tzmap, lon, lat);568 zone = cc_timezone_map_get_timezone_at_coords (tzmap, lon, lat);
551 }569 }
552570
553 g_value_unset (&value);571 GSettings * conf = g_settings_new (SETTINGS_INTERFACE);
572 gchar * tz_name = g_strdup_printf ("%s %s", zone, name);
573 g_settings_set_string (conf, SETTINGS_TIMEZONE_NAME_S, tz_name);
574 g_free (tz_name);
575 g_object_unref (conf);
576
577 cc_timezone_map_set_timezone (tzmap, zone);
554578
555 return FALSE; // Do normal action too579 return FALSE; // Do normal action too
556}580}
557581
=== modified file 'src/settings-shared.h'
--- src/settings-shared.h 2011-03-21 18:17:44 +0000
+++ src/settings-shared.h 2011-03-29 20:25:22 +0000
@@ -34,6 +34,7 @@
34#define SETTINGS_SHOW_EVENTS_S "show-events"34#define SETTINGS_SHOW_EVENTS_S "show-events"
35#define SETTINGS_SHOW_LOCATIONS_S "show-locations"35#define SETTINGS_SHOW_LOCATIONS_S "show-locations"
36#define SETTINGS_LOCATIONS_S "locations"36#define SETTINGS_LOCATIONS_S "locations"
37#define SETTINGS_TIMEZONE_NAME_S "timezone-name"
3738
38enum {39enum {
39 SETTINGS_TIME_LOCALE = 0,40 SETTINGS_TIME_LOCALE = 0,

Subscribers

People subscribed via source and target branches