From 385ec7a3f0e8938206813c17142a8beab5955191 Mon Sep 17 00:00:00 2001 From: Monsta Date: Mon, 2 Nov 2015 14:40:19 +0300 Subject: GTK+3: work with "draw" signal instead of "expose" in print preview adapted from https://git.gnome.org/browse/gedit/commit?id=9453de86abac1cf1bf4702091944301ac800bdef fixes https://github.com/mate-desktop/pluma/issues/47 --- pluma/pluma-print-preview.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/pluma/pluma-print-preview.c b/pluma/pluma-print-preview.c index 7effe8e2..51390cb7 100644 --- a/pluma/pluma-print-preview.c +++ b/pluma/pluma-print-preview.c @@ -1103,26 +1103,40 @@ draw_page (cairo_t *cr, } static gboolean +#if GTK_CHECK_VERSION (3, 0, 0) +preview_draw (GtkWidget *widget, + cairo_t *cr, +#else preview_expose (GtkWidget *widget, GdkEventExpose *event, +#endif PlumaPrintPreview *preview) { PlumaPrintPreviewPrivate *priv; GdkWindow *bin_window; - cairo_t *cr; gint pg; gint i, j; priv = preview->priv; bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (priv->layout)); + +#if GTK_CHECK_VERSION (3, 0, 0) + if (!gtk_cairo_should_draw_window (cr, bin_window)) + return TRUE; + + cairo_save (cr); + + gtk_cairo_transform_to_window (cr, widget, bin_window); +#else if (event->window != bin_window) return FALSE; - cr = gdk_cairo_create (bin_window); + cairo_t *cr = gdk_cairo_create (bin_window); gdk_cairo_rectangle (cr, &event->area); cairo_clip (cr); +#endif /* get the first page to display */ pg = get_first_page_displayed (preview); @@ -1149,7 +1163,12 @@ preview_expose (GtkWidget *widget, ++pg; } } + +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif return TRUE; } @@ -1205,8 +1224,13 @@ preview_ready (GtkPrintOperationPreview *gtk_preview, /* let the default gtklayout handler clear the background */ g_signal_connect_after (preview->priv->layout, +#if GTK_CHECK_VERSION (3, 0, 0) + "draw", + G_CALLBACK (preview_draw), +#else "expose-event", G_CALLBACK (preview_expose), +#endif preview); gtk_widget_queue_draw (preview->priv->layout); -- cgit v1.2.1