aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-12-01 02:36:38 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-12-01 03:28:35 +0800
commit7c2e05401bfed572a7253d3da24a30306497d570 (patch)
tree5c9f30e506f4ccaf2a13d140426b3be8fe1780ed /widgets
parentb15e0d6df6e3e626a7c8b33fd1d0504fca7ca5b5 (diff)
downloadgsoc2013-evolution-7c2e05401bfed572a7253d3da24a30306497d570.tar
gsoc2013-evolution-7c2e05401bfed572a7253d3da24a30306497d570.tar.gz
gsoc2013-evolution-7c2e05401bfed572a7253d3da24a30306497d570.tar.bz2
gsoc2013-evolution-7c2e05401bfed572a7253d3da24a30306497d570.tar.lz
gsoc2013-evolution-7c2e05401bfed572a7253d3da24a30306497d570.tar.xz
gsoc2013-evolution-7c2e05401bfed572a7253d3da24a30306497d570.tar.zst
gsoc2013-evolution-7c2e05401bfed572a7253d3da24a30306497d570.zip
Avoid GtkStyle-based "paint" functions.
Use GtkStyleContext-based "render" functions instead. gtk_paint_arrow() --> gtk_render_arrow() gtk_paint_box() --> gtk_render_background() gtk_paint_expander() --> gtk_render_expander() gtk_paint_flat_box() --> gtk_render_background() gtk_paint_shadow() --> gtk_render_frame() gtk_paint_vline() --> gtk_render_line()
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-calendar-item.c110
-rw-r--r--widgets/table/e-cell-popup.c85
-rw-r--r--widgets/table/e-cell-tree.c44
-rw-r--r--widgets/text/e-reflow.c41
4 files changed, 183 insertions, 97 deletions
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index 16ce64583b..96b39529b1 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -1051,13 +1051,14 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item,
gint height)
{
ECalendarItem *calitem;
- GtkStyle *style;
+ GtkWidget *widget;
+ GtkStyleContext *style_context;
gint char_height, row, col, row_y, bar_height, col_x;
- gint xthickness, ythickness;
- PangoFontDescription *font_desc;
+ const PangoFontDescription *font_desc;
PangoContext *pango_context;
PangoFontMetrics *font_metrics;
- GdkColor base, bg;
+ GdkRGBA bg_color;
+ GtkBorder border;
#if 0
g_print (
@@ -1065,13 +1066,17 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item,
x, y, width, height);
#endif
calitem = E_CALENDAR_ITEM (canvas_item);
- style = gtk_widget_get_style (GTK_WIDGET (canvas_item->canvas));
+
+ widget = GTK_WIDGET (canvas_item->canvas);
+ style_context = gtk_widget_get_style_context (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 (GTK_WIDGET (canvas_item->canvas));
+ 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));
font_metrics = pango_context_get_metrics (
pango_context, font_desc,
pango_context_get_language (pango_context));
@@ -1079,15 +1084,16 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item,
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;
- base = style->base[GTK_STATE_NORMAL];
- bg = style->bg[GTK_STATE_NORMAL];
+ gtk_style_context_get_background_color (
+ style_context, GTK_STATE_NORMAL, &bg_color);
+
+ gtk_style_context_get_border (
+ style_context, GTK_STATE_NORMAL, &border);
/* Clear the entire background. */
cairo_save (cr);
- gdk_cairo_set_source_color (cr, &base);
+ gdk_cairo_set_source_rgba (cr, &bg_color);
cairo_rectangle (
cr, calitem->x1 - x, calitem->y1 - y,
calitem->x2 - calitem->x1 + 1,
@@ -1096,53 +1102,73 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item,
cairo_restore (cr);
/* Draw the shadow around the entire item. */
- gtk_paint_shadow (
- style, cr, GTK_STATE_NORMAL, GTK_SHADOW_IN,
- NULL, "entry",
- calitem->x1 - x, calitem->y1 - y,
- calitem->x2 - calitem->x1 + 1,
- calitem->y2 - calitem->y1 + 1);
+ gtk_style_context_save (style_context);
+ gtk_style_context_add_class (
+ style_context, GTK_STYLE_CLASS_ENTRY);
+ cairo_save (cr);
+ gtk_render_frame (
+ style_context, cr,
+ (gdouble) calitem->x1 - x,
+ (gdouble) calitem->y1 - y,
+ (gdouble) calitem->x2 - calitem->x1 + 1,
+ (gdouble) calitem->y2 - calitem->y1 + 1);
+ cairo_restore (cr);
+ gtk_style_context_restore (style_context);
- row_y = canvas_item->y1 + ythickness;
- bar_height = ythickness * 2
- + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME + char_height
- + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME;
+ row_y = canvas_item->y1 + border.top;
+ bar_height =
+ border.top + border.bottom +
+ E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME + char_height +
+ E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME;
for (row = 0; row < calitem->rows; row++) {
/* Draw the background for the title bars and the shadow around
* it, and the vertical lines between columns. */
cairo_save (cr);
- gdk_cairo_set_source_color (cr, &bg);
+ gdk_cairo_set_source_rgba (cr, &bg_color);
cairo_rectangle (
- cr, calitem->x1 + xthickness - x, row_y - y,
- calitem->x2 - calitem->x1 + 1
- - xthickness * 2,
+ cr, calitem->x1 + border.left - x,
+ row_y - y,
+ calitem->x2 - calitem->x1 + 1 -
+ (border.left + border.right),
bar_height);
cairo_fill (cr);
cairo_restore (cr);
- gtk_paint_shadow (
- style, cr,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- NULL, "calendar-header",
- calitem->x1 + xthickness - x, row_y - y,
- calitem->x2 - calitem->x1 + 1
- - xthickness * 2,
- bar_height);
+ gtk_style_context_save (style_context);
+ gtk_style_context_add_class (
+ style_context, GTK_STYLE_CLASS_HEADER);
+ cairo_save (cr);
+ gtk_render_frame (
+ style_context, cr,
+ (gdouble) calitem->x1 + border.left - x,
+ (gdouble) row_y - y,
+ (gdouble) calitem->x2 - calitem->x1 + 1 -
+ (border.left + border.right),
+ (gdouble) bar_height);
+ cairo_restore (cr);
+ gtk_style_context_restore (style_context);
for (col = 0; col < calitem->cols; col++) {
if (col != 0) {
col_x = calitem->x1 + calitem->x_offset
+ calitem->month_width * col;
- gtk_paint_vline (
- style, cr,
- GTK_STATE_NORMAL, NULL,
- "calendar-separator",
- row_y + ythickness + 1 - y,
- row_y + bar_height
- - ythickness - 2 - y,
- col_x - 1 - x);
+
+ gtk_style_context_save (style_context);
+ gtk_style_context_add_class (
+ style_context,
+ GTK_STYLE_CLASS_SEPARATOR);
+ cairo_save (cr);
+ gtk_render_line (
+ style_context, cr,
+ (gdouble) col_x - 1 - x,
+ (gdouble) row_y + border.top + 1 - y,
+ (gdouble) row_y + bar_height -
+ border.bottom - 2 - y,
+ (gdouble) col_x - x);
+ cairo_restore (cr);
+ gtk_style_context_restore (style_context);
}
e_calendar_item_draw_month (
diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c
index 0f549748fe..ce821700f3 100644
--- a/widgets/table/e-cell-popup.c
+++ b/widgets/table/e-cell-popup.c
@@ -43,9 +43,8 @@
#include "e-table-item.h"
#include <gtk/gtk.h>
-#define E_CELL_POPUP_ARROW_WIDTH 16
-#define E_CELL_POPUP_ARROW_XPAD 3
-#define E_CELL_POPUP_ARROW_YPAD 3
+#define E_CELL_POPUP_ARROW_SIZE 16
+#define E_CELL_POPUP_ARROW_PAD 3
static void e_cell_popup_dispose (GObject *object);
@@ -264,8 +263,6 @@ ecp_draw (ECellView *ecv,
ECellPopup *ecp = E_CELL_POPUP (ecv->ecell);
ECellPopupView *ecp_view = (ECellPopupView *) ecv;
GtkWidget *canvas;
- GtkShadowType shadow;
- GdkRectangle rect;
gboolean show_popup_arrow;
cairo_save (cr);
@@ -286,39 +283,57 @@ ecp_draw (ECellView *ecv,
ecp->popup_arrow_shown = show_popup_arrow;
if (show_popup_arrow) {
- GtkStyle *style;
+ GtkStyleContext *style_context;
+ GdkRGBA color;
+ gint arrow_x;
+ gint arrow_y;
+ gint arrow_size;
+ gint midpoint_y;
e_cell_draw (
ecp_view->child_view, cr, model_col,
view_col, row, flags,
- x1, y1, x2 - E_CELL_POPUP_ARROW_WIDTH, y2);
-
- rect.x = x2 - E_CELL_POPUP_ARROW_WIDTH;
- rect.y = y1 + 1;
- rect.width = E_CELL_POPUP_ARROW_WIDTH;
- rect.height = y2 - y1 - 2;
-
- if (ecp->popup_shown)
- shadow = GTK_SHADOW_IN;
- else
- shadow = GTK_SHADOW_OUT;
-
- style = gtk_widget_get_style (canvas);
-
- gtk_paint_box (
- style, cr,
- GTK_STATE_NORMAL, shadow,
- canvas, "ecellpopup",
- rect.x, rect.y, rect.width, rect.height);
- gtk_paint_arrow (
- style, cr,
- GTK_STATE_NORMAL, GTK_SHADOW_NONE,
- canvas, NULL,
- GTK_ARROW_DOWN, TRUE,
- rect.x + E_CELL_POPUP_ARROW_XPAD,
- rect.y + E_CELL_POPUP_ARROW_YPAD,
- rect.width - E_CELL_POPUP_ARROW_XPAD * 2,
- rect.height - E_CELL_POPUP_ARROW_YPAD * 2);
+ x1, y1, x2 - E_CELL_POPUP_ARROW_SIZE, y2);
+
+ midpoint_y = y1 + ((y2 - y1 + 1) / 2);
+
+ arrow_x = x2 - E_CELL_POPUP_ARROW_SIZE;
+ arrow_y = midpoint_y - E_CELL_POPUP_ARROW_SIZE / 2;
+ arrow_size = E_CELL_POPUP_ARROW_SIZE;
+
+ style_context = gtk_widget_get_style_context (canvas);
+
+ gtk_style_context_save (style_context);
+
+ gtk_style_context_add_class (
+ style_context, GTK_STYLE_CLASS_CELL);
+
+ gtk_style_context_get_background_color (
+ style_context, GTK_STATE_FLAG_NORMAL, &color);
+
+ cairo_save (cr);
+ gdk_cairo_set_source_rgba (cr, &color);
+ gtk_render_background (
+ style_context, cr,
+ (gdouble) arrow_x,
+ (gdouble) arrow_y,
+ (gdouble) arrow_size,
+ (gdouble) arrow_size);
+ cairo_restore (cr);
+
+ arrow_x += E_CELL_POPUP_ARROW_PAD;
+ arrow_y += E_CELL_POPUP_ARROW_PAD;
+ arrow_size -= (E_CELL_POPUP_ARROW_PAD * 2);
+
+ cairo_save (cr);
+ gtk_render_arrow (
+ style_context, cr, G_PI,
+ (gdouble) arrow_x,
+ (gdouble) arrow_y,
+ (gdouble) arrow_size);
+ cairo_restore (cr);
+
+ gtk_style_context_restore (style_context);
} else {
e_cell_draw (
ecp_view->child_view, cr, model_col,
@@ -356,7 +371,7 @@ ecp_event (ECellView *ecv,
/* FIXME: The event coords seem to be relative to the
* text within the cell, so we have to add 4. */
- if (event->button.x + 4 >= width - E_CELL_POPUP_ARROW_WIDTH) {
+ if (event->button.x + 4 >= width - E_CELL_POPUP_ARROW_SIZE) {
return e_cell_popup_do_popup (ecp_view, event, row, view_col);
}
}
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index 3a3bd7be99..00d096f4e6 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -203,19 +203,51 @@ draw_expander (ECellTreeView *ectv,
GtkStateType state,
GdkRectangle *rect)
{
- GtkStyle *style;
+ GtkStyleContext *style_context;
GtkWidget *tree;
+ GtkStateFlags flags = 0;
gint exp_size;
tree = gtk_widget_get_parent (GTK_WIDGET (ectv->canvas));
- style = gtk_widget_get_style (tree);
+ style_context = gtk_widget_get_style_context (tree);
+
+ gtk_style_context_save (style_context);
+
+ gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_EXPANDER);
+
+ switch (state) {
+ case GTK_STATE_PRELIGHT:
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ break;
+ case GTK_STATE_SELECTED:
+ flags |= GTK_STATE_FLAG_SELECTED;
+ break;
+ case GTK_STATE_INSENSITIVE:
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ break;
+ default:
+ break;
+ }
+
+ if (expander_style == GTK_EXPANDER_EXPANDED)
+ flags |= GTK_STATE_FLAG_ACTIVE;
+
+ gtk_style_context_set_state (style_context, flags);
gtk_widget_style_get (tree, "expander_size", &exp_size, NULL);
- gtk_paint_expander (
- style, cr, state, tree, "treeview",
- rect->x + rect->width - exp_size / 2,
- rect->y + rect->height / 2, expander_style);
+ cairo_save (cr);
+
+ gtk_render_expander (
+ style_context, cr,
+ (gdouble) rect->x + rect->width - exp_size,
+ (gdouble) (rect->y + rect->height / 2) - (exp_size / 2),
+ (gdouble) exp_size,
+ (gdouble) exp_size);
+
+ cairo_restore (cr);
+
+ gtk_style_context_restore (style_context);
}
/*
diff --git a/widgets/text/e-reflow.c b/widgets/text/e-reflow.c
index 350550fd80..faad196c83 100644
--- a/widgets/text/e-reflow.c
+++ b/widgets/text/e-reflow.c
@@ -1246,10 +1246,12 @@ e_reflow_draw (GnomeCanvasItem *item,
gint width,
gint height)
{
- GtkStyle *style;
+ GtkStyleContext *style_context;
+ GtkWidget *widget;
gint x_rect, y_rect, width_rect, height_rect;
gdouble running_width;
EReflow *reflow = E_REFLOW (item);
+ GdkRGBA color;
gint i;
gdouble column_width;
@@ -1266,25 +1268,32 @@ e_reflow_draw (GnomeCanvasItem *item,
i /= column_width + E_REFLOW_FULL_GUTTER;
running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
- style = gtk_widget_get_style (GTK_WIDGET (item->canvas));
+ widget = GTK_WIDGET (item->canvas);
+ style_context = gtk_widget_get_style_context (widget);
+
+ cairo_save (cr);
+
+ gtk_style_context_get_background_color (
+ style_context, GTK_STATE_FLAG_ACTIVE, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
for (; i < reflow->column_count; i++) {
if (running_width > x + width)
break;
x_rect = running_width;
- gtk_paint_flat_box (
- style,
- cr,
- GTK_STATE_ACTIVE,
- GTK_SHADOW_NONE,
- GTK_WIDGET (item->canvas),
- "reflow",
- x_rect - x,
- y_rect - y,
- width_rect,
- height_rect);
+
+ gtk_render_background (
+ style_context, cr,
+ (gdouble) x_rect - x,
+ (gdouble) y_rect - y,
+ (gdouble) width_rect,
+ (gdouble) height_rect);
+
running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
}
+
+ cairo_restore (cr);
+
if (reflow->column_drag) {
GtkAdjustment *adjustment;
GtkLayout *layout;
@@ -1311,7 +1320,10 @@ e_reflow_draw (GnomeCanvasItem *item,
running_width += i * (column_width + E_REFLOW_FULL_GUTTER);
cairo_save (cr);
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+
+ gtk_style_context_get_color (
+ style_context, GTK_STATE_FLAG_NORMAL, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
for (; i < reflow->column_count; i++) {
if (running_width > x + width)
@@ -1326,6 +1338,7 @@ e_reflow_draw (GnomeCanvasItem *item,
cairo_fill (cr);
running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH;
}
+
cairo_restore (cr);
}
}