Also change bg color of attachments view.
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 26 Aug 2009 16:07:25 +0000 (18:07 +0200)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 27 Aug 2009 06:42:58 +0000 (08:42 +0200)
src/widgets/modest-attachment-view.c
src/widgets/modest-attachments-view.c
src/widgets/modest-compact-mail-header-view.c
src/widgets/modest-ui-constants.h

index 33ce114..bd53bf6 100644 (file)
@@ -94,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 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 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);
 static void update_size_label (ModestAttachmentView *self)
 {
        ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (self);
@@ -492,6 +525,11 @@ modest_attachment_view_instance_init (GTypeInstance *instance, gpointer g_class)
 
        GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (instance), GTK_CAN_FOCUS);
 
 
        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;
 }
 
        return;
 }
 
index 3fae008..8d498f3 100644 (file)
@@ -41,6 +41,7 @@
 #include <modest-attachments-view.h>
 #include <modest-tny-mime-part.h>
 #include <modest-tny-msg.h>
 #include <modest-attachments-view.h>
 #include <modest-tny-mime-part.h>
 #include <modest-tny-msg.h>
+#include <modest-ui-constants.h>
 
 static GObjectClass *parent_class = NULL;
 
 
 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 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};
 
 
 static guint signals[LAST_SIGNAL] = {0};
 
@@ -366,6 +369,10 @@ modest_attachments_view_instance_init (GTypeInstance *instance, gpointer g_class
 
        GTK_WIDGET_SET_FLAGS (instance, GTK_CAN_FOCUS);
 
 
        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;
 }
 
        return;
 }
 
@@ -1102,3 +1109,33 @@ modest_attachments_view_get_num_attachments (ModestAttachmentsView *atts_view)
 
        return result;
 }
 
        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
+}
+
index 1016792..5837ad3 100644 (file)
@@ -718,7 +718,7 @@ update_style (ModestCompactMailHeaderView *self)
        }
        pango_attr_list_unref (attr_list);
 
        }
        pango_attr_list_unref (attr_list);
 
-       gdk_color_parse ("#ff00ff", &bg_color);
+       gdk_color_parse (MODEST_COMPACT_HEADER_BG, &bg_color);
        gtk_widget_modify_bg (GTK_WIDGET (priv->event_box), GTK_STATE_NORMAL, &bg_color);
 }
 
        gtk_widget_modify_bg (GTK_WIDGET (priv->event_box), GTK_STATE_NORMAL, &bg_color);
 }
 
index 17bb04a..7ced3a4 100644 (file)
@@ -44,6 +44,7 @@
 #define MODEST_DIALOG_WINDOW_MAX_WIDTH 642
 #define MODEST_DIALOG_WINDOW_MIN_WIDTH 172
 #ifdef MODEST_TOOLKIT_HILDON2
 #define MODEST_DIALOG_WINDOW_MAX_WIDTH 642
 #define MODEST_DIALOG_WINDOW_MIN_WIDTH 172
 #ifdef MODEST_TOOLKIT_HILDON2
+#define MODEST_COMPACT_HEADER_BG "#404040"
 #define MODEST_MARGIN_HALF HILDON_MARGIN_HALF
 #define MODEST_MARGIN_DEFAULT HILDON_MARGIN_DEFAULT
 #define MODEST_MARGIN_DOUBLE HILDON_MARGIN_DOUBLE
 #define MODEST_MARGIN_HALF HILDON_MARGIN_HALF
 #define MODEST_MARGIN_DEFAULT HILDON_MARGIN_DEFAULT
 #define MODEST_MARGIN_DOUBLE HILDON_MARGIN_DOUBLE