X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-attachment-view.c;h=bd53bf6963647eb908fd5071543ef44eeed17ff6;hb=0ca412c0351f777d1fb3e3ff12317a3068b01642;hp=38d78300f83f0ffd28c25477cadcb35dc4113449;hpb=4847d8f92f276a204862e502316486c4e04a1fca;p=modest diff --git a/src/widgets/modest-attachment-view.c b/src/widgets/modest-attachment-view.c index 38d7830..bd53bf6 100644 --- a/src/widgets/modest-attachment-view.c +++ b/src/widgets/modest-attachment-view.c @@ -43,6 +43,7 @@ #include #include #include +#include #define GET_SIZE_BUFFER_SIZE 128 @@ -93,10 +94,43 @@ static void modest_attachment_view_finalize (GObject *object); static void modest_attachment_view_class_init (ModestAttachmentViewClass *klass); static void tny_mime_part_view_init (gpointer g, gpointer iface_data); +static void on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata); +static void update_style (ModestAttachmentView *self); static void update_filename_request (ModestAttachmentView *self); +static void +on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata) +{ + if (strcmp ("style", spec->name) == 0) { + update_style (MODEST_ATTACHMENT_VIEW (obj)); + gtk_widget_queue_draw (GTK_WIDGET (obj)); + } +} + +/* This method updates the color (and other style settings) of widgets using secondary text color, + * tracking the gtk style */ +static void +update_style (ModestAttachmentView *self) +{ +#ifdef MODEST_COMPACT_HEADER_BG + GdkColor bg_color; + GtkStyle *style; + GdkColor *current_bg; + + g_return_if_fail (MODEST_IS_ATTACHMENT_VIEW (self)); + + gdk_color_parse (MODEST_COMPACT_HEADER_BG, &bg_color); + style = gtk_widget_get_style (GTK_WIDGET (self)); + current_bg = &(style->bg[GTK_STATE_NORMAL]); + if (current_bg->red != bg_color.red || current_bg->blue != bg_color.blue || current_bg->green != bg_color.green) + gtk_widget_modify_bg (GTK_WIDGET (self), GTK_STATE_NORMAL, &bg_color); +#endif +} + + + static void update_size_label (ModestAttachmentView *self) { ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (self); @@ -266,8 +300,11 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim gchar *header_content_type; header_content_type = modest_tny_mime_part_get_content_type (mime_part); if ((g_str_has_prefix (header_content_type, "message/rfc822") || - g_str_has_prefix (header_content_type, "multipart/") || - g_str_has_prefix (header_content_type, "text/"))) { + g_str_has_prefix (header_content_type, "multipart/"))) { + file_icon_name = + modest_platform_get_file_icon_name ( + NULL, "message/rfc822", NULL); + } else if (g_str_has_prefix (header_content_type, "text/")) { file_icon_name = modest_platform_get_file_icon_name ( NULL, tny_mime_part_get_content_type (mime_part), NULL); @@ -281,13 +318,31 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim g_object_unref (header); } } else { + gboolean is_other_body = FALSE; filename = g_strdup (tny_mime_part_get_filename (mime_part)); + if (filename == NULL) { + gchar *description; + description = modest_tny_mime_part_get_header_value (mime_part, "Content-Description"); + if (description) { + g_strstrip (description); + filename = description; + } + if (!filename || filename[0] == '\0') { + g_free (filename); + filename = g_strdup (_("mail_va_no_subject")); + } + is_other_body = TRUE; + } if (priv->is_purged) { file_icon_name = modest_platform_get_file_icon_name (NULL, NULL, NULL); } else { - file_icon_name = modest_platform_get_file_icon_name ( - filename, modest_tny_mime_part_get_content_type (mime_part), NULL); - show_size = TRUE; + if (is_other_body) { + file_icon_name = modest_platform_get_file_icon_name (NULL, "message/rfc822", NULL); + } else { + file_icon_name = modest_platform_get_file_icon_name ( + filename, modest_tny_mime_part_get_content_type (mime_part), NULL); + show_size = TRUE; + } } } @@ -413,6 +468,7 @@ modest_attachment_view_instance_init (GTypeInstance *instance, gpointer g_class) ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (instance); PangoContext *context; GtkWidget *box = NULL; + GtkWidget *icon_alignment = NULL; #ifdef MODEST_TOOLKIT_HILDON2 PangoAttrList *attr_list; @@ -421,6 +477,8 @@ modest_attachment_view_instance_init (GTypeInstance *instance, gpointer g_class) #endif priv->mime_part = NULL; + icon_alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); + gtk_alignment_set_padding (GTK_ALIGNMENT (icon_alignment), 0, 0, 0, MODEST_MARGIN_DEFAULT); priv->icon = gtk_image_new (); priv->filename_view = gtk_label_new (""); gtk_label_set_line_wrap (GTK_LABEL (priv->filename_view), FALSE); @@ -443,7 +501,8 @@ modest_attachment_view_instance_init (GTypeInstance *instance, gpointer g_class) priv->detect_size = TRUE; box = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), priv->icon, FALSE, FALSE, 0); + gtk_container_add (GTK_CONTAINER (icon_alignment), priv->icon); + gtk_box_pack_start (GTK_BOX (box), icon_alignment, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box), priv->filename_view, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (box), priv->size_view, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (instance), box); @@ -466,6 +525,11 @@ modest_attachment_view_instance_init (GTypeInstance *instance, gpointer g_class) GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (instance), GTK_CAN_FOCUS); + g_signal_connect (G_OBJECT (instance), "notify::style", G_CALLBACK (on_notify_style), (gpointer) instance); + + update_style (MODEST_ATTACHMENT_VIEW (instance)); + + return; }