[evolution/gtk3: 38/47] save/restore cairo context when drawing



commit 54cb286ccdef22321ca547500d3eea03b682393c
Author: Milan Crha <mcrha redhat com>
Date:   Mon Dec 20 17:42:01 2010 +0100

    save/restore cairo context when drawing
    
    Earlier was context created and destroyed. Now we should make sure that
    the cairo context is in the same state as it was at the draw routine begin.

 calendar/gui/e-day-view-main-item.c        |    4 +++
 calendar/gui/e-day-view-time-item.c        |    7 +++++
 calendar/gui/e-meeting-time-sel-item.c     |    3 ++
 calendar/gui/e-meeting-time-sel.c          |    4 +++
 calendar/gui/e-week-view-main-item.c       |    3 ++
 calendar/gui/e-week-view-titles-item.c     |    2 +
 libgnomecanvas/gnome-canvas-pixbuf.c       |    7 ++++-
 libgnomecanvas/gnome-canvas-rect.c         |    8 +++++-
 libgnomecanvas/gnome-canvas-text.c         |    4 +++
 libgnomecanvas/gnome-canvas.c              |   36 ++++++++++++++++++++++++++-
 widgets/misc/e-calendar-item.c             |   14 +++++++++-
 widgets/misc/e-map.c                       |    6 ++++-
 widgets/table/e-cell-checkbox.c            |    2 +-
 widgets/table/e-cell-hbox.c                |    1 +
 widgets/table/e-cell-pixbuf.c              |    3 ++
 widgets/table/e-cell-popup.c               |    4 +++
 widgets/table/e-cell-text.c                |    2 +
 widgets/table/e-cell-tree.c                |    7 +++++
 widgets/table/e-cell.c                     |    8 ++++++
 widgets/table/e-table-field-chooser-item.c |    4 +++
 widgets/table/e-table-header-utils.c       |    7 ++++-
 widgets/table/e-table-item.c               |    4 +++
 widgets/text/e-text.c                      |    4 +++
 23 files changed, 135 insertions(+), 9 deletions(-)
---
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 129b25f..2b047f6 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -524,6 +524,8 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
 			bar_y1 = item_y + 1;
 
 		else if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_BOTTOM_EDGE) {
+			cairo_matrix_t save_matrix;
+
 			bar_y2 = item_y + item_h - 1;
 
 			end_minute = event->end_minute;
@@ -536,6 +538,7 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
 							    &end_resize_suffix,
 							    &end_suffix_width);
 
+			cairo_get_matrix (cr, &save_matrix);
 			cairo_save (cr);
 			cairo_rectangle (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + 2.75,
 				item_w - E_DAY_VIEW_BAR_WIDTH - 4.5,
@@ -563,6 +566,7 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
 			cairo_show_text (cr, end_regsizeime);
 			cairo_close_path (cr);
 			cairo_restore (cr);
+			cairo_set_matrix (cr, &save_matrix);
 		}
 	}
 
diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c
index 2340f25..5066b5f 100644
--- a/calendar/gui/e-day-view-time-item.c
+++ b/calendar/gui/e-day-view-time-item.c
@@ -303,6 +303,7 @@ edvti_draw_zone (GnomeCanvasItem   *canvas_item,
 	PangoFontMetrics *large_font_metrics, *small_font_metrics;
 	GdkColor fg, dark;
 	GdkColor mb_color;
+	cairo_matrix_t save_matrix;
 
 	time_item = E_DAY_VIEW_TIME_ITEM (canvas_item);
 	day_view = e_day_view_time_item_get_day_view (time_item);
@@ -494,6 +495,7 @@ edvti_draw_zone (GnomeCanvasItem   *canvas_item,
 					    display_hour, suffix);
 			}
 
+			cairo_get_matrix (cr, &save_matrix);
 			cairo_save (cr);
 			if (show_midnight_date)
 				gdk_cairo_set_source_color (cr, &mb_color);
