diff options
55 files changed, 1139 insertions, 764 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); diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c index fa1aca0253..8b67324f55 100644 --- a/calendar/gui/e-cal-component-preview.c +++ b/calendar/gui/e-cal-component-preview.c @@ -440,7 +440,7 @@ e_cal_component_preview_init (ECalComponentPreview *preview) preview->priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (preview); g_signal_connect ( - preview, "style-set", + preview, "style-updated", G_CALLBACK (load_comp), NULL); } diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 7a0983b422..95eec04f39 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -167,8 +167,6 @@ setup_e_table (ECalListView *cal_list_view) ETableSpecification *specification; GList *strings; ECell *cell, *popup_cell; - GnomeCanvas *canvas; - GtkStyle *style; GtkWidget *container; GtkWidget *widget; gchar *etspecfile; @@ -302,15 +300,6 @@ setup_e_table (ECalListView *cal_list_view) g_object_unref (specification); g_free (etspecfile); - /* Make sure text is readable on top of our color coding */ - - canvas = GNOME_CANVAS (cal_list_view->table->table_canvas); - style = gtk_widget_get_style (GTK_WIDGET (canvas)); - - style->fg[GTK_STATE_SELECTED] = style->text[GTK_STATE_NORMAL]; - style->fg[GTK_STATE_ACTIVE] = style->text[GTK_STATE_NORMAL]; - gtk_widget_set_style (GTK_WIDGET (canvas), style); - /* Connect signals */ g_signal_connect ( cal_list_view->table, "double_click", diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 1fac6e7855..686327ac2f 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -2029,11 +2029,11 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data) icalcomponent *clone_comp; time_t t_start, t_end; ECalendarViewEvent *pevent; - GtkStyle *style = gtk_widget_get_default_style (); GtkWidget *widget; GdkWindow *window; GdkDisplay *display; GdkDeviceManager *device_manager; + GdkRGBA bg_rgba, fg_rgba; GQueue *grabbed_keyboards; ECalComponent *newcomp = e_cal_component_new (); icaltimezone *zone, *default_zone; @@ -2047,6 +2047,9 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data) g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (E_IS_CALENDAR_VIEW (data->cal_view), FALSE); + e_utils_get_theme_color (GTK_WIDGET (data->cal_view), "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &bg_rgba); + e_utils_get_theme_color (GTK_WIDGET (data->cal_view), "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &fg_rgba); + model = e_calendar_view_get_model (data->cal_view); /* Delete any stray tooltip if left */ @@ -2092,8 +2095,8 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data) gtk_box_pack_start ((GtkBox *) hbox, label, FALSE, FALSE, 0); ebox = gtk_event_box_new (); gtk_container_add ((GtkContainer *) ebox, hbox); - gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); - gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); + gtk_widget_override_background_color (ebox, GTK_STATE_FLAG_NORMAL, &bg_rgba); + gtk_widget_override_color (label, GTK_STATE_FLAG_NORMAL, &fg_rgba); gtk_box_pack_start ((GtkBox *) box, ebox, FALSE, FALSE, 0); g_free (tmp); diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index b30951bb5b..259e073909 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -272,7 +272,6 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, EDayViewTimeItem *time_item; ECalendarView *cal_view; ECalModel *model; - GtkStyle *style; const gchar *suffix; gchar buffer[64], *midnight_day = NULL, *midnight_month = NULL; gint time_divisions; @@ -284,32 +283,30 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, gint max_suffix_width, max_minute_or_suffix_width; PangoLayout *layout; PangoContext *context; - PangoFontDescription *small_font_desc; PangoFontMetrics *large_font_metrics, *small_font_metrics; - GdkColor fg, dark; + GtkWidget *widget; + GdkRGBA fg, dark; GdkColor mb_color; time_item = E_DAY_VIEW_TIME_ITEM (canvas_item); day_view = e_day_view_time_item_get_day_view (time_item); g_return_if_fail (day_view != NULL); + widget = GTK_WIDGET (day_view); cal_view = E_CALENDAR_VIEW (day_view); model = e_calendar_view_get_model (cal_view); time_divisions = e_calendar_view_get_time_divisions (cal_view); - style = gtk_widget_get_style (GTK_WIDGET (day_view)); - small_font_desc = style->font_desc; - context = gtk_widget_get_pango_context (GTK_WIDGET (day_view)); + small_font_metrics = pango_context_get_metrics ( + context, NULL, + pango_context_get_language (context)); large_font_metrics = pango_context_get_metrics ( context, day_view->large_font_desc, pango_context_get_language (context)); - small_font_metrics = pango_context_get_metrics ( - context, small_font_desc, - pango_context_get_language (context)); - fg = style->fg[GTK_STATE_NORMAL]; - dark = style->dark[GTK_STATE_NORMAL]; + e_utils_get_theme_color (widget, "theme_fg_color,theme_text_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &fg); + e_utils_get_theme_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &dark); /* The start and end of the long horizontal line between hours. */ long_line_x1 = @@ -496,7 +493,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, * between hours and display as one long string, * e.g. "14:00" or "2 pm". */ cairo_save (cr); - gdk_cairo_set_source_color (cr, &dark); + gdk_cairo_set_source_rgba (cr, &dark); cairo_save (cr); cairo_set_line_width (cr, 0.7); cairo_move_to (cr, long_line_x1, row_y); @@ -520,7 +517,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, if (show_midnight_date) gdk_cairo_set_source_color (cr, &mb_color); else - gdk_cairo_set_source_color (cr, &fg); + gdk_cairo_set_source_rgba (cr, &fg); layout = pango_cairo_create_layout (cr); pango_layout_set_text (layout, buffer, -1); pango_layout_get_pixel_size (layout, &minute_width, NULL); @@ -541,7 +538,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, * large font. */ cairo_save (cr); - gdk_cairo_set_source_color (cr, &dark); + gdk_cairo_set_source_rgba (cr, &dark); if (show_midnight_date) g_snprintf (buffer, sizeof (buffer), "%s", midnight_day); else @@ -559,7 +556,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, if (show_midnight_date) gdk_cairo_set_source_color (cr, &mb_color); else - gdk_cairo_set_source_color (cr, &fg); + gdk_cairo_set_source_rgba (cr, &fg); layout = pango_cairo_create_layout (cr); pango_layout_set_text (layout, buffer, -1); pango_layout_set_font_description ( @@ -578,7 +575,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, /* Within the hour - draw a short line before * the time. */ cairo_save (cr); - gdk_cairo_set_source_color (cr, &dark); + gdk_cairo_set_source_rgba (cr, &dark); cairo_set_line_width (cr, 0.7); cairo_move_to (cr, short_line_x1, row_y); cairo_line_to (cr, long_line_x2, row_y); @@ -607,7 +604,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, if (show_midnight_date) gdk_cairo_set_source_color (cr, &mb_color); else - gdk_cairo_set_source_color (cr, &fg); + gdk_cairo_set_source_rgba (cr, &fg); layout = pango_cairo_create_layout (cr); pango_layout_set_text (layout, buffer, -1); pango_layout_set_font_description ( @@ -1061,12 +1058,11 @@ e_day_view_time_item_set_day_view (EDayViewTimeItem *time_item, /* Returns the minimum width needed for the column, by adding up all the * maximum widths of the strings. The string widths are all calculated in - * the style_set handlers of EDayView and EDayViewTimeCanvas. */ + * the style_updated handlers of EDayView and EDayViewTimeCanvas. */ gint e_day_view_time_item_get_column_width (EDayViewTimeItem *time_item) { EDayView *day_view; - GtkStyle *style; gint digit, large_digit_width, max_large_digit_width = 0; gint max_suffix_width, max_minute_or_suffix_width; gint column_width_default, column_width_60_min_rows; @@ -1074,9 +1070,6 @@ e_day_view_time_item_get_column_width (EDayViewTimeItem *time_item) day_view = e_day_view_time_item_get_day_view (time_item); g_return_val_if_fail (day_view != NULL, 0); - style = gtk_widget_get_style (GTK_WIDGET (day_view)); - g_return_val_if_fail (style != NULL, 0); - /* Find the maximum width a digit can have. FIXME: We could use pango's * approximation function, but I worry it won't be precise enough. Also * it needs a language tag that I don't know where to get. */ diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c index 300170ba07..6ef99f4afb 100644 --- a/calendar/gui/e-day-view-top-item.c +++ b/calendar/gui/e-day-view-top-item.c @@ -68,7 +68,7 @@ day_view_top_item_draw_triangle (EDayViewTopItem *top_item, { EDayView *day_view; EDayViewEvent *event; - GdkColor bg_color; + GdkRGBA bg_color; GdkPoint points[3]; gint c1, c2; @@ -98,11 +98,11 @@ day_view_top_item_draw_triangle (EDayViewTopItem *top_item, cairo_save (cr); /* Fill it in. */ - if (gdk_color_parse ( + if (gdk_rgba_parse (&bg_color, e_cal_model_get_color_for_component ( e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), - event->comp_data), &bg_color)) { - gdk_cairo_set_source_color (cr, &bg_color); + event->comp_data))) { + gdk_cairo_set_source_rgba (cr, &bg_color); } else { gdk_cairo_set_source_color ( cr, &day_view->colors @@ -139,7 +139,6 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, { EDayView *day_view; EDayViewEvent *event; - GtkStyle *style; gint start_day, end_day; gint item_x, item_y, item_w, item_h; gint text_x, icon_x, icon_y, icon_x_inc; @@ -152,7 +151,7 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, gboolean draw_start_triangle, draw_end_triangle; GSList *categories_list, *elem; PangoLayout *layout; - GdkColor bg_color; + GdkRGBA bg_color, rgba; cairo_pattern_t *pat; guint16 red, green, blue; gdouble cc = 65535.0; @@ -182,15 +181,14 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, if (!is_comp_data_valid (event)) return; - style = gtk_widget_get_style (GTK_WIDGET (day_view)); comp = e_cal_component_new (); e_cal_component_set_icalcomponent ( comp, icalcomponent_new_clone (event->comp_data->icalcomp)); - if (gdk_color_parse ( + if (gdk_rgba_parse (&bg_color, e_cal_model_get_color_for_component ( e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), - event->comp_data), &bg_color)) { + event->comp_data))) { red = bg_color.red; green = bg_color.green; blue = bg_color.blue; @@ -308,7 +306,8 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, time_width = e_day_view_get_time_string_width (day_view); - gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]); + e_utils_get_theme_color (GTK_WIDGET (day_view), "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &rgba); + gdk_cairo_set_source_rgba (cr, &rgba); if (event->start > day_view->day_starts[start_day]) { offset = day_view->first_hour_shown * 60 @@ -574,14 +573,13 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item, { EDayViewTopItem *top_item; EDayView *day_view; - GtkStyle *style; gchar buffer[128]; GtkAllocation allocation; GdkRectangle clip_rect; gint canvas_width, canvas_height, left_edge, day, date_width, date_x; gint item_height, event_num; PangoLayout *layout; - GdkColor bg, light, dark; + GdkRGBA bg, fg, light, dark; gboolean show_dates; top_item = E_DAY_VIEW_TOP_ITEM (canvas_item); @@ -589,7 +587,6 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item, g_return_if_fail (day_view != NULL); show_dates = top_item->priv->show_dates; - style = gtk_widget_get_style (GTK_WIDGET (day_view)); gtk_widget_get_allocation ( GTK_WIDGET (canvas_item->canvas), &allocation); canvas_width = allocation.width; @@ -600,14 +597,15 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item, left_edge = 0; item_height = day_view->top_row_height - E_DAY_VIEW_TOP_CANVAS_Y_GAP; - bg = style->bg[GTK_STATE_NORMAL]; - light = style->light[GTK_STATE_NORMAL]; - dark = style->dark[GTK_STATE_NORMAL]; + e_utils_get_theme_color (GTK_WIDGET (day_view), "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg); + e_utils_get_theme_color (GTK_WIDGET (day_view), "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &fg); + e_utils_shade_color (&bg, &light, E_UTILS_LIGHTNESS_MULT); + e_utils_shade_color (&bg, &dark, E_UTILS_DARKNESS_MULT); if (show_dates) { /* Draw the shadow around the dates. */ cairo_save (cr); - gdk_cairo_set_source_color (cr, &light); + gdk_cairo_set_source_rgba (cr, &light); cairo_move_to (cr, left_edge - x, 1 - y); cairo_line_to (cr, canvas_width - 2 - x, 1 - y); cairo_move_to (cr, left_edge - x, 2 - y); @@ -616,7 +614,7 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item, cairo_restore (cr); cairo_save (cr); - gdk_cairo_set_source_color (cr, &dark); + gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to (cr, left_edge - x, item_height - 1 - y); cairo_line_to (cr, canvas_width - 1 - x, item_height - 1 - y); cairo_move_to (cr, canvas_width - 1 - x, 1 - y); @@ -626,7 +624,7 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item, /* Draw the background for the dates. */ cairo_save (cr); - gdk_cairo_set_source_color (cr, &bg); + gdk_cairo_set_source_rgba (cr, &bg); cairo_rectangle ( cr, left_edge + 2 - x, 2 - y, canvas_width - left_edge - 3, @@ -709,8 +707,7 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item, date_x = day_view->day_offsets[day] + (clip_rect.width - date_width) / 2; - gdk_cairo_set_source_color ( - cr, &style->fg[GTK_STATE_NORMAL]); + gdk_cairo_set_source_rgba (cr, &fg); cairo_move_to (cr, date_x - x, 3 - y); pango_cairo_show_layout (cr, layout); @@ -720,7 +717,7 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item, /* Draw the lines down the left and right of the date cols. */ if (day != 0) { cairo_save (cr); - gdk_cairo_set_source_color (cr, &light); + gdk_cairo_set_source_rgba (cr, &light); cairo_move_to ( cr, day_view->day_offsets[day] - x, 4 - y); @@ -728,7 +725,7 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item, cr, day_view->day_offsets[day] - x, item_height - 4 - y); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &dark); + gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to ( cr, day_view->day_offsets[day] - 1 - x, 4 - y); diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index eb73b8a86e..8f09d27a5b 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -42,6 +42,7 @@ #include "dialogs/recur-comp.h" #include "dialogs/goto-dialog.h" #include "dialogs/save-comp.h" +#include "e-util/e-util.h" #include "calendar-config.h" #include "comp-util.h" @@ -169,7 +170,7 @@ static GtkTargetEntry target_table[] = { { (gchar *) "application/x-e-calendar-event", 0, 0 } }; -static void e_day_view_set_colors (EDayView *day_view, GtkWidget *widget); +static void e_day_view_set_colors (EDayView *day_view); static gboolean e_day_view_update_scroll_regions (EDayView *day_view); static gboolean e_day_view_get_next_tab_event (EDayView *day_view, GtkDirectionType direction, @@ -575,11 +576,9 @@ e_day_view_recalc_main_canvas_size (EDayView *day_view) static GdkColor e_day_view_get_text_color (EDayView *day_view, - EDayViewEvent *event, - GtkWidget *widget) + EDayViewEvent *event) { - GtkStyle *style; - GdkColor bg_color; + GdkColor color; guint16 red, green, blue; gdouble cc = 65535.0; @@ -588,18 +587,23 @@ e_day_view_get_text_color (EDayView *day_view, blue = day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].blue; if (is_comp_data_valid (event) && gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data), - &bg_color)) { - red = bg_color.red; - green = bg_color.green; - blue = bg_color.blue; + &color)) { + red = color.red; + green = color.green; + blue = color.blue; } - style = gtk_widget_get_style (widget); + if ((red / cc > 0.7) || (green / cc > 0.7) || (blue / cc > 0.7)) { + color.red = 0.0; + color.green = 0.0; + color.blue = 0.0; + } else { + color.red = 65535.0f; + color.green = 65535.0f; + color.blue = 65535.0f; + } - if ((red / cc > 0.7) || (green / cc > 0.7) || (blue / cc > 0.7)) - return style->black; - else - return style->white; + return color; } /* Returns the selected time range. */ @@ -1259,7 +1263,7 @@ day_view_realize (GtkWidget *widget) /* Allocate the colors. */ - e_day_view_set_colors (day_view, widget); + e_day_view_set_colors (day_view); /* Create the pixmaps. */ day_view->reminder_icon = e_icon_factory_get_icon ("stock_bell", GTK_ICON_SIZE_MENU); @@ -1320,8 +1324,7 @@ day_view_size_allocate (GtkWidget *widget, } static void -day_view_style_set (GtkWidget *widget, - GtkStyle *previous_style) +day_view_style_updated (GtkWidget *widget) { EDayView *day_view; gint hour; @@ -1341,17 +1344,17 @@ day_view_style_set (GtkWidget *widget, EDayViewEvent *event; GdkColor color; - if (GTK_WIDGET_CLASS (e_day_view_parent_class)->style_set) - (*GTK_WIDGET_CLASS (e_day_view_parent_class)->style_set)(widget, previous_style); + if (GTK_WIDGET_CLASS (e_day_view_parent_class)->style_updated) + (*GTK_WIDGET_CLASS (e_day_view_parent_class)->style_updated) (widget); day_view = E_DAY_VIEW (widget); - e_day_view_set_colors (day_view, widget); + e_day_view_set_colors (day_view); for (week_day = 0; week_day < E_DAY_VIEW_MAX_DAYS; week_day++) { for (event_num = 0; event_num < day_view->events[week_day]->len; event_num++) { event = &g_array_index (day_view->events[week_day], EDayViewEvent, event_num); if (event->canvas_item) { - color = e_day_view_get_text_color (day_view, event, widget); + color = e_day_view_get_text_color (day_view, event); gnome_canvas_item_set ( event->canvas_item, "fill_color_gdk", &color, @@ -1362,7 +1365,7 @@ day_view_style_set (GtkWidget *widget, for (event_num = 0; event_num < day_view->long_events->len; event_num++) { event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); if (event->canvas_item) { - color = e_day_view_get_text_color (day_view, event, widget); + color = e_day_view_get_text_color (day_view, event); gnome_canvas_item_set ( event->canvas_item, "fill_color_gdk", &color, @@ -1371,8 +1374,8 @@ day_view_style_set (GtkWidget *widget, } /* Set up Pango prerequisites */ - font_desc = gtk_widget_get_style (widget)->font_desc; pango_context = gtk_widget_get_pango_context (widget); + font_desc = pango_context_get_font_description (pango_context); font_metrics = pango_context_get_metrics ( pango_context, font_desc, pango_context_get_language (pango_context)); @@ -1841,7 +1844,7 @@ e_day_view_class_init (EDayViewClass *class) widget_class->realize = day_view_realize; widget_class->unrealize = day_view_unrealize; widget_class->size_allocate = day_view_size_allocate; - widget_class->style_set = day_view_style_set; + widget_class->style_updated = day_view_style_updated; widget_class->focus = day_view_focus; widget_class->key_press_event = day_view_key_press; widget_class->focus_in_event = day_view_focus_in; @@ -2649,28 +2652,40 @@ e_day_view_new (ECalModel *model) } static void -e_day_view_set_colors (EDayView *day_view, - GtkWidget *widget) -{ - GtkStyle *style; - - style = gtk_widget_get_style (widget); +e_day_view_set_colors (EDayView *day_view) +{ + GtkWidget *widget = GTK_WIDGET (day_view); + GdkRGBA base_bg, bg_bg, selected_bg, unfocused_selected_bg, dark_bg, light_bg; + + e_utils_get_theme_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &base_bg); + e_utils_get_theme_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg_bg); + e_utils_get_theme_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &selected_bg); + e_utils_get_theme_color (widget, "theme_unfocused_selected_bg_color,theme_selected_bg_color", E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_BG_COLOR, &unfocused_selected_bg); + + e_utils_shade_color (&bg_bg, &dark_bg, E_UTILS_DARKNESS_MULT); + e_utils_shade_color (&bg_bg, &light_bg, E_UTILS_LIGHTNESS_MULT); + + e_rgba_to_color (&base_bg, &day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING]); + e_rgba_to_color (&bg_bg, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]); + e_rgba_to_color (&selected_bg, &day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED]); + e_rgba_to_color (&unfocused_selected_bg, &day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED_UNFOCUSSED]); + e_rgba_to_color (&dark_bg, &day_view->colors[E_DAY_VIEW_COLOR_BG_GRID]); + e_rgba_to_color (&dark_bg, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS]); + e_rgba_to_color (&selected_bg, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED]); + e_rgba_to_color (&light_bg, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID]); + e_rgba_to_color (&selected_bg, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]); + e_rgba_to_color (&base_bg, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND]); + e_rgba_to_color (&dark_bg, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER]); + e_rgba_to_color (&base_bg, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]); + e_rgba_to_color (&dark_bg, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]); - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING] = style->base[GTK_STATE_NORMAL]; - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING] = style->bg[GTK_STATE_ACTIVE]; - day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED] = style->base[GTK_STATE_SELECTED]; - day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED_UNFOCUSSED] = style->bg[GTK_STATE_SELECTED]; - day_view->colors[E_DAY_VIEW_COLOR_BG_GRID] = style->dark[GTK_STATE_NORMAL]; day_view->colors[E_DAY_VIEW_COLOR_BG_MULTIDAY_TODAY] = get_today_background (day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING]); - day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS] = style->dark[GTK_STATE_NORMAL]; - day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED] = style->bg[GTK_STATE_SELECTED]; - day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID] = style->light[GTK_STATE_NORMAL]; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR] = style->base[GTK_STATE_SELECTED]; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND] = style->base[GTK_STATE_NORMAL]; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER] = style->dark[GTK_STATE_NORMAL]; - day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND] = style->bg[GTK_STATE_ACTIVE]; - day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER] = style->dark[GTK_STATE_NORMAL]; - day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE] = style->dark[GTK_STATE_PRELIGHT]; + + bg_bg.red = 0.5; + bg_bg.green = 1.0; + bg_bg.blue = 1.0; + + e_rgba_to_color (&bg_bg, &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]); } static void @@ -2734,8 +2749,6 @@ e_day_view_recalc_cell_sizes (EDayView *day_view) gint pango_width; gint days_shown; - g_return_if_fail (gtk_widget_get_style (GTK_WIDGET (day_view)) != NULL); - days_shown = e_day_view_get_days_shown (day_view); gtk_widget_get_allocation (day_view->main_canvas, &allocation); @@ -5657,12 +5670,9 @@ e_day_view_reshape_long_event (EDayView *day_view, } if (!event->canvas_item) { - GtkWidget *widget; GdkColor color; - widget = (GtkWidget *) day_view; - - color = e_day_view_get_text_color (day_view, event, widget); + color = e_day_view_get_text_color (day_view, event); event->canvas_item = gnome_canvas_item_new ( @@ -5845,12 +5855,9 @@ e_day_view_reshape_day_event (EDayView *day_view, } if (!event->canvas_item) { - GtkWidget *widget; GdkColor color; - widget = (GtkWidget *) day_view; - - color = e_day_view_get_text_color (day_view, event, widget); + color = e_day_view_get_text_color (day_view, event); event->canvas_item = gnome_canvas_item_new ( GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->main_canvas)->root), diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c index 3caf71795d..bdc404765d 100644 --- a/calendar/gui/e-meeting-time-sel.c +++ b/calendar/gui/e-meeting-time-sel.c @@ -105,8 +105,7 @@ static void e_meeting_time_selector_autopick_menu_detacher (GtkWidget *widget, GtkMenu *menu); static void e_meeting_time_selector_realize (GtkWidget *widget); static void e_meeting_time_selector_unrealize (GtkWidget *widget); -static void e_meeting_time_selector_style_set (GtkWidget *widget, - GtkStyle *previous_style); +static void e_meeting_time_selector_style_updated (GtkWidget *widget); static gint e_meeting_time_selector_draw (GtkWidget *widget, cairo_t *cr); static void e_meeting_time_selector_draw_shadow (EMeetingTimeSelector *mts, cairo_t *cr); static void e_meeting_time_selector_hadjustment_changed (GtkAdjustment *adjustment, @@ -291,7 +290,7 @@ e_meeting_time_selector_class_init (EMeetingTimeSelectorClass *class) widget_class = GTK_WIDGET_CLASS (class); widget_class->realize = e_meeting_time_selector_realize; widget_class->unrealize = e_meeting_time_selector_unrealize; - widget_class->style_set = e_meeting_time_selector_style_set; + widget_class->style_updated = e_meeting_time_selector_style_updated; widget_class->draw = e_meeting_time_selector_draw; g_object_class_install_property ( @@ -1072,17 +1071,15 @@ style_change_idle_func (EMeetingTimeSelector *mts) GtkWidget *widget; gint hour, max_hour_width; /*int maxheight; */ - PangoFontDescription *font_desc; PangoContext *pango_context; PangoFontMetrics *font_metrics; PangoLayout *layout; /* Set up Pango prerequisites */ widget = GTK_WIDGET (mts); - font_desc = gtk_widget_get_style (widget)->font_desc; pango_context = gtk_widget_get_pango_context (widget); font_metrics = pango_context_get_metrics ( - pango_context, font_desc, + pango_context, NULL, pango_context_get_language (pango_context)); layout = pango_layout_new (pango_context); @@ -1140,13 +1137,12 @@ style_change_idle_func (EMeetingTimeSelector *mts) } static void -e_meeting_time_selector_style_set (GtkWidget *widget, - GtkStyle *previous_style) +e_meeting_time_selector_style_updated (GtkWidget *widget) { EMeetingTimeSelector *mts = E_MEETING_TIME_SELECTOR (widget); - if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->style_set) - (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->style_set)(widget, previous_style); + if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->style_updated) + (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->style_updated) (widget); if (!mts->style_change_idle_id) mts->style_change_idle_id = g_idle_add ( diff --git a/calendar/gui/e-meeting-time-sel.h b/calendar/gui/e-meeting-time-sel.h index ca726bc00c..20c5f0ca9f 100644 --- a/calendar/gui/e-meeting-time-sel.h +++ b/calendar/gui/e-meeting-time-sel.h @@ -69,7 +69,7 @@ G_BEGIN_DECLS /* This is used to specify the format used when displaying the dates. * The abbreviated format is like 'Sun 12/9/99'. * The short format is like '12/9/99'. - * The actual format used is determined in e_meeting_time_selector_style_set (), + * The actual format used is determined in e_meeting_time_selector_style_updated (), * once we know the font being used. */ typedef enum diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index 092ea379f2..146a63bf43 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -455,7 +455,7 @@ memo_table_query_tooltip (GtkWidget *widget, ECalModelComponent *comp_data; gint row = -1, col = -1; GtkWidget *box, *l, *w; - GtkStyle *style = gtk_widget_get_default_style (); + GdkRGBA sel_bg, sel_fg, norm_bg, norm_text; gchar *tmp; const gchar *str; GString *tmp2; @@ -499,6 +499,11 @@ memo_table_query_tooltip (GtkWidget *widget, return FALSE; } + e_utils_get_theme_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &sel_bg); + e_utils_get_theme_color (widget, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &sel_fg); + e_utils_get_theme_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &norm_bg); + e_utils_get_theme_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &norm_text); + box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); str = e_calendar_view_get_icalcomponent_summary ( @@ -517,8 +522,8 @@ memo_table_query_tooltip (GtkWidget *widget, gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); w = gtk_event_box_new (); - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); + gtk_widget_override_background_color (w, GTK_STATE_FLAG_NORMAL, &sel_bg); + gtk_widget_override_color (l, GTK_STATE_FLAG_NORMAL, &sel_fg); gtk_container_add (GTK_CONTAINER (w), l); gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); g_free (tmp); @@ -528,7 +533,7 @@ memo_table_query_tooltip (GtkWidget *widget, free_text = FALSE; w = gtk_event_box_new (); - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL])); + gtk_widget_override_background_color (w, GTK_STATE_FLAG_NORMAL, &norm_bg); l = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (w), l); @@ -559,7 +564,7 @@ memo_table_query_tooltip (GtkWidget *widget, gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); g_free (tmp); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_NORMAL])); + gtk_widget_override_color (l, GTK_STATE_FLAG_NORMAL, &norm_text); } e_cal_component_get_dtstart (new_comp, &dtstart); @@ -623,7 +628,7 @@ memo_table_query_tooltip (GtkWidget *widget, gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_NORMAL])); + gtk_widget_override_color (l, GTK_STATE_FLAG_NORMAL, &norm_text); } g_string_free (tmp2, TRUE); @@ -653,7 +658,7 @@ memo_table_query_tooltip (GtkWidget *widget, gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_NORMAL])); + gtk_widget_override_color (l, GTK_STATE_FLAG_NORMAL, &norm_text); } g_string_free (tmp2, TRUE); diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c index 0370997c32..036d64305b 100644 --- a/calendar/gui/e-task-table.c +++ b/calendar/gui/e-task-table.c @@ -756,7 +756,7 @@ task_table_query_tooltip (GtkWidget *widget, ECalModelComponent *comp_data; gint row = -1, col = -1; GtkWidget *box, *l, *w; - GtkStyle *style = gtk_widget_get_default_style (); + GdkRGBA sel_bg, sel_fg, norm_bg, norm_text; gchar *tmp; const gchar *str; GString *tmp2; @@ -801,6 +801,11 @@ task_table_query_tooltip (GtkWidget *widget, return FALSE; } + e_utils_get_theme_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &sel_bg); + e_utils_get_theme_color (widget, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &sel_fg); + e_utils_get_theme_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &norm_bg); + e_utils_get_theme_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &norm_text); + box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); str = e_calendar_view_get_icalcomponent_summary ( @@ -819,8 +824,8 @@ task_table_query_tooltip (GtkWidget *widget, gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); w = gtk_event_box_new (); - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_SELECTED])); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); + gtk_widget_override_background_color (w, GTK_STATE_FLAG_NORMAL, &sel_bg); + gtk_widget_override_color (l, GTK_STATE_FLAG_NORMAL, &sel_fg); gtk_container_add (GTK_CONTAINER (w), l); gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); g_free (tmp); @@ -830,7 +835,7 @@ task_table_query_tooltip (GtkWidget *widget, free_text = FALSE; w = gtk_event_box_new (); - gtk_widget_modify_bg (w, GTK_STATE_NORMAL, &(style->bg[GTK_STATE_NORMAL])); + gtk_widget_override_background_color (w, GTK_STATE_FLAG_NORMAL, &norm_bg); l = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (w), l); @@ -859,7 +864,7 @@ task_table_query_tooltip (GtkWidget *widget, gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); g_free (tmp); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_NORMAL])); + gtk_widget_override_color (l, GTK_STATE_FLAG_NORMAL, &norm_text); } e_cal_component_get_dtstart (new_comp, &dtstart); @@ -921,7 +926,7 @@ task_table_query_tooltip (GtkWidget *widget, gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_NORMAL])); + gtk_widget_override_color (l, GTK_STATE_FLAG_NORMAL, &norm_text); } g_string_free (tmp2, TRUE); @@ -939,7 +944,7 @@ task_table_query_tooltip (GtkWidget *widget, g_free (tmp); tmp = NULL; - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_NORMAL])); + gtk_widget_override_color (l, GTK_STATE_FLAG_NORMAL, &norm_text); } tmp2 = g_string_new (""); @@ -965,7 +970,7 @@ task_table_query_tooltip (GtkWidget *widget, gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); - gtk_widget_modify_fg (l, GTK_STATE_NORMAL, &(style->text[GTK_STATE_NORMAL])); + gtk_widget_override_color (l, GTK_STATE_FLAG_NORMAL, &norm_text); } g_string_free (tmp2, TRUE); diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c index 481daff2e3..59358ca6e0 100644 --- a/calendar/gui/e-week-view-event-item.c +++ b/calendar/gui/e-week-view-event-item.c @@ -295,6 +295,7 @@ week_view_event_item_button_release (EWeekViewEventItem *event_item, static void week_view_draw_time (EWeekView *week_view, + GdkColor bg_color, cairo_t *cr, gint time_x, gint time_y, @@ -302,24 +303,38 @@ week_view_draw_time (EWeekView *week_view, gint minute) { ECalModel *model; - GtkStyle *style; gint hour_to_display, suffix_width; gint time_y_normal_font, time_y_small_font; const gchar *suffix; gchar buffer[128]; PangoLayout *layout; PangoFontDescription *small_font_desc; + PangoContext *pango_context; + GdkColor color; + gdouble cc = 65535.0; + + color.pixel = 0; + + if ((bg_color.red / cc > 0.7) || (bg_color.green / cc > 0.7) || (bg_color.blue / cc > 0.7)) { + color.red = 0.0; + color.green = 0.0; + color.blue = 0.0; + } else { + color.red = 65535.0f; + color.green = 65535.0f; + color.blue = 65535.0f; + } cairo_save (cr); model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)); - style = gtk_widget_get_style (GTK_WIDGET (week_view)); small_font_desc = week_view->small_font_desc; - gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT]); + gdk_cairo_set_source_color (cr, &color); layout = gtk_widget_create_pango_layout (GTK_WIDGET (week_view), NULL); + pango_context = gtk_widget_create_pango_context (GTK_WIDGET (week_view)); time_y_normal_font = time_y_small_font = time_y; if (small_font_desc) @@ -330,6 +345,10 @@ week_view_draw_time (EWeekView *week_view, &suffix, &suffix_width); if (week_view->use_small_font && week_view->small_font_desc) { + PangoFontDescription *font_desc; + + font_desc = pango_font_description_copy (pango_context_get_font_description (pango_context)); + g_snprintf ( buffer, sizeof (buffer), "%2i:%02i", hour_to_display, minute); @@ -362,7 +381,7 @@ week_view_draw_time (EWeekView *week_view, time_y_small_font); pango_cairo_show_layout (cr, layout); - pango_layout_set_font_description (layout, style->font_desc); + pango_layout_set_font_description (layout, font_desc); time_x += week_view->small_digit_width * 2; @@ -376,6 +395,8 @@ week_view_draw_time (EWeekView *week_view, time_y_normal_font); pango_cairo_show_layout (cr, layout); } + + pango_font_description_free (font_desc); } else { /* Draw the start time in one go. */ g_snprintf ( @@ -398,6 +419,7 @@ week_view_draw_time (EWeekView *week_view, } } + g_object_unref (pango_context); g_object_unref (layout); cairo_restore (cr); @@ -895,7 +917,7 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item, if (draw_start) { week_view_draw_time ( - week_view, cr, time_x, + week_view, bg_color, cr, time_x, time_y, start_hour, start_minute); time_x += time_width; } @@ -903,7 +925,7 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item, if (draw_end) { time_x += E_WEEK_VIEW_EVENT_TIME_SPACING; week_view_draw_time ( - week_view, cr, time_x, + week_view, bg_color, cr, time_x, time_y, end_hour, end_minute); time_x += time_width; } @@ -1058,7 +1080,7 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item, cairo_clip (cr); week_view_draw_time ( - week_view, cr, time_x, + week_view, bg_color, cr, time_x, time_y, start_hour, start_minute); cairo_restore (cr); @@ -1086,7 +1108,7 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item, * the minimum calculated above. */ if (time_x >= min_end_time_x) { week_view_draw_time ( - week_view, cr, time_x, + week_view, bg_color, cr, time_x, time_y, end_hour, end_minute); max_icon_x -= time_width + E_WEEK_VIEW_EVENT_TIME_X_PAD; diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c index b766a370dc..69caa624e9 100644 --- a/calendar/gui/e-week-view-main-item.c +++ b/calendar/gui/e-week-view-main-item.c @@ -61,7 +61,6 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item, { EWeekView *week_view; ECalModel *model; - GtkStyle *style; gint right_edge, bottom_edge, date_width, date_x, line_y; gboolean show_day_name, show_month_name, selected; gchar buffer[128], *format_string; @@ -77,13 +76,12 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item, week_view = e_week_view_main_item_get_week_view (main_item); model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)); - style = gtk_widget_get_style (GTK_WIDGET (week_view)); multi_week_view = e_week_view_get_multi_week_view (week_view); /* Set up Pango prerequisites */ - font_desc = pango_font_description_copy (style->font_desc); pango_context = gtk_widget_get_pango_context (GTK_WIDGET (week_view)); + font_desc = pango_font_description_copy (pango_context_get_font_description (pango_context)); font_metrics = pango_context_get_metrics ( pango_context, font_desc, pango_context_get_language (pango_context)); diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c index a03e7a3448..23a41be879 100644 --- a/calendar/gui/e-week-view-titles-item.c +++ b/calendar/gui/e-week-view-titles-item.c @@ -126,7 +126,7 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item, { EWeekViewTitlesItem *titles_item; EWeekView *week_view; - GtkStyle *style; + GdkRGBA bg_bg, light_bg, dark_bg; gint col_width, col, date_width, date_x; gchar buffer[128]; GtkAllocation allocation; @@ -147,18 +147,21 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item, gtk_widget_get_allocation ( GTK_WIDGET (canvas_item->canvas), &allocation); - style = gtk_widget_get_style (GTK_WIDGET (week_view)); + e_utils_get_theme_color (GTK_WIDGET (week_view), "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg_bg); + e_utils_shade_color (&bg_bg, &dark_bg, E_UTILS_DARKNESS_MULT); + e_utils_shade_color (&bg_bg, &light_bg, E_UTILS_LIGHTNESS_MULT); + layout = gtk_widget_create_pango_layout (GTK_WIDGET (week_view), NULL); /* Draw the shadow around the dates. */ - gdk_cairo_set_source_color (cr, &style->light[GTK_STATE_NORMAL]); + gdk_cairo_set_source_rgba (cr, &light_bg); cairo_move_to (cr, 1.5 - x, 1.5 - y); cairo_rel_line_to (cr, allocation.width - 1, 0); cairo_move_to (cr, 1.5 - x, 2.5 - y); cairo_rel_line_to (cr, 0, allocation.height - 1); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &style->dark[GTK_STATE_NORMAL]); + gdk_cairo_set_source_rgba (cr, &dark_bg); cairo_rectangle (cr, 0.5 - x, 0.5 - y, allocation.width - 1, allocation.height); cairo_stroke (cr); @@ -213,12 +216,12 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item, /* Draw the lines down the left and right of the date cols. */ if (col != 0) { - gdk_cairo_set_source_color (cr, &style->light[GTK_STATE_NORMAL]); + gdk_cairo_set_source_rgba (cr, &light_bg); cairo_move_to (cr, week_view->col_offsets[col] - x + 0.5, 4.5 - y); cairo_rel_line_to (cr, 0, allocation.height - 8); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &style->dark[GTK_STATE_NORMAL]); + gdk_cairo_set_source_rgba (cr, &dark_bg); cairo_move_to (cr, week_view->col_offsets[col] - x - 0.5, 4.5 - y); cairo_rel_line_to (cr, 0, allocation.height - 8); cairo_stroke (cr); diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 93d40cdb35..317a78cb29 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -111,7 +111,7 @@ typedef struct { ECalModelComponent *comp_data; } AddEventData; -static void e_week_view_set_colors (EWeekView *week_view, GtkWidget *widget); +static void e_week_view_set_colors (EWeekView *week_view); static void e_week_view_recalc_cell_sizes (EWeekView *week_view); static gboolean e_week_view_get_next_tab_event (EWeekView *week_view, GtkDirectionType direction, @@ -768,6 +768,7 @@ week_view_constructed (GObject *object) EWeekView *week_view; ECalModel *model; ECalendarView *calendar_view; + PangoContext *pango_context; /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_week_view_parent_class)->constructed (object); @@ -776,6 +777,13 @@ week_view_constructed (GObject *object) calendar_view = E_CALENDAR_VIEW (object); model = e_calendar_view_get_model (calendar_view); + pango_context = gtk_widget_get_pango_context (GTK_WIDGET (week_view)); + g_warn_if_fail (pango_context != NULL); + week_view->small_font_desc = pango_font_description_copy (pango_context_get_font_description (pango_context)); + pango_font_description_set_size ( + week_view->small_font_desc, + E_WEEK_VIEW_SMALL_FONT_PTSIZE * PANGO_SCALE); + e_week_view_recalc_display_start_day (E_WEEK_VIEW (object)); week_view->priv->notify_week_start_day_id = e_signal_connect_notify_swapped ( @@ -814,7 +822,7 @@ week_view_realize (GtkWidget *widget) week_view = E_WEEK_VIEW (widget); /* Allocate the colors. */ - e_week_view_set_colors (week_view, widget); + e_week_view_set_colors (week_view); /* Create the pixmaps. */ week_view->reminder_icon = @@ -851,12 +859,44 @@ week_view_unrealize (GtkWidget *widget) (*GTK_WIDGET_CLASS (e_week_view_parent_class)->unrealize)(widget); } +static GdkColor +e_week_view_get_text_color (EWeekView *week_view, + EWeekViewEvent *event) +{ + GdkColor color; + guint16 red, green, blue; + gdouble cc = 65535.0; + + red = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].red; + green = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green; + blue = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].blue; + + if (is_comp_data_valid (event) && gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), event->comp_data), + &color)) { + red = color.red; + green = color.green; + blue = color.blue; + } + + color.pixel = 0; + + if ((red / cc > 0.7) || (green / cc > 0.7) || (blue / cc > 0.7)) { + color.red = 0.0; + color.green = 0.0; + color.blue = 0.0; + } else { + color.red = 65535.0f; + color.green = 65535.0f; + color.blue = 65535.0f; + } + + return color; +} + static void -week_view_style_set (GtkWidget *widget, - GtkStyle *previous_style) +week_view_style_updated (GtkWidget *widget) { EWeekView *week_view; - GtkStyle *style; gint day, day_width, max_day_width, max_abbr_day_width; gint month, month_width, max_month_width, max_abbr_month_width; gint span_num; @@ -867,30 +907,39 @@ week_view_style_set (GtkWidget *widget, PangoLayout *layout; EWeekViewEventSpan *span; - if (GTK_WIDGET_CLASS (e_week_view_parent_class)->style_set) - (*GTK_WIDGET_CLASS (e_week_view_parent_class)->style_set)(widget, previous_style); + if (GTK_WIDGET_CLASS (e_week_view_parent_class)->style_updated) + (*GTK_WIDGET_CLASS (e_week_view_parent_class)->style_updated) (widget); week_view = E_WEEK_VIEW (widget); - style = gtk_widget_get_style (widget); - e_week_view_set_colors (week_view, widget); + e_week_view_set_colors (week_view); if (week_view->spans) { - for (span_num = 0; span_num < week_view->spans->len; - span_num++) { - span = &g_array_index (week_view->spans, - EWeekViewEventSpan, span_num); - if (span->text_item) { - gnome_canvas_item_set ( - span->text_item, - "fill_color_gdk", &style->text[GTK_STATE_NORMAL], - NULL); + for (span_num = 0; span_num < week_view->spans->len; span_num++) { + span = &g_array_index (week_view->spans, EWeekViewEventSpan, span_num); + if (span->text_item && span->background_item) { + gint event_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (span->background_item), "event-num")); + EWeekViewEvent *event = NULL; + + if (is_array_index_in_bounds (week_view->events, event_num)) + event = &g_array_index (week_view->events, EWeekViewEvent, event_num); + + if (event) { + GdkColor text_color; + + text_color = e_week_view_get_text_color (week_view, event); + + gnome_canvas_item_set ( + span->text_item, + "fill_color_gdk", &text_color, + NULL); + } } } } /* Set up Pango prerequisites */ - font_desc = style->font_desc; pango_context = gtk_widget_get_pango_context (widget); + font_desc = pango_font_description_copy (pango_context_get_font_description (pango_context)); font_metrics = pango_context_get_metrics ( pango_context, font_desc, pango_context_get_language (pango_context)); @@ -955,7 +1004,7 @@ week_view_style_set (GtkWidget *widget, if (week_view->small_font_desc) { pango_layout_set_font_description (layout, week_view->small_font_desc); week_view->small_digit_width = get_digit_width (layout); - pango_layout_set_font_description (layout, style->font_desc); + pango_layout_set_font_description (layout, font_desc); } week_view->max_day_width = max_day_width; week_view->max_abbr_day_width = max_abbr_day_width; @@ -971,6 +1020,7 @@ week_view_style_set (GtkWidget *widget, g_object_unref (layout); pango_font_metrics_unref (font_metrics); + pango_font_description_free (font_desc); } static void @@ -1432,7 +1482,7 @@ e_week_view_class_init (EWeekViewClass *class) widget_class = GTK_WIDGET_CLASS (class); widget_class->realize = week_view_realize; widget_class->unrealize = week_view_unrealize; - widget_class->style_set = week_view_style_set; + widget_class->style_updated = week_view_style_updated; widget_class->size_allocate = week_view_size_allocate; widget_class->focus_in_event = week_view_focus_in; widget_class->focus_out_event = week_view_focus_out; @@ -1533,14 +1583,9 @@ e_week_view_init (EWeekView *week_view) week_view->last_edited_comp_string = NULL; - /* Create the small font. */ + /* Create the small font in constructed. */ week_view->use_small_font = TRUE; - - week_view->small_font_desc = - pango_font_description_copy (gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc); - pango_font_description_set_size ( - week_view->small_font_desc, - E_WEEK_VIEW_SMALL_FONT_PTSIZE * PANGO_SCALE); + week_view->small_font_desc = NULL; /* String to use in 12-hour time format for times in the morning. */ week_view->am_string = _("am"); @@ -1685,57 +1730,37 @@ color_inc (GdkColor c, } static void -e_week_view_set_colors (EWeekView *week_view, - GtkWidget *widget) +e_week_view_set_colors (EWeekView *week_view) { - GtkStyle *style; - - style = gtk_widget_get_style (widget); - - week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS] = style->base[GTK_STATE_INSENSITIVE]; - week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS] = style->base[GTK_STATE_NORMAL]; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND] = style->base[GTK_STATE_NORMAL]; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER] = style->dark[GTK_STATE_NORMAL]; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT] = style->text[GTK_STATE_NORMAL]; - week_view->colors[E_WEEK_VIEW_COLOR_GRID] = style->dark[GTK_STATE_NORMAL]; - week_view->colors[E_WEEK_VIEW_COLOR_SELECTED] = style->base[GTK_STATE_SELECTED]; - week_view->colors[E_WEEK_VIEW_COLOR_SELECTED_UNFOCUSSED] = style->bg[GTK_STATE_SELECTED]; - week_view->colors[E_WEEK_VIEW_COLOR_DATES] = style->text[GTK_STATE_NORMAL]; - week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED] = style->text[GTK_STATE_SELECTED]; - week_view->colors[E_WEEK_VIEW_COLOR_TODAY] = style->base[GTK_STATE_SELECTED]; + GtkWidget *widget = GTK_WIDGET (week_view); + GdkRGBA base_bg, bg_bg, text_fg, selected_bg, selected_fg, unfocused_selected_bg, dark_bg, light_bg; + + e_utils_get_theme_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &base_bg); + e_utils_get_theme_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg_bg); + e_utils_get_theme_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &text_fg); + e_utils_get_theme_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &selected_bg); + e_utils_get_theme_color (widget, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &selected_fg); + e_utils_get_theme_color (widget, "theme_unfocused_selected_bg_color,theme_selected_bg_color", E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_BG_COLOR, &unfocused_selected_bg); + + e_utils_shade_color (&bg_bg, &dark_bg, E_UTILS_DARKNESS_MULT); + e_utils_shade_color (&bg_bg, &light_bg, E_UTILS_LIGHTNESS_MULT); + + e_rgba_to_color (&bg_bg, &week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS]); + e_rgba_to_color (&base_bg, &week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS]); + e_rgba_to_color (&base_bg, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]); + e_rgba_to_color (&dark_bg, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]); + e_rgba_to_color (&text_fg, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT]); + e_rgba_to_color (&dark_bg, &week_view->colors[E_WEEK_VIEW_COLOR_GRID]); + e_rgba_to_color (&selected_bg, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED]); + e_rgba_to_color (&unfocused_selected_bg, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED_UNFOCUSSED]); + e_rgba_to_color (&text_fg, &week_view->colors[E_WEEK_VIEW_COLOR_DATES]); + e_rgba_to_color (&selected_fg, &week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED]); + e_rgba_to_color (&selected_bg, &week_view->colors[E_WEEK_VIEW_COLOR_TODAY]); + week_view->colors[E_WEEK_VIEW_COLOR_TODAY_BACKGROUND] = get_today_background (week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]); week_view->colors[E_WEEK_VIEW_COLOR_MONTH_NONWORKING_DAY] = color_inc (week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS], -0x0A0A); } -static GdkColor -e_week_view_get_text_color (EWeekView *week_view, - EWeekViewEvent *event, - GtkWidget *widget) -{ - GtkStyle *style; - GdkColor bg_color; - guint16 red, green, blue; - gdouble cc = 65535.0; - - red = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].red; - green = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green; - blue = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].blue; - - if (is_comp_data_valid (event) && gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), event->comp_data), - &bg_color)) { - red = bg_color.red; - green = bg_color.green; - blue = bg_color.blue; - } - - style = gtk_widget_get_style (widget); - - if ((red / cc > 0.7) || (green / cc > 0.7) || (blue / cc > 0.7)) - return style->black; - else - return style->white; -} - static void e_week_view_recalc_cell_sizes (EWeekView *week_view) { @@ -1743,9 +1768,7 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view) gint row, col; GtkAllocation allocation; GtkWidget *widget; - GtkStyle *style; gint width, height, time_width; - PangoFontDescription *font_desc; PangoContext *pango_context; PangoFontMetrics *font_metrics; @@ -1795,18 +1818,14 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view) - week_view->row_offsets[row]; } - /* If the font hasn't been set yet just return. */ widget = GTK_WIDGET (week_view); - style = gtk_widget_get_style (widget); - if (!style) - return; - font_desc = style->font_desc; - if (!font_desc) - return; pango_context = gtk_widget_get_pango_context (widget); + if (!pango_context) + return; + font_metrics = pango_context_get_metrics ( - pango_context, font_desc, + pango_context, NULL, pango_context_get_language (pango_context)); /* Calculate the number of rows of events in each cell, for the large @@ -3377,7 +3396,6 @@ e_week_view_reshape_event_span (EWeekView *week_view, gdouble text_x, text_y, text_w, text_h; gchar *text, *end_of_line; gint line_len, text_width; - PangoFontDescription *font_desc; PangoContext *pango_context; PangoFontMetrics *font_metrics; PangoLayout *layout; @@ -3421,10 +3439,9 @@ e_week_view_reshape_event_span (EWeekView *week_view, } /* Set up Pango prerequisites */ - font_desc = gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc; pango_context = gtk_widget_get_pango_context (GTK_WIDGET (week_view)); font_metrics = pango_context_get_metrics ( - pango_context, font_desc, + pango_context, NULL, pango_context_get_language (pango_context)); layout = pango_layout_new (pango_context); @@ -3475,13 +3492,10 @@ e_week_view_reshape_event_span (EWeekView *week_view, /* Create the text item if necessary. */ if (!span->text_item) { const gchar *summary; - GtkWidget *widget; GdkColor color; gboolean free_text = FALSE; - widget = (GtkWidget *) week_view; - - color = e_week_view_get_text_color (week_view, event, widget); + color = e_week_view_get_text_color (week_view, event); summary = get_comp_summary (event->comp_data->client, event->comp_data->icalcomp, &free_text); span->text_item = diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index 3c773e2f7f..ee67592b4d 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -227,7 +227,7 @@ struct _EWeekView { PangoFontDescription *small_font_desc; /* The widths of various pieces of text, used to determine which of - * several date formats to display, set in e_week_view_style_set (). */ + * several date formats to display, set in e_week_view_style_updated (). */ gint space_width; /* One space character ' '. */ gint colon_width; /* Size of ':' in the font. */ gint slash_width; /* Size of '/' in the font. */ diff --git a/calendar/gui/e-weekday-chooser.c b/calendar/gui/e-weekday-chooser.c index 90216821c3..3e4d1b7480 100644 --- a/calendar/gui/e-weekday-chooser.c +++ b/calendar/gui/e-weekday-chooser.c @@ -75,25 +75,21 @@ G_DEFINE_TYPE_WITH_CODE ( static void colorize_items (EWeekdayChooser *chooser) { - GdkColor *outline, *focus_outline; - GdkColor *fill, *sel_fill; - GdkColor *text_fill, *sel_text_fill; - GtkStateType state; - GtkStyle *style; + GdkColor outline, focus_outline; + GdkColor fill, sel_fill; + GdkColor text_fill, sel_text_fill; GDateWeekday weekday; + GtkWidget *widget; gint ii; - state = gtk_widget_get_state (GTK_WIDGET (chooser)); - style = gtk_widget_get_style (GTK_WIDGET (chooser)); + widget = GTK_WIDGET (chooser); - outline = &style->fg[state]; - focus_outline = &style->bg[state]; - - fill = &style->base[state]; - text_fill = &style->fg[state]; - - sel_fill = &style->bg[GTK_STATE_SELECTED]; - sel_text_fill = &style->fg[GTK_STATE_SELECTED]; + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &outline); + e_utils_get_theme_color_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &focus_outline); + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &fill); + e_utils_get_theme_color_color (widget, "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &text_fill); + e_utils_get_theme_color_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &sel_fill); + e_utils_get_theme_color_color (widget, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &sel_text_fill); weekday = e_weekday_chooser_get_week_start_day (chooser); @@ -101,17 +97,17 @@ colorize_items (EWeekdayChooser *chooser) GdkColor *f, *t, *o; if (chooser->priv->selected_weekdays[weekday]) { - f = sel_fill; - t = sel_text_fill; + f = &sel_fill; + t = &sel_text_fill; } else { - f = fill; - t = text_fill; + f = &fill; + t = &text_fill; } if (weekday == chooser->priv->focus_day) - o = focus_outline; + o = &focus_outline; else - o = outline; + o = &outline; gnome_canvas_item_set ( chooser->priv->boxes[ii], @@ -247,14 +243,12 @@ weekday_chooser_size_allocate (GtkWidget *widget, } static void -weekday_chooser_style_set (GtkWidget *widget, - GtkStyle *previous_style) +weekday_chooser_style_updated (GtkWidget *widget) { GtkWidgetClass *widget_class; EWeekdayChooser *chooser; EWeekdayChooserPrivate *priv; gint max_width; - PangoFontDescription *font_desc; PangoContext *pango_context; PangoFontMetrics *font_metrics; PangoLayout *layout; @@ -264,10 +258,9 @@ weekday_chooser_style_set (GtkWidget *widget, priv = chooser->priv; /* Set up Pango prerequisites */ - font_desc = gtk_widget_get_style (widget)->font_desc; pango_context = gtk_widget_get_pango_context (widget); font_metrics = pango_context_get_metrics ( - pango_context, font_desc, + pango_context, NULL, pango_context_get_language (pango_context)); layout = pango_layout_new (pango_context); @@ -296,9 +289,9 @@ weekday_chooser_style_set (GtkWidget *widget, g_object_unref (layout); pango_font_metrics_unref (font_metrics); - /* Chain up to parent's style_set() method. */ + /* Chain up to parent's style_updated() method. */ widget_class = GTK_WIDGET_CLASS (e_weekday_chooser_parent_class); - widget_class->style_set (widget, previous_style); + widget_class->style_updated (widget); } static void @@ -372,7 +365,7 @@ e_weekday_chooser_class_init (EWeekdayChooserClass *class) widget_class = GTK_WIDGET_CLASS (class); widget_class->realize = weekday_chooser_realize; widget_class->size_allocate = weekday_chooser_size_allocate; - widget_class->style_set = weekday_chooser_style_set; + widget_class->style_updated = weekday_chooser_style_updated; widget_class->get_preferred_height = weekday_chooser_get_preferred_height; widget_class->get_preferred_width = weekday_chooser_get_preferred_width; widget_class->focus = weekday_chooser_focus; diff --git a/e-util/e-attachment-button.c b/e-util/e-attachment-button.c index 016e293f72..7a99775c69 100644 --- a/e-util/e-attachment-button.c +++ b/e-util/e-attachment-button.c @@ -480,14 +480,12 @@ attachment_button_dispose (GObject *object) } static void -attachment_button_style_set (GtkWidget *widget, - GtkStyle *previous_style) +attachment_button_style_updated (GtkWidget *widget) { EAttachmentButton *button; - /* Chain up to parent's style_set() method. */ - GTK_WIDGET_CLASS (e_attachment_button_parent_class)-> - style_set (widget, previous_style); + /* Chain up to parent's method. */ + GTK_WIDGET_CLASS (e_attachment_button_parent_class)->style_updated (widget); button = E_ATTACHMENT_BUTTON (widget); attachment_button_update_pixbufs (button); @@ -507,7 +505,7 @@ e_attachment_button_class_init (EAttachmentButtonClass *class) object_class->dispose = attachment_button_dispose; widget_class = GTK_WIDGET_CLASS (class); - widget_class->style_set = attachment_button_style_set; + widget_class->style_updated = attachment_button_style_updated; g_object_class_install_property ( object_class, diff --git a/e-util/e-calendar-item.c b/e-util/e-calendar-item.c index 8f58b6d1e6..1c01610a97 100644 --- a/e-util/e-calendar-item.c +++ b/e-util/e-calendar-item.c @@ -145,7 +145,9 @@ static void e_calendar_item_get_day_style (ECalendarItem *calitem, GdkColor **fg_color, GdkColor **box_color, gboolean *bold, - gboolean *italic); + gboolean *italic, + GdkColor *local_bg_color, + GdkColor *local_fg_color); static void e_calendar_item_check_selection_end (ECalendarItem *calitem, gint start_month, @@ -886,7 +888,7 @@ e_calendar_item_realize (GnomeCanvasItem *item) calitem = E_CALENDAR_ITEM (item); - e_calendar_item_style_set (GTK_WIDGET (item->canvas), calitem); + e_calendar_item_style_updated (GTK_WIDGET (item->canvas), calitem); e_extensible_load_extensions (E_EXTENSIBLE (calitem)); } @@ -914,21 +916,20 @@ e_calendar_item_update (GnomeCanvasItem *item, { GnomeCanvasItemClass *item_class; ECalendarItem *calitem; - GtkStyle *style; gint char_height, width, height, space, space_per_cal, space_per_cell; gint rows, cols, xthickness, ythickness; - PangoFontDescription *font_desc; PangoContext *pango_context; PangoFontMetrics *font_metrics; + GtkBorder padding; item_class = GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class); if (item_class->update != NULL) item_class->update (item, i2c, flags); calitem = E_CALENDAR_ITEM (item); - style = gtk_widget_get_style (GTK_WIDGET (item->canvas)); - xthickness = style->xthickness; - ythickness = style->ythickness; + gtk_style_context_get_padding (gtk_widget_get_style_context (GTK_WIDGET (item->canvas)), 0, &padding); + xthickness = padding.left; + ythickness = padding.top; item->x1 = calitem->x1; item->y1 = calitem->y1; @@ -936,10 +937,9 @@ e_calendar_item_update (GnomeCanvasItem *item, item->y2 = calitem->y2 >= calitem->y1 ? calitem->y2 : calitem->y1; /* Set up Pango prerequisites */ - font_desc = style->font_desc; pango_context = gtk_widget_get_pango_context (GTK_WIDGET (item->canvas)); font_metrics = pango_context_get_metrics ( - pango_context, font_desc, + pango_context, NULL, pango_context_get_language (pango_context)); /* @@ -1055,7 +1055,6 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item, GtkWidget *widget; GtkStyleContext *style_context; gint char_height, row, col, row_y, bar_height, col_x; - const PangoFontDescription *font_desc; PangoContext *pango_context; PangoFontMetrics *font_metrics; GdkRGBA bg_color; @@ -1072,14 +1071,11 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item, style_context = gtk_widget_get_style_context (widget); /* Set up Pango prerequisites */ - font_desc = calitem->font_desc; - if (!font_desc) - font_desc = gtk_style_context_get_font ( - style_context, GTK_STATE_FLAG_NORMAL); pango_context = gtk_widget_get_pango_context ( GTK_WIDGET (canvas_item->canvas)); + /* It's OK when the calitem->font_desc is NUL, then the currently set font is used */ font_metrics = pango_context_get_metrics ( - pango_context, font_desc, + pango_context, calitem->font_desc, pango_context_get_language (pango_context)); char_height = @@ -1206,8 +1202,6 @@ e_calendar_item_draw_month (ECalendarItem *calitem, { GnomeCanvasItem *item; GtkWidget *widget; - GtkStyle *style; - PangoFontDescription *font_desc; struct tm tmp_tm; GdkRectangle clip_rect; GDateWeekday start_weekday; @@ -1222,6 +1216,9 @@ e_calendar_item_draw_month (ECalendarItem *calitem, PangoContext *pango_context; PangoFontMetrics *font_metrics; PangoLayout *layout; + GtkBorder padding; + PangoFontDescription *font_desc; + GdkRGBA rgba; #if 0 g_print ( @@ -1230,22 +1227,23 @@ e_calendar_item_draw_month (ECalendarItem *calitem, #endif item = GNOME_CANVAS_ITEM (calitem); widget = GTK_WIDGET (item->canvas); - style = gtk_widget_get_style (widget); /* Set up Pango prerequisites */ font_desc = calitem->font_desc; - if (!font_desc) - font_desc = style->font_desc; pango_context = gtk_widget_get_pango_context (widget); font_metrics = pango_context_get_metrics ( pango_context, font_desc, pango_context_get_language (pango_context)); + if (!font_desc) + font_desc = pango_context_get_font_description (pango_context); + font_desc = pango_font_description_copy (font_desc); char_height = PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - xthickness = style->xthickness; - ythickness = style->ythickness; + gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding); + xthickness = padding.left; + ythickness = padding.top; arrow_button_size = PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)) @@ -1267,8 +1265,10 @@ e_calendar_item_draw_month (ECalendarItem *calitem, /* Just return if the month is outside the given area. */ if (month_x >= width || month_x + calitem->month_width <= 0 - || month_y >= height || month_y + calitem->month_height <= 0) + || month_y >= height || month_y + calitem->month_height <= 0) { + pango_font_description_free (font_desc); return; + } month = calitem->month + row * calitem->cols + col; year = calitem->year + month / 12; @@ -1290,7 +1290,7 @@ e_calendar_item_draw_month (ECalendarItem *calitem, else max_x -= E_CALENDAR_ITEM_XPAD_AFTER_MONTH_NAME; - text_y = month_y + style->ythickness + text_y = month_y + padding.top + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME; clip_rect.x = month_x + min_x; clip_rect.x = MAX (0, clip_rect.x); @@ -1313,7 +1313,8 @@ e_calendar_item_draw_month (ECalendarItem *calitem, gdk_cairo_rectangle (cr, &clip_rect); cairo_clip (cr); - gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]); + e_utils_get_theme_color (widget, "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &rgba); + gdk_cairo_set_source_rgba (cr, &rgba); if (row == 0 && col == 0) { PangoLayout *layout_yr; @@ -1388,6 +1389,7 @@ e_calendar_item_draw_month (ECalendarItem *calitem, if (clip_width <= 0 || clip_height <= 0) { g_object_unref (layout); + pango_font_description_free (font_desc); return; } @@ -1421,7 +1423,8 @@ e_calendar_item_draw_month (ECalendarItem *calitem, + E_CALENDAR_ITEM_YPAD_ABOVE_CELLS; cairo_save (cr); - gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]); + e_utils_get_theme_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &rgba); + gdk_cairo_set_source_rgba (cr, &rgba); cairo_rectangle ( cr, cells_x , text_y - E_CALENDAR_ITEM_YPAD_ABOVE_CELLS - 1, @@ -1433,7 +1436,8 @@ e_calendar_item_draw_month (ECalendarItem *calitem, pango_layout_set_font_description (layout, font_desc); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) text_x += (7 - 1) * calitem->cell_width; - gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_ACTIVE]); + e_utils_get_theme_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &rgba); + gdk_cairo_set_source_rgba (cr, &rgba); for (day = 0; day < 7; day++) { cairo_save (cr); layout_set_day_text (calitem, layout, weekday); @@ -1452,7 +1456,8 @@ e_calendar_item_draw_month (ECalendarItem *calitem, /* Draw the rectangle around the week number. */ if (calitem->show_week_numbers) { cairo_save (cr); - gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]); + e_utils_get_theme_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &rgba); + gdk_cairo_set_source_rgba (cr, &rgba); cairo_rectangle ( cr, cells_x, cells_y - (cells_y - text_y + 2) , -20, E_CALENDAR_ROWS_PER_MONTH * calitem->cell_height + 18); @@ -1466,6 +1471,7 @@ e_calendar_item_draw_month (ECalendarItem *calitem, g_object_unref (layout); cairo_restore (cr); + pango_font_description_free (font_desc); } static const gchar * @@ -1511,9 +1517,9 @@ e_calendar_item_draw_day_numbers (ECalendarItem *calitem, { GnomeCanvasItem *item; GtkWidget *widget; - GtkStyle *style; PangoFontDescription *font_desc; GdkColor *bg_color, *fg_color, *box_color; + GdkRGBA rgba; struct tm today_tm; time_t t; gint char_height, min_cell_width, min_cell_height; @@ -1533,17 +1539,17 @@ e_calendar_item_draw_day_numbers (ECalendarItem *calitem, item = GNOME_CANVAS_ITEM (calitem); widget = GTK_WIDGET (item->canvas); - style = gtk_widget_get_style (widget); /* Set up Pango prerequisites */ font_desc = calitem->font_desc; - if (!font_desc) - font_desc = style->font_desc; pango_context = gtk_widget_get_pango_context (widget); font_metrics = pango_context_get_metrics ( pango_context, font_desc, pango_context_get_language (pango_context)); + if (!font_desc) + font_desc = pango_context_get_font_description (pango_context); + font_desc = pango_font_description_copy (font_desc); char_height = PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + @@ -1640,8 +1646,8 @@ e_calendar_item_draw_day_numbers (ECalendarItem *calitem, get_digit_fomat (), digit); cairo_save (cr); - gdk_cairo_set_source_color ( - cr, &style->text[GTK_STATE_ACTIVE]); + e_utils_get_theme_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &rgba); + gdk_cairo_set_source_rgba (cr, &rgba); pango_layout_set_font_description (layout, font_desc); pango_layout_set_text (layout, buffer, num_chars); cairo_move_to (cr, text_x, text_y); @@ -1652,6 +1658,8 @@ e_calendar_item_draw_day_numbers (ECalendarItem *calitem, for (dcol = 0; dcol < 7; dcol++) { if (draw_day) { + GdkColor local_bg_color, local_fg_color; + day_x = cells_x + ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? 7 - 1 - dcol : dcol) * calitem->cell_width; @@ -1717,7 +1725,9 @@ e_calendar_item_draw_day_numbers (ECalendarItem *calitem, &fg_color, &box_color, &bold, - &italic); + &italic, + &local_bg_color, + &local_fg_color); /* Draw the background, if set. */ if (bg_color) { @@ -1771,8 +1781,8 @@ e_calendar_item_draw_day_numbers (ECalendarItem *calitem, gdk_cairo_set_source_color ( cr, fg_color); } else { - gdk_cairo_set_source_color ( - cr, &style->fg[GTK_STATE_NORMAL]); + e_utils_get_theme_color (widget, "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &rgba); + gdk_cairo_set_source_rgba (cr, &rgba); } if (bold) { @@ -1830,6 +1840,7 @@ e_calendar_item_draw_day_numbers (ECalendarItem *calitem, g_object_unref (layout); pango_font_metrics_unref (font_metrics); + pango_font_description_free (font_desc); } gint @@ -2085,7 +2096,6 @@ static void e_calendar_item_recalc_sizes (ECalendarItem *calitem) { GnomeCanvasItem *canvas_item; - GtkStyle *style; gint max_day_width, digit, max_digit_width, max_week_number_digit_width; gint char_height, width, min_cell_width, min_cell_height; gchar buffer[64]; @@ -2095,24 +2105,25 @@ e_calendar_item_recalc_sizes (ECalendarItem *calitem) PangoFontMetrics *font_metrics; PangoLayout *layout; GDateWeekday weekday; + GtkWidget *widget; + GtkBorder padding; canvas_item = GNOME_CANVAS_ITEM (calitem); - style = gtk_widget_get_style (GTK_WIDGET (canvas_item->canvas)); - - if (!style) - return; + widget = GTK_WIDGET (canvas_item->canvas); + gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding); /* Set up Pango prerequisites */ font_desc = calitem->font_desc; wkfont_desc = calitem->week_number_font_desc; - if (!font_desc) - font_desc = style->font_desc; pango_context = gtk_widget_create_pango_context ( GTK_WIDGET (canvas_item->canvas)); font_metrics = pango_context_get_metrics ( pango_context, font_desc, pango_context_get_language (pango_context)); + if (!font_desc) + font_desc = pango_context_get_font_description (pango_context); + font_desc = pango_font_description_copy (font_desc); layout = pango_layout_new (pango_context); char_height = @@ -2175,7 +2186,7 @@ e_calendar_item_recalc_sizes (ECalendarItem *calitem) + E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS + 1; } - calitem->min_month_height = style->ythickness * 2 + calitem->min_month_height = padding.top * 2 + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME + char_height + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME + 1 + E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS @@ -2203,6 +2214,7 @@ e_calendar_item_recalc_sizes (ECalendarItem *calitem) g_object_unref (layout); g_object_unref (pango_context); pango_font_metrics_unref (font_metrics); + pango_font_description_free (font_desc); } static void @@ -2220,13 +2232,13 @@ e_calendar_item_get_day_style (ECalendarItem *calitem, GdkColor **fg_color, GdkColor **box_color, gboolean *bold, - gboolean *italic) + gboolean *italic, + GdkColor *local_bg_color, + GdkColor *local_fg_color) { GtkWidget *widget; - GtkStyle *style; widget = GTK_WIDGET (GNOME_CANVAS_ITEM (calitem)->canvas); - style = gtk_widget_get_style (widget); *bg_color = NULL; *fg_color = NULL; @@ -2240,22 +2252,31 @@ e_calendar_item_get_day_style (ECalendarItem *calitem, if (today) *box_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX]; - if (prev_or_next_month) - *fg_color = &style->mid[gtk_widget_get_state (widget)]; + if (prev_or_next_month) { + *fg_color = local_fg_color; + e_utils_get_theme_color_color (widget, "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, local_fg_color); + } if (selected) { + *bg_color = local_bg_color; + *fg_color = local_fg_color; + if (has_focus) { - *fg_color = &style->text[GTK_STATE_SELECTED]; - *bg_color = &style->base[GTK_STATE_SELECTED]; + e_utils_get_theme_color_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, local_bg_color); + e_utils_get_theme_color_color (widget, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, local_fg_color); } else { - *fg_color = &style->text[GTK_STATE_ACTIVE]; - *bg_color = &style->base[GTK_STATE_ACTIVE]; - - if ((*bg_color)->red == style->base[GTK_STATE_NORMAL].red && - (*bg_color)->green == style->base[GTK_STATE_NORMAL].green && - (*bg_color)->blue == style->base[GTK_STATE_NORMAL].blue) { - *fg_color = &style->text[GTK_STATE_SELECTED]; - *bg_color = &style->base[GTK_STATE_SELECTED]; + GdkColor base_bg; + + e_utils_get_theme_color_color (widget, "theme_unfocused_selected_bg_color,theme_selected_bg_color", E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_BG_COLOR, local_bg_color); + e_utils_get_theme_color_color (widget, "theme_unfocused_selected_fg_color,theme_selected_fg_color", E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_FG_COLOR, local_fg_color); + + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &base_bg); + + if (local_bg_color->red == base_bg.red && + local_bg_color->green == base_bg.green && + local_bg_color->blue == base_bg.blue) { + e_utils_get_theme_color_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, local_bg_color); + e_utils_get_theme_color_color (widget, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, local_fg_color); } } } @@ -2613,32 +2634,28 @@ e_calendar_item_convert_position_to_day (ECalendarItem *calitem, { GnomeCanvasItem *item; GtkWidget *widget; - GtkStyle *style; + GtkBorder padding; gint xthickness, ythickness, char_height; gint x, y, row, col, cells_x, cells_y, day_row, day_col; gint first_day_offset, days_in_month, days_in_prev_month; gint week_num_x1, week_num_x2; - PangoFontDescription *font_desc; PangoContext *pango_context; PangoFontMetrics *font_metrics; item = GNOME_CANVAS_ITEM (calitem); widget = GTK_WIDGET (item->canvas); - style = gtk_widget_get_style (widget); + gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding); - font_desc = calitem->font_desc; - if (!font_desc) - font_desc = style->font_desc; pango_context = gtk_widget_create_pango_context (widget); font_metrics = pango_context_get_metrics ( - pango_context, font_desc, + pango_context, calitem->font_desc, pango_context_get_language (pango_context)); char_height = PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - xthickness = style->xthickness; - ythickness = style->ythickness; + xthickness = padding.left; + ythickness = padding.top; pango_font_metrics_unref (font_metrics); @@ -3413,28 +3430,20 @@ e_calendar_item_set_selection_if_emission (ECalendarItem *calitem, } void -e_calendar_item_style_set (GtkWidget *widget, - ECalendarItem *calitem) +e_calendar_item_style_updated (GtkWidget *widget, + ECalendarItem *calitem) { - GtkStyle *style; - GdkColor *color; - - style = gtk_widget_get_style (widget); - - color = &style->bg[GTK_STATE_SELECTED]; - calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX] = *color; - - color = &style->base[GTK_STATE_NORMAL]; - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG] = *color; - - color = &style->bg[GTK_STATE_SELECTED]; - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED] = *color; + GdkRGBA selected_bg, fg, base_bg; - color = &style->fg[GTK_STATE_INSENSITIVE]; - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG] = *color; + e_utils_get_theme_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &selected_bg); + e_utils_get_theme_color (widget, "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &fg); + e_utils_get_theme_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &base_bg); - color = &style->fg[GTK_STATE_INSENSITIVE]; - calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG] = *color; + e_rgba_to_color (&selected_bg, &calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX]); + e_rgba_to_color (&base_bg, &calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG]); + e_rgba_to_color (&selected_bg, &calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED]); + e_rgba_to_color (&fg, &calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG]); + e_rgba_to_color (&fg, &calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG]); e_calendar_item_recalc_sizes (calitem); } diff --git a/e-util/e-calendar-item.h b/e-util/e-calendar-item.h index 202a77a7b0..29a6741c91 100644 --- a/e-util/e-calendar-item.h +++ b/e-util/e-calendar-item.h @@ -383,7 +383,7 @@ gint e_calendar_item_get_week_number (ECalendarItem *calitem, gint day, gint month, gint year); -void e_calendar_item_style_set (GtkWidget *widget, +void e_calendar_item_style_updated (GtkWidget *widget, ECalendarItem *calitem); G_END_DECLS diff --git a/e-util/e-calendar.c b/e-util/e-calendar.c index cb989bf72f..ed34bb41e8 100644 --- a/e-util/e-calendar.c +++ b/e-util/e-calendar.c @@ -38,6 +38,8 @@ #include <libgnomecanvas/gnome-canvas-widget.h> +#include "e-misc-utils.h" + #define E_CALENDAR_SMALL_FONT_PTSIZE 6 #define E_CALENDAR_SMALL_FONT \ @@ -66,8 +68,7 @@ static void e_calendar_dispose (GObject *object); static void e_calendar_realize (GtkWidget *widget); -static void e_calendar_style_set (GtkWidget *widget, - GtkStyle *previous_style); +static void e_calendar_style_updated (GtkWidget *widget); static void e_calendar_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint *natural_width); @@ -126,7 +127,7 @@ e_calendar_class_init (ECalendarClass *class) object_class->dispose = e_calendar_dispose; widget_class->realize = e_calendar_realize; - widget_class->style_set = e_calendar_style_set; + widget_class->style_updated = e_calendar_style_updated; widget_class->get_preferred_width = e_calendar_get_preferred_width; widget_class->get_preferred_height = e_calendar_get_preferred_height; widget_class->size_allocate = e_calendar_size_allocate; @@ -140,13 +141,17 @@ e_calendar_init (ECalendar *cal) { GnomeCanvasGroup *canvas_group; PangoFontDescription *small_font_desc; + PangoContext *pango_context; GtkWidget *button, *pixmap; AtkObject *a11y; + pango_context = gtk_widget_create_pango_context (GTK_WIDGET (cal)); + g_warn_if_fail (pango_context != NULL); + /* Create the small font. */ small_font_desc = pango_font_description_copy ( - gtk_widget_get_style (GTK_WIDGET (cal))->font_desc); + pango_context_get_font_description (pango_context)); pango_font_description_set_size ( small_font_desc, E_CALENDAR_SMALL_FONT_PTSIZE * PANGO_SCALE); @@ -161,6 +166,7 @@ e_calendar_init (ECalendar *cal) NULL)); pango_font_description_free (small_font_desc); + g_object_unref (pango_context); /* Create the arrow buttons to move to the previous/next month. */ button = gtk_button_new (); @@ -311,42 +317,42 @@ e_calendar_dispose (GObject *object) } static void -e_calendar_realize (GtkWidget *widget) +e_calendar_update_window_background (GtkWidget *widget) { - GtkStyle *style; GdkWindow *window; + GdkRGBA bg_bg; - (*GTK_WIDGET_CLASS (e_calendar_parent_class)->realize) (widget); + e_utils_get_theme_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg_bg); /* Set the background of the canvas window to the normal color, * or the arrow buttons are not displayed properly. */ - style = gtk_widget_get_style (widget); window = gtk_layout_get_bin_window (GTK_LAYOUT (widget)); - gdk_window_set_background (window, &style->bg[GTK_STATE_NORMAL]); + gdk_window_set_background_rgba (window, &bg_bg); } static void -e_calendar_style_set (GtkWidget *widget, - GtkStyle *previous_style) +e_calendar_realize (GtkWidget *widget) +{ + (*GTK_WIDGET_CLASS (e_calendar_parent_class)->realize) (widget); + + e_calendar_update_window_background (widget); +} + +static void +e_calendar_style_updated (GtkWidget *widget) { ECalendar *e_calendar; e_calendar = E_CALENDAR (widget); - if (GTK_WIDGET_CLASS (e_calendar_parent_class)->style_set) - (*GTK_WIDGET_CLASS (e_calendar_parent_class)->style_set) (widget, - previous_style); + if (GTK_WIDGET_CLASS (e_calendar_parent_class)->style_updated) + (*GTK_WIDGET_CLASS (e_calendar_parent_class)->style_updated) (widget); /* Set the background of the canvas window to the normal color, * or the arrow buttons are not displayed properly. */ - if (gtk_widget_get_realized (widget)) { - GtkStyle *style; - GdkWindow *window; + if (gtk_widget_get_realized (widget)) + e_calendar_update_window_background (widget); - style = gtk_widget_get_style (widget); - window = gtk_layout_get_bin_window (GTK_LAYOUT (widget)); - gdk_window_set_background (window, &style->bg[GTK_STATE_NORMAL]); - } - e_calendar_item_style_set (widget, e_calendar->calitem); + e_calendar_item_style_updated (widget, e_calendar->calitem); } static void @@ -355,15 +361,15 @@ e_calendar_get_preferred_width (GtkWidget *widget, gint *natural) { ECalendar *cal; - GtkStyle *style; + GtkBorder padding; gint col_width; cal = E_CALENDAR (widget); - style = gtk_widget_get_style (GTK_WIDGET (cal)); g_object_get ((cal->calitem), "column_width", &col_width, NULL); + gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding); - *minimum = *natural = col_width * cal->min_cols + style->xthickness * 2; + *minimum = *natural = col_width * cal->min_cols + padding.left * 2; } static void @@ -372,15 +378,15 @@ e_calendar_get_preferred_height (GtkWidget *widget, gint *natural) { ECalendar *cal; - GtkStyle *style; + GtkBorder padding; gint row_height; cal = E_CALENDAR (widget); - style = gtk_widget_get_style (GTK_WIDGET (cal)); g_object_get ((cal->calitem), "row_height", &row_height, NULL); + gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding); - *minimum = *natural = row_height * cal->min_rows + style->ythickness * 2; + *minimum = *natural = row_height * cal->min_rows + padding.top * 2; } static void @@ -388,9 +394,8 @@ e_calendar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { ECalendar *cal; - GtkStyle *style; + GtkBorder padding; GtkAllocation old_allocation; - PangoFontDescription *font_desc; PangoContext *pango_context; PangoFontMetrics *font_metrics; gdouble old_x2, old_y2, new_x2, new_y2; @@ -398,17 +403,16 @@ e_calendar_size_allocate (GtkWidget *widget, gboolean is_rtl; cal = E_CALENDAR (widget); - style = gtk_widget_get_style (widget); - xthickness = style->xthickness; - ythickness = style->ythickness; + gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding); + xthickness = padding.left; + ythickness = padding.top; (*GTK_WIDGET_CLASS (e_calendar_parent_class)->size_allocate) (widget, allocation); /* Set up Pango prerequisites */ - font_desc = gtk_widget_get_style (widget)->font_desc; pango_context = gtk_widget_get_pango_context (widget); font_metrics = pango_context_get_metrics ( - pango_context, font_desc, + pango_context, NULL, pango_context_get_language (pango_context)); /* Set the scroll region to its allocated size, if changed. */ @@ -540,17 +544,21 @@ e_calendar_get_border_size (ECalendar *cal, gint *left, gint *right) { - GtkStyle *style; + GtkStyleContext *style_context; g_return_if_fail (E_IS_CALENDAR (cal)); - style = gtk_widget_get_style (GTK_WIDGET (cal)); + style_context = gtk_widget_get_style_context (GTK_WIDGET (cal)); + + if (style_context) { + GtkBorder padding; + + gtk_style_context_get_padding (style_context, 0, &padding); - if (style) { - *top = style->ythickness; - *bottom = style->ythickness; - *left = style->xthickness; - *right = style->xthickness; + *top = padding.top; + *bottom = padding.top; + *left = padding.left; + *right = padding.left; } else { *top = *bottom = *left = *right = 0; } diff --git a/e-util/e-canvas-background.c b/e-util/e-canvas-background.c index af0ddb688a..b7612ca087 100644 --- a/e-util/e-canvas-background.c +++ b/e-util/e-canvas-background.c @@ -57,7 +57,7 @@ struct _ECanvasBackgroundPrivate { }; enum { - STYLE_SET, + STYLE_UPDATED, LAST_SIGNAL }; @@ -208,8 +208,7 @@ ecb_point (GnomeCanvasItem *item, } static void -ecb_style_set (ECanvasBackground *ecb, - GtkStyle *previous_style) +ecb_style_updated (ECanvasBackground *ecb) { GnomeCanvasItem *item = GNOME_CANVAS_ITEM (ecb); @@ -233,7 +232,7 @@ ecb_class_init (ECanvasBackgroundClass *ecb_class) item_class->point = ecb_point; item_class->bounds = ecb_bounds; - ecb_class->style_set = ecb_style_set; + ecb_class->style_updated = ecb_style_updated; g_object_class_install_property ( object_class, @@ -265,14 +264,13 @@ ecb_class_init (ECanvasBackgroundClass *ecb_class) 0, G_MAXUINT, 0, G_PARAM_READWRITE)); - ecb_signals[STYLE_SET] = g_signal_new ( - "style_set", + ecb_signals[STYLE_UPDATED] = g_signal_new ( + "style_updated", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECanvasBackgroundClass, style_set), + G_STRUCT_OFFSET (ECanvasBackgroundClass, 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); } diff --git a/e-util/e-canvas-background.h b/e-util/e-canvas-background.h index 690d52403d..e698e49c24 100644 --- a/e-util/e-canvas-background.h +++ b/e-util/e-canvas-background.h @@ -63,8 +63,7 @@ struct _ECanvasBackground { struct _ECanvasBackgroundClass { GnomeCanvasItemClass parent_class; - void (*style_set) (ECanvasBackground *eti, - GtkStyle *previous_style); + void (*style_updated) (ECanvasBackground *eti); }; GType e_canvas_background_get_type (void) G_GNUC_CONST; diff --git a/e-util/e-canvas.c b/e-util/e-canvas.c index 2183b3d628..f9f6b14822 100644 --- a/e-util/e-canvas.c +++ b/e-util/e-canvas.c @@ -338,25 +338,22 @@ pick_current_item (GnomeCanvas *canvas, } static void -canvas_style_set_recursive (GnomeCanvasItem *item, - GtkStyle *previous_style) +canvas_style_updated_recursive (GnomeCanvasItem *item) { - guint signal_id = g_signal_lookup ("style_set", G_OBJECT_TYPE (item)); + guint signal_id = g_signal_lookup ("style_updated", G_OBJECT_TYPE (item)); if (signal_id >= 1) { GSignalQuery query; g_signal_query (signal_id, &query); if (query.return_type == G_TYPE_NONE && - query.n_params == 1 && - query.param_types[0] == GTK_TYPE_STYLE) { - g_signal_emit (item, signal_id, 0, previous_style); + query.n_params == 0) { + g_signal_emit (item, signal_id, 0); } } if (GNOME_IS_CANVAS_GROUP (item)) { GList *items = GNOME_CANVAS_GROUP (item)->item_list; for (; items; items = items->next) - canvas_style_set_recursive ( - items->data, previous_style); + canvas_style_updated_recursive (items->data); } } @@ -426,12 +423,13 @@ canvas_unrealize (GtkWidget *widget) } static void -canvas_style_set (GtkWidget *widget, - GtkStyle *previous_style) +canvas_style_updated (GtkWidget *widget) { - canvas_style_set_recursive ( + GTK_WIDGET_CLASS (e_canvas_parent_class)->style_updated (widget); + + canvas_style_updated_recursive ( GNOME_CANVAS_ITEM (gnome_canvas_root ( - GNOME_CANVAS (widget))), previous_style); + GNOME_CANVAS (widget)))); } static gint @@ -605,7 +603,7 @@ e_canvas_class_init (ECanvasClass *class) widget_class = GTK_WIDGET_CLASS (class); widget_class->realize = canvas_realize; widget_class->unrealize = canvas_unrealize; - widget_class->style_set = canvas_style_set; + widget_class->style_updated = canvas_style_updated; widget_class->button_press_event = canvas_button_event; widget_class->button_release_event = canvas_button_event; widget_class->key_press_event = canvas_key_event; diff --git a/e-util/e-cell-combo.c b/e-util/e-cell-combo.c index d499026a9d..22d48f3737 100644 --- a/e-util/e-cell-combo.c +++ b/e-util/e-cell-combo.c @@ -464,8 +464,8 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc, GtkWidget *widget; GtkWidget *popwin_child; GtkWidget *popup_child; - GtkStyle *popwin_style; - GtkStyle *popup_style; + GtkBorder popwin_padding; + GtkBorder popup_padding; GdkWindow *window; GtkBin *popwin; GtkScrolledWindow *popup; @@ -533,18 +533,18 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc, list_requisition.height += E_CELL_COMBO_LIST_EMPTY_HEIGHT; popwin_child = gtk_bin_get_child (popwin); - popwin_style = gtk_widget_get_style (popwin_child); + gtk_style_context_get_padding (gtk_widget_get_style_context (popwin_child), 0, &popwin_padding); popup_child = gtk_bin_get_child (GTK_BIN (popup)); - popup_style = gtk_widget_get_style (popup_child); + gtk_style_context_get_padding (gtk_widget_get_style_context (popup_child), 0, &popup_padding); /* Calculate the desired width. */ *width = list_requisition.width - + 2 * popwin_style->xthickness + + 2 * popwin_padding.left + 2 * gtk_container_get_border_width (GTK_CONTAINER (popwin_child)) + 2 * gtk_container_get_border_width (GTK_CONTAINER (popup)) + 2 * gtk_container_get_border_width (GTK_CONTAINER (popup_child)) - + 2 * popup_style->xthickness; + + 2 * popup_padding.left; /* Use at least the same width as the column. */ if (*width < column_width) @@ -558,11 +558,11 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc, } /* Calculate all the borders etc. that we need to add to the height. */ - work_height = (2 * popwin_style->ythickness + work_height = (2 * popwin_padding.top + 2 * gtk_container_get_border_width (GTK_CONTAINER (popwin_child)) + 2 * gtk_container_get_border_width (GTK_CONTAINER (popup)) + 2 * gtk_container_get_border_width (GTK_CONTAINER (popup_child)) - + 2 * popup_style->xthickness); + + 2 * popup_padding.top); widget = gtk_scrolled_window_get_hscrollbar (popup); gtk_widget_get_preferred_size (widget, &requisition, NULL); diff --git a/e-util/e-cell-text.c b/e-util/e-cell-text.c index 757954b4f2..6d5a4ed353 100644 --- a/e-util/e-cell-text.c +++ b/e-util/e-cell-text.c @@ -535,8 +535,8 @@ build_layout (ECellTextView *text_view, if (text_view->edit || width <= 0) return layout; - if (ect->font_name) - { + if (ect->font_name) { + PangoContext *pango_context; PangoFontDescription *desc = NULL, *fixed_desc = NULL; gchar *fixed_family = NULL; gint fixed_size = 0; @@ -549,7 +549,8 @@ build_layout (ECellTextView *text_view, fixed_points = !pango_font_description_get_size_is_absolute (fixed_desc); } - desc = pango_font_description_copy (gtk_widget_get_style (GTK_WIDGET (((GnomeCanvasItem *) ecell_view->e_table_item_view)->canvas))->font_desc); + pango_context = gtk_widget_get_pango_context (GTK_WIDGET (((GnomeCanvasItem *) ecell_view->e_table_item_view)->canvas)); + desc = pango_font_description_copy (pango_context_get_font_description (pango_context)); pango_font_description_set_family (desc, fixed_family); if (fixed_points) pango_font_description_set_size (desc, fixed_size); @@ -708,21 +709,24 @@ ect_draw (ECellView *ecell_view, CellEdit *edit = text_view->edit; gboolean selected; GtkWidget *canvas = GTK_WIDGET (text_view->canvas); - GtkStyle *style; + GdkRGBA fg_rgba, bg_rgba; gint x_origin, y_origin, vspacing; cairo_save (cr); - style = gtk_widget_get_style (canvas); selected = flags & E_CELL_SELECTED; if (selected) { if (gtk_widget_has_focus (canvas)) - gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_SELECTED]); + e_utils_get_theme_color (canvas, "theme_unfocused_selected_fg_color,theme_selected_fg_color", E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_FG_COLOR, &fg_rgba); else - gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_ACTIVE]); + e_utils_get_theme_color (canvas, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &fg_rgba); + gdk_cairo_set_source_rgba (cr, &fg_rgba); } else { - gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]); + gboolean color_overwritten = FALSE; + + e_utils_get_theme_color (canvas, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &fg_rgba); + gdk_cairo_set_source_rgba (cr, &fg_rgba); if (ect->color_column != -1) { gchar *color_spec; @@ -731,8 +735,51 @@ ect_draw (ECellView *ecell_view, color_spec = e_table_model_value_at ( ecell_view->e_table_model, ect->color_column, row); - if (color_spec && gdk_color_parse (color_spec, &color)) + if (color_spec && gdk_color_parse (color_spec, &color)) { gdk_cairo_set_source_color (cr, &color); + color_overwritten = TRUE; + } + + if (color_spec) + e_table_model_free_value (ecell_view->e_table_model, ect->color_column, color_spec); + } + + if (!color_overwritten && ect->bg_color_column != -1) { + GdkColor bg_color; + gchar *color_spec; + + /* if the background color is overwritten and the text color is not, then + pick either black or white text color, because the theme text color might + be hard to read on the overwritten background */ + color_spec = e_table_model_value_at ( + ecell_view->e_table_model, + ect->bg_color_column, row); + + if (color_spec && gdk_color_parse (color_spec, &bg_color)) { + guint16 red, green, blue; + gdouble cc = 65535.0; + GdkRGBA rgba; + + red = bg_color.red; + green = bg_color.green; + blue = bg_color.blue; + rgba.alpha = 1.0; + + if ((red / cc > 0.7) || (green / cc > 0.7) || (blue / cc > 0.7)) { + rgba.red = 0.0; + rgba.green = 0.0; + rgba.blue = 0.0; + } else { + rgba.red = 1.0; + rgba.green = 1.0; + rgba.blue = 1.0; + } + + gdk_cairo_set_source_rgba (cr, &rgba); + } + + if (color_spec) + e_table_model_free_value (ecell_view->e_table_model, ect->bg_color_column, color_spec); } } @@ -762,9 +809,19 @@ ect_draw (ECellView *ecell_view, if (edit->selection_start != edit->selection_end) { cairo_region_t *clip_region; gint indices[2]; - GtkStateType state; - state = edit->has_selection ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE; + if (edit->has_selection) { + if (gtk_widget_has_focus (canvas)) { + e_utils_get_theme_color (canvas, "theme_unfocused_selected_bg_color,theme_selected_bg_color", E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_BG_COLOR, &bg_rgba); + e_utils_get_theme_color (canvas, "theme_unfocused_selected_fg_color,theme_selected_fg_color", E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_FG_COLOR, &fg_rgba); + } else { + e_utils_get_theme_color (canvas, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &bg_rgba); + e_utils_get_theme_color (canvas, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &fg_rgba); + } + } else { + e_utils_get_theme_color (canvas, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &bg_rgba); + e_utils_get_theme_color (canvas, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &fg_rgba); + } indices[0] = MIN (edit->selection_start, edit->selection_end); indices[1] = MAX (edit->selection_start, edit->selection_end); @@ -775,10 +832,10 @@ ect_draw (ECellView *ecell_view, cairo_clip (cr); cairo_region_destroy (clip_region); - gdk_cairo_set_source_color (cr, &style->base[state]); + gdk_cairo_set_source_rgba (cr, &bg_rgba); cairo_paint (cr); - gdk_cairo_set_source_color (cr, &style->text[state]); + gdk_cairo_set_source_rgba (cr, &fg_rgba); cairo_move_to (cr, x_origin, y_origin); pango_cairo_show_layout (cr, layout); } else { @@ -1312,7 +1369,6 @@ ect_print (ECellView *ecell_view, ECellText *ect = E_CELL_TEXT (ecell_view->ecell); ECellTextView *ectView = (ECellTextView *) ecell_view; GtkWidget *canvas = GTK_WIDGET (ectView->canvas); - GtkStyle *style; PangoDirection dir; gboolean strikeout, underline; cairo_t *cr; @@ -1334,10 +1390,9 @@ ect_print (ECellView *ecell_view, cairo_rectangle (cr, 2, 2, width + 2, height + 2); cairo_clip (cr); - style = gtk_widget_get_style (canvas); pango_context = gtk_widget_get_pango_context (canvas); font_metrics = pango_context_get_metrics ( - pango_context, style->font_desc, + pango_context, NULL, pango_context_get_language (pango_context)); ty = (gdouble)(text_height - pango_font_metrics_get_ascent (font_metrics) - diff --git a/e-util/e-cell.c b/e-util/e-cell.c index b22149b9c1..d66276ebbe 100644 --- a/e-util/e-cell.c +++ b/e-util/e-cell.c @@ -661,14 +661,13 @@ e_cell_get_bg_color (ECellView *ecell_view, } void -e_cell_style_set (ECellView *ecell_view, - GtkStyle *previous_style) +e_cell_style_updated (ECellView *ecell_view) { ECellClass *class; class = E_CELL_GET_CLASS (ecell_view->ecell); - if (class->style_set != NULL) - class->style_set (ecell_view, previous_style); + if (class->style_updated != NULL) + class->style_updated (ecell_view); } diff --git a/e-util/e-cell.h b/e-util/e-cell.h index 8d5e306c79..7a764c021e 100644 --- a/e-util/e-cell.h +++ b/e-util/e-cell.h @@ -193,8 +193,7 @@ struct _ECellClass { gchar * (*get_bg_color) (ECellView *ecell_view, gint row); - void (*style_set) (ECellView *ecell_view, - GtkStyle *previous_style); + void (*style_updated) (ECellView *ecell_view); }; GType e_cell_get_type (void) G_GNUC_CONST; @@ -249,8 +248,7 @@ gboolean e_cell_max_width_by_row_implemented (ECellView *ecell_view); gchar * e_cell_get_bg_color (ECellView *ecell_view, gint row); -void e_cell_style_set (ECellView *ecell_view, - GtkStyle *previous_style); +void e_cell_style_updated (ECellView *ecell_view); void e_cell_focus (ECellView *ecell_view, gint model_col, diff --git a/e-util/e-html-editor-page-dialog.c b/e-util/e-html-editor-page-dialog.c index 27552576c6..b01e15b0b0 100644 --- a/e-util/e-html-editor-page-dialog.c +++ b/e-util/e-html-editor-page-dialog.c @@ -322,18 +322,8 @@ html_editor_page_dialog_show (GtkWidget *widget) tmp = webkit_dom_html_body_element_get_text ( WEBKIT_DOM_HTML_BODY_ELEMENT (body)); - if (!tmp || !*tmp) { - GdkColor *color; - GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (view)); - color = &style->text[GTK_STATE_NORMAL]; - - rgba.alpha = 1; - rgba.red = ((gdouble) color->red) / G_MAXUINT16; - rgba.green = ((gdouble) color->green) / G_MAXUINT16; - rgba.blue = ((gdouble) color->blue) / G_MAXUINT16; - } else { - gdk_rgba_parse (&rgba, tmp); - } + if (!tmp || !*tmp || !gdk_rgba_parse (&rgba, tmp)) + e_utils_get_theme_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &rgba); g_free (tmp); e_color_combo_set_current_color ( E_COLOR_COMBO (dialog->priv->text_color_picker), &rgba); @@ -358,19 +348,8 @@ html_editor_page_dialog_show (GtkWidget *widget) tmp = webkit_dom_html_body_element_get_bg_color ( WEBKIT_DOM_HTML_BODY_ELEMENT (body)); - if (!tmp || !*tmp) { - GdkColor *color; - GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (view)); - color = &style->base[GTK_STATE_NORMAL]; - - rgba.alpha = 1; - rgba.red = ((gdouble) color->red) / G_MAXUINT16; - rgba.green = ((gdouble) color->green) / G_MAXUINT16; - rgba.blue = ((gdouble) color->blue) / G_MAXUINT16; - - } else { - gdk_rgba_parse (&rgba, tmp); - } + if (!tmp || !*tmp || !gdk_rgba_parse (&rgba, tmp)) + e_utils_get_theme_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &rgba); g_free (tmp); e_color_combo_set_current_color ( E_COLOR_COMBO (dialog->priv->background_color_picker), &rgba); diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c index 88f6da9599..4b54e4af66 100644 --- a/e-util/e-misc-utils.c +++ b/e-util/e-misc-utils.c @@ -1223,7 +1223,6 @@ e_color_to_value (const GdkColor *color) * e_rgba_to_value: * @rgba: a #GdkRGBA * - * * Converts #GdkRGBA to a 24-bit RGB color value * * Returns: a 24-bit color value @@ -1247,6 +1246,280 @@ e_rgba_to_value (const GdkRGBA *rgba) (blue & 0xFF)) & 0xffffff); } +/** + * e_rgba_to_color: + * @rgba: a source #GdkRGBA + * @color: a destination #GdkColor + * + * Converts @rgba into @color, but loses the alpha chnnel from @rgba. + **/ +void +e_rgba_to_color (const GdkRGBA *rgba, + GdkColor *color) +{ + g_return_if_fail (rgba != NULL); + g_return_if_fail (color != NULL); + + color->pixel = 0; + color->red = rgba->red * 65535.0; + color->green = rgba->green * 65535.0; + color->blue = rgba->blue * 65535.0; +} + +/** + * e_utils_get_theme_color: + * @widget: a #GtkWidget instance + * @color_names: comma-separated theme color names + * @fallback_color_ident: fallback color identificator, in a format for gdk_rgba_parse() + * @rgba: where to store the read color + * + * Reads named theme color from a #GtkStyleContext of @widget. + * The @color_names are read one after another from left to right, + * the next are meant as fallbacks, in case the theme doesn't + * define the previous color. If none is found then the @fallback_color_ident + * is set to @rgba. + **/ +void +e_utils_get_theme_color (GtkWidget *widget, + const gchar *color_names, + const gchar *fallback_color_ident, + GdkRGBA *rgba) +{ + GtkStyleContext *style_context; + gchar **names; + gint ii; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (color_names != NULL); + g_return_if_fail (fallback_color_ident != NULL); + g_return_if_fail (rgba != NULL); + + style_context = gtk_widget_get_style_context (widget); + + names = g_strsplit (color_names, ",", -1); + for (ii = 0; names && names[ii]; ii++) { + if (gtk_style_context_lookup_color (style_context, names[ii], rgba)) { + g_strfreev (names); + return; + } + } + + g_strfreev (names); + + g_warn_if_fail (gdk_rgba_parse (rgba, fallback_color_ident)); +} + +/** + * e_utils_get_theme_color_color: + * @widget: a #GtkWidget instance + * @color_names: comma-separated theme color names + * @fallback_color_ident: fallback color identificator, in a format for gdk_rgba_parse() + * @color: where to store the read color + * + * The same as e_utils_get_theme_color(), only populates #GdkColor, + * instead of #GdkRGBA. + **/ +void +e_utils_get_theme_color_color (GtkWidget *widget, + const gchar *color_names, + const gchar *fallback_color_ident, + GdkColor *color) +{ + GdkRGBA rgba; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (color_names != NULL); + g_return_if_fail (fallback_color_ident != NULL); + g_return_if_fail (color != NULL); + + e_utils_get_theme_color (widget, color_names, fallback_color_ident, &rgba); + + e_rgba_to_color (&rgba, color); +} + +/* This is copied from gtk+ sources */ +static void +rgb_to_hls (gdouble *r, + gdouble *g, + gdouble *b) +{ + gdouble min; + gdouble max; + gdouble red; + gdouble green; + gdouble blue; + gdouble h, l, s; + gdouble delta; + + red = *r; + green = *g; + blue = *b; + + if (red > green) { + if (red > blue) + max = red; + else + max = blue; + + if (green < blue) + min = green; + else + min = blue; + } else { + if (green > blue) + max = green; + else + max = blue; + + if (red < blue) + min = red; + else + min = blue; + } + + l = (max + min) / 2; + s = 0; + h = 0; + + if (max != min) { + if (l <= 0.5) + s = (max - min) / (max + min); + else + s = (max - min) / (2 - max - min); + + delta = max -min; + if (red == max) + h = (green - blue) / delta; + else if (green == max) + h = 2 + (blue - red) / delta; + else if (blue == max) + h = 4 + (red - green) / delta; + + h *= 60; + if (h < 0.0) + h += 360; + } + + *r = h; + *g = l; + *b = s; +} + +/* This is copied from gtk+ sources */ +static void +hls_to_rgb (gdouble *h, + gdouble *l, + gdouble *s) +{ + gdouble hue; + gdouble lightness; + gdouble saturation; + gdouble m1, m2; + gdouble r, g, b; + + lightness = *l; + saturation = *s; + + if (lightness <= 0.5) + m2 = lightness * (1 + saturation); + else + m2 = lightness + saturation - lightness * saturation; + m1 = 2 * lightness - m2; + + if (saturation == 0) { + *h = lightness; + *l = lightness; + *s = lightness; + } else { + hue = *h + 120; + while (hue > 360) + hue -= 360; + while (hue < 0) + hue += 360; + + if (hue < 60) + r = m1 + (m2 - m1) * hue / 60; + else if (hue < 180) + r = m2; + else if (hue < 240) + r = m1 + (m2 - m1) * (240 - hue) / 60; + else + r = m1; + + hue = *h; + while (hue > 360) + hue -= 360; + while (hue < 0) + hue += 360; + + if (hue < 60) + g = m1 + (m2 - m1) * hue / 60; + else if (hue < 180) + g = m2; + else if (hue < 240) + g = m1 + (m2 - m1) * (240 - hue) / 60; + else + g = m1; + + hue = *h - 120; + while (hue > 360) + hue -= 360; + while (hue < 0) + hue += 360; + + if (hue < 60) + b = m1 + (m2 - m1) * hue / 60; + else if (hue < 180) + b = m2; + else if (hue < 240) + b = m1 + (m2 - m1) * (240 - hue) / 60; + else + b = m1; + + *h = r; + *l = g; + *s = b; + } +} + +/* This is copied from gtk+ sources */ +void +e_utils_shade_color (const GdkRGBA *a, + GdkRGBA *b, + gdouble mult) +{ + gdouble red; + gdouble green; + gdouble blue; + + g_return_if_fail (a != NULL); + g_return_if_fail (b != NULL); + + red = a->red; + green = a->green; + blue = a->blue; + + rgb_to_hls (&red, &green, &blue); + + green *= mult; + if (green > 1.0) + green = 1.0; + else if (green < 0.0) + green = 0.0; + + blue *= mult; + if (blue > 1.0) + blue = 1.0; + else if (blue < 0.0) + blue = 0.0; + + hls_to_rgb (&red, &green, &blue); + + b->red = red; + b->green = green; + b->blue = blue; +} + static gint epow10 (gint number) { diff --git a/e-util/e-misc-utils.h b/e-util/e-misc-utils.h index 5810490b4f..903f26c28e 100644 --- a/e-util/e-misc-utils.h +++ b/e-util/e-misc-utils.h @@ -114,6 +114,34 @@ guint32 e_color_to_value (const GdkColor *color); guint32 e_rgba_to_value (const GdkRGBA *rgba); +void e_rgba_to_color (const GdkRGBA *rgba, + GdkColor *color); + +void e_utils_get_theme_color (GtkWidget *widget, + const gchar *color_names, + const gchar *fallback_color_ident, + GdkRGBA *rgba); + +void e_utils_get_theme_color_color (GtkWidget *widget, + const gchar *color_names, + const gchar *fallback_color_ident, + GdkColor *color); + +#define E_UTILS_LIGHTNESS_MULT 1.3 +#define E_UTILS_DARKNESS_MULT 0.7 +#define E_UTILS_DEFAULT_THEME_BG_COLOR "#AAAAAA" +#define E_UTILS_DEFAULT_THEME_BASE_COLOR "#FFFFFF" +#define E_UTILS_DEFAULT_THEME_FG_COLOR "#000000" +#define E_UTILS_DEFAULT_THEME_TEXT_COLOR "#000000" +#define E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR "#729fcf" +#define E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR "#000000" +#define E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_BG_COLOR "#808080" +#define E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_FG_COLOR "#000000" + +void e_utils_shade_color (const GdkRGBA *a, + GdkRGBA *b, + gdouble mult); + /* This only makes a filename safe for usage as a filename. * It still may have shell meta-characters in it. */ gchar * e_format_number (gint number); diff --git a/e-util/e-table-click-to-add.c b/e-util/e-table-click-to-add.c index 77422534c4..4295c906f8 100644 --- a/e-util/e-table-click-to-add.c +++ b/e-util/e-table-click-to-add.c @@ -42,7 +42,7 @@ enum { CURSOR_CHANGE, - STYLE_SET, + STYLE_UPDATED, LAST_SIGNAL }; @@ -76,26 +76,28 @@ etcta_cursor_change (GObject *object, } static void -etcta_style_set (ETableClickToAdd *etcta, - GtkStyle *previous_style) +etcta_style_updated (ETableClickToAdd *etcta) { GtkWidget *widget; - GtkStyle *style; + GdkColor fg, bg, text; widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etcta)->canvas); - style = gtk_widget_get_style (widget); + + e_utils_get_theme_color_color (widget, "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &fg); + e_utils_get_theme_color_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg); + e_utils_get_theme_color_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &text); if (etcta->rect) gnome_canvas_item_set ( etcta->rect, - "outline_color_gdk", &style->fg[GTK_STATE_NORMAL], - "fill_color_gdk", &style->bg[GTK_STATE_NORMAL], + "outline_color_gdk", &fg, + "fill_color_gdk", &bg, NULL); if (etcta->text) gnome_canvas_item_set ( etcta->text, - "fill_color_gdk", &style->text[GTK_STATE_NORMAL], + "fill_color_gdk", &text, NULL); } @@ -258,10 +260,13 @@ static void create_rect_and_text (ETableClickToAdd *etcta) { GtkWidget *widget; - GtkStyle *style; + GdkColor fg, bg, text; widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etcta)->canvas); - style = gtk_widget_get_style (widget); + + e_utils_get_theme_color_color (widget, "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &fg); + e_utils_get_theme_color_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg); + e_utils_get_theme_color_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &text); if (!etcta->rect) etcta->rect = gnome_canvas_item_new ( @@ -271,8 +276,8 @@ create_rect_and_text (ETableClickToAdd *etcta) "y1", (gdouble) 0, "x2", (gdouble) etcta->width - 1, "y2", (gdouble) etcta->height - 1, - "outline_color_gdk", &style->fg[GTK_STATE_NORMAL], - "fill_color_gdk", &style->bg[GTK_STATE_NORMAL], + "outline_color_gdk", &fg, + "fill_color_gdk", &bg, NULL); if (!etcta->text) @@ -281,7 +286,7 @@ create_rect_and_text (ETableClickToAdd *etcta) e_text_get_type (), "text", etcta->message ? etcta->message : "", "width", etcta->width - 4, - "fill_color_gdk", &style->text[GTK_STATE_NORMAL], + "fill_color_gdk", &text, NULL); } @@ -552,7 +557,7 @@ e_table_click_to_add_class_init (ETableClickToAddClass *class) GObjectClass *object_class = G_OBJECT_CLASS (class); class->cursor_change = NULL; - class->style_set = etcta_style_set; + class->style_updated = etcta_style_updated; object_class->dispose = etcta_dispose; object_class->set_property = etcta_set_property; @@ -635,15 +640,14 @@ e_table_click_to_add_class_init (ETableClickToAddClass *class) G_TYPE_INT, G_TYPE_INT); - etcta_signals[STYLE_SET] = g_signal_new ( - "style_set", + etcta_signals[STYLE_UPDATED] = g_signal_new ( + "style_updated", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETableClickToAddClass, style_set), + G_STRUCT_OFFSET (ETableClickToAddClass, 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); gal_a11y_e_table_click_to_add_init (); } diff --git a/e-util/e-table-click-to-add.h b/e-util/e-table-click-to-add.h index e8607978da..509a0ff219 100644 --- a/e-util/e-table-click-to-add.h +++ b/e-util/e-table-click-to-add.h @@ -86,8 +86,7 @@ struct _ETableClickToAddClass { void (*cursor_change) (ETableClickToAdd *etcta, gint row, gint col); - void (*style_set) (ETableClickToAdd *etcta, - GtkStyle *previous_style); + void (*style_updated) (ETableClickToAdd *etcta); }; GType e_table_click_to_add_get_type (void) G_GNUC_CONST; diff --git a/e-util/e-table-field-chooser-item.c b/e-util/e-table-field-chooser-item.c index d713bc3359..66191888d5 100644 --- a/e-util/e-table-field-chooser-item.c +++ b/e-util/e-table-field-chooser-item.c @@ -227,15 +227,15 @@ etfci_update (GnomeCanvasItem *item, static void etfci_font_load (ETableFieldChooserItem *etfci) { + PangoContext *pango_context; GtkWidget *widget; - GtkStyle *style; if (etfci->font_desc) pango_font_description_free (etfci->font_desc); widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas); - style = gtk_widget_get_style (widget); - etfci->font_desc = pango_font_description_copy (style->font_desc); + pango_context = gtk_widget_get_pango_context (widget); + etfci->font_desc = pango_font_description_copy (pango_context_get_font_description (pango_context)); } static void diff --git a/e-util/e-table-group-container.c b/e-util/e-table-group-container.c index aa8366a8e4..0069e43183 100644 --- a/e-util/e-table-group-container.c +++ b/e-util/e-table-group-container.c @@ -152,7 +152,7 @@ e_table_group_container_construct (GnomeCanvasGroup *parent, ETableColumnSpecification *spec; ETableCol *col; GtkWidget *widget; - GtkStyle *style; + PangoContext *pango_context; GtkSortType sort_type; spec = e_table_sort_info_grouping_get_nth (sort_info, n, &sort_type); @@ -171,8 +171,8 @@ e_table_group_container_construct (GnomeCanvasGroup *parent, etgc->ascending = (sort_type == GTK_SORT_ASCENDING); widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etgc)->canvas); - style = gtk_widget_get_style (widget); - etgc->font_desc = pango_font_description_copy (style->font_desc); + pango_context = gtk_widget_get_pango_context (widget); + etgc->font_desc = pango_font_description_copy (pango_context_get_font_description (pango_context)); etgc->open = TRUE; } diff --git a/e-util/e-table-header-item.c b/e-util/e-table-header-item.c index 0b93d01433..e3f83d3908 100644 --- a/e-util/e-table-header-item.c +++ b/e-util/e-table-header-item.c @@ -907,7 +907,6 @@ static void ethi_realize (GnomeCanvasItem *item) { ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GtkStyle *style; GtkTargetEntry ethi_drop_types[] = { { (gchar *) TARGET_ETABLE_COL_TYPE, 0, TARGET_ETABLE_COL_HEADER }, }; @@ -915,10 +914,13 @@ ethi_realize (GnomeCanvasItem *item) if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)-> realize) (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->realize)(item); - style = gtk_widget_get_style (GTK_WIDGET (item->canvas)); + if (!ethi->font_desc) { + PangoContext *pango_context; - if (!ethi->font_desc) - ethi_font_set (ethi, style->font_desc); + pango_context = gtk_widget_get_pango_context (GTK_WIDGET (item->canvas)); + + ethi_font_set (ethi, pango_context_get_font_description (pango_context)); + } /* * Now, configure DnD diff --git a/e-util/e-table-item.c b/e-util/e-table-item.c index 9066d6d1d6..da6171b5d8 100644 --- a/e-util/e-table-item.c +++ b/e-util/e-table-item.c @@ -78,7 +78,7 @@ enum { CLICK, KEY_PRESS, START_DRAG, - STYLE_SET, + STYLE_UPDATED, SELECTION_MODEL_REMOVED, SELECTION_MODEL_ADDED, LAST_SIGNAL @@ -127,16 +127,16 @@ static void e_table_item_redraw_row (ETableItem *eti, gint row); * how much you want their respective channels modified (and in what direction). * if it can't do the specified modification, it does it in the oppositon direction */ static void -e_hsv_tweak (GdkColor *color, +e_hsv_tweak (GdkRGBA *rgba, gdouble delta_h, gdouble delta_s, gdouble delta_v) { gdouble h, s, v, r, g, b; - r = color->red / 65535.0f; - g = color->green / 65535.0f; - b = color->blue / 65535.0f; + r = rgba->red; + g = rgba->green; + b = rgba->blue; gtk_rgb_to_hsv (r, g, b, &h, &s, &v); @@ -160,9 +160,9 @@ e_hsv_tweak (GdkColor *color, gtk_hsv_to_rgb (h, s, v, &r, &g, &b); - color->red = r * 65535.0f; - color->green = g * 65535.0f; - color->blue = b * 65535.0f; + rgba->red = r; + rgba->green = g; + rgba->blue = b; } inline static gint @@ -307,85 +307,44 @@ eti_editing (ETableItem *eti) return TRUE; } -inline static GdkColor * +static void eti_get_cell_background_color (ETableItem *eti, gint row, gint col, gboolean selected, - gboolean *allocatedp) + GdkRGBA *background) { ECellView *ecell_view = eti->cell_views[col]; GtkWidget *canvas; - GdkColor *background, bg; - GtkStyle *style; gchar *color_spec = NULL; - gboolean allocated = FALSE; canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas); - style = gtk_widget_get_style (canvas); if (selected) { if (gtk_widget_has_focus (canvas)) - background = &style->bg[GTK_STATE_SELECTED]; + e_utils_get_theme_color (canvas, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, background); else - background = &style->bg[GTK_STATE_ACTIVE]; + e_utils_get_theme_color (canvas, "theme_unfocused_selected_bg_color,theme_selected_bg_color", E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_BG_COLOR, background); } else { - background = &style->base[GTK_STATE_NORMAL]; + e_utils_get_theme_color (canvas, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, background); } color_spec = e_cell_get_bg_color (ecell_view, row); if (color_spec != NULL) { - if (gdk_color_parse (color_spec, &bg)) { - background = gdk_color_copy (&bg); - allocated = TRUE; - } + GdkRGBA bg; + + if (gdk_rgba_parse (&bg, color_spec)) + *background = bg; } if (eti->alternating_row_colors) { if (row % 2) { } else { - if (!allocated) { - background = gdk_color_copy (background); - allocated = TRUE; - } e_hsv_tweak (background, 0.0f, 0.0f, -0.07f); } } - if (allocatedp) - *allocatedp = allocated; - - return background; -} - -inline static GdkColor * -eti_get_cell_foreground_color (ETableItem *eti, - gint row, - gint col, - gboolean selected, - gboolean *allocated) -{ - GtkWidget *canvas; - GdkColor *foreground; - GtkStyle *style; - - canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas); - style = gtk_widget_get_style (canvas); - - if (allocated) - *allocated = FALSE; - - if (selected) { - if (gtk_widget_has_focus (canvas)) - foreground = &style->fg[GTK_STATE_SELECTED]; - else - foreground = &style->fg[GTK_STATE_ACTIVE]; - } else { - foreground = &style->text[GTK_STATE_NORMAL]; - } - - return foreground; } static void @@ -1888,7 +1847,7 @@ eti_unrealize (GnomeCanvasItem *item) static void eti_draw_grid_line (ETableItem *eti, cairo_t *cr, - GtkStyle *style, + const GdkRGBA *rgba, gint x1, gint y1, gint x2, @@ -1897,7 +1856,7 @@ eti_draw_grid_line (ETableItem *eti, cairo_save (cr); cairo_set_line_width (cr, 1.0); - gdk_cairo_set_source_color (cr, &style->dark[GTK_STATE_NORMAL]); + gdk_cairo_set_source_rgba (cr, rgba); cairo_move_to (cr, x1 + 0.5, y1 + 0.5); cairo_line_to (cr, x2 + 0.5, y2 + 0.5); @@ -1926,9 +1885,12 @@ eti_draw (GnomeCanvasItem *item, cairo_matrix_t i2c; gdouble eti_base_x, eti_base_y, lower_right_y, lower_right_x; GtkWidget *canvas = GTK_WIDGET (item->canvas); - GtkStyle *style = gtk_widget_get_style (canvas); + GdkRGBA line_color; gint height_extra = eti->horizontal_draw_grid ? 1 : 0; + e_utils_get_theme_color (canvas, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &line_color); + e_utils_shade_color (&line_color, &line_color, E_UTILS_DARKNESS_MULT); + /* * Find out our real position after grouping */ @@ -2021,7 +1983,7 @@ eti_draw (GnomeCanvasItem *item, f_found = FALSE; if (eti->horizontal_draw_grid && first_row == 0) - eti_draw_grid_line (eti, cr, style, eti_base_x - x, yd, eti_base_x + eti->width - x, yd); + eti_draw_grid_line (eti, cr, &line_color, eti_base_x - x, yd, eti_base_x + eti->width - x, yd); yd += height_extra; @@ -2048,8 +2010,7 @@ eti_draw (GnomeCanvasItem *item, gboolean col_selected = selected; gboolean cursor = FALSE; ECellFlags flags; - gboolean free_background; - GdkColor *background; + GdkRGBA background; gint x1, x2, y1, y2; cairo_pattern_t *pat; @@ -2071,24 +2032,24 @@ eti_draw (GnomeCanvasItem *item, x2 = x1 + ecol->width; y2 = yd + height; - background = eti_get_cell_background_color (eti, row, col, col_selected, &free_background); + eti_get_cell_background_color (eti, row, col, col_selected, &background); cairo_save (cr); pat = cairo_pattern_create_linear (0, y1, 0, y2); cairo_pattern_add_color_stop_rgba ( - pat, 0.0, background->red / 65535.0 , - background->green / 65535.0, - background->blue / 65535.0, selected ? 0.8: 1.0); + pat, 0.0, background.red, + background.green, + background.blue, selected ? 0.8: 1.0); if (selected) cairo_pattern_add_color_stop_rgba ( - pat, 0.5, background->red / 65535.0 , - background->green / 65535.0, - background->blue / 65535.0, 0.9); + pat, 0.5, background.red, + background.green, + background.blue, 0.9); cairo_pattern_add_color_stop_rgba ( - pat, 1, background->red / 65535.0 , - background->green / 65535.0, - background->blue / 65535.0, selected ? 0.8 : 1.0); + pat, 1, background.red, + background.green, + background.blue, selected ? 0.8 : 1.0); cairo_rectangle (cr, x1, y1, ecol->width, height - 1); cairo_set_source (cr, pat); cairo_fill_preserve (cr); @@ -2100,26 +2061,23 @@ eti_draw (GnomeCanvasItem *item, cairo_save (cr); cairo_set_line_width (cr, 1.0); cairo_set_source_rgba ( - cr, background->red / 65535.0 , - background->green / 65535.0, - background->blue / 65535.0, 1); + cr, background.red, + background.green, + background.blue, 1); cairo_move_to (cr, x1, y1); cairo_line_to (cr, x2, y1); cairo_stroke (cr); cairo_set_line_width (cr, 1.0); cairo_set_source_rgba ( - cr, background->red / 65535.0 , - background->green / 65535.0, - background->blue / 65535.0, 1); + cr, background.red, + background.green, + background.blue, 1); cairo_move_to (cr, x1, y2); cairo_line_to (cr, x2, y2); cairo_stroke (cr); cairo_restore (cr); - if (free_background) - gdk_color_free (background); - flags = col_selected ? E_CELL_SELECTED : 0; flags |= gtk_widget_has_focus (canvas) ? E_CELL_FOCUSED : 0; flags |= cursor ? E_CELL_CURSOR : 0; @@ -2175,7 +2133,7 @@ eti_draw (GnomeCanvasItem *item, yd += height; if (eti->horizontal_draw_grid) { - eti_draw_grid_line (eti, cr, style, eti_base_x - x, yd, eti_base_x + eti->width - x, yd); + eti_draw_grid_line (eti, cr, &line_color, eti_base_x - x, yd, eti_base_x + eti->width - x, yd); yd++; } } @@ -2186,7 +2144,7 @@ eti_draw (GnomeCanvasItem *item, for (col = first_col; col <= last_col; col++) { ETableCol *ecol = e_table_header_get_column (eti->header, col); - eti_draw_grid_line (eti, cr, style, xd, y_offset, xd, yd - 1); + eti_draw_grid_line (eti, cr, &line_color, xd, y_offset, xd, yd - 1); /* * This looks wierd, but it is to draw the last line @@ -2201,17 +2159,22 @@ eti_draw (GnomeCanvasItem *item, */ if (eti->draw_focus && f_found) { static const double dash[] = { 1.0, 1.0 }; + GdkRGBA bg, fg; + + e_utils_get_theme_color (canvas, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg); + e_utils_get_theme_color (canvas, "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &fg); + cairo_set_line_width (cr, 1.0); cairo_rectangle ( cr, f_x1 + 0.5, f_x2 + 0.5, f_x2 - f_x1 - 1, f_y2 - f_y1); - gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]); + gdk_cairo_set_source_rgba (cr, &bg); cairo_stroke_preserve (cr); cairo_set_dash (cr, dash, G_N_ELEMENTS (dash), 0.0); - gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]); + gdk_cairo_set_source_rgba (cr, &fg); cairo_stroke (cr); } } @@ -3105,8 +3068,7 @@ eti_event (GnomeCanvasItem *item, } static void -eti_style_set (ETableItem *eti, - GtkStyle *previous_style) +eti_style_updated (ETableItem *eti) { GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti); @@ -3118,7 +3080,7 @@ eti_style_set (ETableItem *eti, gint n_cells = eti->n_cells; for (i = 0; i < n_cells; i++) { - e_cell_style_set (eti->cell_views[i], previous_style); + e_cell_style_updated (eti->cell_views[i]); } } @@ -3156,7 +3118,7 @@ e_table_item_class_init (ETableItemClass *class) class->click = NULL; class->key_press = NULL; class->start_drag = NULL; - class->style_set = eti_style_set; + class->style_updated = eti_style_updated; class->selection_model_removed = NULL; class->selection_model_added = NULL; @@ -3392,15 +3354,14 @@ e_table_item_class_init (ETableItemClass *class) G_TYPE_INT, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - eti_signals[STYLE_SET] = g_signal_new ( - "style_set", + eti_signals[STYLE_UPDATED] = g_signal_new ( + "style_updated", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETableItemClass, style_set), + G_STRUCT_OFFSET (ETableItemClass, 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); eti_signals[SELECTION_MODEL_REMOVED] = g_signal_new ( "selection_model_removed", diff --git a/e-util/e-table-item.h b/e-util/e-table-item.h index 1c16adb079..5fc9346ab1 100644 --- a/e-util/e-table-item.h +++ b/e-util/e-table-item.h @@ -200,8 +200,7 @@ struct _ETableItemClass { gint row, gint col, GdkEvent *event); - void (*style_set) (ETableItem *eti, - GtkStyle *previous_style); + void (*style_updated) (ETableItem *eti); void (*selection_model_removed) (ETableItem *eti, ESelectionModel *selection); diff --git a/e-util/e-table.c b/e-util/e-table.c index 096313549e..10c370dd00 100644 --- a/e-util/e-table.c +++ b/e-util/e-table.c @@ -50,6 +50,7 @@ #include "e-table-subset.h" #include "e-table-utils.h" #include "e-unicode.h" +#include "e-misc-utils.h" #include "gal-a11y-e-table.h" #define COLUMN_HEADER_HEIGHT 16 @@ -1216,18 +1217,34 @@ changed_idle (gpointer data) } static void +et_canvas_style_updated (GtkWidget *widget) +{ + GdkColor color; + + GTK_WIDGET_CLASS (e_table_parent_class)->style_updated (widget); + + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &color); + + gnome_canvas_item_set ( + E_TABLE (widget)->white_item, + "fill_color_gdk", &color, + NULL); +} + +static void et_canvas_realize (GtkWidget *canvas, ETable *e_table) { GtkWidget *widget; - GtkStyle *style; + GdkColor color; widget = GTK_WIDGET (e_table->table_canvas); - style = gtk_widget_get_style (widget); + + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &color); gnome_canvas_item_set ( e_table->white_item, - "fill_color_gdk", &style->base[GTK_STATE_NORMAL], + "fill_color_gdk", &color, NULL); CHECK_HORIZONTAL (e_table); @@ -1428,7 +1445,7 @@ e_table_setup_table (ETable *e_table, ETableModel *model) { GtkWidget *widget; - GtkStyle *style; + GdkColor color; e_table->table_canvas = GNOME_CANVAS (e_canvas_new ()); g_signal_connect ( @@ -1471,14 +1488,15 @@ e_table_setup_table (ETable *e_table, G_CALLBACK (table_canvas_reflow), e_table); widget = GTK_WIDGET (e_table->table_canvas); - style = gtk_widget_get_style (widget); gtk_widget_show (widget); + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &color); + e_table->white_item = gnome_canvas_item_new ( gnome_canvas_root (e_table->table_canvas), e_canvas_background_get_type (), - "fill_color_gdk", &style->base[GTK_STATE_NORMAL], + "fill_color_gdk", &color, NULL); g_signal_connect ( @@ -2598,12 +2616,10 @@ e_table_drag_highlight (ETable *table, GtkAllocation allocation; GtkAdjustment *adjustment; GtkScrollable *scrollable; - GtkStyle *style; g_return_if_fail (E_IS_TABLE (table)); scrollable = GTK_SCROLLABLE (table->table_canvas); - style = gtk_widget_get_style (GTK_WIDGET (table)); gtk_widget_get_allocation (GTK_WIDGET (scrollable), &allocation); if (row != -1) { @@ -2622,11 +2638,15 @@ e_table_drag_highlight (ETable *table, y += gtk_adjustment_get_value (adjustment); if (table->drop_highlight == NULL) { + GdkColor fg; + + e_utils_get_theme_color_color (GTK_WIDGET (table), "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &fg); + table->drop_highlight = gnome_canvas_item_new ( gnome_canvas_root (table->table_canvas), gnome_canvas_rect_get_type (), "fill_color", NULL, - "outline_color_gdk", &style->fg[GTK_STATE_NORMAL], + "outline_color_gdk", &fg, NULL); } gnome_canvas_item_set ( @@ -3157,6 +3177,7 @@ e_table_class_init (ETableClass *class) widget_class->unrealize = et_unrealize; widget_class->get_preferred_width = et_get_preferred_width; widget_class->get_preferred_height = et_get_preferred_height; + widget_class->style_updated = et_canvas_style_updated; widget_class->focus = et_focus; diff --git a/e-util/e-text.c b/e-util/e-text.c index a6dfc9d870..e8826216c1 100644 --- a/e-util/e-text.c +++ b/e-util/e-text.c @@ -52,6 +52,7 @@ #include "e-marshal.h" #include "e-text-event-processor-emacs-like.h" #include "e-unicode.h" +#include "e-misc-utils.h" #include "gal-a11y-e-text.h" G_DEFINE_TYPE (EText, e_text, GNOME_TYPE_CANVAS_ITEM) @@ -380,31 +381,34 @@ reset_layout (EText *text) if (text->layout == NULL) { create_layout (text); - } - else { - GtkStyle *style; + } else { + PangoContext *pango_context; + PangoFontDescription *font_desc; - style = gtk_widget_get_style (GTK_WIDGET (item->canvas)); + pango_context = gtk_widget_create_pango_context (GTK_WIDGET (item->canvas)); + font_desc = pango_context_get_font_description (pango_context); if (text->font_desc) { pango_font_description_free (text->font_desc); } text->font_desc = pango_font_description_new (); - if (!pango_font_description_get_size_is_absolute (style->font_desc)) + if (!pango_font_description_get_size_is_absolute (font_desc)) pango_font_description_set_size ( text->font_desc, - pango_font_description_get_size (style->font_desc)); + pango_font_description_get_size (font_desc)); else pango_font_description_set_absolute_size ( text->font_desc, - pango_font_description_get_size (style->font_desc)); + pango_font_description_get_size (font_desc)); pango_font_description_set_family ( text->font_desc, - pango_font_description_get_family (style->font_desc)); + pango_font_description_get_family (font_desc)); pango_layout_set_font_description (text->layout, text->font_desc); pango_layout_set_text (text->layout, text->text, -1); reset_layout_attrs (text); + + g_object_unref (pango_context); } if (!text->button_down) { @@ -1214,19 +1218,19 @@ e_text_draw (GnomeCanvasItem *item, gint xpos, ypos; GnomeCanvas *canvas; GtkWidget *widget; - GtkStyle *style; - GtkStateType state; + GdkRGBA rgba; + gboolean backdrop; text = E_TEXT (item); canvas = GNOME_CANVAS_ITEM (text)->canvas; widget = GTK_WIDGET (canvas); - state = gtk_widget_get_state (widget); - style = gtk_widget_get_style (widget); + backdrop = (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_BACKDROP) != 0; cairo_save (cr); if (!text->rgba_set) { - gdk_cairo_set_source_color (cr, &style->fg[state]); + e_utils_get_theme_color (widget, backdrop ? "theme_unfocused_fg_color,theme_fg_color" : "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &rgba); + gdk_cairo_set_source_rgba (cr, &rgba); } else { cairo_set_source_rgba ( cr, @@ -1279,9 +1283,6 @@ e_text_draw (GnomeCanvasItem *item, if (text->selection_start != text->selection_end) { cairo_region_t *clip_region; gint indices[2]; - GtkStateType state; - - state = GTK_STATE_ACTIVE; indices[0] = MIN ( text->selection_start, @@ -1302,10 +1303,13 @@ e_text_draw (GnomeCanvasItem *item, cairo_clip (cr); cairo_region_destroy (clip_region); - gdk_cairo_set_source_color (cr, &style->base[state]); + e_utils_get_theme_color (widget, backdrop ? "theme_unfocused_base_color,theme_base_color" : "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &rgba); + + gdk_cairo_set_source_rgba (cr, &rgba); cairo_paint (cr); - gdk_cairo_set_source_color (cr, &style->text[state]); + e_utils_get_theme_color (widget, backdrop ? "theme_unfocused_text_color,theme_text_color" : "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &rgba); + gdk_cairo_set_source_rgba (cr, &rgba); cairo_move_to (cr, xpos, ypos); pango_cairo_show_layout (cr, text->layout); } else { diff --git a/e-util/e-text.h b/e-util/e-text.h index bd682ad04d..49b8fd0bb0 100644 --- a/e-util/e-text.h +++ b/e-util/e-text.h @@ -234,8 +234,7 @@ struct _ETextClass { GdkEvent *button_event, gint pos, GtkMenu *menu); - void (*style_set) (EText *text, - GtkStyle *previous_style); + void (*style_updated) (EText *text); }; GType e_text_get_type (void) G_GNUC_CONST; diff --git a/e-util/e-tree.c b/e-util/e-tree.c index 697e88c800..ce502212be 100644 --- a/e-util/e-tree.c +++ b/e-util/e-tree.c @@ -46,6 +46,7 @@ #include "e-tree-selection-model.h" #include "e-tree-table-adapter.h" #include "e-tree.h" +#include "e-misc-utils.h" #include "gal-a11y-e-tree.h" #define COLUMN_HEADER_HEIGHT 16 @@ -1171,16 +1172,17 @@ et_build_item (ETree *tree) } static void -et_canvas_style_set (GtkWidget *widget, - GtkStyle *prev_style) +et_canvas_style_updated (GtkWidget *widget) { - GtkStyle *style; + GdkColor color; - style = gtk_widget_get_style (widget); + GTK_WIDGET_CLASS (e_tree_parent_class)->style_updated (widget); + + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &color); gnome_canvas_item_set ( E_TREE (widget)->priv->white_item, - "fill_color_gdk", &style->base[GTK_STATE_NORMAL], + "fill_color_gdk", &color, NULL); } @@ -1293,7 +1295,7 @@ static void e_tree_setup_table (ETree *tree) { GtkWidget *widget; - GtkStyle *style; + GdkColor color; tree->priv->table_canvas = GNOME_CANVAS (e_canvas_new ()); g_signal_connect ( @@ -1341,14 +1343,15 @@ e_tree_setup_table (ETree *tree) G_CALLBACK (et_setup_table_canvas_vadjustment), tree); widget = GTK_WIDGET (tree->priv->table_canvas); - style = gtk_widget_get_style (widget); gtk_widget_show (widget); + e_utils_get_theme_color_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &color); + tree->priv->white_item = gnome_canvas_item_new ( gnome_canvas_root (tree->priv->table_canvas), e_canvas_background_get_type (), - "fill_color_gdk", &style->base[GTK_STATE_NORMAL], + "fill_color_gdk", &color, NULL); g_signal_connect ( @@ -2809,7 +2812,7 @@ e_tree_class_init (ETreeClass *class) widget_class = GTK_WIDGET_CLASS (class); widget_class->grab_focus = et_grab_focus; widget_class->unrealize = et_unrealize; - widget_class->style_set = et_canvas_style_set; + widget_class->style_updated = et_canvas_style_updated; widget_class->focus = et_focus; class->start_drag = et_real_start_drag; diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c index e17a18080e..fb644418db 100644 --- a/e-util/e-web-view.c +++ b/e-util/e-web-view.c @@ -618,7 +618,7 @@ style_updated_cb (EWebView *web_view) &color)) color_value = g_strdup_printf ("#%06x", e_rgba_to_value (&color)); else - color_value = g_strdup("#ffffff"); + color_value = g_strdup (E_UTILS_DEFAULT_THEME_BASE_COLOR); style = g_strconcat ("background-color: ", color_value, ";", NULL); @@ -637,7 +637,7 @@ style_updated_cb (EWebView *web_view) &color)) color_value = g_strdup_printf ("#%06x", e_rgba_to_value (&color)); else - color_value = g_strdup("#000000"); + color_value = g_strdup (E_UTILS_DEFAULT_THEME_FG_COLOR); style = g_strconcat ("color: ", color_value, ";", NULL); diff --git a/e-util/ea-calendar-item.c b/e-util/ea-calendar-item.c index fe52134891..cc7d4d535d 100644 --- a/e-util/ea-calendar-item.c +++ b/e-util/ea-calendar-item.c @@ -1192,8 +1192,7 @@ e_calendar_item_get_day_extents (ECalendarItem *calitem, { GnomeCanvasItem *item; GtkWidget *widget; - GtkStyle *style; - PangoFontDescription *font_desc; + GtkBorder padding; PangoContext *pango_context; PangoFontMetrics *font_metrics; gint char_height, xthickness, ythickness, text_y; @@ -1207,23 +1206,20 @@ e_calendar_item_get_day_extents (ECalendarItem *calitem, item = GNOME_CANVAS_ITEM (calitem); widget = GTK_WIDGET (item->canvas); - style = gtk_widget_get_style (widget); + gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding); /* Set up Pango prerequisites */ - font_desc = calitem->font_desc; - if (!font_desc) - font_desc = style->font_desc; pango_context = gtk_widget_get_pango_context (widget); font_metrics = pango_context_get_metrics ( - pango_context, font_desc, + pango_context, calitem->font_desc, pango_context_get_language (pango_context)); char_height = PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - xthickness = style->xthickness; - ythickness = style->ythickness; + xthickness = padding.left; + ythickness = padding.top; new_year = year; new_month = month; diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c index 4d00cf2b84..2e44fe7d9b 100644 --- a/em-format/e-mail-formatter.c +++ b/em-format/e-mail-formatter.c @@ -503,7 +503,7 @@ mail_formatter_update_style (EMailFormatter *formatter, style_context, backdrop ? "theme_unfocused_bg_color" : "theme_bg_color", &rgba)) - gdk_rgba_parse (&rgba, "#eeeeee"); + gdk_rgba_parse (&rgba, E_UTILS_DEFAULT_THEME_BG_COLOR); e_mail_formatter_set_color ( formatter, E_MAIL_FORMATTER_COLOR_BODY, &rgba); @@ -517,7 +517,7 @@ mail_formatter_update_style (EMailFormatter *formatter, style_context, backdrop ? "theme_unfocused_fg_color" : "theme_fg_color", &rgba)) - gdk_rgba_parse (&rgba, "#000000"); + gdk_rgba_parse (&rgba, E_UTILS_DEFAULT_THEME_FG_COLOR); e_mail_formatter_set_color ( formatter, E_MAIL_FORMATTER_COLOR_HEADER, &rgba); @@ -525,7 +525,7 @@ mail_formatter_update_style (EMailFormatter *formatter, style_context, backdrop ? "theme_unfocused_base_color" : "theme_base_color", &rgba)) - gdk_rgba_parse (&rgba, "#ffffff"); + gdk_rgba_parse (&rgba, E_UTILS_DEFAULT_THEME_BASE_COLOR); e_mail_formatter_set_color ( formatter, E_MAIL_FORMATTER_COLOR_CONTENT, &rgba); @@ -533,7 +533,7 @@ mail_formatter_update_style (EMailFormatter *formatter, style_context, backdrop ? "theme_unfocused_fg_color" : "theme_fg_color", &rgba)) - gdk_rgba_parse (&rgba, "#000000"); + gdk_rgba_parse (&rgba, E_UTILS_DEFAULT_THEME_FG_COLOR); e_mail_formatter_set_color ( formatter, E_MAIL_FORMATTER_COLOR_TEXT, &rgba); diff --git a/libgnomecanvas/gnome-canvas-text.c b/libgnomecanvas/gnome-canvas-text.c index e030b9b73b..548055125e 100644 --- a/libgnomecanvas/gnome-canvas-text.c +++ b/libgnomecanvas/gnome-canvas-text.c @@ -1184,12 +1184,13 @@ static void gnome_canvas_text_apply_font_desc (GnomeCanvasText *text) { PangoFontDescription *font_desc; + PangoContext *pango_context; GtkWidget *widget; - GtkStyle *style; widget = GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas); - style = gtk_widget_get_style (widget); - font_desc = pango_font_description_copy (style->font_desc); + pango_context = gtk_widget_create_pango_context (widget); + font_desc = pango_font_description_copy (pango_context_get_font_description (pango_context)); + g_object_unref (pango_context); if (text->font_desc) pango_font_description_merge (font_desc, text->font_desc, TRUE); diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c index 45b383b47f..4d482c5594 100644 --- a/libgnomecanvas/gnome-canvas.c +++ b/libgnomecanvas/gnome-canvas.c @@ -2817,12 +2817,15 @@ gnome_canvas_draw_background (GnomeCanvas *canvas, gint width, gint height) { - GtkStyle *style; + GtkStyleContext *style_context; + GdkRGBA rgba; - style = gtk_widget_get_style (GTK_WIDGET (canvas)); + style_context = gtk_widget_get_style_context (GTK_WIDGET (canvas)); + if (!gtk_style_context_lookup_color (style_context, "theme_bg_color", &rgba)) + gdk_rgba_parse (&rgba, "#aaaaaa"); cairo_save (cr); - gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]); + gdk_cairo_set_source_rgba (cr, &rgba); cairo_paint (cr); cairo_restore (cr); } diff --git a/libgnomecanvas/gnome-canvas.h b/libgnomecanvas/gnome-canvas.h index f24c929f95..675de55742 100644 --- a/libgnomecanvas/gnome-canvas.h +++ b/libgnomecanvas/gnome-canvas.h @@ -195,7 +195,7 @@ void gnome_canvas_item_construct (GnomeCanvasItem *item, GnomeCanvasGroup *paren /* Configure an item using the standard Gtk argument mechanism. The last * argument must be a NULL pointer. */ -void gnome_canvas_item_set (GnomeCanvasItem *item, const gchar *first_arg_name, ...); +void gnome_canvas_item_set (GnomeCanvasItem *item, const gchar *first_arg_name, ...) G_GNUC_NULL_TERMINATED; /* Used only for language wrappers and the like */ void gnome_canvas_item_set_valist (GnomeCanvasItem *item, diff --git a/modules/mail/e-mail-shell-sidebar.c b/modules/mail/e-mail-shell-sidebar.c index d4c9e2d954..e0e12a081b 100644 --- a/modules/mail/e-mail-shell-sidebar.c +++ b/modules/mail/e-mail-shell-sidebar.c @@ -264,7 +264,7 @@ mail_shell_sidebar_get_preferred_width (GtkWidget *widget, EMailShellSidebar *sidebar; PangoLayout *layout; PangoRectangle ink_rect; - GtkStyle *style; + GtkBorder padding; gint border; gint sidebar_width; gint screen_width; @@ -280,12 +280,12 @@ mail_shell_sidebar_get_preferred_width (GtkWidget *widget, pango_layout_get_pixel_extents (layout, &ink_rect, NULL); g_object_unref (layout); - style = gtk_widget_get_style (widget); + gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding); screen_width = guess_screen_width (sidebar); /* Thickness of frame shadow plus some slack for padding. */ - border = 2 * style->xthickness + 4; + border = 2 * padding.left + 4; sidebar_width = ink_rect.width + border; sidebar_width = MIN (sidebar_width, screen_width / 4); *minimum_width = *natural_width = MAX (*natural_width, sidebar_width); diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c index 268eaf3373..3a4d791203 100644 --- a/shell/e-shell-sidebar.c +++ b/shell/e-shell-sidebar.c @@ -295,6 +295,21 @@ shell_sidebar_size_allocate (GtkWidget *widget, } static void +shell_sidebar_style_updated (GtkWidget *widget) +{ + EShellSidebar *shell_sidebar; + GdkRGBA bg; + + /* Chain up to parent's method. */ + GTK_WIDGET_CLASS (e_shell_sidebar_parent_class)->style_updated (widget); + + shell_sidebar = E_SHELL_SIDEBAR (widget); + + e_utils_get_theme_color (shell_sidebar->priv->event_box, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg); + gtk_widget_override_background_color (shell_sidebar->priv->event_box, GTK_STATE_FLAG_NORMAL, &bg); +} + +static void shell_sidebar_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, @@ -351,6 +366,7 @@ e_shell_sidebar_class_init (EShellSidebarClass *class) widget_class->get_preferred_width = shell_sidebar_get_preferred_width; widget_class->get_preferred_height = shell_sidebar_get_preferred_height; widget_class->size_allocate = shell_sidebar_size_allocate; + widget_class->style_updated = shell_sidebar_style_updated; container_class = GTK_CONTAINER_CLASS (class); container_class->forall = shell_sidebar_forall; @@ -431,12 +447,11 @@ e_shell_sidebar_alert_sink_init (EAlertSinkInterface *iface) static void e_shell_sidebar_init (EShellSidebar *shell_sidebar) { - GtkStyle *style; GtkWidget *widget; GtkWidget *container; PangoAttribute *attribute; PangoAttrList *attribute_list; - const GdkColor *color; + GdkRGBA bg; const gchar *icon_name; shell_sidebar->priv = E_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar); @@ -444,9 +459,8 @@ e_shell_sidebar_init (EShellSidebar *shell_sidebar) gtk_widget_set_has_window (GTK_WIDGET (shell_sidebar), FALSE); widget = gtk_event_box_new (); - style = gtk_widget_get_style (widget); - color = &style->bg[GTK_STATE_ACTIVE]; - gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color); + e_utils_get_theme_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg); + gtk_widget_override_background_color (widget, GTK_STATE_FLAG_NORMAL, &bg); gtk_widget_set_parent (widget, GTK_WIDGET (shell_sidebar)); shell_sidebar->priv->event_box = g_object_ref (widget); gtk_widget_show (widget); |