diff options
author | Milan Crha <mcrha@redhat.com> | 2014-07-07 18:51:41 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2014-07-07 18:51:41 +0800 |
commit | 50bda1bad222082488d3d9bc9fe1d0fb3867e974 (patch) | |
tree | 27042fc0a39e4a7f79d920bae88cb29aa5677d10 /addressbook | |
parent | 534864b39850ea2354b87419da6dc77538867756 (diff) | |
download | gsoc2013-evolution-50bda1bad222082488d3d9bc9fe1d0fb3867e974.tar gsoc2013-evolution-50bda1bad222082488d3d9bc9fe1d0fb3867e974.tar.gz gsoc2013-evolution-50bda1bad222082488d3d9bc9fe1d0fb3867e974.tar.bz2 gsoc2013-evolution-50bda1bad222082488d3d9bc9fe1d0fb3867e974.tar.lz gsoc2013-evolution-50bda1bad222082488d3d9bc9fe1d0fb3867e974.tar.xz gsoc2013-evolution-50bda1bad222082488d3d9bc9fe1d0fb3867e974.tar.zst gsoc2013-evolution-50bda1bad222082488d3d9bc9fe1d0fb3867e974.zip |
Replace GtkStyle usages with GtkStyleContext
This makes evolution depend on theme-defined named colors, namely:
theme_bg_color
theme_base_color
theme_fg_color
theme_text_color
theme_selected_bg_color
theme_selected_fg_color
theme_unfocused_selected_bg_color
theme_unfocused_selected_fg_color
If it's not defined, then a fallback color is used, in the worse case
one of the fallbacks defined in evolution itself.
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/gui/widgets/e-minicard-label.c | 46 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-label.h | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view-widget.c | 31 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 53 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.h | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-contact-display.c | 2 |
6 files changed, 69 insertions, 67 deletions
diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c index 2fedce3dea..7e8094599a 100644 --- a/addressbook/gui/widgets/e-minicard-label.c +++ b/addressbook/gui/widgets/e-minicard-label.c @@ -38,7 +38,7 @@ static void e_minicard_label_get_property (GObject *object, guint property_id, static gboolean e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event); static void e_minicard_label_realize (GnomeCanvasItem *item); static void e_minicard_label_reflow (GnomeCanvasItem *item, gint flags); -static void e_minicard_label_style_set (EMinicardLabel *label, GtkStyle *previous_style); +static void e_minicard_label_style_updated (EMinicardLabel *label); static void e_minicard_label_resize_children (EMinicardLabel *e_minicard_label); @@ -57,7 +57,7 @@ enum { }; enum { - STYLE_SET, + STYLE_UPDATED, LAST_SIGNAL }; @@ -77,7 +77,7 @@ e_minicard_label_class_init (EMinicardLabelClass *class) object_class = G_OBJECT_CLASS (class); item_class = (GnomeCanvasItemClass *) class; - class->style_set = e_minicard_label_style_set; + class->style_updated = e_minicard_label_style_updated; object_class->set_property = e_minicard_label_set_property; object_class->get_property = e_minicard_label_get_property; @@ -162,15 +162,14 @@ e_minicard_label_class_init (EMinicardLabelClass *class) FALSE, G_PARAM_READWRITE)); - e_minicard_label_signals[STYLE_SET] = g_signal_new ( - "style_set", + e_minicard_label_signals[STYLE_UPDATED] = g_signal_new ( + "style_updated", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EMinicardLabelClass, style_set), + G_STRUCT_OFFSET (EMinicardLabelClass, style_updated), NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - GTK_TYPE_STYLE); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); /* GnomeCanvasItem method overrides */ item_class->realize = e_minicard_label_realize; @@ -418,27 +417,33 @@ set_colors (EMinicardLabel *label) GnomeCanvasItem *item = GNOME_CANVAS_ITEM (label); if ((item->flags & GNOME_CANVAS_ITEM_REALIZED)) { - GnomeCanvas *canvas; - GtkStyle *style; + GdkColor text; + GtkWidget *widget; - canvas = GNOME_CANVAS_ITEM (label)->canvas; - style = gtk_widget_get_style (GTK_WIDGET (canvas)); + widget = GTK_WIDGET (GNOME_CANVAS_ITEM (label)->canvas); + + e_utils_get_theme_color_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &text); if (label->has_focus) { + GdkColor outline, fill; + + e_utils_get_theme_color_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &outline); + e_utils_get_theme_color_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &fill); + gnome_canvas_item_set ( label->rect, - "outline_color_gdk", &style->mid[GTK_STATE_SELECTED], - "fill_color_gdk", &style->bg[GTK_STATE_NORMAL], + "outline_color_gdk", &outline, + "fill_color_gdk", &fill, NULL); gnome_canvas_item_set ( label->field, - "fill_color_gdk", &style->text[GTK_STATE_NORMAL], + "fill_color_gdk", &text, NULL); gnome_canvas_item_set ( label->fieldname, - "fill_color_gdk", &style->text[GTK_STATE_NORMAL], + "fill_color_gdk", &text, NULL); } else { @@ -450,20 +455,19 @@ set_colors (EMinicardLabel *label) gnome_canvas_item_set ( label->field, - "fill_color_gdk", &style->text[GTK_STATE_NORMAL], + "fill_color_gdk", &text, NULL); gnome_canvas_item_set ( label->fieldname, - "fill_color_gdk", &style->text[GTK_STATE_NORMAL], + "fill_color_gdk", &text, NULL); } } } static void -e_minicard_label_style_set (EMinicardLabel *label, - GtkStyle *previous_style) +e_minicard_label_style_updated (EMinicardLabel *label) { set_colors (label); } diff --git a/addressbook/gui/widgets/e-minicard-label.h b/addressbook/gui/widgets/e-minicard-label.h index 3b93601324..32afa44618 100644 --- a/addressbook/gui/widgets/e-minicard-label.h +++ b/addressbook/gui/widgets/e-minicard-label.h @@ -67,7 +67,7 @@ struct _EMinicardLabelClass { GnomeCanvasGroupClass parent_class; - void (* style_set) (EMinicardLabel *label, GtkStyle *previous_style); + void (* style_updated) (EMinicardLabel *label); }; GType e_minicard_label_get_type (void); diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c index ea6c8013f0..4ed6161434 100644 --- a/addressbook/gui/widgets/e-minicard-view-widget.c +++ b/addressbook/gui/widgets/e-minicard-view-widget.c @@ -45,9 +45,8 @@ static void e_minicard_view_widget_reflow (ECanvas *canvas); static void e_minicard_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void e_minicard_view_widget_style_set - (GtkWidget *widget, - GtkStyle *previous_style); +static void e_minicard_view_widget_style_updated + (GtkWidget *widget); static void e_minicard_view_widget_realize (GtkWidget *widget); static gboolean e_minicard_view_widget_real_focus_in_event (GtkWidget *widget, @@ -90,7 +89,7 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *class) object_class->dispose = e_minicard_view_widget_dispose; widget_class = GTK_WIDGET_CLASS (class); - widget_class->style_set = e_minicard_view_widget_style_set; + widget_class->style_updated = e_minicard_view_widget_style_updated; widget_class->realize = e_minicard_view_widget_realize; widget_class->size_allocate = e_minicard_view_widget_size_allocate; widget_class->focus_in_event = e_minicard_view_widget_real_focus_in_event; @@ -372,33 +371,33 @@ right_click (EMinicardView *view, } static void -e_minicard_view_widget_style_set (GtkWidget *widget, - GtkStyle *previous_style) +e_minicard_view_widget_style_updated (GtkWidget *widget) { EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET (widget); - GtkStyle *style; - style = gtk_widget_get_style (widget); + if (view->background) { + GdkColor color; - if (view->background) - gnome_canvas_item_set ( - view->background, "fill_color_gdk", - &style->base[GTK_STATE_NORMAL], NULL); + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &color); - GTK_WIDGET_CLASS (e_minicard_view_widget_parent_class)-> - style_set (widget, previous_style); + gnome_canvas_item_set (view->background, "fill_color_gdk", &color, NULL); + } + + GTK_WIDGET_CLASS (e_minicard_view_widget_parent_class)->style_updated (widget); } static void e_minicard_view_widget_realize (GtkWidget *widget) { EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET (widget); - GtkStyle *style = gtk_widget_get_style (widget); + GdkColor color; + + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &color); view->background = gnome_canvas_item_new ( gnome_canvas_root (GNOME_CANVAS (view)), e_canvas_background_get_type (), - "fill_color_gdk", &style->base[GTK_STATE_NORMAL], + "fill_color_gdk", &color, NULL); view->emv = gnome_canvas_item_new ( diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 7166e7de24..474f588f94 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -46,7 +46,7 @@ static void e_minicard_finalize (GObject *object); static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event); static void e_minicard_realize (GnomeCanvasItem *item); static void e_minicard_reflow (GnomeCanvasItem *item, gint flags); -static void e_minicard_style_set (EMinicard *minicard, GtkStyle *previous_style); +static void e_minicard_style_updated (EMinicard *minicard); static void e_minicard_resize_children (EMinicard *e_minicard); static void remodel (EMinicard *e_minicard); @@ -79,7 +79,7 @@ enum { SELECTED, DRAG_BEGIN, OPEN_CONTACT, - STYLE_SET, + STYLE_UPDATED, LAST_SIGNAL }; @@ -103,7 +103,7 @@ e_minicard_class_init (EMinicardClass *class) item_class->realize = e_minicard_realize; item_class->event = e_minicard_event; - class->style_set = e_minicard_style_set; + class->style_updated = e_minicard_style_updated; class->selected = NULL; g_object_class_install_property ( @@ -209,15 +209,14 @@ e_minicard_class_init (EMinicardClass *class) G_TYPE_NONE, 1, E_TYPE_CONTACT); - signals[STYLE_SET] = g_signal_new ( - "style_set", + signals[STYLE_UPDATED] = g_signal_new ( + "style_updated", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EMinicardClass, style_set), + G_STRUCT_OFFSET (EMinicardClass, style_updated), NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - GTK_TYPE_STYLE); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); /* init the accessibility support for e_minicard */ e_minicard_a11y_init (); @@ -249,37 +248,43 @@ static void set_selected (EMinicard *minicard, gboolean selected) { - GnomeCanvas *canvas; - GtkStyle *style; + GtkWidget *widget; + GdkColor outline, header, text; - canvas = GNOME_CANVAS_ITEM (minicard)->canvas; - style = gtk_widget_get_style (GTK_WIDGET (canvas)); + widget = GTK_WIDGET (GNOME_CANVAS_ITEM (minicard)->canvas); if (selected) { + e_utils_get_theme_color_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &outline); + e_utils_get_theme_color_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &header); + e_utils_get_theme_color_color (widget, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &text); + gnome_canvas_item_set ( minicard->rect, - "outline_color_gdk", &style->bg[GTK_STATE_ACTIVE], + "outline_color_gdk", &outline, NULL); gnome_canvas_item_set ( minicard->header_rect, - "fill_color_gdk", &style->bg[GTK_STATE_SELECTED], + "fill_color_gdk", &header, NULL); gnome_canvas_item_set ( minicard->header_text, - "fill_color_gdk", &style->text[GTK_STATE_SELECTED], + "fill_color_gdk", &text, NULL); } else { + e_utils_get_theme_color_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &header); + e_utils_get_theme_color_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &text); + gnome_canvas_item_set ( minicard->rect, "outline_color", NULL, NULL); gnome_canvas_item_set ( minicard->header_rect, - "fill_color_gdk", &style->bg[GTK_STATE_NORMAL], + "fill_color_gdk", &header, NULL); gnome_canvas_item_set ( minicard->header_text, - "fill_color_gdk", &style->text[GTK_STATE_NORMAL], + "fill_color_gdk", &text, NULL); } minicard->selected = selected; @@ -463,8 +468,7 @@ e_minicard_finalize (GObject *object) } static void -e_minicard_style_set (EMinicard *minicard, - GtkStyle *previous_style) +e_minicard_style_updated (EMinicard *minicard) { GnomeCanvasItem *item = GNOME_CANVAS_ITEM (minicard); @@ -477,15 +481,10 @@ e_minicard_realize (GnomeCanvasItem *item) { EMinicard *e_minicard; GnomeCanvasGroup *group; - GnomeCanvas *canvas; - GtkStyle *style; e_minicard = E_MINICARD (item); group = GNOME_CANVAS_GROUP (item); - canvas = GNOME_CANVAS_ITEM (item)->canvas; - style = gtk_widget_get_style (GTK_WIDGET (canvas)); - GNOME_CANVAS_ITEM_CLASS (e_minicard_parent_class)->realize (item); e_minicard->rect = gnome_canvas_item_new ( @@ -505,7 +504,7 @@ e_minicard_realize (GnomeCanvasItem *item) "y1", (gdouble) 2, "x2", (gdouble) MAX (e_minicard->width - 3, 0), "y2", (gdouble) MAX (e_minicard->height - 3, 0), - "fill_color_gdk", &style->bg[GTK_STATE_NORMAL], + "fill_color_gdk", NULL, NULL); e_minicard->header_text = gnome_canvas_item_new ( @@ -514,7 +513,7 @@ e_minicard_realize (GnomeCanvasItem *item) "width", (gdouble) MAX (e_minicard->width - 12, 0), "clip", TRUE, "use_ellipsis", TRUE, - "fill_color_gdk", &style->fg[GTK_STATE_NORMAL], + "fill_color_gdk", NULL, "text", "", NULL); diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h index 91162c5d9b..e42dc6ccbb 100644 --- a/addressbook/gui/widgets/e-minicard.h +++ b/addressbook/gui/widgets/e-minicard.h @@ -102,7 +102,7 @@ struct _EMinicardClass gint (* drag_begin) (EMinicard *minicard, GdkEvent *event); void (* open_contact) (EMinicard *minicard, EContact *contact); - void (* style_set) (EMinicard *minicard, GtkStyle *previous_style); + void (* style_updated) (EMinicard *minicard); }; typedef struct _EMinicardField EMinicardField; diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c index cd1e41cc5b..cd7fafdb8b 100644 --- a/addressbook/gui/widgets/eab-contact-display.c +++ b/addressbook/gui/widgets/eab-contact-display.c @@ -517,7 +517,7 @@ eab_contact_display_init (EABContactDisplay *display) web_view, "notify::load-status", G_CALLBACK (contact_display_load_status_changed), NULL); g_signal_connect ( - web_view, "style-set", + web_view, "style-updated", G_CALLBACK (load_contact), NULL); e_web_view_install_request_handler (E_WEB_VIEW (display), E_TYPE_FILE_REQUEST); |