]> git.0d.be Git - empathy.git/commitdiff
Order location fields
authorFrederic Peters <fpeters@0d.be>
Thu, 20 Aug 2009 19:54:02 +0000 (15:54 -0400)
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>
Thu, 12 Nov 2009 15:05:46 +0000 (10:05 -0500)
libempathy-gtk/empathy-contact-widget.c

index 81e01ff0b7928aa9b79be53fc4137a51fbd1ec33..c8e14e05b097c30152a203b89a32093e04bc1e25 100644 (file)
@@ -1320,8 +1320,16 @@ contact_widget_location_update (EmpathyContactWidget *information)
   gboolean has_position = TRUE;
   GtkWidget *label;
   guint row = 0;
-  GHashTableIter iter;
-  gpointer key, pvalue;
+  static const gchar* ordered_geolocation_keys[] = {
+    EMPATHY_LOCATION_STREET,
+    EMPATHY_LOCATION_AREA,
+    EMPATHY_LOCATION_LOCALITY,
+    EMPATHY_LOCATION_REGION,
+    EMPATHY_LOCATION_COUNTRY,
+    NULL
+  };
+  int i;
+  const gchar *skey;
 
   if (!(information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION))
     {
@@ -1379,18 +1387,18 @@ contact_widget_location_update (EmpathyContactWidget *information)
   gtk_box_pack_start (GTK_BOX (information->subvbox_location),
       information->table_location, FALSE, FALSE, 5);
 
-  g_hash_table_iter_init (&iter, location);
-  while (g_hash_table_iter_next (&iter, &key, &pvalue))
+
+  for (i = 0; (skey = ordered_geolocation_keys[i]); i++)
     {
-      const gchar *skey;
       const gchar* user_label;
       GValue *gvalue;
       char *svalue = NULL;
 
-      skey = (const gchar *) key;
+      gvalue = g_hash_table_lookup (location, (gpointer) skey);
+      if (gvalue == NULL)
+        continue;
 
       user_label = location_key_to_label (skey);
-      gvalue = (GValue *) pvalue;
 
       label = gtk_label_new (user_label);
       gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
@@ -1429,6 +1437,12 @@ contact_widget_location_update (EmpathyContactWidget *information)
       row++;
     }
 
+  if (row == 0)
+    {
+      gtk_widget_hide (information->vbox_location);
+      return;
+    }
+
   gtk_widget_show (information->table_location);
 
 #if HAVE_LIBCHAMPLAIN