@@ -506,6 +508,7 @@ edvti_draw_zone (GnomeCanvasItem   *canvas_item,
 			pango_cairo_update_layout (cr, layout);
 			pango_cairo_show_layout (cr, layout);
 			cairo_restore (cr);
+			cairo_set_matrix (cr, &save_matrix);
 
 			g_object_unref (layout);
 		} else {
@@ -530,6 +533,7 @@ edvti_draw_zone (GnomeCanvasItem   *canvas_item,
 				cairo_stroke (cr);
 				cairo_restore (cr);
 
+				cairo_get_matrix (cr, &save_matrix);
 				cairo_save (cr);
 				if (show_midnight_date)
 					gdk_cairo_set_source_color (cr, &mb_color);
@@ -543,6 +547,7 @@ edvti_draw_zone (GnomeCanvasItem   *canvas_item,
 				pango_cairo_update_layout (cr, layout);
 				pango_cairo_show_layout (cr, layout);
 				cairo_restore (cr);
+				cairo_set_matrix (cr, &save_matrix);
 
 				g_object_unref (layout);
 			} else {
@@ -573,6 +578,7 @@ edvti_draw_zone (GnomeCanvasItem   *canvas_item,
 						    "%02i", minute);
 				}
 
+				cairo_get_matrix (cr, &save_matrix);
 				cairo_save (cr);
 				if (show_midnight_date)
 					gdk_cairo_set_source_color (cr, &mb_color);
@@ -586,6 +592,7 @@ edvti_draw_zone (GnomeCanvasItem   *canvas_item,
 				pango_cairo_update_layout (cr, layout);
 				pango_cairo_show_layout (cr, layout);
 				cairo_restore (cr);
+				cairo_set_matrix (cr, &save_matrix);
 
 				g_object_unref (layout);
 			}
diff --git a/calendar/gui/e-meeting-time-sel-item.c b/calendar/gui/e-meeting-time-sel-item.c
index 156a083..fb8ae95 100644
--- a/calendar/gui/e-meeting-time-sel-item.c
+++ b/calendar/gui/e-meeting-time-sel-item.c
@@ -205,7 +205,9 @@ draw_strikeout_box (EMeetingTimeSelectorItem *mts_item, cairo_t *cr,
 {
 	GnomeCanvas *canvas = GNOME_CANVAS_ITEM (mts_item)->canvas;
 	EMeetingTimeSelector *mts = mts_item->mts;
+	cairo_matrix_t save_matrix;
 
+	cairo_get_matrix (cr, &save_matrix);
 	cairo_save (cr);
 
 	cairo_rectangle (cr, x, y, width, height);
@@ -216,6 +218,7 @@ draw_strikeout_box (EMeetingTimeSelectorItem *mts_item, cairo_t *cr,
 	cairo_paint (cr);
 
 	cairo_restore (cr);
+	cairo_set_matrix (cr, &save_matrix);
 }
 
 static void
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index 803d25a..bf6aed4 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -1228,6 +1228,8 @@ e_meeting_time_selector_draw_shadow (EMeetingTimeSelector *mts, cairo_t *cr)
 	GtkStyle *style;
 	gint x, y, w, h;
 
+	cairo_save (cr);
+
 	/* Draw the shadow around the graphical displays. */
 	gtk_widget_get_allocation (mts->display_top, &allocation);
 	x = allocation.x - 2;
@@ -1240,6 +1242,8 @@ e_meeting_time_selector_draw_shadow (EMeetingTimeSelector *mts, cairo_t *cr)
 	gtk_paint_shadow (
 		style, cr, GTK_STATE_NORMAL,
 		GTK_SHADOW_IN, NULL, NULL, x, y, w, h);
+
+	cairo_restore (cr);
 }
 
 /* When the main canvas scrolls, we scroll the other canvases. */
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index ae4316c..7593dfc 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -88,6 +88,7 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
 	PangoLayout *layout;
 	gboolean today = FALSE;
 	CalWeekdays working_days;
+	cairo_matrix_t save_matrix;
 
 	week_view = e_week_view_main_item_get_week_view (main_item);
 	style = gtk_widget_get_style (GTK_WIDGET (week_view));
@@ -235,6 +236,7 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
 			format_string = _("%d %b");
 	}
 
+	cairo_get_matrix (cr, &save_matrix);
 	cairo_save (cr);
 	if (selected) {
 		gdk_cairo_set_source_color (
@@ -278,6 +280,7 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
 	pango_cairo_update_layout (cr, layout);
 	pango_cairo_show_layout (cr, layout);
 	cairo_restore (cr);
+	cairo_set_matrix (cr, &save_matrix);
 	g_object_unref (layout);
 
 	/* Draw the line under the date. */
diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c
index 5491d4e..7ea7b1f 100644
--- a/calendar/gui/e-week-view-titles-item.c
+++ b/calendar/gui/e-week-view-titles-item.c
@@ -135,6 +135,7 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
 	week_view = e_week_view_titles_item_get_week_view (titles_item);
 	g_return_if_fail (week_view != NULL);
 
+	cairo_save (cr);
         cairo_set_line_width (cr, 1.0);
 
 	gtk_widget_get_allocation (
@@ -232,6 +233,7 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
 	}
 
 	g_object_unref (layout);
+	cairo_restore (cr);
 }
 
 static GnomeCanvasItem *
diff --git a/libgnomecanvas/gnome-canvas-pixbuf.c b/libgnomecanvas/gnome-canvas-pixbuf.c
index d377351..143b182 100644
--- a/libgnomecanvas/gnome-canvas-pixbuf.c
+++ b/libgnomecanvas/gnome-canvas-pixbuf.c
@@ -269,7 +269,7 @@ gnome_canvas_pixbuf_draw (GnomeCanvasItem *item, cairo_t *cr,
 {
 	GnomeCanvasPixbuf *gcp;
 	GnomeCanvasPixbufPrivate *priv;
-        cairo_matrix_t matrix;
+        cairo_matrix_t matrix, save_matrix;
 
 	gcp = GNOME_CANVAS_PIXBUF (item);
 	priv = gcp->priv;
@@ -281,10 +281,15 @@ gnome_canvas_pixbuf_draw (GnomeCanvasItem *item, cairo_t *cr,
         if (cairo_matrix_invert (&matrix)) {
                 return;
 	}
+
+	cairo_get_matrix (cr, &save_matrix);
+	cairo_save (cr);
         cairo_transform (cr, &matrix);
 
         gdk_cairo_set_source_pixbuf (cr, priv->pixbuf, 0, 0);
         cairo_paint (cr);
+	cairo_restore (cr);
+	cairo_set_matrix (cr, &save_matrix);
 }
 
 
diff --git a/libgnomecanvas/gnome-canvas-rect.c b/libgnomecanvas/gnome-canvas-rect.c
index 29e4c29..c397be3 100644
--- a/libgnomecanvas/gnome-canvas-rect.c
+++ b/libgnomecanvas/gnome-canvas-rect.c
@@ -399,10 +399,13 @@ gnome_canvas_rect_draw (GnomeCanvasItem *item,
                         gint height)
 {
 	GnomeCanvasRect *rect;
-	cairo_matrix_t matrix;
+	cairo_matrix_t matrix, save_matrix;
 
 	rect = GNOME_CANVAS_RECT (item);
 
+	cairo_get_matrix (cr, &save_matrix);
+	cairo_save (cr);
+
 	gnome_canvas_item_i2c_matrix (item, &matrix);
 	cairo_transform (cr, &matrix);
 
@@ -418,6 +421,9 @@ gnome_canvas_rect_draw (GnomeCanvasItem *item,
 
 	if (gnome_canvas_rect_setup_for_stroke (rect, cr))
 		cairo_stroke_preserve (cr);
+
+	cairo_restore (cr);
+	cairo_set_matrix (cr, &save_matrix);
 }
 
 static GnomeCanvasItem *
diff --git a/libgnomecanvas/gnome-canvas-text.c b/libgnomecanvas/gnome-canvas-text.c
index 33dee52..69f5b4e 100644
--- a/libgnomecanvas/gnome-canvas-text.c
+++ b/libgnomecanvas/gnome-canvas-text.c
@@ -1197,6 +1197,8 @@ gnome_canvas_text_draw (GnomeCanvasItem *item, cairo_t *cr,
 	if (!text->text)
 		return;
 
+	cairo_save (cr);
+
         if (text->clip) {
                 cairo_rectangle (cr,
                                  text->clip_cx - x,
@@ -1214,6 +1216,8 @@ gnome_canvas_text_draw (GnomeCanvasItem *item, cairo_t *cr,
 
         cairo_move_to (cr, text->cx - x, text->cy - y);
         pango_cairo_show_layout (cr, text->layout);
+
+	cairo_restore (cr);
 }
 
 /* Point handler for the text item */
diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c
index 1b17b7c..a1a8585 100644
--- a/libgnomecanvas/gnome-canvas.c
+++ b/libgnomecanvas/gnome-canvas.c
@@ -1510,9 +1510,18 @@ gnome_canvas_group_draw (GnomeCanvasItem *item,
 			&& (child->x1 < child->canvas->redraw_x2)
 			&& (child->y1 < child->canvas->redraw_y2)
 			&& (child->x2 > child->canvas->redraw_x1)
-			&& (child->y2 > child->canvas->redraw_y2)))
+			&& (child->y2 > child->canvas->redraw_y2))) {
+			cairo_matrix_t save_matrix;
+
+			cairo_get_matrix (cr, &save_matrix);
+			cairo_save (cr);
+
 			GNOME_CANVAS_ITEM_GET_CLASS (child)->draw (
 				child, cr, x, y, width, height);
+
+			cairo_restore (cr);
+			cairo_set_matrix (cr, &save_matrix);
+		}
 	}
 }
 
@@ -1738,6 +1747,7 @@ gnome_canvas_paint_rect (GnomeCanvas *canvas,
 	gint draw_width, draw_height;
 	gdouble hadjustment_value;
 	gdouble vadjustment_value;
+	cairo_matrix_t save_matrix;
 
 	g_return_if_fail (!canvas->need_update);
 
@@ -1770,15 +1780,27 @@ gnome_canvas_paint_rect (GnomeCanvas *canvas,
 	canvas->draw_xofs = draw_x1;
 	canvas->draw_yofs = draw_y1;
 
+	cairo_get_matrix (cr, &save_matrix);
+	cairo_save (cr);
+
 	g_signal_emit (
 		canvas, canvas_signals[DRAW_BACKGROUND], 0, cr,
 		draw_x1, draw_y1, draw_width, draw_height);
 
-	if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE)
+	cairo_restore (cr);
+	cairo_set_matrix (cr, &save_matrix);
+
+	if (canvas->root->flags & GNOME_CANVAS_ITEM_VISIBLE) {
+		cairo_save (cr);
+
 		(* GNOME_CANVAS_ITEM_GET_CLASS (canvas->root)->draw) (
 			canvas->root, cr,
 			draw_x1, draw_y1,
 			draw_width, draw_height);
+
+		cairo_restore (cr);
+		cairo_set_matrix (cr, &save_matrix);
+	}
 }
 
 /**
@@ -2266,6 +2288,7 @@ gnome_canvas_draw (GtkWidget *widget,
 	GnomeCanvas *canvas;
 	cairo_rectangle_list_t *list;
 	gint i;
+	cairo_matrix_t save_matrix;
 
 	canvas = GNOME_CANVAS (widget);
 
@@ -2298,9 +2321,15 @@ gnome_canvas_draw (GtkWidget *widget,
                                                  rect.x + rect.width,
                                                  rect.y + rect.height);
 
+			cairo_get_matrix (cr, &save_matrix);
+			cairo_save (cr);
+
 			/* And call expose on parent container class */
 			GTK_WIDGET_CLASS (canvas_parent_class)->
 				draw (widget, cr);
+
+			cairo_restore (cr);
+			cairo_set_matrix (cr, &save_matrix);
 		}
 	}
 
@@ -2788,8 +2817,11 @@ gnome_canvas_draw_background (GnomeCanvas *canvas,
 	GtkStyle *style;
 
 	style = gtk_widget_get_style (GTK_WIDGET (canvas));
+
+	cairo_save (cr);
 	gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
 	cairo_paint (cr);
+	cairo_restore (cr);
 }
 
 static void
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index dd07f34..f849d3b 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -1261,6 +1261,8 @@ e_calendar_item_draw_month	(ECalendarItem   *calitem,
 	clip_rect.width = clip_width;
 	clip_rect.height = clip_height;
 
+	cairo_save (cr);
+
         gdk_cairo_rectangle (cr, &clip_rect);
         cairo_clip (cr);
 
@@ -1299,6 +1301,7 @@ e_calendar_item_draw_month	(ECalendarItem   *calitem,
 		text_x += (7-1) * calitem->cell_width;
         gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_ACTIVE]);
 	for (day = 0; day < 7; day++) {
+		cairo_save (cr);
 		layout_set_day_text (calitem, layout, day_index);
                 cairo_move_to (cr,
                                text_x - calitem->day_widths[day_index],
@@ -1309,6 +1312,7 @@ e_calendar_item_draw_month	(ECalendarItem   *calitem,
 		day_index++;
 		if (day_index == 7)
 			day_index = 0;
+		cairo_restore (cr);
 	}
 
 	/* Draw the rectangle around the week number. */
@@ -1326,6 +1330,7 @@ e_calendar_item_draw_month	(ECalendarItem   *calitem,
 		year, month, start_weekday, cells_x, cells_y);
 
 	g_object_unref (layout);
+	cairo_restore (cr);
 }
 
 static const gchar *
@@ -1390,6 +1395,7 @@ e_calendar_item_draw_day_numbers (ECalendarItem	*calitem,
 	PangoContext *pango_context;
 	PangoFontMetrics *font_metrics;
 	PangoLayout *layout;
+	cairo_matrix_t save_matrix;
 
 	item = GNOME_CANVAS_ITEM (calitem);
 	widget = GTK_WIDGET (item->canvas);
@@ -1495,14 +1501,16 @@ e_calendar_item_draw_day_numbers (ECalendarItem	*calitem,
 			text_x -= calitem->week_number_digit_widths[digit] + 6;
 			num_chars += sprintf (&buffer[num_chars], get_digit_fomat (), digit);
 
+			cairo_get_matrix (cr, &save_matrix);
 			cairo_save (cr);
 			gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_ACTIVE]);
 			pango_layout_set_font_description (layout, font_desc);
 			pango_layout_set_text (layout, buffer, num_chars);
-			cairo_translate (cr, text_x, text_y);
+			cairo_move_to (cr, text_x, text_y);
 			pango_cairo_update_layout (cr, layout);
 			pango_cairo_show_layout (cr, layout);
 			cairo_restore (cr);
+			cairo_set_matrix (cr, &save_matrix);
 		}
 
 		for (dcol = 0; dcol < 7; dcol++) {
@@ -1613,6 +1621,7 @@ e_calendar_item_draw_day_numbers (ECalendarItem	*calitem,
 				day_x -= calitem->digit_widths[digit];
 				num_chars += sprintf (&buffer[num_chars], get_digit_fomat (), digit);
 
+				cairo_get_matrix (cr, &save_matrix);
 				cairo_save (cr);
 				if (fg_color) {
 					gdk_cairo_set_source_color (cr, fg_color);
@@ -1634,10 +1643,11 @@ e_calendar_item_draw_day_numbers (ECalendarItem	*calitem,
 
 				pango_layout_set_font_description (layout, font_desc);
 				pango_layout_set_text (layout, buffer, num_chars);
-				cairo_translate (cr, day_x, day_y);
+				cairo_move_to (cr, day_x, day_y);
 				pango_cairo_update_layout (cr, layout);
 				pango_cairo_show_layout (cr, layout);
 				cairo_restore (cr);
+				cairo_set_matrix (cr, &save_matrix);
 			}
 
 			/* See if we've reached the end of a month. */
diff --git a/widgets/misc/e-map.c b/widgets/misc/e-map.c
index 5465b18..23a7bd4 100644
--- a/widgets/misc/e-map.c
+++ b/widgets/misc/e-map.c
@@ -509,19 +509,23 @@ static gboolean
 e_map_draw (GtkWidget *widget, cairo_t *cr)
 {
 	EMap *map;
-	cairo_matrix_t matrix;
+	cairo_matrix_t matrix, save_matrix;
 
 	if (!gtk_widget_is_drawable (widget))
 		return FALSE;
 
 	map = E_MAP (widget);
 
+	cairo_get_matrix (cr, &save_matrix);
+
 	e_map_tweens_compute_matrix (map, &matrix);
 	cairo_transform (cr, &matrix);
 
 	cairo_set_source_surface (cr, map->priv->map_render_surface, 0, 0);
 	cairo_paint (cr);
 
+	cairo_set_matrix (cr, &save_matrix);
+
 	return FALSE;
 }
 
diff --git a/widgets/table/e-cell-checkbox.c b/widgets/table/e-cell-checkbox.c
index 441f672..20f56b4 100644
--- a/widgets/table/e-cell-checkbox.c
+++ b/widgets/table/e-cell-checkbox.c
@@ -50,13 +50,13 @@ ecc_print (ECellView *ecell_view, GtkPrintContext *context,
 	cairo_save (cr);
 
 	if ( value == 1) {
-
 		cairo_set_line_width (cr, 2);
 		cairo_move_to (cr, 3, 11);
 		cairo_line_to (cr, 7, 14);
 		cairo_line_to (cr, 11, 5);
 		cairo_stroke (cr);
 	}
+
 	cairo_restore (cr);
 }
 
diff --git a/widgets/table/e-cell-hbox.c b/widgets/table/e-cell-hbox.c
index ab087df..7cfd8b2 100644
--- a/widgets/table/e-cell-hbox.c
+++ b/widgets/table/e-cell-hbox.c
@@ -163,6 +163,7 @@ ecv_draw (ECellView *ecell_view,
 		if (width < hbox_view->def_size_cols[i])
 			width = hbox_view->def_size_cols[i];
 		printf("width of %d %d of %d\n", width,hbox_view->def_size_cols[i], allotted_width ); */
+
 		e_cell_draw (
 			hbox_view->subcell_views[i], cr,
 			hbox_view->model_cols[i], view_col, row, flags,
diff --git a/widgets/table/e-cell-pixbuf.c b/widgets/table/e-cell-pixbuf.c
index b634683..ec70dd8 100644
--- a/widgets/table/e-cell-pixbuf.c
+++ b/widgets/table/e-cell-pixbuf.c
@@ -193,17 +193,20 @@ pixbuf_print (ECellView *ecell_view, GtkPrintContext *context,
 	GdkPixbuf *pixbuf;
 	gint scale;
 	cairo_t *cr = gtk_print_context_get_cairo_context (context);
+	cairo_matrix_t save_matrix;
 
 	pixbuf = (GdkPixbuf *) e_table_model_value_at (ecell_view->e_table_model, 1, row);
 	if (pixbuf == NULL)
 		return;
 
 	scale = gdk_pixbuf_get_height (pixbuf);
+	cairo_get_matrix (cr, &save_matrix);
 	cairo_save (cr);
 	cairo_translate (cr, 0, (gdouble)(height - scale) / (gdouble)2);
 	gdk_cairo_set_source_pixbuf (cr, pixbuf, (gdouble)scale, (gdouble)scale);
 	cairo_paint (cr);
 	cairo_restore (cr);
+	cairo_set_matrix (cr, &save_matrix);
 }
 
 static gdouble
diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c
index 39d7234..95c5668 100644
--- a/widgets/table/e-cell-popup.c
+++ b/widgets/table/e-cell-popup.c
@@ -258,6 +258,8 @@ ecp_draw (ECellView *ecv, cairo_t *cr,
 	GdkRectangle rect;
 	gboolean show_popup_arrow;
 
+	cairo_save (cr);
+
 	canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ecv->e_table_item_view)->canvas);
 
 	/* Display the popup arrow if we are the cursor cell, or the popup
@@ -308,6 +310,8 @@ ecp_draw (ECellView *ecv, cairo_t *cr,
 		e_cell_draw (ecp_view->child_view, cr, model_col,
 			     view_col, row, flags, x1, y1, x2, y2);
 	}
+
+	cairo_restore (cr);
 }
 
 /*
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 0a44654..c3cbeeb 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -687,6 +687,7 @@ ect_draw (ECellView *ecell_view, cairo_t *cr,
 	GtkStyle *style;
 	gint x_origin, y_origin, vspacing;
 
+	cairo_save (cr);
 	style = gtk_widget_get_style (canvas);
 
 	selected = flags & E_CELL_SELECTED;
@@ -773,6 +774,7 @@ ect_draw (ECellView *ecell_view, cairo_t *cr,
 	}
 
 	g_object_unref (layout);
+	cairo_restore (cr);
 }
 
 /*
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index f08c580..51a764d 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -238,6 +238,8 @@ ect_draw (ECellView *ecell_view,
 
 	selected = flags & E_CELL_SELECTED;
 
+	cairo_save (cr);
+
 	/* only draw the tree effects if we're the active sort */
 	if (/* XXX */ TRUE) {
 		GdkPixbuf *node_image;
@@ -293,6 +295,8 @@ ect_draw (ECellView *ecell_view,
 	e_cell_draw (tree_view->subcell_view, cr,
 		     model_col, view_col, row, flags,
 		     x1 + subcell_offset, y1, x2, y2);
+
+	cairo_restore (cr);
 }
 
 static void
@@ -620,7 +624,9 @@ ect_print (ECellView *ecell_view, GtkPrintContext *context,
 {
 	ECellTreeView *tree_view = (ECellTreeView *) ecell_view;
 	cairo_t *cr = gtk_print_context_get_cairo_context (context);
+	cairo_matrix_t save_matrix;
 
+	cairo_get_matrix (cr, &save_matrix);
 	cairo_save (cr);
 
 	if (/* XXX only if we're the active sort */ TRUE) {
@@ -688,6 +694,7 @@ ect_print (ECellView *ecell_view, GtkPrintContext *context,
 	}
 
 	cairo_restore (cr);
+	cairo_set_matrix (cr, &save_matrix);
 
 	e_cell_print (tree_view->subcell_view, context, model_col, view_col, row, width, height);
 }
diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c
index d1f61c8..67d2e1c 100644
--- a/widgets/table/e-cell.c
+++ b/widgets/table/e-cell.c
@@ -261,11 +261,19 @@ e_cell_draw (ECellView *ecell_view, cairo_t *cr,
 	     gint model_col, gint view_col, gint row, ECellFlags flags,
 	     gint x1, gint y1, gint x2, gint y2)
 {
+	cairo_matrix_t save_matrix;
+
 	g_return_if_fail (ecell_view != NULL);
 	g_return_if_fail (row >= 0);
 	g_return_if_fail (row < e_table_model_row_count (ecell_view->e_table_model));
 
+	cairo_get_matrix (cr, &save_matrix);
+	cairo_save (cr);
+
 	ECVIEW_EC_CLASS (ecell_view)->draw (ecell_view, cr, model_col, view_col, row, flags, x1, y1, x2, y2);
+
+	cairo_restore (cr);
+	cairo_set_matrix (cr, &save_matrix);
 }
 
 /**
diff --git a/widgets/table/e-table-field-chooser-item.c b/widgets/table/e-table-field-chooser-item.c
index bc48d4f..a9e659d 100644
--- a/widgets/table/e-table-field-chooser-item.c
+++ b/widgets/table/e-table-field-chooser-item.c
@@ -505,6 +505,8 @@ etfci_draw (GnomeCanvasItem *item,
 		if (y2 < y)
 			continue;
 
+		cairo_save (cr);
+
 		e_table_header_draw_button (cr, ecol,
 					    style, state,
 					    GTK_WIDGET (canvas),
@@ -512,6 +514,8 @@ etfci_draw (GnomeCanvasItem *item,
 					    width, height,
 					    etfci->width, y2 - y1,
 					    E_TABLE_COL_ARROW_NONE);
+
+		cairo_restore (cr);
 	}
 }
 
diff --git a/widgets/table/e-table-header-utils.c b/widgets/table/e-table-header-utils.c
index 47fa422..da60ce0 100644
--- a/widgets/table/e-table-header-utils.c
+++ b/widgets/table/e-table-header-utils.c
@@ -271,7 +271,7 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol,
 		gtk_widget_realize (g_label);
 	}
 
-
+	cairo_save (cr);
         gdk_cairo_set_source_color (cr, &gtk_widget_get_style (GTK_WIDGET (g_label))->fg[state]);
 
 	xthick = style->xthickness;
@@ -289,6 +289,7 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol,
 	inner_height = button_height - 2 * (ythick + HEADER_PADDING);
 
 	if (inner_width < 1 || inner_height < 1) {
+		cairo_restore (cr);
 		return; /* nothing fits */
 	}
 
@@ -310,10 +311,12 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol,
 			inner_width -= arrow_width + HEADER_PADDING;
 		break;
 	default:
+		cairo_restore (cr);
 		g_return_if_reached ();
 	}
 
 	if (inner_width < 1) {
+		cairo_restore (cr);
 		return; /* nothing else fits */
 	}
 
@@ -404,8 +407,10 @@ e_table_header_draw_button (cairo_t *cr, ETableCol *ecol,
 	}
 
 	default:
+		cairo_restore (cr);
 		g_return_if_reached ();
 	}
 
 	g_object_unref (layout);
+	cairo_restore (cr);
 }
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 7707c29..45b9389 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -3417,7 +3417,9 @@ e_table_item_print_page  (EPrintable *ep,
 
 		for (col = 0; col < cols; col++) {
 			ECellView *ecell_view = eti->cell_views[col];
+			cairo_matrix_t save_matrix;
 
+			cairo_get_matrix (cr, &save_matrix);
 			cairo_save (cr);
 			cairo_translate (cr, xd, yd);
 			cairo_rectangle (cr, 0, 0, widths[col] - 1, row_height);
@@ -3431,6 +3433,8 @@ e_table_item_print_page  (EPrintable *ep,
 				      row_height + 2 );
 
 			cairo_restore (cr);
+			cairo_set_matrix (cr, &save_matrix);
+
 			xd += widths[col];
 		}
 
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index ef3e7d9..0f68cc2 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -1450,6 +1450,8 @@ e_text_draw (GnomeCanvasItem *item, cairo_t *cr,
 	xpos = xpos - x + text->xofs;
 	ypos = ypos - y + text->yofs;
 
+	cairo_save (cr);
+
 	if (text->clip) {
                 cairo_rectangle (cr,
                                  xpos, ypos,
@@ -1512,6 +1514,8 @@ e_text_draw (GnomeCanvasItem *item, cairo_t *cr,
 			}
 		}
 	}
+
+	cairo_restore (cr);
 }
 
 /* Point handler for the text item */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]