aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>2009-05-27 04:52:48 +0800
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>2009-05-28 00:52:10 +0800
commitcc7656ce36f0a531cc21585de63d1c2e493bc993 (patch)
tree396f77cb4868d00ba1767f6ee7f237c65c9bef3e
parenteb7d4bbe7b4dac195cf0cc26f7bfd50fb49dde69 (diff)
downloadgsoc2013-empathy-cc7656ce36f0a531cc21585de63d1c2e493bc993.tar
gsoc2013-empathy-cc7656ce36f0a531cc21585de63d1c2e493bc993.tar.gz
gsoc2013-empathy-cc7656ce36f0a531cc21585de63d1c2e493bc993.tar.bz2
gsoc2013-empathy-cc7656ce36f0a531cc21585de63d1c2e493bc993.tar.lz
gsoc2013-empathy-cc7656ce36f0a531cc21585de63d1c2e493bc993.tar.xz
gsoc2013-empathy-cc7656ce36f0a531cc21585de63d1c2e493bc993.tar.zst
gsoc2013-empathy-cc7656ce36f0a531cc21585de63d1c2e493bc993.zip
Move the geocoding to when the location is updated
This way, when the location is updated, the lat,lon is fetched too (not only upon showing the map).
-rw-r--r--src/empathy-map-view.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/src/empathy-map-view.c b/src/empathy-map-view.c
index 8029f75e2..4173128cc 100644
--- a/src/empathy-map-view.c
+++ b/src/empathy-map-view.c
@@ -55,9 +55,6 @@ typedef struct {
GtkWidget *zoom_out;
ChamplainView *map_view;
ChamplainLayer *layer;
-#if HAVE_GEOCLUE
- GeoclueGeocode *geocode;
-#endif
} EmpathyMapView;
static void map_view_destroy_cb (GtkWidget *widget,
@@ -155,10 +152,6 @@ map_view_destroy_cb (GtkWidget *widget,
g_object_unref (window->list_store);
g_object_unref (window->layer);
-#if HAVE_GEOCLUE
- if (window->geocode != NULL)
- g_object_unref (window->geocode);
-#endif
g_slice_free (EmpathyMapView, window);
}
@@ -213,6 +206,7 @@ map_view_geocode_cb (GeoclueGeocode *geocode,
/* Don't change the accuracy as we used an address to get this position */
g_object_notify (userdata, "location");
+ g_object_unref (geocode);
}
#endif
@@ -238,6 +232,49 @@ map_view_marker_update_position (ChamplainMarker *marker,
GHashTable *location;
location = empathy_contact_get_location (contact);
+
+#if HAVE_GEOCLUE
+ gchar *str;
+ GHashTable *address;
+
+ value = g_hash_table_lookup (location, EMPATHY_LOCATION_LON);
+ if (value == NULL)
+ {
+ static GeoclueGeocode *geocode;
+ if (geocode == NULL)
+ {
+ geocode = geoclue_geocode_new (GEOCODE_SERVICE, GEOCODE_PATH);
+ g_object_add_weak_pointer (G_OBJECT (geocode), (gpointer*)&geocode);
+ }
+ else
+ g_object_ref (geocode);
+
+ address = geoclue_address_details_new();
+
+ str = get_dup_string (location, EMPATHY_LOCATION_COUNTRY);
+ if (str != NULL)
+ g_hash_table_insert (address, g_strdup ("country"), str);
+
+ str = get_dup_string (location, EMPATHY_LOCATION_POSTAL_CODE);
+ if (str != NULL)
+ g_hash_table_insert (address, g_strdup ("postalcode"), str);
+
+ str = get_dup_string (location, EMPATHY_LOCATION_LOCALITY);
+ if (str != NULL)
+ g_hash_table_insert (address, g_strdup ("locality"), str);
+
+ str = get_dup_string (location, EMPATHY_LOCATION_STREET);
+ if (str != NULL)
+ g_hash_table_insert (address, g_strdup ("street"), str);
+
+ geoclue_geocode_address_to_position_async (geocode, address,
+ map_view_geocode_cb, contact);
+
+ g_hash_table_unref (address);
+ return;
+ }
+#endif
+
if (location == NULL ||
g_hash_table_size (location) == 0)
{
@@ -339,42 +376,6 @@ map_view_contacts_foreach (GtkTreeModel *model,
G_CALLBACK (map_view_contact_location_notify), marker);
-#if HAVE_GEOCLUE
- gchar *str;
- GHashTable *address;
- GValue *value;
-
- value = g_hash_table_lookup (location, EMPATHY_LOCATION_LON);
- if (value == NULL)
- {
- if (window->geocode == NULL)
- window->geocode = geoclue_geocode_new (GEOCODE_SERVICE, GEOCODE_PATH);
-
- address = geoclue_address_details_new();
-
- str = get_dup_string (location, EMPATHY_LOCATION_COUNTRY);
- if (str != NULL)
- g_hash_table_insert (address, g_strdup ("country"), str);
-
- str = get_dup_string (location, EMPATHY_LOCATION_POSTAL_CODE);
- if (str != NULL)
- g_hash_table_insert (address, g_strdup ("postalcode"), str);
-
- str = get_dup_string (location, EMPATHY_LOCATION_LOCALITY);
- if (str != NULL)
- g_hash_table_insert (address, g_strdup ("locality"), str);
-
- str = get_dup_string (location, EMPATHY_LOCATION_STREET);
- if (str != NULL)
- g_hash_table_insert (address, g_strdup ("street"), str);
-
- geoclue_geocode_address_to_position_async (window->geocode, address,
- map_view_geocode_cb, contact);
-
- g_hash_table_unref (address);
- }
-#endif
-
map_view_marker_update_position (CHAMPLAIN_MARKER (marker), contact);
g_object_unref (contact);