diff options
-rw-r--r-- | libempathy-gtk/empathy-cell-renderer-text.c | 34 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-store.h | 1 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-view.c | 41 |
3 files changed, 34 insertions, 42 deletions
diff --git a/libempathy-gtk/empathy-cell-renderer-text.c b/libempathy-gtk/empathy-cell-renderer-text.c index f64ee6b0c..910b5ab1b 100644 --- a/libempathy-gtk/empathy-cell-renderer-text.c +++ b/libempathy-gtk/empathy-cell-renderer-text.c @@ -38,6 +38,8 @@ typedef struct { gboolean is_valid; gboolean is_selected; + gchar **types; + gboolean compact; } EmpathyCellRendererTextPriv; @@ -67,7 +69,8 @@ enum { PROP_PRESENCE_TYPE, PROP_STATUS, PROP_IS_GROUP, - PROP_COMPACT + PROP_COMPACT, + PROP_CLIENT_TYPES }; G_DEFINE_TYPE (EmpathyCellRendererText, empathy_cell_renderer_text, GTK_TYPE_CELL_RENDERER_TEXT); @@ -137,6 +140,11 @@ empathy_cell_renderer_text_class_init (EmpathyCellRendererTextClass *klass) FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_COMPACT, spec); + spec = g_param_spec_boxed ("client-types", "Contact client types", + "Client types of the contact", + G_TYPE_STRV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_CLIENT_TYPES, spec); + g_type_class_add_private (object_class, sizeof (EmpathyCellRendererTextPriv)); } @@ -167,6 +175,7 @@ cell_renderer_text_finalize (GObject *object) g_free (priv->name); g_free (priv->status); + g_strfreev (priv->types); (G_OBJECT_CLASS (empathy_cell_renderer_text_parent_class)->finalize) (object); } @@ -199,6 +208,9 @@ cell_renderer_text_get_property (GObject *object, case PROP_COMPACT: g_value_set_boolean (value, priv->compact); break; + case PROP_CLIENT_TYPES: + g_value_set_boxed (value, priv->types); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -245,6 +257,10 @@ cell_renderer_text_set_property (GObject *object, priv->compact = g_value_get_boolean (value); priv->is_valid = FALSE; break; + case PROP_CLIENT_TYPES: + priv->types = g_value_dup_boxed (value); + priv->is_valid = FALSE; + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -282,7 +298,7 @@ cell_renderer_text_update_text (EmpathyCellRendererText *cell, { EmpathyCellRendererTextPriv *priv; PangoAttrList *attr_list; - PangoAttribute *attr_color, *attr_size; + PangoAttribute *attr_color = NULL, *attr_size; GtkStyle *style; gchar *str; @@ -335,15 +351,27 @@ cell_renderer_text_update_text (EmpathyCellRendererText *cell, } } else { const gchar *status = priv->status; + gboolean on_a_phone = FALSE; if (EMP_STR_EMPTY (priv->status)) { status = empathy_presence_get_default_message (priv->presence_type); } + if (!priv->is_group && priv->types != NULL && g_strv_length (priv->types) > 0 + // FIXME: why don't we check the whole array? + && !tp_strdiff (priv->types[0], "phone")) { + on_a_phone = TRUE; + /* We want the phone black. */ + if (attr_color) + attr_color->start_index += 3; + } + if (status == NULL) str = g_strdup (priv->name); else - str = g_strdup_printf ("%s\n%s", priv->name, status); + str = g_strdup_printf ("%s\n%s%s", priv->name, + on_a_phone ? "☎ " : "", + status); } g_object_set (cell, diff --git a/libempathy-gtk/empathy-contact-list-store.h b/libempathy-gtk/empathy-contact-list-store.h index 1760a0066..b68a274d6 100644 --- a/libempathy-gtk/empathy-contact-list-store.h +++ b/libempathy-gtk/empathy-contact-list-store.h @@ -65,6 +65,7 @@ typedef enum { EMPATHY_CONTACT_LIST_STORE_COL_CAN_VIDEO_CALL, EMPATHY_CONTACT_LIST_STORE_COL_FLAGS, EMPATHY_CONTACT_LIST_STORE_COL_IS_FAKE_GROUP, + EMPATHY_CONTACT_LIST_STORE_COL_CLIENT_TYPES, EMPATHY_CONTACT_LIST_STORE_COL_COUNT, } EmpathyContactListStoreCol; diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c index 4fef0d733..a04682569 100644 --- a/libempathy-gtk/empathy-individual-view.c +++ b/libempathy-gtk/empathy-individual-view.c @@ -1193,36 +1193,6 @@ individual_view_avatar_cell_data_func (GtkTreeViewColumn *tree_column, } static void -individual_view_phone_cell_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyIndividualView *view) -{ - gboolean is_group; - gboolean is_active; - gchar **types; - - gtk_tree_model_get (model, iter, - EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, &is_group, - EMPATHY_INDIVIDUAL_STORE_COL_IS_ACTIVE, &is_active, - EMPATHY_INDIVIDUAL_STORE_COL_CLIENT_TYPES, &types, - -1); - - g_object_set (cell, - "visible", - !is_group - && types != NULL - && g_strv_length (types) > 0 - && !tp_strdiff (types[0], "phone"), - NULL); - - g_strfreev (types); - - individual_view_cell_set_background (view, cell, is_group, is_active); -} - -static void individual_view_text_cell_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, @@ -1863,15 +1833,8 @@ individual_view_constructed (GObject *object) "is_group", EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP); gtk_tree_view_column_add_attribute (col, cell, "compact", EMPATHY_INDIVIDUAL_STORE_COL_COMPACT); - - /* Phone Icon */ - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (col, cell, FALSE); - gtk_tree_view_column_set_cell_data_func (col, cell, - (GtkTreeCellDataFunc) individual_view_phone_cell_data_func, - view, NULL); - - g_object_set (cell, "visible", FALSE, "icon-name", "phone", NULL); + gtk_tree_view_column_add_attribute (col, cell, + "client-types", EMPATHY_INDIVIDUAL_STORE_COL_CLIENT_TYPES); /* Audio Call Icon */ cell = empathy_cell_renderer_activatable_new (); |