show service icon in footer
authorArtem Garmash <artemgarmash@gmail.com>
Thu, 28 Jan 2010 17:18:05 +0000 (19:18 +0200)
committerArtem Garmash <artem.garmash@nokia.com>
Sun, 27 Jun 2010 19:13:45 +0000 (22:13 +0300)
src/el-home-applet.c

index a2f2923..bc4443c 100644 (file)
@@ -62,7 +62,7 @@
 #define MESSAGE_HEIGHT (C_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT)
 #define MESSAGE_WIDTH (C_WIDTH - 2*HILDON_MARGIN_DEFAULT)
 
-#define SERVICE_ICON_SIZE 64
+#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)
@@ -97,7 +97,7 @@ struct _ELHomeAppletPrivate
         RTComEl *eventlogger;
 
         GtkWidget *sender;
-        /* GtkWidget *icon; */
+        GtkWidget *icon;
         GtkWidget *unread;
         GtkWidget *received;
         GtkWidget *empty;
@@ -120,7 +120,6 @@ struct _ELHomeAppletPrivate
         PangoFontDescription *font_desc;
 
         GdkPixbuf *avatar_pixbuf;
-        GdkPixbuf *service_pixbuf;
 
         guint idle_id;
 
@@ -499,16 +498,22 @@ expose_event (GtkWidget *self, GdkEventExpose *event)
                                        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) {
-                if (priv->service_pixbuf) {
-                        cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
-                        gdk_cairo_set_source_pixbuf (cr,
-                                                     priv->service_pixbuf,
-                                                     C_WIDTH - SERVICE_ICON_SIZE,
-                                                     C_HEIGHT - FOOTER_HEIGHT - SERVICE_ICON_SIZE);
-                        cairo_paint_with_alpha (cr, 0.3);
-                }
 
                 /* draw footer unread part bg */
                 rounded_rectangle (cr,
@@ -589,10 +594,7 @@ clean_state (ELHomeApplet *self)
                                      C_WIDTH,
                                      HILDON_ICON_PIXEL_SIZE_THUMB);
 
-        if (priv->service_pixbuf) {
-                g_object_unref (priv->service_pixbuf);
-                priv->service_pixbuf = NULL;
-        }
+        gtk_widget_hide (priv->icon);
 
         if (priv->avatar_pixbuf) {
                 g_object_unref (priv->avatar_pixbuf);
@@ -746,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);
@@ -969,6 +971,7 @@ read_event (ELHomeApplet *self)
 {
         ELHomeAppletPrivate *priv = self->priv;
         RTComElIter *it = NULL;
+        const gchar *icon_name = NULL;
 
         clean_state (self);
 
@@ -976,27 +979,24 @@ read_event (ELHomeApplet *self)
         show_event (self, it);
         resolve_contact (self);
 
-        if (g_strcmp0 (priv->local_id, "ring/tel/ring" == 0)) {
+        if (g_strcmp0 (priv->local_id, "ring/tel/ring") == 0) {
+                icon_name = "general_sms";
+        }
+        else{
                 McAccount *account;
-                const gchar *icon_name = NULL;
                 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) {
-                        GdkScreen *screen;
-                        GtkIconTheme *icon_theme;
-
-                        screen = gtk_widget_get_screen (GTK_WIDGET (self));
-                        icon_theme = gtk_icon_theme_get_for_screen (screen);
+        }
 
-                        priv->service_pixbuf = gtk_icon_theme_load_icon (icon_theme,
-                                                                         icon_name,
-                                                                         SERVICE_ICON_SIZE,
-                                                                         0, NULL);
-                }
+        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);
@@ -1389,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);
@@ -1437,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, 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);
@@ -1502,7 +1501,7 @@ el_home_applet_init (ELHomeApplet *self)
 
         osso_abook_init_with_name (PACKAGE, NULL);
 
-        read_new_event (self);
+        add_new_idle (self);
 #endif
 }