diff options
author | Pierre-Luc Beaudoin <pierre-luc@pierlux.com> | 2009-05-21 02:29:44 +0800 |
---|---|---|
committer | Pierre-Luc Beaudoin <pierre-luc@pierlux.com> | 2009-05-28 00:52:07 +0800 |
commit | 1a8aefd70a364e8b3e7eac6eda4f93bb04022d1e (patch) | |
tree | 9601bcbb4438e5c2b0a742be802e4c99af2c6a9a /src/empathy-map-view.c | |
parent | 9c540f20d87d06867eac63c8378fb83ee59b9329 (diff) | |
download | gsoc2013-empathy-1a8aefd70a364e8b3e7eac6eda4f93bb04022d1e.tar gsoc2013-empathy-1a8aefd70a364e8b3e7eac6eda4f93bb04022d1e.tar.gz gsoc2013-empathy-1a8aefd70a364e8b3e7eac6eda4f93bb04022d1e.tar.bz2 gsoc2013-empathy-1a8aefd70a364e8b3e7eac6eda4f93bb04022d1e.tar.lz gsoc2013-empathy-1a8aefd70a364e8b3e7eac6eda4f93bb04022d1e.tar.xz gsoc2013-empathy-1a8aefd70a364e8b3e7eac6eda4f93bb04022d1e.tar.zst gsoc2013-empathy-1a8aefd70a364e8b3e7eac6eda4f93bb04022d1e.zip |
Simplify and clarify map_view_geocode_cb
Diffstat (limited to 'src/empathy-map-view.c')
-rw-r--r-- | src/empathy-map-view.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/empathy-map-view.c b/src/empathy-map-view.c index e9acdc205..7262f209b 100644 --- a/src/empathy-map-view.c +++ b/src/empathy-map-view.c @@ -159,6 +159,10 @@ map_view_destroy_cb (GtkWidget *widget, #define GEOCODE_SERVICE "org.freedesktop.Geoclue.Providers.Yahoo" #define GEOCODE_PATH "/org/freedesktop/Geoclue/Providers/Yahoo" +/* This callback is called by geoclue when it found a position + * for the given address. A position is necessary for a contact + * to show up on the map + */ static void map_view_geocode_cb (GeoclueGeocode *geocode, GeocluePositionFields fields, @@ -170,11 +174,9 @@ map_view_geocode_cb (GeoclueGeocode *geocode, gpointer userdata) { GValue *new_value; - gboolean found = FALSE; GHashTable *location; location = empathy_contact_get_location (EMPATHY_CONTACT (userdata)); - g_hash_table_ref (location); if (error != NULL) { @@ -184,30 +186,29 @@ map_view_geocode_cb (GeoclueGeocode *geocode, if (fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { - new_value = tp_g_value_slice_new (G_TYPE_DOUBLE); - g_value_set_double (new_value, longitude); + new_value = tp_g_value_slice_new_double (longitude); g_hash_table_replace (location, EMPATHY_LOCATION_LON, new_value); DEBUG ("\t - Longitude: %f", longitude); } if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE) { - new_value = tp_g_value_slice_new (G_TYPE_DOUBLE); - g_value_set_double (new_value, latitude); + new_value = tp_g_value_slice_new_double (latitude); g_hash_table_replace (location, EMPATHY_LOCATION_LAT, new_value); DEBUG ("\t - Latitude: %f", latitude); - found = TRUE; } if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE) { - new_value = tp_g_value_slice_new (G_TYPE_DOUBLE); - g_value_set_double (new_value, altitude); + new_value = tp_g_value_slice_new_double (altitude); g_hash_table_replace (location, EMPATHY_LOCATION_ALT, new_value); DEBUG ("\t - Altitude: %f", altitude); } /* Don't change the accuracy as we used an address to get this position */ - if (found == TRUE) - empathy_contact_set_location (EMPATHY_CONTACT (userdata), location); + + /* Ref the location hash table as it will be unref'd in set_location, + * and we are only updating it */ + g_hash_table_ref (location); + empathy_contact_set_location (EMPATHY_CONTACT (userdata), location); g_hash_table_unref (location); } #endif |