[empathy] factor out contact_has_location



commit 7dc3996067e1b97aaf49a478dcb7a72265fecba3
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Mar 26 15:53:55 2010 +0100

    factor out contact_has_location

 src/empathy-map-view.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/src/empathy-map-view.c b/src/empathy-map-view.c
index 2770a5a..cf89e2a 100644
--- a/src/empathy-map-view.c
+++ b/src/empathy-map-view.c
@@ -74,6 +74,19 @@ map_view_state_changed (ChamplainView *view,
     ephy_spinner_stop (EPHY_SPINNER (window->throbber));
 }
 
+static gboolean
+contact_has_location (EmpathyContact *contact)
+{
+  GHashTable *location;
+
+  location = empathy_contact_get_location (contact);
+
+  if (location == NULL || g_hash_table_size (location) == 0)
+    return FALSE;
+
+  return TRUE;
+}
+
 static void
 map_view_update_contact_position (EmpathyMapView *self,
     EmpathyContact *contact)
@@ -88,12 +101,11 @@ map_view_update_contact_position (EmpathyMapView *self,
 
   location = empathy_contact_get_location (contact);
 
-  if (location == NULL ||
-      g_hash_table_size (location) == 0)
-  {
-    champlain_base_marker_animate_out (CHAMPLAIN_BASE_MARKER (marker));
-    return;
-  }
+  if (!contact_has_location (contact))
+    {
+      champlain_base_marker_animate_out (CHAMPLAIN_BASE_MARKER (marker));
+      return;
+    }
 
   value = g_hash_table_lookup (location, EMPATHY_LOCATION_LAT);
   if (value == NULL)
@@ -275,7 +287,6 @@ map_view_contacts_foreach (GtkTreeModel *model,
 {
   EmpathyMapView *window = (EmpathyMapView *) user_data;
   EmpathyContact *contact;
-  GHashTable *location;
 
   gtk_tree_model_get (model, iter, EMPATHY_CONTACT_LIST_STORE_COL_CONTACT,
      &contact, -1);
@@ -283,9 +294,7 @@ map_view_contacts_foreach (GtkTreeModel *model,
   if (contact == NULL)
     return FALSE;
 
-  location = empathy_contact_get_location (contact);
-
-  if (location == NULL || g_hash_table_size (location) == 0)
+  if (!contact_has_location (contact))
     return FALSE;
 
   g_signal_connect (contact, "notify::location",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]