show service icon in footer
[conv-inbox] / src / el-home-applet.c
index 236c783..bc4443c 100644 (file)
 
 #define HEADER_HEIGHT 48
 #define FOOTER_HEIGHT 24
-#define FOOTER_HEIGHT_PRESS 48 /* approx, used only for checking clicks, bigger than controls */
-#define FOOTER_WIDTH C_WIDTH/5
+#define FOOTER_HEIGHT_PRESS FOOTER_HEIGHT*2 /* approx, used only for checking clicks */
+#define FOOTER_WIDTH C_WIDTH/4
+#define FOOTER_WIDTH_PRESS (FOOTER_WIDTH + FOOTER_WIDTH/2) /* approx, used only for checking clicks, bigger than controls */
 
 #define MESSAGE_HEIGHT (C_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT)
 #define MESSAGE_WIDTH (C_WIDTH - 2*HILDON_MARGIN_DEFAULT)
 
-#define BOX_RADIOUS 10
+#define SERVICE_ICON_SIZE HILDON_ICON_PIXEL_SIZE_SMALL
+#define AVATAR_SIZE HILDON_ICON_PIXEL_SIZE_THUMB
+
+#define AVATAR_X (C_WIDTH - AVATAR_SIZE - HILDON_MARGIN_DEFAULT)
+#define AVATAR_Y 3*HILDON_MARGIN_HALF
+
+#define BOX_RADIOUS 20
 
 #define SCROLL_PERIOD 100 /* ms */
 #define SCROLL_STEP 1 /* pixel */
 #define NOTIFICATION_UI_DBUS_PATH     "/org/freedesktop/Telepathy/Client/NotificationUI"
 #define NOTIFICATION_UI_DBUS_IFACE    "com.nokia.RtcomNotificationUi"
 
+static const gchar *conv_services[] = {"RTCOM_EL_SERVICE_SMS",
+                                       "RTCOM_EL_SERVICE_CHAT",
+                                       NULL};
+static const gchar *conv_event_types[] = {"RTCOM_EL_EVENTTYPE_SMS_INBOUND",
+                                          "RTCOM_EL_EVENTTYPE_CHAT_INBOUND",
+                                          NULL};
+
 typedef enum {
         SELECTED_NONE,
         SELECTED_HEADER,
@@ -83,7 +97,7 @@ struct _ELHomeAppletPrivate
         RTComEl *eventlogger;
 
         GtkWidget *sender;
-        /* GtkWidget *icon; */
+        GtkWidget *icon;
         GtkWidget *unread;
         GtkWidget *received;
         GtkWidget *empty;
@@ -105,6 +119,8 @@ struct _ELHomeAppletPrivate
         guint8 border_color[4];
         PangoFontDescription *font_desc;
 
+        GdkPixbuf *avatar_pixbuf;
+
         guint idle_id;
 
         cairo_surface_t *message_surface;
@@ -153,34 +169,79 @@ el_home_applet_realize (GtkWidget *widget)
         GTK_WIDGET_CLASS (el_home_applet_parent_class)->realize (widget);
 }
 
