aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>2009-05-27 00:42:10 +0800
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>2009-05-28 00:52:08 +0800
commit2d38908c639e7fbc6b90daf395919987e3d0c844 (patch)
treead0637995e24dc01600e468d2a57de2b9dd8adf2 /libempathy-gtk
parent09998744f5092ee928a5a7b8cfd97e62d059acdc (diff)
downloadgsoc2013-empathy-2d38908c639e7fbc6b90daf395919987e3d0c844.tar
gsoc2013-empathy-2d38908c639e7fbc6b90daf395919987e3d0c844.tar.gz
gsoc2013-empathy-2d38908c639e7fbc6b90daf395919987e3d0c844.tar.bz2
gsoc2013-empathy-2d38908c639e7fbc6b90daf395919987e3d0c844.tar.lz
gsoc2013-empathy-2d38908c639e7fbc6b90daf395919987e3d0c844.tar.xz
gsoc2013-empathy-2d38908c639e7fbc6b90daf395919987e3d0c844.tar.zst
gsoc2013-empathy-2d38908c639e7fbc6b90daf395919987e3d0c844.zip
Simplifly the logic on when to display the location
By verifying earlier on
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c3
-rw-r--r--libempathy-gtk/empathy-contact-widget.c113
2 files changed, 60 insertions, 56 deletions
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 9fcf5fc41..c106653b1 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -169,7 +169,8 @@ contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
if (!priv->tooltip_widget) {
priv->tooltip_widget = empathy_contact_widget_new (contact,
- EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP);
+ EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP |
+ EMPATHY_CONTACT_WIDGET_SHOW_LOCATION);
g_object_ref (priv->tooltip_widget);
g_signal_connect (priv->tooltip_widget, "destroy",
G_CALLBACK (contact_list_view_tooltip_destroy_cb),
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 9166a6546..22f274640 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -1297,6 +1297,16 @@ contact_widget_location_update (EmpathyContactWidget *information)
GValue *value;
gdouble lat, lon;
gboolean has_position = TRUE;
+ GtkWidget *label;
+ guint row = 0;
+ GHashTableIter iter;
+ gpointer key, pvalue;
+
+ if (!(information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION))
+ {
+ gtk_widget_hide (information->vbox_location);
+ return;
+ }
location = empathy_contact_get_location (information->contact);
if (location == NULL || g_hash_table_size (location) == 0)
@@ -1337,77 +1347,70 @@ contact_widget_location_update (EmpathyContactWidget *information)
g_free (text);
}
- if (information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP ||
- information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION)
+
+ /* Prepare the location information table */
+ if (information->table_location != NULL)
+ {
+ gtk_widget_destroy (information->table_location);
+ }
+
+ information->table_location = gtk_table_new (1, 2, FALSE);
+ 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))
{
- GtkWidget *label;
- guint row = 0;
- GHashTableIter iter;
- gpointer key, value;
+ const gchar *skey;
+ const gchar* user_label;
+ GValue *gvalue;
+ char *svalue = NULL;
+
+ skey = (const gchar *) key;
+ if (tp_strdiff (skey, EMPATHY_LOCATION_TIMESTAMP) == FALSE)
+ continue;
+
+ user_label = location_key_to_label (skey);
+ gvalue = (GValue *) pvalue;
- if (information->table_location != NULL)
+ label = gtk_label_new (user_label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_table_attach (GTK_TABLE (information->table_location),
+ label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 10, 0);
+ gtk_widget_show (label);
+
+ if (G_VALUE_TYPE (gvalue) == G_TYPE_DOUBLE)
{
- gtk_widget_destroy (information->table_location);
+ gdouble dvalue;
+ dvalue = g_value_get_double (gvalue);
+ svalue = g_strdup_printf ("%f", dvalue);
+ }
+ else if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING)
+ {
+ svalue = g_value_dup_string (gvalue);
}
- information->table_location = gtk_table_new (1, 2, FALSE);
- 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, &value))
+ if (svalue != NULL)
{
- const gchar *skey;
- const gchar* user_label;
- GValue *gvalue;
- char *svalue = NULL;
-
- skey = (const gchar *) key;
- if (tp_strdiff (skey, EMPATHY_LOCATION_TIMESTAMP) == FALSE)
- continue;
-
- user_label = location_key_to_label (skey);
- gvalue = (GValue *) value;
-
- label = gtk_label_new (user_label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_table_attach (GTK_TABLE (information->table_location),
- label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 10, 0);
+ label = gtk_label_new (svalue);
+ gtk_table_attach_defaults (GTK_TABLE (information->table_location),
+ label, 1, 2, row, row + 1);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
gtk_widget_show (label);
-
- if (G_VALUE_TYPE (gvalue) == G_TYPE_DOUBLE)
- {
- gdouble dvalue;
- dvalue = g_value_get_double (gvalue);
- svalue = g_strdup_printf ("%f", dvalue);
- }
- else if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING)
- {
- svalue = g_value_dup_string (gvalue);
- }
-
- if (svalue != NULL)
- {
- label = gtk_label_new (svalue);
- gtk_table_attach_defaults (GTK_TABLE (information->table_location),
- label, 1, 2, row, row + 1);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
- gtk_widget_show (label);
- }
-
- g_free (svalue);
- row++;
}
- gtk_widget_show (information->table_location);
+ g_free (svalue);
+ row++;
}
+ gtk_widget_show (information->table_location);
+
#if HAVE_LIBCHAMPLAIN
/* Cannot be displayed in tooltips until Clutter-Gtk can deal with such
* windows
*/
if (has_position &&
- information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION)
+ !(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
{
ClutterActor *marker;
ChamplainLayer *layer;