X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-attachments-view.c;h=e7d5a5c31ec08c45d986d55c76716e84fc02d6fb;hp=f8ccd694f3d32d29f5fe534c7e01510fadcc0c8c;hb=12a672c559d983c4e49a7e4054ee14c0177ecb1c;hpb=b0807b9f7bea9cdce9e43071c4976f4de226d5c3 diff --git a/src/widgets/modest-attachments-view.c b/src/widgets/modest-attachments-view.c index f8ccd69..e7d5a5c 100644 --- a/src/widgets/modest-attachments-view.c +++ b/src/widgets/modest-attachments-view.c @@ -41,6 +41,7 @@ #include #include #include +#include static GObjectClass *parent_class = NULL; @@ -81,6 +82,8 @@ static void select_range (ModestAttachmentsView *atts_view, ModestAttachmentView static void clipboard_get (GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, gpointer userdata); static void own_clipboard (ModestAttachmentsView *atts_view); +static void on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata); +static void update_style (ModestAttachmentsView *self); static guint signals[LAST_SIGNAL] = {0}; @@ -150,21 +153,13 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn priv->selected = NULL; gtk_container_foreach (GTK_CONTAINER (priv->box), (GtkCallback) gtk_widget_destroy, NULL); - - if (priv->msg == NULL) { + + if (priv->msg == NULL) return; - } part_to_check = modest_tny_msg_get_attachments_parent (TNY_MSG (msg)); - - if (part_to_check) { - msg_content_type = modest_tny_mime_part_get_content_type (TNY_MIME_PART (part_to_check)); - is_alternate = !strcasecmp (msg_content_type, "multipart/alternative"); - } else { - /* If we couldn't find parent, just go through fallback */ - msg_content_type = NULL; - is_alternate = FALSE; - } + msg_content_type = modest_tny_mime_part_get_content_type (TNY_MIME_PART (part_to_check)); + is_alternate = (msg_content_type != NULL) && !strcasecmp (msg_content_type, "multipart/alternative"); /* If the top mime part is a multipart/related, we don't show the attachments, as they're * embedded images in body */ @@ -175,7 +170,7 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn g_free (msg_content_type); header_content_type = modest_tny_mime_part_get_headers_content_type (TNY_MIME_PART (part_to_check)); - + if ((header_content_type != NULL) && !strstr (header_content_type, "application/")) { application_multipart = TRUE; @@ -241,7 +236,6 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn g_object_unref (iter); g_object_unref (parts); g_object_unref (part_to_check); - gtk_widget_queue_draw (GTK_WIDGET (attachments_view)); @@ -375,6 +369,10 @@ modest_attachments_view_instance_init (GTypeInstance *instance, gpointer g_class GTK_WIDGET_SET_FLAGS (instance, GTK_CAN_FOCUS); + g_signal_connect (G_OBJECT (instance), "notify::style", G_CALLBACK (on_notify_style), (gpointer) instance); + + update_style (MODEST_ATTACHMENTS_VIEW (instance)); + return; } @@ -1111,3 +1109,33 @@ modest_attachments_view_get_num_attachments (ModestAttachmentsView *atts_view) return result; } + +static void +on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata) +{ + if (strcmp ("style", spec->name) == 0) { + update_style (MODEST_ATTACHMENTS_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 (ModestAttachmentsView *self) +{ +#ifdef MODEST_COMPACT_HEADER_BG + GdkColor bg_color; + GtkStyle *style; + GdkColor *current_bg; + + g_return_if_fail (MODEST_IS_ATTACHMENTS_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 +} +