-/*
- * Thanks http://cairographics.org/cookbook/roundedrectangles/
+enum {
+        ROUND_CORNER_TL = 1,
+        ROUND_CORNER_TR = 1<<1,
+        ROUND_CORNER_BL = 1<<2,
+        ROUND_CORNER_BR = 1<<3,
+        ROUND_CORNER_ALL = ROUND_CORNER_TL | ROUND_CORNER_TR |
+                           ROUND_CORNER_BL | ROUND_CORNER_BR
+};
+
+/**
+ * Draw rectangle with optional round corners.
+ *
+ * @x
+ * @y
+ * @w width
+ * @h height
+ * @r round corner radious
+ * @round_corners define which corners draw round, ROUND_CORNER_TL,
+ *                ROUND_CORNER_TR, ROUND_CORNER_BL, ROUND_CORNER_BR
  */
 static void
 rounded_rectangle (cairo_t *cr,
-                   double   x,
-                   double   y,
-                   double   w,
-                   double   h,
-                   double   r)
+                   double x,
+                   double y,
+                   double w,
+                   double h,
+                   double r,
+                   guint round_corners)
 {
-        cairo_move_to (cr, x + r, y);
-        cairo_line_to (cr, x + w - r, y);
-        cairo_curve_to (cr, x + w, y,
-                        x + w, y,
-                        x + w, y + r);
-        cairo_line_to (cr, x + w, y + h - r);
-        cairo_curve_to (cr, x + w, y + h,
-                        x + w, y + h,
-                        x + w - r, y + h);
-        cairo_line_to (cr, x + r, y + h);
-        cairo_curve_to (cr, x, y + h,
-                        x, y + h,
-                        x, y + h - r);
-        cairo_line_to (cr, x, y + r);
-        cairo_curve_to (cr, x, y,
-                        x, y,
-                        x + r, y);
+        if (round_corners & ROUND_CORNER_TL)
+                cairo_move_to (cr, x + r, y);
+        else
+                cairo_move_to (cr, x, y);
+
+        if (round_corners & ROUND_CORNER_TR) {
+                cairo_line_to (cr, x + w - r, y);
+                cairo_rel_curve_to (cr,
+                                    r, 0,
+                                    r, 0,
+                                    r, r);
+        }
+        else
+                cairo_line_to (cr, x + w, y);
+
+        if (round_corners & ROUND_CORNER_BR) {
+                cairo_line_to (cr, x + w, y + h - r);
+                cairo_rel_curve_to (cr,
+                                    0, r,
+                                    0, r,
+                                    -r, r);
+        }
+        else
+                cairo_line_to (cr, x + w, y + h);
+
+        if (round_corners & ROUND_CORNER_BL) {
+                cairo_line_to (cr, x + r, y + h);
+                cairo_rel_curve_to (cr,
+                                    -r, 0,
+                                    -r, 0,
+                                    -r, -r);
+        }
+        else
+                cairo_line_to (cr, x, y + h);
+
+        if (round_corners & ROUND_CORNER_TL) {
+                cairo_line_to (cr, x, y + r);
+                cairo_rel_curve_to (cr,
+                                    0, -r,
+                                    0, -r,
+                                    r, -r);
+        }
+        else
+                cairo_line_to (cr, x, y);
 }
 
 static cairo_surface_t*
@@ -331,7 +392,8 @@ expose_event (GtkWidget *self, GdkEventExpose *event)
                            CONTENT_OFFSET_Y_TOP,
                            BOX_WIDTH - 2*CONTENT_OFFSET_X,
                            BOX_HEIGHT - (CONTENT_OFFSET_Y_TOP + CONTENT_OFFSET_Y_BOTTOM),
-                           BOX_RADIOUS);
+                           BOX_RADIOUS,
+                           ROUND_CORNER_ALL);
 
         cairo_close_path (cr);
         cairo_stroke (cr);
@@ -340,14 +402,11 @@ expose_event (GtkWidget *self, GdkEventExpose *event)
         cairo_set_line_width (cr, 1.0f);
 
         cairo_translate (cr, CONTENT_OFFSET_X, CONTENT_OFFSET_Y_TOP);
