gboolean is_valid;
gboolean is_selected;
+ gchar **types;
+
gboolean compact;
} EmpathyCellRendererTextPriv;
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);
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));
}
g_free (priv->name);
g_free (priv->status);
+ g_strfreev (priv->types);
(G_OBJECT_CLASS (empathy_cell_renderer_text_parent_class)->finalize) (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;
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;
{
EmpathyCellRendererTextPriv *priv;
PangoAttrList *attr_list;
- PangoAttribute *attr_color, *attr_size;
+ PangoAttribute *attr_color = NULL, *attr_size;
GtkStyle *style;
gchar *str;
}
} 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,
individual_view_cell_set_background (view, cell, is_group, is_active);
}
-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,
"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 ();