diff options
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-attachment-button.c | 10 | ||||
-rw-r--r-- | e-util/e-calendar-item.c | 185 | ||||
-rw-r--r-- | e-util/e-calendar-item.h | 2 | ||||
-rw-r--r-- | e-util/e-calendar.c | 92 | ||||
-rw-r--r-- | e-util/e-canvas-background.c | 18 | ||||
-rw-r--r-- | e-util/e-canvas-background.h | 3 | ||||
-rw-r--r-- | e-util/e-canvas.c | 24 | ||||
-rw-r--r-- | e-util/e-cell-combo.c | 16 | ||||
-rw-r--r-- | e-util/e-cell-text.c | 87 | ||||
-rw-r--r-- | e-util/e-cell.c | 7 | ||||
-rw-r--r-- | e-util/e-cell.h | 6 | ||||
-rw-r--r-- | e-util/e-html-editor-page-dialog.c | 29 | ||||
-rw-r--r-- | e-util/e-misc-utils.c | 275 | ||||
-rw-r--r-- | e-util/e-misc-utils.h | 28 | ||||
-rw-r--r-- | e-util/e-table-click-to-add.c | 44 | ||||
-rw-r--r-- | e-util/e-table-click-to-add.h | 3 | ||||
-rw-r--r-- | e-util/e-table-field-chooser-item.c | 6 | ||||
-rw-r--r-- | e-util/e-table-group-container.c | 6 | ||||
-rw-r--r-- | e-util/e-table-header-item.c | 10 | ||||
-rw-r--r-- | e-util/e-table-item.c | 155 | ||||
-rw-r--r-- | e-util/e-table-item.h | 3 | ||||
-rw-r--r-- | e-util/e-table.c | 39 | ||||
-rw-r--r-- | e-util/e-text.c | 40 | ||||
-rw-r--r-- | e-util/e-text.h | 3 | ||||
-rw-r--r-- | e-util/e-tree.c | 21 | ||||
-rw-r--r-- | e-util/e-web-view.c | 4 | ||||
-rw-r--r-- | e-util/ea-calendar-item.c | 14 |
27 files changed, 730 insertions, 400 deletions
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; |