summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonsta <[email protected]>2015-11-02 14:40:19 +0300
committerMonsta <[email protected]>2015-11-02 14:47:56 +0300
commit385ec7a3f0e8938206813c17142a8beab5955191 (patch)
treec3fb441f8543d22daa6bbd87b924e085cb1ed667
parente29b9b4c99dcf9df21d417d2d107cdcdc69392b6 (diff)
downloadpluma-385ec7a3f0e8938206813c17142a8beab5955191.tar.bz2
pluma-385ec7a3f0e8938206813c17142a8beab5955191.tar.xz
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
-rw-r--r--pluma/pluma-print-preview.c28
1 files 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);