]> git.0d.be Git - empathy.git/commitdiff
Display the phone next to the status
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Wed, 17 Nov 2010 11:16:17 +0000 (12:16 +0100)
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Wed, 17 Nov 2010 13:28:06 +0000 (14:28 +0100)
As shown in the mockup in bug 547658.

libempathy-gtk/empathy-cell-renderer-text.c
libempathy-gtk/empathy-contact-list-store.h
libempathy-gtk/empathy-individual-view.c

index f64ee6b0c0745b8f8052608ded7ffe14eba62f73..910b5ab1ba4899d0829f73e04ed593c0e940a8ca 100644 (file)
@@ -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,
index 1760a0066faba628672e49557c43bad68b76cb54..b68a274d6f6d4b999c88aa65c2dff1bbc3843b69 100644 (file)
@@ -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;
 
index 4fef0d7337d3ab674110131abeddf51446609224..a04682569c5eb44de0dc111fc90c532ee1d3a1be 100644 (file)
@@ -1192,36 +1192,6 @@ individual_view_avatar_cell_data_func (GtkTreeViewColumn *tree_column,
   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,
@@ -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 ();