* Philip Withnall <philip.withnall@collabora.co.uk>
*/
-#include <config.h>
-
-#include <string.h>
-#include <stdlib.h>
+#include "config.h"
+#include "empathy-individual-widget.h"
-#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
-
-#include <telepathy-glib/util.h>
-
-#include <folks/folks.h>
-#include <folks/folks-telepathy.h>
+#include <tp-account-widgets/tpaw-builder.h>
+#include <tp-account-widgets/tpaw-contactinfo-utils.h>
+#include <tp-account-widgets/tpaw-time.h>
+#include <tp-account-widgets/tpaw-utils.h>
+#include <telepathy-glib/telepathy-glib-dbus.h>
#ifdef HAVE_LIBCHAMPLAIN
#include <champlain/champlain.h>
#include <champlain-gtk/champlain-gtk.h>
#endif
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-location.h>
-#include <libempathy/empathy-time.h>
-
#include "empathy-avatar-image.h"
#include "empathy-groups-widget.h"
#include "empathy-gtk-enum-types.h"
-#include "empathy-individual-widget.h"
-#include "empathy-string-parser.h"
+#include "empathy-location.h"
+#include "empathy-request-util.h"
#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
/**
* SECTION:empathy-individual-widget
/* weak pointer to the contact whose contact details we're displaying */
TpContact *contact;
- /* unowned Persona (borrowed from priv->individual) -> GtkTable child */
- GHashTable *persona_tables;
+ /* unowned Persona (borrowed from priv->individual) -> GtkGrid child */
+ GHashTable *persona_grids;
/* Table containing the information for the individual as whole, or NULL */
- GtkTable *individual_table;
+ GtkGrid *individual_grid;
/* Individual */
GtkWidget *hbox_presence;
/* Location */
GtkWidget *vbox_location;
GtkWidget *subvbox_location;
- GtkWidget *table_location;
+ GtkWidget *grid_location;
GtkWidget *label_location;
#ifdef HAVE_LIBCHAMPLAIN
GtkWidget *viewport_map;
/* Details */
GtkWidget *vbox_details;
- GtkWidget *table_details;
+ GtkWidget *grid_details;
GtkWidget *hbox_details_requested;
GtkWidget *details_spinner;
GCancellable *details_cancellable; /* owned */
gtk_widget_show (priv->details_spinner);
}
-typedef struct
-{
- const gchar *field_name;
- const gchar *title;
- gboolean linkify;
-} InfoFieldData;
-
-static InfoFieldData info_field_data[] =
-{
- { "fn", N_("Full name:"), FALSE },
- { "tel", N_("Phone number:"), FALSE },
- { "email", N_("E-mail address:"), TRUE },
- { "url", N_("Website:"), TRUE },
- { "bday", N_("Birthday:"), FALSE },
- { NULL, NULL }
-};
-
-static InfoFieldData *
-find_info_field_data (const gchar *field_name)
-{
- guint i;
-
- for (i = 0; info_field_data[i].field_name != NULL; i++)
- {
- if (tp_strdiff (info_field_data[i].field_name, field_name) == FALSE)
- return info_field_data + i;
- }
- return NULL;
-}
-
-static gint
-contact_info_field_name_cmp (const gchar *name1,
- const gchar *name2)
-{
- guint i;
-
- if (tp_strdiff (name1, name2) == FALSE)
- return 0;
-
- /* We use the order of info_field_data */
- for (i = 0; info_field_data[i].field_name != NULL; i++)
- {
- if (tp_strdiff (info_field_data[i].field_name, name1) == FALSE)
- return -1;
- if (tp_strdiff (info_field_data[i].field_name, name2) == FALSE)
- return +1;
- }
-
- return g_strcmp0 (name1, name2);
-}
-
-static gint
-contact_info_field_cmp (TpContactInfoField *field1,
- TpContactInfoField *field2)
-{
- return contact_info_field_name_cmp (field1->field_name, field2->field_name);
-}
-
static void
client_types_notify_cb (TpContact *contact,
GParamSpec *pspec,
client_types_update (self);
}
+typedef struct {
+ EmpathyIndividualWidget *widget; /* weak */
+ TpContact *contact; /* owned */
+} DetailsData;
+
static void
update_weak_contact (EmpathyIndividualWidget *self)
{
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;
}
}
-typedef struct {
- EmpathyIndividualWidget *widget; /* weak */
- TpContact *contact; /* owned */
-} DetailsData;
-
static void
-details_data_free (DetailsData *data)
+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 gboolean
+channel_name_activated_cb (
+ GtkLabel *label,
+ gchar *uri,
+ TpAccount *account)
{
- if (data->widget != NULL)
+ empathy_join_muc (account, uri, empathy_get_current_action_time ());
+ return TRUE;
+}
+
+static GtkWidget *
+create_channel_list_label (TpAccount *account,
+ GList *info,
+ guint row)
+{
+ GtkWidget *label = NULL;
+ GString *label_markup = g_string_new ("");
+ guint i;
+ GPtrArray *channels;
+ GList *l;
+
+ /* Is there channels? */
+ channels = g_ptr_array_new ();
+
+ for (l = info; l != NULL; l = l->next)
{
- g_object_remove_weak_pointer (G_OBJECT (data->widget),
- (gpointer *) &data->widget);
+ TpContactInfoField *field = l->data;
+
+ if (!tp_strdiff (field->field_name, "x-irc-channel"))
+ g_ptr_array_add (channels, (gpointer) field->field_value[0]);
}
- g_object_unref (data->contact);
- g_slice_free (DetailsData, data);
-}
+ if (channels->len == 0)
+ goto out;
+
+ for (i = 0; i < channels->len; i++)
+ {
+ const gchar *channel_name = g_ptr_array_index (channels, i);
+ /* We abuse the URI of the link to hold the channel name. It seems to
+ * be okay to just use it essentially verbatim, rather than trying to
+ * ensure it's actually a valid URI. */
+ gchar *escaped = g_markup_escape_text (channel_name, -1);
+
+ if (i > 0)
+ g_string_append (label_markup, ", ");
+
+ g_string_append_printf (label_markup, "<a href='%s'>%s</a>",
+ escaped, escaped);
+ g_free (escaped);
+ }
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), label_markup->str);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+
+ g_signal_connect (label, "activate-link",
+ (GCallback) channel_name_activated_cb, account);
+
+out:
+ g_ptr_array_unref (channels);
+ g_string_free (label_markup, TRUE);
+
+ return label;
+}
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) contact_info_field_cmp);
+ info = tp_contact_dup_contact_info (contact);
+ info = g_list_sort (info, (GCompareFunc) tpaw_contact_info_field_cmp);
for (l = info; l != NULL; l = l->next)
{
TpContactInfoField *field = l->data;
- InfoFieldData *field_data;
+ gchar *title;
const gchar *value;
- GtkWidget *w;
+ TpawContactInfoFormatFunc format;
+ GtkWidget *title_widget, *value_widget;
if (field->field_value == NULL || field->field_value[0] == NULL)
continue;
value = field->field_value[0];
- field_data = find_info_field_data (field->field_name);
- if (field_data == NULL)
+ if (!tpaw_contact_info_lookup_field (field->field_name,
+ NULL, &format))
{
DEBUG ("Unhandled ContactInfo field: %s", field->field_name);
continue;
}
+ /* Skip empty field */
+ if (tp_str_empty (value))
+ continue;
+
/* Add Title */
- w = gtk_label_new (_(field_data->title));
- gtk_table_attach (GTK_TABLE (priv->table_details),
- w, 0, 1, n_rows, n_rows + 1, GTK_FILL, 0, 0, 0);
- gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
- gtk_widget_show (w);
+ title = tpaw_contact_info_field_label (field->field_name,
+ field->parameters, TRUE);
+ title_widget = gtk_label_new (title);
/* Add Value */
- w = gtk_label_new (value);
- if (field_data->linkify == TRUE)
+ value_widget = gtk_label_new (value);
+
+ 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_table_attach_defaults (GTK_TABLE (priv->table_details),
- w, 1, 2, n_rows, n_rows + 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++;
}
- g_list_free (info);
+
+ conn = tp_contact_get_connection (contact);
+ account = tp_connection_get_account (conn);
+
+ channels_label = 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++;
+ }
+
+ tp_contact_info_list_free (info);
return n_rows;
}
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
guint n_rows;
- gtk_container_foreach (GTK_CONTAINER (priv->table_details),
+ gtk_container_foreach (GTK_CONTAINER (priv->grid_details),
(GtkCallback) gtk_widget_destroy, NULL);
n_rows = details_update_show (self, contact);
if (n_rows > 0)
{
gtk_widget_show (priv->vbox_details);
- gtk_widget_show (priv->table_details);
+ gtk_widget_show (priv->grid_details);
}
else
{
}
static void
-details_request_cb (TpContact *contact,
+details_request_cb (GObject *source,
GAsyncResult *res,
- DetailsData *data)
+ gpointer user_data)
{
- EmpathyIndividualWidget *self = data->widget;
+ EmpathyIndividualWidget *self = user_data;
+ EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
+ TpContact *contact = (TpContact *) source;
gboolean hide_widget = FALSE;
GError *error = NULL;
if (tp_contact_request_contact_info_finish (contact, res, &error) == TRUE)
- details_notify_cb (contact, NULL, self);
+ {
+ details_notify_cb (contact, NULL, self);
+ }
else
- hide_widget = TRUE;
-
- g_clear_error (&error);
-
- if (self != NULL)
{
- EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
+ /* If the request got cancelled it could mean the contact widget is
+ * destroyed, so we should not dereference information */
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ {
+ g_error_free (error);
+ return;
+ }
- if (hide_widget == TRUE)
- gtk_widget_hide (GET_PRIV (self)->vbox_details);
+ hide_widget = TRUE;
+ g_error_free (error);
+ }
- tp_clear_object (&priv->details_cancellable);
+ if (hide_widget == TRUE)
+ gtk_widget_hide (GET_PRIV (self)->vbox_details);
- tp_g_signal_connect_object (contact, "notify::contact-info",
- (GCallback) details_notify_cb, self, 0);
- }
+ tp_clear_object (&priv->details_cancellable);
- details_data_free (data);
+ tp_g_signal_connect_object (contact, "notify::contact-info",
+ (GCallback) details_notify_cb, self, 0);
}
static void
-details_feature_prepared_cb (TpConnection *connection,
- GAsyncResult *res,
- DetailsData *data)
+fetch_contact_information (EmpathyIndividualWidget *self)
{
- EmpathyIndividualWidget *self = data->widget;
- EmpathyIndividualWidgetPriv *priv = NULL;
+ EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
+ TpConnection *connection;
+
+ connection = tp_contact_get_connection (priv->contact);
- if (tp_proxy_prepare_finish (connection, res, NULL) == FALSE || self == NULL)
+ if (!tp_proxy_has_interface_by_id (connection,
+ TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_INFO))
{
- if (self != NULL)
- gtk_widget_hide (GET_PRIV (self)->vbox_details);
- details_data_free (data);
+ gtk_widget_hide (GET_PRIV (self)->vbox_details);
return;
}
- priv = GET_PRIV (self);
-
/* Request the Individual's info */
gtk_widget_show (priv->vbox_details);
gtk_widget_show (priv->hbox_details_requested);
- gtk_widget_hide (priv->table_details);
+ gtk_widget_hide (priv->grid_details);
gtk_spinner_start (GTK_SPINNER (priv->details_spinner));
if (priv->details_cancellable == NULL)
{
priv->details_cancellable = g_cancellable_new ();
- tp_contact_request_contact_info_async (data->contact,
- priv->details_cancellable, (GAsyncReadyCallback) details_request_cb,
- data);
+
+ tp_contact_request_contact_info_async (priv->contact,
+ priv->details_cancellable, details_request_cb, self);
}
}
if (priv->contact != NULL)
{
- GQuark features[] = { TP_CONNECTION_FEATURE_CONTACT_INFO, 0 };
- TpConnection *connection;
- DetailsData *data;
-
- data = g_slice_new (DetailsData);
- data->widget = self;
- g_object_add_weak_pointer (G_OBJECT (self), (gpointer *) &data->widget);
- data->contact = g_object_ref (priv->contact);
-
- /* First, make sure the CONTACT_INFO feature is ready on the connection */
- connection = tp_contact_get_connection (priv->contact);
- tp_proxy_prepare_async (connection, features,
- (GAsyncReadyCallback) details_feature_prepared_cb, data);
+ fetch_contact_information (self);
}
}
* have to keep it alive for the duration of the function, since we're
* accessing its private data. */
tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
- contact = empathy_contact_dup_from_tp_contact (tp_contact);
- empathy_contact_set_persona (contact, persona);
-
- /* Try and get a location */
- location = empathy_contact_get_location (contact);
- /* if location isn't fully valid, treat the contact as insufficient */
- if (location != NULL && g_hash_table_size (location) <= 0)
+ if (tp_contact != NULL)
{
- location = NULL;
- g_clear_object (&contact);
+ contact = empathy_contact_dup_from_tp_contact (tp_contact);
+ empathy_contact_set_persona (contact, persona);
+
+ /* Try and get a location */
+ location = empathy_contact_get_location (contact);
+ /* if location isn't fully valid, treat the contact as
+ * insufficient */
+ if (location != NULL && g_hash_table_size (location) <= 0)
+ {
+ location = NULL;
+ g_clear_object (&contact);
+ }
}
}
g_clear_object (&persona);
stamp = g_value_get_int64 (value);
- user_date = empathy_time_to_string_relative (stamp);
+ user_date = tpaw_time_to_string_relative (stamp);
tmp = g_strdup_printf ("<b>%s</b>", _("Location"));
/* translators: format is "Location, $date" */
}
/* 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)
gint64 time_;
time_ = g_value_get_int64 (value);
- svalue = empathy_time_to_string_utc (time_, _("%B %e, %Y at %R UTC"));
+ svalue = tpaw_time_to_string_utc (time_, _("%B %e, %Y at %R UTC"));
}
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);
#ifdef HAVE_LIBCHAMPLAIN
if ((g_hash_table_lookup (location, EMPATHY_LOCATION_LAT) != NULL) &&
- (g_hash_table_lookup (location, EMPATHY_LOCATION_LON) != NULL) &&
- !(priv->flags & EMPATHY_INDIVIDUAL_WIDGET_FOR_TOOLTIP))
+ (g_hash_table_lookup (location, EMPATHY_LOCATION_LON) != NULL))
{
/* Cannot be displayed in tooltips until Clutter-Gtk can deal with such
* windows */
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)
{
/* Get the contact */
tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
+ if (tp_contact == NULL)
+ goto while_finish;
+
contact = empathy_contact_dup_from_tp_contact (tp_contact);
empathy_contact_set_persona (contact, persona);
types = tp_contact_get_client_types (priv->contact);
- if (types != NULL
- && g_strv_length ((gchar **) types) > 0
- && !tp_strdiff (types[0], "phone"))
+ if (empathy_client_types_contains_mobile_device ((GStrv) types))
{
gtk_widget_show (priv->hbox_client_types);
}
return NULL;
tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
+ if (tp_contact == NULL)
+ return NULL;
+
contact = empathy_contact_dup_from_tp_contact (tp_contact);
empathy_contact_set_persona (contact, persona);
if (TPF_IS_PERSONA (persona))
{
TpContact *tp_contact;
- EmpathyContact *contact;
+ EmpathyContact *contact = NULL;
/* Get the contact */
tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
- contact = empathy_contact_dup_from_tp_contact (tp_contact);
- empathy_contact_set_persona (contact, persona);
+ if (tp_contact != NULL)
+ {
+ contact = empathy_contact_dup_from_tp_contact (tp_contact);
+ empathy_contact_set_persona (contact, persona);
- /* Determine if the contact is the user */
- if (empathy_contact_is_user (contact))
- retval = g_object_ref (empathy_contact_get_account (contact));
+ /* Determine if the contact is the user */
+ if (empathy_contact_is_user (contact))
+ retval = g_object_ref (empathy_contact_get_account (contact));
+ }
g_object_unref (contact);
}
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
EmpathyAvatar *avatar = NULL;
- GObject *table;
+ GObject *grid;
GtkWidget *avatar_widget;
if (FOLKS_IS_INDIVIDUAL (folks_object))
{
avatar = individual_dup_avatar (FOLKS_INDIVIDUAL (folks_object));
- table = G_OBJECT (priv->individual_table);
+ grid = G_OBJECT (priv->individual_grid);
}
else if (FOLKS_IS_PERSONA (folks_object))
{
avatar = persona_dup_avatar (FOLKS_PERSONA (folks_object));
- table = g_hash_table_lookup (priv->persona_tables, folks_object);
+ grid = g_hash_table_lookup (priv->persona_grids, folks_object);
}
else
{
g_assert_not_reached ();
}
- if (table == NULL)
+ if (grid == NULL)
return;
- avatar_widget = g_object_get_data (table, "avatar-widget");
+ avatar_widget = g_object_get_data (grid, "avatar-widget");
empathy_avatar_image_set (EMPATHY_AVATAR_IMAGE (avatar_widget), avatar);
if (avatar != NULL)
EmpathyIndividualWidget *self)
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
- GObject *table;
+ GObject *grid;
GtkWidget *alias_widget;
if (FOLKS_IS_INDIVIDUAL (folks_object))
- table = G_OBJECT (priv->individual_table);
+ grid = G_OBJECT (priv->individual_grid);
else if (FOLKS_IS_PERSONA (folks_object))
- table = g_hash_table_lookup (priv->persona_tables, folks_object);
+ grid = g_hash_table_lookup (priv->persona_grids, folks_object);
else
g_assert_not_reached ();
- if (table == NULL)
+ if (grid == NULL)
return;
- alias_widget = g_object_get_data (table, "alias-widget");
+ alias_widget = g_object_get_data (grid, "alias-widget");
if (GTK_IS_ENTRY (alias_widget))
{
EmpathyIndividualWidget *self)
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
- GObject *table;
+ GObject *grid;
GtkWidget *status_label, *state_image;
const gchar *message;
gchar *markup_text = NULL;
+ FolksPresenceType presence;
+ gboolean visible = TRUE;
if (FOLKS_IS_INDIVIDUAL (folks_object))
- table = G_OBJECT (priv->individual_table);
+ grid = G_OBJECT (priv->individual_grid);
else if (FOLKS_IS_PERSONA (folks_object))
- table = g_hash_table_lookup (priv->persona_tables, folks_object);
+ grid = g_hash_table_lookup (priv->persona_grids, folks_object);
else
g_assert_not_reached ();
- if (table == NULL)
+ if (grid == NULL)
return;
- status_label = g_object_get_data (table, "status-label");
- state_image = g_object_get_data (table, "state-image");
+ status_label = g_object_get_data (grid, "status-label");
+ state_image = g_object_get_data (grid, "state-image");
+
+ presence = folks_presence_details_get_presence_type (
+ FOLKS_PRESENCE_DETAILS (folks_object));
+ if (presence == FOLKS_PRESENCE_TYPE_UNKNOWN ||
+ presence == FOLKS_PRESENCE_TYPE_ERROR)
+ {
+ /* Don't display anything if we don't know the presence */
+ visible = FALSE;
+ goto out;
+ }
- /* FIXME: Default messages should be moved into libfolks (bgo#627403) */
message = folks_presence_details_get_presence_message (
FOLKS_PRESENCE_DETAILS (folks_object));
- if (EMP_STR_EMPTY (message))
+ if (TPAW_STR_EMPTY (message))
{
- message = empathy_presence_get_default_message (
- folks_presence_details_get_presence_type (
- FOLKS_PRESENCE_DETAILS (folks_object)));
+ message = folks_presence_details_get_default_message_from_type (presence);
}
if (message != NULL)
- markup_text = empathy_add_link_markup (message);
+ markup_text = tpaw_add_link_markup (message);
gtk_label_set_markup (GTK_LABEL (status_label), markup_text);
g_free (markup_text);
gtk_image_set_from_icon_name (GTK_IMAGE (state_image),
empathy_icon_name_for_presence (
- folks_presence_details_get_presence_type (
- FOLKS_PRESENCE_DETAILS (folks_object))),
+ empathy_folks_presence_type_to_tp (presence)),
GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (state_image);
+
+out:
+ gtk_widget_set_visible (status_label, visible);
+ gtk_widget_set_visible (state_image, visible);
}
static void
EmpathyIndividualWidget *self)
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
- GObject *table;
+ GObject *grid;
GtkWidget *favourite_widget;
if (FOLKS_IS_INDIVIDUAL (folks_object))
- table = G_OBJECT (priv->individual_table);
+ grid = G_OBJECT (priv->individual_grid);
else if (FOLKS_IS_PERSONA (folks_object))
- table = g_hash_table_lookup (priv->persona_tables, folks_object);
+ grid = g_hash_table_lookup (priv->persona_grids, folks_object);
else
g_assert_not_reached ();
- if (table == NULL)
+ if (grid == NULL)
return;
- favourite_widget = g_object_get_data (table, "favourite-widget");
+ favourite_widget = g_object_get_data (grid, "favourite-widget");
if (GTK_IS_TOGGLE_BUTTON (favourite_widget))
{
static void
alias_presence_avatar_favourite_set_up (EmpathyIndividualWidget *self,
- GtkTable *table,
+ GtkGrid *grid,
guint starting_row)
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
- GtkWidget *label, *alias, *image, *avatar, *alignment;
+ GtkWidget *label, *alias, *image, *avatar;
guint current_row = starting_row;
/* Alias */
label = gtk_label_new (_("Alias:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (table, label, 0, 1, current_row, current_row + 1, GTK_FILL,
- GTK_FILL, 0, 0);
+ gtk_grid_attach (grid, label, 0, current_row, 1, 1);
gtk_widget_show (label);
/* Set up alias label/entry */
gtk_misc_set_alignment (GTK_MISC (alias), 0.0, 0.5);
}
- g_object_set_data (G_OBJECT (table), "alias-widget", alias);
- gtk_table_attach (table, alias, 1, 2, current_row, current_row + 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ g_object_set_data (G_OBJECT (grid), "alias-widget", alias);
+ gtk_grid_attach_next_to (grid, alias, label,
+ GTK_POS_RIGHT, 1, 1);
gtk_widget_show (alias);
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_ICON_SIZE_BUTTON);
- g_object_set_data (G_OBJECT (table), "state-image", image);
+ g_object_set_data (G_OBJECT (grid), "state-image", image);
gtk_box_pack_start (GTK_BOX (priv->hbox_presence), image, FALSE,
FALSE, 0);
gtk_widget_show (image);
gtk_label_set_selectable (GTK_LABEL (label),
(priv->flags & EMPATHY_INDIVIDUAL_WIDGET_FOR_TOOLTIP) ? FALSE : TRUE);
- g_object_set_data (G_OBJECT (table), "status-label", label);
- gtk_box_pack_start (GTK_BOX (priv->hbox_presence), label, TRUE,
- TRUE, 0);
+ g_object_set_data (G_OBJECT (grid), "status-label", label);
+ gtk_box_pack_start (GTK_BOX (priv->hbox_presence), label, FALSE,
+ FALSE, 0);
gtk_widget_show (label);
- gtk_table_attach (table, priv->hbox_presence, 0, 2, current_row,
- current_row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_grid_attach (grid, priv->hbox_presence,
+ 0, current_row, 2, 1);
gtk_widget_show (priv->hbox_presence);
current_row++;
g_signal_connect (favourite, "toggled",
(GCallback) favourite_toggled_cb, self);
- g_object_set_data (G_OBJECT (table), "favourite-widget", favourite);
- gtk_table_attach (table, favourite, 0, 2, current_row, current_row + 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ g_object_set_data (G_OBJECT (grid), "favourite-widget", favourite);
+ gtk_grid_attach (grid, favourite,
+ 0, current_row, 2, 1);
gtk_widget_show (favourite);
current_row++;
(GCallback) avatar_widget_button_press_event_cb, self);
}
- g_object_set_data (G_OBJECT (table), "avatar-widget", avatar);
+ g_object_set_data (G_OBJECT (grid), "avatar-widget", avatar);
+ g_object_set (avatar,
+ "valign", GTK_ALIGN_START,
+ "margin-left", 6,
+ "margin-right", 6,
+ "margin-top", 6,
+ "margin-bottom", 6,
+ NULL);
- alignment = gtk_alignment_new (1.0, 0.0, 0.0, 0.0);
- gtk_container_add (GTK_CONTAINER (alignment), avatar);
+ gtk_grid_attach (grid, avatar,
+ 2, 0, 1, current_row);
gtk_widget_show (avatar);
-
- gtk_table_attach (table, alignment, 2, 3, 0, current_row,
- GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 6, 6);
- gtk_widget_show (alignment);
}
static void
TpContact *tp_contact;
EmpathyContact *contact;
TpAccount *account;
- GtkTable *table;
+ GtkGrid *grid;
GtkLabel *label;
GtkImage *image;
const gchar *id;
- table = g_hash_table_lookup (priv->persona_tables, persona);
+ grid = g_hash_table_lookup (priv->persona_grids, persona);
- g_assert (table != NULL);
+ g_assert (grid != NULL);
tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
+ if (tp_contact == NULL)
+ return;
+
contact = empathy_contact_dup_from_tp_contact (tp_contact);
empathy_contact_set_persona (contact, persona);
{
const gchar *name;
- label = g_object_get_data (G_OBJECT (table), "account-label");
- image = g_object_get_data (G_OBJECT (table), "account-image");
+ label = g_object_get_data (G_OBJECT (grid), "account-label");
+ image = g_object_get_data (G_OBJECT (grid), "account-image");
name = tp_account_get_display_name (account);
gtk_label_set_label (label, name);
}
/* Update id widget */
- label = g_object_get_data (G_OBJECT (table), "id-widget");
+ label = g_object_get_data (G_OBJECT (grid), "id-widget");
id = folks_persona_get_display_id (persona);
gtk_label_set_label (label, (id != NULL) ? id : "");
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
GtkBox *hbox;
- GtkTable *table;
+ GtkGrid *grid;
GtkWidget *label, *account_label, *account_image, *separator;
guint current_row = 0;
return;
if (priv->flags & EMPATHY_INDIVIDUAL_WIDGET_EDIT_FAVOURITE)
- table = GTK_TABLE (gtk_table_new (5, 3, FALSE));
+ grid = GTK_GRID (gtk_grid_new ());
else
- table = GTK_TABLE (gtk_table_new (4, 3, FALSE));
- gtk_table_set_row_spacings (table, 6);
- gtk_table_set_col_spacings (table, 6);
+ grid = GTK_GRID (gtk_grid_new ());
+
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (grid, 6);
+ gtk_grid_set_column_spacing (grid, 6);
/* Account and Identifier */
label = gtk_label_new (_("Account:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (table, label, 0, 1, current_row, current_row + 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (grid, label, 0, current_row, 1, 1);
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_box_pack_start (hbox, account_image, FALSE, FALSE, 0);
gtk_box_pack_start (hbox, account_label, FALSE, TRUE, 0);
- g_object_set_data (G_OBJECT (table), "account-image", account_image);
- g_object_set_data (G_OBJECT (table), "account-label", account_label);
- gtk_table_attach (table, GTK_WIDGET (hbox), 1, 2, current_row,
- current_row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ g_object_set_data (G_OBJECT (grid), "account-image", account_image);
+ g_object_set_data (G_OBJECT (grid), "account-label", account_label);
+ gtk_grid_attach_next_to (grid, GTK_WIDGET (hbox), label, GTK_POS_RIGHT, 1, 1);
gtk_widget_show (GTK_WIDGET (hbox));
current_row++;
/* Translators: Identifier to connect to Instant Messaging network */
label = gtk_label_new (_("Identifier:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (table, label, 0, 1, current_row, current_row + 1,
- GTK_FILL, GTK_FILL, 0, 0);
+ gtk_grid_attach (grid, label, 0, current_row, 1, 1);
gtk_widget_show (label);
/* Set up ID label */
(priv->flags & EMPATHY_INDIVIDUAL_WIDGET_FOR_TOOLTIP) ? FALSE : TRUE);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- g_object_set_data (G_OBJECT (table), "id-widget", label);
- gtk_table_attach (table, label, 1, 2, current_row, current_row + 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ g_object_set_data (G_OBJECT (grid), "id-widget", label);
+ gtk_grid_attach (grid, label, 1, current_row, 1, 1);
gtk_widget_show (label);
current_row++;
- alias_presence_avatar_favourite_set_up (self, table, current_row);
+ alias_presence_avatar_favourite_set_up (self, grid, current_row);
- /* Connect to signals and display the table */
+ /* Connect to signals and display the grid */
g_signal_connect (persona, "notify::alias",
(GCallback) notify_alias_cb, self);
g_signal_connect (persona, "notify::avatar",
}
gtk_box_pack_start (GTK_BOX (priv->vbox_individual),
- GTK_WIDGET (table), FALSE, TRUE, 0);
- gtk_widget_show (GTK_WIDGET (table));
+ GTK_WIDGET (grid), FALSE, TRUE, 0);
+ gtk_widget_show (GTK_WIDGET (grid));
- /* Pack a separator after the table */
- separator = gtk_hseparator_new ();
- g_object_set_data (G_OBJECT (table), "separator", separator);
+ /* Pack a separator after the grid */
+ 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);
gtk_widget_show (separator);
- g_hash_table_replace (priv->persona_tables, persona, table);
+ g_hash_table_replace (priv->persona_grids, persona, grid);
/* Update the new widgets */
update_persona (self, persona);
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
GtkWidget *separator;
- GtkTable *table;
+ GtkGrid *grid;
if (!empathy_folks_persona_is_interesting (persona))
return;
- table = g_hash_table_lookup (priv->persona_tables, persona);
- if (table == NULL)
+ grid = g_hash_table_lookup (priv->persona_grids, persona);
+ if (grid == NULL)
return;
g_signal_handlers_disconnect_by_func (persona, notify_alias_cb, self);
}
/* Remove the separator */
- separator = g_object_get_data (G_OBJECT (table), "separator");
+ separator = g_object_get_data (G_OBJECT (grid), "separator");
if (separator != NULL)
gtk_container_remove (GTK_CONTAINER (priv->vbox_individual), separator);
/* Remove the widget */
gtk_container_remove (GTK_CONTAINER (priv->vbox_individual),
- GTK_WIDGET (table));
+ GTK_WIDGET (grid));
- g_hash_table_remove (priv->persona_tables, persona);
+ g_hash_table_remove (priv->persona_grids, persona);
}
static void
-update_individual_table (EmpathyIndividualWidget *self)
+update_individual_grid (EmpathyIndividualWidget *self)
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
}
static void
-individual_table_set_up (EmpathyIndividualWidget *self)
+individual_grid_set_up (EmpathyIndividualWidget *self)
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
- GtkTable *table;
guint current_row = 0;
- guint nb_rows = 2;
-
- if (priv->flags & EMPATHY_INDIVIDUAL_WIDGET_EDIT_FAVOURITE)
- nb_rows++;
-
- if (priv->flags & EMPATHY_INDIVIDUAL_WIDGET_FOR_TOOLTIP)
- nb_rows++;
+ GtkGrid *grid;
- table = GTK_TABLE (gtk_table_new (nb_rows, 3, FALSE));
- gtk_table_set_row_spacings (table, 6);
- gtk_table_set_col_spacings (table, 6);
+ grid = GTK_GRID (gtk_grid_new ());
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (grid, 6);
+ gtk_grid_set_column_spacing (grid, 6);
/* We only display the number of personas in tooltips */
if (priv->flags & EMPATHY_INDIVIDUAL_WIDGET_FOR_TOOLTIP)
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
g_free (message);
- gtk_table_attach (table, label, 0, 2, current_row, current_row + 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_grid_attach (grid, label, 0, current_row, 2, 1);
gtk_widget_show (label);
current_row++;
}
- alias_presence_avatar_favourite_set_up (self, table, current_row);
+ alias_presence_avatar_favourite_set_up (self, grid, current_row);
- /* Display the table */
- gtk_box_pack_start (GTK_BOX (priv->vbox_individual), GTK_WIDGET (table),
+ /* Display the grid */
+ gtk_box_pack_start (GTK_BOX (priv->vbox_individual), GTK_WIDGET (grid),
FALSE, TRUE, 0);
- gtk_widget_show (GTK_WIDGET (table));
+ gtk_widget_show (GTK_WIDGET (grid));
- priv->individual_table = table;
+ priv->individual_grid = grid;
- /* Update the table */
- update_individual_table (self);
+ /* Update the grid */
+ update_individual_grid (self);
}
static void
-individual_table_destroy (EmpathyIndividualWidget *self)
+individual_grid_destroy (EmpathyIndividualWidget *self)
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (self);
- if (priv->individual_table == NULL)
+ if (priv->individual_grid == NULL)
return;
gtk_container_remove (GTK_CONTAINER (priv->vbox_individual),
- GTK_WIDGET (priv->individual_table));
- priv->individual_table = NULL;
+ GTK_WIDGET (priv->individual_grid));
+
+#ifdef HAVE_LIBCHAMPLAIN
+ if (priv->map_view_embed != NULL)
+ {
+ gtk_container_remove (GTK_CONTAINER (priv->viewport_map),
+ priv->map_view_embed);
+
+ priv->map_view_embed = NULL;
+ }
+#endif
+
+ priv->individual_grid = NULL;
}
static void
/* we'll re-use this iterator throughout */
iter = gee_iterable_iterator (GEE_ITERABLE (personas));
- /* Note that old_num_personas is the number of persona tables we were
+ /* Note that old_num_personas is the number of persona gridss we were
* displaying, not the number of Personas which were in the Individual
* before. */
- old_num_personas = g_hash_table_size (priv->persona_tables);
+ old_num_personas = g_hash_table_size (priv->persona_grids);
while (gee_iterator_next (iter))
{
g_clear_object (&persona);
}
+ g_clear_object (&iter);
/*
* What we display for various conditions:
* - "Personas": display the alias, avatar, presence account and identifier
- * for each of the Individual's Personas. (i.e. One table per
+ * for each of the Individual's Personas. (i.e. One grid per
* Persona.)
* - "Individual": display the alias, avatar and presence for the Individual,
* and a label saying "Meta-contact containing x contacts".
- * (i.e. One table in total.)
+ * (i.e. One grid in total.)
*
* | SHOW_PERSONAS | !SHOW_PERSONAS
* -------------+---------------+---------------
will_show_personas = show_personas || new_num_personas == 1;
/* If both @added and @removed are NULL, we're being called manually, and we
- * need to set up the tables for the first time. We do this simply by
+ * need to set up the gridss for the first time. We do this simply by
* ensuring was_showing_personas and will_show_personas are different so that
* the code resets the UI.
*/
}
else if (!was_showing_personas && will_show_personas)
{
- gboolean c;
+ /* Remove the old Individual grid */
+ individual_grid_destroy (self);
- /* Remove the old Individual table */
- individual_table_destroy (self);
-
- /* Set up all the Persona tables instead */
- for (c = gee_iterator_first (iter); c; c = gee_iterator_next (iter))
+ /* Set up all the Persona grids instead */
+ iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+ while (gee_iterator_next (iter))
{
FolksPersona *persona = gee_iterator_get (iter);
add_persona (self, persona);
g_clear_object (&persona);
}
+ g_clear_object (&iter);
}
else if (was_showing_personas && !will_show_personas)
{
- gboolean c;
-
/* Remove all Personas */
- for (c = gee_iterator_first (iter); c; c = gee_iterator_next (iter))
+ iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+ while (gee_iterator_next (iter))
{
FolksPersona *persona = gee_iterator_get (iter);
remove_persona (self, persona);
g_clear_object (&persona);
}
+ g_clear_object (&iter);
if (removed != NULL)
{
g_clear_object (&iter_changed);
}
- /* Set up the Individual table instead */
- individual_table_set_up (self);
+ /* Set up the Individual grid instead */
+ individual_grid_set_up (self);
}
- g_clear_object (&iter);
/* Hide the last separator and show the others */
children = gtk_container_get_children (GTK_CONTAINER (priv->vbox_individual));
g_clear_object (&persona);
}
g_clear_object (&iter);
- individual_table_destroy (self);
+ individual_grid_destroy (self);
if (priv->contact != NULL)
remove_weak_contact (self);
(GCallback) notify_is_favourite_cb, self);
}
- /* Update individual table */
+ /* Update individual grid */
personas_changed_cb (priv->individual, NULL, NULL, self);
}
{
gtk_widget_hide (priv->vbox_individual);
}
- else if (priv->individual_table != NULL)
+ else if (priv->individual_grid != NULL)
{
/* We only need to update the details for the Individual as a whole */
- update_individual_table (self);
+ update_individual_grid (self);
gtk_widget_show (priv->vbox_individual);
}
else
filename = empathy_file_lookup ("empathy-individual-widget.ui",
"libempathy-gtk");
- gui = empathy_builder_get_file (filename,
+ gui = tpaw_builder_get_file (filename,
"scrolled_window_individual", &priv->scrolled_window_individual,
"viewport_individual", &priv->viewport_individual,
"vbox_individual_widget", &priv->vbox_individual_widget,
#endif
"groups_widget", &priv->groups_widget,
"vbox_details", &priv->vbox_details,
- "table_details", &priv->table_details,
+ "grid_details", &priv->grid_details,
"hbox_details_requested", &priv->hbox_details_requested,
"hbox_client_types", &priv->hbox_client_types,
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);
gtk_widget_show (priv->vbox_individual_widget);
- priv->persona_tables = g_hash_table_new (NULL, NULL);
- priv->individual_table = NULL;
+ priv->persona_grids = g_hash_table_new (NULL, NULL);
+ priv->individual_grid = NULL;
/* Create widgets */
details_set_up (self);
{
EmpathyIndividualWidgetPriv *priv = GET_PRIV (object);
- g_hash_table_destroy (priv->persona_tables);
+ g_hash_table_unref (priv->persona_grids);
G_OBJECT_CLASS (empathy_individual_widget_parent_class)->finalize (object);
}