-        cairo_move_to (cr, 0, HEADER_HEIGHT);
-        cairo_line_to (cr, 0, BOX_RADIOUS);
-        cairo_curve_to (cr, 0, 0, 0, 0, BOX_RADIOUS, 0);
-        cairo_line_to (cr, C_WIDTH - BOX_RADIOUS, 0);
-        cairo_curve_to (cr, C_WIDTH, 0, C_WIDTH, 0, C_WIDTH, BOX_RADIOUS);
-        cairo_line_to (cr, C_WIDTH, HEADER_HEIGHT);
-        cairo_line_to (cr, 0, HEADER_HEIGHT);
-
+        rounded_rectangle (cr,
+                           0, 0,
+                           C_WIDTH, HEADER_HEIGHT,
+                           BOX_RADIOUS,
+                           ROUND_CORNER_TL | ROUND_CORNER_TR);
         cairo_close_path (cr);
 
         switch (priv->active) {
@@ -375,13 +434,11 @@ expose_event (GtkWidget *self, GdkEventExpose *event)
 
         /* draw body */
         if (!priv->message) {
-                cairo_move_to (cr, 0, HEADER_HEIGHT);
-                cairo_line_to (cr, 0, C_HEIGHT - BOX_RADIOUS);
-                cairo_curve_to (cr, 0, C_HEIGHT, 0, C_HEIGHT, BOX_RADIOUS, C_HEIGHT);
-                cairo_line_to (cr, C_WIDTH - BOX_RADIOUS, C_HEIGHT);
-                cairo_curve_to (cr, C_WIDTH, C_HEIGHT, C_WIDTH, C_HEIGHT, C_WIDTH, C_HEIGHT - BOX_RADIOUS);
-                cairo_line_to (cr, C_WIDTH, HEADER_HEIGHT);
-                cairo_line_to (cr, 0, HEADER_HEIGHT);
+                rounded_rectangle (cr,
+                                   0, HEADER_HEIGHT,
+                                   C_WIDTH, C_HEIGHT,
+                                   BOX_RADIOUS,
+                                   ROUND_CORNER_BL | ROUND_CORNER_BR);
                 cairo_close_path (cr);
         }
         else
@@ -419,14 +476,51 @@ expose_event (GtkWidget *self, GdkEventExpose *event)
 
         cairo_pattern_destroy (grad);
 
+        /* draw avatar */
+        if (priv->avatar_pixbuf) {
+                rounded_rectangle (cr,
+                                   AVATAR_X, -AVATAR_Y,
+                                   AVATAR_SIZE, AVATAR_SIZE,
+                                   BOX_RADIOUS,
+                                   ROUND_CORNER_ALL);
+                cairo_close_path (cr);
+
+                gdk_cairo_set_source_pixbuf (cr,
+                                             priv->avatar_pixbuf,
+                                             AVATAR_X,
+                                             -AVATAR_Y);
+                cairo_fill_preserve (cr);
+
+                cairo_set_source_rgba (cr,
+                                       priv->active_color.red,
+                                       priv->active_color.green,
+                                       priv->active_color.blue,
+                                       1.0f);
+                cairo_stroke (cr);
+        }
+#if 0
+        if (priv->service_pixbuf) {
+                guint x = C_WIDTH - SERVICE_ICON_SIZE - HILDON_MARGIN_DEFAULT;
+                guint y = (HEADER_HEIGHT - SERVICE_ICON_SIZE)/2;
+
+                if (priv->avatar_pixbuf)
+                        x -= AVATAR_SIZE + HILDON_MARGIN_DEFAULT;
+
+                cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+                gdk_cairo_set_source_pixbuf (cr,
+                                             priv->service_pixbuf,
+                                             x, y);
+                cairo_paint (cr);
+        }
+#endif
         if (priv->message) {
+
                 /* draw footer unread part bg */
-                cairo_move_to (cr, 0, C_HEIGHT - FOOTER_HEIGHT);
-                cairo_line_to (cr, 0, C_HEIGHT - BOX_RADIOUS);
-                cairo_curve_to (cr, 0, C_HEIGHT, 0, C_HEIGHT, BOX_RADIOUS, C_HEIGHT);
-                cairo_line_to (cr, FOOTER_WIDTH, C_HEIGHT);
-                cairo_line_to (cr, FOOTER_WIDTH, C_HEIGHT - FOOTER_HEIGHT);
-                cairo_line_to (cr, 0, C_HEIGHT - FOOTER_HEIGHT);
+                rounded_rectangle (cr,
+                                   0, C_HEIGHT - FOOTER_HEIGHT,
+                                   FOOTER_WIDTH, FOOTER_HEIGHT,
+                                   BOX_RADIOUS,
+                                   ROUND_CORNER_BL);
                 cairo_close_path (cr);
 
                 /* draw body filling depending on (in)active state */
@@ -444,12 +538,11 @@ expose_event (GtkWidget *self, GdkEventExpose *event)
                 cairo_fill (cr);
 
                 /* draw footer received part bg */
-                cairo_move_to (cr, FOOTER_WIDTH, C_HEIGHT - FOOTER_HEIGHT);
-                cairo_rel_line_to (cr, 0, FOOTER_HEIGHT);
-                cairo_rel_line_to (cr, C_WIDTH - FOOTER_WIDTH - BOX_RADIOUS, 0);
-                cairo_rel_curve_to (cr, BOX_RADIOUS, 0, BOX_RADIOUS, 0, BOX_RADIOUS, -BOX_RADIOUS);
-                cairo_rel_line_to (cr, 0, -(FOOTER_HEIGHT - BOX_RADIOUS));
-                cairo_rel_line_to (cr, -(C_WIDTH - FOOTER_WIDTH), 0);
+                rounded_rectangle (cr,
+                                   FOOTER_WIDTH, C_HEIGHT - FOOTER_HEIGHT,
+                                   C_WIDTH - FOOTER_WIDTH, FOOTER_HEIGHT,
+                                   BOX_RADIOUS,
+                                   ROUND_CORNER_BR);
                 cairo_close_path (cr);
 
                 cairo_set_source_rgba (cr, 0.2f, 0.2f, 0.2f, 0.8f);
@@ -497,6 +590,17 @@ clean_state (ELHomeApplet *self)
 {
         ELHomeAppletPrivate *priv = self->priv;
 
+        gtk_widget_set_size_request (priv->sender,
+                                     C_WIDTH,
+                                     HILDON_ICON_PIXEL_SIZE_THUMB);
+
+        gtk_widget_hide (priv->icon);
+
+        if (priv->avatar_pixbuf) {
+                g_object_unref (priv->avatar_pixbuf);
+                priv->avatar_pixbuf = NULL;
+        }
+
         if (priv->message) {
                 g_free (priv->message);
                 priv->message = NULL;
@@ -573,7 +677,7 @@ aggregator_ready_cb (OssoABookWaitable *waitable,
         ELHomeApplet *self = EL_HOME_APPLET(userdata);
         ELHomeAppletPrivate *priv = self->priv;
         GList *contacts = NULL;
-
+                g_warning (G_STRFUNC);
         priv->aggregator_ready_closure = NULL;
 
         if (error) {
@@ -608,26 +712,32 @@ aggregator_ready_cb (OssoABookWaitable *waitable,
         }
 
         if (contacts && contacts->data) {
-                GdkPixbuf *avatar_image;
-
                 priv->contact = g_object_ref (OSSO_ABOOK_CONTACT (contacts->data));
                 gtk_label_set_text (GTK_LABEL (priv->sender),
                                     osso_abook_contact_get_display_name (priv->contact));
 
-                avatar_image = osso_abook_avatar_get_image_rounded
+                priv->avatar_pixbuf = osso_abook_avatar_get_image_scaled /*rounded*/
                         (OSSO_ABOOK_AVATAR (priv->contact),
                          HILDON_ICON_PIXEL_SIZE_THUMB,
                          HILDON_ICON_PIXEL_SIZE_THUMB,
-                         TRUE,
-                         -1,
-                         priv->border_color);
+                         TRUE);
+                         /* -1, */
+                         /* priv->border_color); */
+                g_warning ("HAVE avatar");
+                if (priv->avatar_pixbuf) {
+                        gtk_widget_set_size_request (priv->sender,
+                                                     C_WIDTH - AVATAR_SIZE - HILDON_MARGIN_DEFAULT,
+                                                     HILDON_ICON_PIXEL_SIZE_THUMB);
 
-                if (avatar_image) {
+                }
+#if 0
+                if (priv->avatar_pixbuf) {
                         gtk_image_set_from_pixbuf (GTK_IMAGE (priv->avatar),
-                                                   avatar_image);
+                                                   priv->avatar_pixbuf);
                         gtk_widget_show (priv->avatar);
-                        g_object_unref (avatar_image);
+                        /* g_object_unref (avatar_image); */
                 }
+#endif
                 gtk_widget_queue_draw (GTK_WIDGET (self));
         }
 }
@@ -638,7 +748,7 @@ resolve_contact (ELHomeApplet *self)
         ELHomeAppletPrivate *priv = self->priv;
         EBookQuery *query = NULL;
         GError *error = NULL;
-
+        g_warning ("%s rid %s lid %s", G_STRFUNC, priv->remote_id, priv->local_id);
         if (priv->local_id && priv->remote_id) {
                 const gchar *vcard = osso_abook_account_manager_get_vcard_field
                         (NULL, priv->local_id);
@@ -649,7 +759,7 @@ resolve_contact (ELHomeApplet *self)
                 else
                         query = e_book_query_any_field_contains (priv->remote_id);
         }
-
+        g_warning ("%s query %p", G_STRFUNC, query);
         if (query) {
                 priv->aggregator = osso_abook_aggregator_new_with_query (NULL,
                                                                          query,
@@ -665,6 +775,7 @@ resolve_contact (ELHomeApplet *self)
         }
 
         if (priv->aggregator) {
+                g_warning ("%s start aggr", G_STRFUNC);
                 priv->aggregator_ready_closure = osso_abook_waitable_call_when_ready
                         (OSSO_ABOOK_WAITABLE (priv->aggregator),
                          aggregator_ready_cb,
@@ -702,41 +813,46 @@ static void
 show_event (ELHomeApplet *self, RTComElIter *it)
 {
         ELHomeAppletPrivate *priv = self->priv;
-        gchar *remote = NULL;
+        const gchar *remote = NULL;
         gchar *received = NULL;
-        /* const gchar *icon_name = NULL; */
+        GValueArray *event = NULL;
 
         if (it && rtcom_el_iter_first (it)) {
-                rtcom_el_iter_dup_string (it, "free-text", &priv->message);
-                if (priv->message) {
-                        /* const gchar *service; */
-                        time_t received_t;
 
-                        rtcom_el_iter_get_int (it, "id", &priv->event_id);
-                        if (rtcom_el_iter_get_int (it, "start-time", (gint*)&received_t))
-                                received = format_time (received_t);
-
-                        if (rtcom_el_iter_dup_string (it, "remote-uid", &priv->remote_id)) {
-                                if (priv->remote_id && priv->remote_id[0])  {
-                                        if (!rtcom_el_iter_dup_string (it, "remote-name", &remote))
-                                                remote = g_strdup (priv->remote_id);
-
-                                        rtcom_el_iter_dup_string (it, "remote-ebook-uid", &priv->contact_id);
-                                        rtcom_el_iter_dup_string (it, "local-uid", &priv->local_id);
-                                }
-                                else if (priv->remote_id) {
-                                        g_free (priv->remote_id);
-                                        priv->remote_id = NULL;
-                                }
+                event = rtcom_el_iter_get_valuearray (it,
+                                                      "id",
+                                                      "start-time",
+                                                      "local-uid",
+                                                      "remote-uid",
+                                                      "remote-name",
+                                                      "remote-ebook-uid",
+                                                      "free-text",
+                                                      "group-uid",
+                                                      NULL);
+                if (event) {
+                        time_t received_t;
+#define _VARR_DUP_STR(array, i) g_value_dup_string (g_value_array_get_nth ((array), (i)))
+
+                        priv->event_id = g_value_get_int (g_value_array_get_nth (event, 0));
+                        received_t = g_value_get_int (g_value_array_get_nth (event, 1));
+                        received = format_time (received_t);
+                        priv->local_id = _VARR_DUP_STR (event, 2);
+                        priv->remote_id = _VARR_DUP_STR (event, 3);
+                        if (priv->remote_id && priv->remote_id[0]) {
+                                remote = g_value_get_string (g_value_array_get_nth (event, 4));
+                                if (!remote)
+                                        remote = priv->remote_id;
+                                priv->contact_id = _VARR_DUP_STR (event, 5);
                         }
-                        rtcom_el_iter_dup_string (it, "group-uid", &priv->group_uid);
-#if 0
-                        service = rtcom_el_iter_get_service (it);
-                        if (!g_strcmp0 (service, "RTCOM_EL_SERVICE_SMS"))
-                                icon_name = "chat_unread_sms";
-                        else if (!g_strcmp0 (service, "RTCOM_EL_SERVICE_CHAT"))
-                                icon_name = "chat_unread_chat";
-#endif
+                        else if (priv->remote_id) {
+                                g_free (priv->remote_id);
+                                priv->remote_id = NULL;
+                        }
+
+                        priv->message = _VARR_DUP_STR (event, 6);
+                        priv->group_uid = _VARR_DUP_STR (event, 7);
+
+#undef _VARR_DUP_STR
                 }
         }
         else {
@@ -754,28 +870,10 @@ show_event (ELHomeApplet *self, RTComElIter *it)
 
         gtk_label_set_text (GTK_LABEL (priv->received), received);
 
-#if 0
-        gtk_widget_hide (priv->avatar);
-        if (icon_name) {
-                const gchar *current_icon_name;
-                gtk_image_get_icon_name (GTK_IMAGE (priv->icon),
-                                         &current_icon_name,
-                                         NULL);
-                if (g_strcmp0 (current_icon_name, icon_name))
-                        gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
-                                                      icon_name,
-                                                      HILDON_ICON_SIZE_FINGER);
-                gtk_widget_show (priv->icon);
-        }
-        else
-                gtk_widget_hide (priv->icon);
-#endif
-
         if (remote)
                 gtk_label_set_text (GTK_LABEL (priv->sender), remote);
         else
                 gtk_label_set_text (GTK_LABEL (priv->sender), priv->remote_id);
-        g_free (remote);
 
         stop_scroll_anim (priv);
         priv->scroll_offset = 0;
@@ -784,6 +882,9 @@ show_event (ELHomeApplet *self, RTComElIter *it)
                 priv->message_surface = NULL;
         }
 
+        if (event)
+                g_value_array_free (event);
+
         gtk_widget_hide (priv->cut_message);
         gtk_widget_queue_draw (GTK_WIDGET (self));
 }
@@ -794,28 +895,18 @@ make_query (RTComEl *el, gint event_id)
         RTComElQuery *query = NULL;
         RTComElIter *it = NULL;
 
-        static const gchar *services[] = {"RTCOM_EL_SERVICE_SMS",
-                                          "RTCOM_EL_SERVICE_CHAT",
-                                          NULL};
-        static const gchar *event_types[] = {"RTCOM_EL_EVENTTYPE_SMS_INBOUND",
-                                             "RTCOM_EL_EVENTTYPE_CHAT_INBOUND",
-                                             NULL};
-
         query = rtcom_el_query_new (el);
         rtcom_el_query_set_limit (query, 1);
         if (event_id >= 0) {
                 rtcom_el_query_prepare (query,
-                                        "is-read", FALSE, RTCOM_EL_OP_EQUAL,
                                         "id", event_id, RTCOM_EL_OP_EQUAL,
-                                        "service", services, RTCOM_EL_OP_IN_STRV,
-                                        "event-type", event_types, RTCOM_EL_OP_IN_STRV,
                                         NULL);
         }
         else {
                 rtcom_el_query_prepare (query,
                                         "is-read", FALSE, RTCOM_EL_OP_EQUAL,
-                                        "service", services, RTCOM_EL_OP_IN_STRV,
-                                        "event-type", event_types, RTCOM_EL_OP_IN_STRV,
+                                        "service", conv_services, RTCOM_EL_OP_IN_STRV,
+                                        /* "event-type", conv_event_types, RTCOM_EL_OP_IN_STRV, */
                                         NULL);
         }
         it = rtcom_el_get_events (el, query);
@@ -880,12 +971,34 @@ read_event (ELHomeApplet *self)
 {
         ELHomeAppletPrivate *priv = self->priv;
         RTComElIter *it = NULL;
+        const gchar *icon_name = NULL;
 
         clean_state (self);
 
         it = make_query (priv->eventlogger, -1);
         show_event (self, it);
         resolve_contact (self);
+
+        if (g_strcmp0 (priv->local_id, "ring/tel/ring") == 0) {
+                icon_name = "general_sms";
+        }
+        else{
+                McAccount *account;
+                account = osso_abook_account_manager_lookup_by_name (NULL,
+                                                                     priv->local_id);
+                if (account) {
+                        McProfile *profile = mc_profile_lookup (mc_account_compat_get_profile (account));
+                        icon_name = mc_profile_get_icon_name (profile);
+                }
+        }
+
+        if (icon_name) {
+                gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
+                                              icon_name,
+                                              HILDON_ICON_SIZE_SMALL);
+                gtk_widget_show (priv->icon);
+        }
+
         if (it) g_object_unref (it);
 }
 
@@ -1032,6 +1145,8 @@ read_new_event (ELHomeApplet *self)
 {
         ELHomeAppletPrivate *priv = self->priv;
 
+        g_warning ("read_new_event");
+
         read_event (self);
         priv->unread_count = query_unread_events (priv->eventlogger);
         update_unread_label (self);
@@ -1045,7 +1160,7 @@ static void
 add_new_idle (ELHomeApplet *self)
 {
         ELHomeAppletPrivate *priv = self->priv;
-
+        g_warning ("add_new_idle");
         if (priv->idle_id)
                 g_source_remove (priv->idle_id);
         priv->idle_id = g_idle_add ((GSourceFunc)read_new_event,
@@ -1062,8 +1177,21 @@ new_event_cb (RTComEl      *backend,
               const gchar  *service,
               ELHomeApplet *self)
 {
-        /* TODO: avoid updating if not related */
+        g_warning ("%s %s %s %s", local_uid, remote_uid, remote_ebook_uid, service);
+#if 0
+        const gchar** conv_service = conv_services;
+                g_warning ("%s", service);
+        do {
+                g_warning ("%s", *conv_service);
+                if (!g_strcmp0 (*conv_service, service)) {
+                        add_new_idle (self);
+                        return;
+                }
+        }
+        while(*++conv_service);
+#else
         add_new_idle (self);
+#endif
 }
 
 static gboolean
@@ -1077,7 +1205,7 @@ scroll_anim_cb (ELHomeApplet *self)
                                     3*CONTENT_OFFSET_X,
                                     HEADER_HEIGHT + CONTENT_OFFSET_Y_TOP,
                                     MESSAGE_WIDTH,
-                                    C_HEIGHT - priv->received->allocation.height - HEADER_HEIGHT);
+                                    MESSAGE_HEIGHT);
 
         to_continue = priv->scroll_offset <= priv->hidden_message_height;
         if (!to_continue) {
@@ -1103,7 +1231,7 @@ button_press_event_cb (GtkWidget      *widget,
                                 priv->active = SELECTED_HEADER;
                 }
                 else if (event->y > (BOX_HEIGHT - CONTENT_OFFSET_Y_BOTTOM - FOOTER_HEIGHT_PRESS) &&
-                         event->x < FOOTER_WIDTH)
+                         event->x < FOOTER_WIDTH_PRESS)
                         priv->active = SELECTED_FOOTER;
                 else
                         priv->active = SELECTED_BODY;
@@ -1261,9 +1389,8 @@ el_home_applet_init (ELHomeApplet *self)
         /* gtk_widget_set_size_request (priv->unread, */
         /*                              -1, */
         /*                              HEADER_HEIGHT); */
-#if 0
-        priv->icon = gtk_image_new_from_icon_name ("chat_unread_sms",
-                                                   HILDON_ICON_SIZE_FINGER);
+#if 1
+        priv->icon = gtk_image_new ();
         gtk_misc_set_alignment (GTK_MISC (priv->icon),
                                 0.5f,
                                 0.5f);
@@ -1282,7 +1409,7 @@ el_home_applet_init (ELHomeApplet *self)
         gtk_widget_set_name (priv->sender, "hildon-shadow-label");
         hildon_helper_set_logical_font (priv->sender, "SystemFont");
         gtk_widget_set_size_request (priv->sender,
-                                     -1,
+                                     C_WIDTH,
                                      HILDON_ICON_PIXEL_SIZE_THUMB);
 
         priv->message = g_strdup ("One two three four five six seven eight nine ten");
@@ -1309,13 +1436,13 @@ el_home_applet_init (ELHomeApplet *self)
         GTK_WIDGET_SET_FLAGS (priv->cut_message, GTK_NO_SHOW_ALL);
 
         hbox = gtk_hbox_new (FALSE, 0);
-        /* gtk_box_pack_start (GTK_BOX (hbox), priv->icon, FALSE, FALSE, 0); */
-        gtk_box_pack_start (GTK_BOX (hbox), priv->sender, TRUE, TRUE, 0);
-        gtk_box_pack_start (GTK_BOX (hbox), priv->avatar, FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (hbox), priv->sender, FALSE, FALSE, 0);
+        /* gtk_box_pack_start (GTK_BOX (hbox), priv->avatar, FALSE, FALSE, 0); */
 
         footer = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
         gtk_box_pack_start (GTK_BOX (footer), priv->unread, FALSE, FALSE, 0);
         gtk_box_pack_start (GTK_BOX (footer), priv->cut_message, TRUE, TRUE, 0);
+        gtk_box_pack_end (GTK_BOX (footer), priv->icon, FALSE, FALSE, 0);
         gtk_box_pack_end (GTK_BOX (footer), priv->received, FALSE, FALSE, 0);
 
         vbox = gtk_vbox_new (FALSE, 0);
@@ -1372,9 +1499,9 @@ el_home_applet_init (ELHomeApplet *self)
                           G_CALLBACK (new_event_cb),
                           self);
 
-        read_new_event (self);
-
         osso_abook_init_with_name (PACKAGE, NULL);
+
+        add_new_idle (self);
 #endif
 }