]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-cell-renderer-text.c
Updated Spanish Translation
[empathy.git] / libempathy-gtk / empathy-cell-renderer-text.c
index f64ee6b0c0745b8f8052608ded7ffe14eba62f73..5ce735f409f351cb3fb99716c50d794319118380 100644 (file)
  */
 
 #include "config.h"
+#include "empathy-cell-renderer-text.h"
 
-#include <string.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
-#include <libempathy/empathy-utils.h>
-#include "empathy-cell-renderer-text.h"
+#include "empathy-utils.h"
 
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCellRendererText)
 typedef struct {
@@ -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,11 @@ cell_renderer_text_set_property (GObject      *object,
                priv->compact = g_value_get_boolean (value);
                priv->is_valid = FALSE;
                break;
+       case PROP_CLIENT_TYPES:
+               g_strfreev (priv->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;
@@ -281,10 +298,12 @@ cell_renderer_text_update_text (EmpathyCellRendererText *cell,
                                gboolean                selected)
 {
        EmpathyCellRendererTextPriv *priv;
+       PangoFontDescription *font_desc;
        PangoAttrList              *attr_list;
-       PangoAttribute             *attr_color, *attr_size;
-       GtkStyle                   *style;
+       PangoAttribute             *attr_color = NULL, *attr_size;
+       GtkStyleContext            *style;
        gchar                      *str;
+       gint                        font_size;
 
        priv = GET_PRIV (cell);
 
@@ -307,43 +326,61 @@ cell_renderer_text_update_text (EmpathyCellRendererText *cell,
                return;
        }
 
-       style = gtk_widget_get_style (widget);
+       style = gtk_widget_get_style_context (widget);
 
        attr_list = pango_attr_list_new ();
 
-       attr_size = pango_attr_size_new (pango_font_description_get_size (style->font_desc) / 1.2);
+       gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
+               "font", &font_desc,
+               NULL);
+       font_size = pango_font_description_get_size (font_desc);
+       pango_font_description_free (font_desc);
+       attr_size = pango_attr_size_new (font_size / 1.2);
        attr_size->start_index = strlen (priv->name) + 1;
        attr_size->end_index = -1;
        pango_attr_list_insert (attr_list, attr_size);
 
        if (!selected) {
-               GdkColor color;
+               GdkRGBA color;
 
-               color = style->text_aa[GTK_STATE_NORMAL];
+               gtk_style_context_get_color (style, 0, &color);
 
-               attr_color = pango_attr_foreground_new (color.red, color.green, color.blue);
+               attr_color = pango_attr_foreground_new (color.red * 0xffff,
+                                                       color.green * 0xffff,
+                                                       color.blue * 0xffff);
                attr_color->start_index = attr_size->start_index;
                attr_color->end_index = -1;
                pango_attr_list_insert (attr_list, attr_color);
        }
 
        if (priv->compact) {
-               if (EMP_STR_EMPTY (priv->status)) {
+               if (TPAW_STR_EMPTY (priv->status)) {
                        str = g_strdup (priv->name);
                } else {
                        str = g_strdup_printf ("%s %s", priv->name, priv->status);
                }
        } else {
                const gchar *status = priv->status;
+               gboolean on_a_phone = FALSE;
 
-               if (EMP_STR_EMPTY (priv->status)) {
+               if (TPAW_STR_EMPTY (priv->status)) {
                        status = empathy_presence_get_default_message (priv->presence_type);
                }
 
+               if (!priv->is_group &&
+                               empathy_client_types_contains_mobile_device (priv->types)) {
+                       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,