#include "empathy-groups-widget.h"
#include "empathy-gtk-enum-types.h"
#include "empathy-individual-widget.h"
-#include "empathy-string-parser.h"
#include "empathy-ui-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
/* Location */
GtkWidget *vbox_location;
GtkWidget *subvbox_location;
- GtkWidget *table_location;
+ GtkWidget *grid_location;
GtkWidget *label_location;
#ifdef HAVE_LIBCHAMPLAIN
GtkWidget *viewport_map;
presence_type_cur = folks_presence_details_get_presence_type (
presence);
- if (folks_presence_details_typecmp (
+ if (tp_contact == NULL || folks_presence_details_typecmp (
presence_type_cur, presence_type) > 0)
{
presence_type = presence_type_cur;
}
}
+static void
+add_row (GtkGrid *grid,
+ guint row,
+ GtkWidget *title,
+ GtkWidget *value)
+{
+ gtk_grid_attach (grid, title, 0, row, 1, 1);
+ gtk_misc_set_alignment (GTK_MISC (title), 0, 0.5);
+ gtk_widget_show (title);
+
+ gtk_grid_attach (grid, value, 1, row, 1, 1);
+ gtk_misc_set_alignment (GTK_MISC (value), 0, 0.5);
+ gtk_widget_show (value);
+}
+
static guint
details_update_show (EmpathyIndividualWidget *self,
TpContact *contact)
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
GList *info, *l;
guint n_rows = 0;
+ GtkWidget *channels_label;
+ TpConnection *conn;
+ TpAccount *account;
info = tp_contact_get_contact_info (contact);
info = g_list_sort (info, (GCompareFunc) empathy_contact_info_field_cmp);
TpContactInfoField *field = l->data;
gchar *title;
const gchar *value;
- gboolean linkify;
- GtkWidget *w;
+ EmpathyContactInfoFormatFunc format;
+ GtkWidget *title_widget, *value_widget;
if (field->field_value == NULL || field->field_value[0] == NULL)
continue;
value = field->field_value[0];
if (!empathy_contact_info_lookup_field (field->field_name,
- NULL, &linkify))
+ NULL, &format))
{
DEBUG ("Unhandled ContactInfo field: %s", field->field_name);
continue;
}
+ /* Skip empty field */
+ if (tp_str_empty (value))
+ continue;
+
/* Add Title */
title = empathy_contact_info_field_label (field->field_name,
field->parameters);
- w = gtk_label_new (title);
- g_free (title);
- gtk_grid_attach (GTK_GRID (priv->grid_details),
- w, 0, n_rows, 1, 1);
- gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
- gtk_widget_show (w);
+ title_widget = gtk_label_new (title);
/* Add Value */
- w = gtk_label_new (value);
+ value_widget = gtk_label_new (value);
- if (linkify == TRUE)
+ if (format != NULL)
{
gchar *markup;
- markup = empathy_add_link_markup (value);
- gtk_label_set_markup (GTK_LABEL (w), markup);
+ markup = format (field->field_value);
+ gtk_label_set_markup (GTK_LABEL (value_widget), markup);
g_free (markup);
}
- gtk_label_set_selectable (GTK_LABEL (w),
+ gtk_label_set_selectable (GTK_LABEL (value_widget),
(priv->flags & EMPATHY_INDIVIDUAL_WIDGET_FOR_TOOLTIP) ? FALSE : TRUE);
- gtk_grid_attach (GTK_GRID (priv->grid_details),
- w, 1, n_rows, 1, 1);
- gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
- gtk_widget_show (w);
+ add_row (GTK_GRID (priv->grid_details), n_rows, title_widget,
+ value_widget);
+
+ n_rows++;
+ }
+
+ conn = tp_contact_get_connection (contact);
+ account = tp_connection_get_account (conn);
+
+ channels_label = empathy_contact_info_create_channel_list_label (account,
+ info, n_rows);
+
+ if (channels_label != NULL)
+ {
+ GtkWidget *title_widget;
+
+ title_widget = gtk_label_new (_("Channels:"));
+
+ add_row (GTK_GRID (priv->grid_details), n_rows, title_widget,
+ channels_label);
n_rows++;
}
+
g_list_free (info);
return n_rows;
}
/* Prepare the location information table */
- if (priv->table_location != NULL)
- gtk_widget_destroy (priv->table_location);
+ if (priv->grid_location != NULL)
+ gtk_widget_destroy (priv->grid_location);
- priv->table_location = gtk_table_new (1, 2, FALSE);
+ priv->grid_location = gtk_grid_new ();
gtk_box_pack_start (GTK_BOX (priv->subvbox_location),
- priv->table_location, FALSE, FALSE, 5);
+ priv->grid_location, FALSE, FALSE, 5);
for (i = 0; (skey = ordered_geolocation_keys[i]); i++)
label = gtk_label_new (user_label);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_table_attach (GTK_TABLE (priv->table_location),
- label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 10, 0);
+ gtk_grid_attach (GTK_GRID (priv->grid_location),
+ label, 0, row, 1, 1);
gtk_widget_show (label);
if (G_VALUE_TYPE (gvalue) == G_TYPE_DOUBLE)
if (svalue != NULL)
{
label = gtk_label_new (svalue);
- gtk_table_attach_defaults (GTK_TABLE (priv->table_location),
- label, 1, 2, row, row + 1);
+ gtk_grid_attach (GTK_GRID (priv->grid_location),
+ label, 1, row, 1, 1);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
gtk_widget_show (label);
if (row > 0)
{
/* We can display some fields */
- gtk_widget_show (priv->table_location);
+ gtk_widget_show (priv->grid_location);
}
else if (display_map == FALSE)
{
current_row++;
/* Presence */
- priv->hbox_presence = gtk_hbox_new (FALSE, 6);
+ priv->hbox_presence = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
/* Presence image */
image = gtk_image_new_from_stock (GTK_STOCK_MISSING_IMAGE,
gtk_widget_show (label);
/* Pack the protocol icon with the account name in an hbox */
- hbox = GTK_BOX (gtk_hbox_new (FALSE, 6));
+ hbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6));
account_label = gtk_label_new (NULL);
gtk_label_set_selectable (GTK_LABEL (account_label),
gtk_widget_show (GTK_WIDGET (grid));
/* Pack a separator after the grid */
- separator = gtk_hseparator_new ();
+ separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
g_object_set_data (G_OBJECT (grid), "separator", separator);
gtk_box_pack_start (GTK_BOX (priv->vbox_individual), separator, FALSE, FALSE,
0);
NULL);
g_free (filename);
- priv->table_location = NULL;
+ priv->grid_location = NULL;
gtk_box_pack_start (GTK_BOX (self), priv->vbox_individual_widget, TRUE, TRUE,
0);
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (object);
- g_hash_table_destroy (priv->persona_grids);
+ g_hash_table_unref (priv->persona_grids);
G_OBJECT_CLASS (empathy_individual_widget_parent_class)->finalize (object);
}