Patchwork [ui/gtk,09/13] Replace expose-event handler with draw handler in GTK3

login
register
mail settings
Submitter Daniel P. Berrange
Date Feb. 25, 2013, 3:20 p.m.
Message ID <1361805646-6425-10-git-send-email-berrange@redhat.com>
Download mbox | patch
Permalink /patch/222932/
State New
Headers show

Comments

Daniel P. Berrange - Feb. 25, 2013, 3:20 p.m.
From: "Daniel P. Berrange" <berrange@redhat.com>

In GTK3 the 'expose-event' signal has been replaced by a new
'draw' signal. The only difference is that the latter will
pre-create the cairo drawing context & set the clip mask.
Since the drawing code is already structured in a nice way,
we can just wire up the 'gd_draw_event' method to the 'draw'
signal in GTK3

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 ui/gtk.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch

diff --git a/ui/gtk.c b/ui/gtk.c
index c89c7c4..fa4c3b0 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -433,6 +433,7 @@  static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
     return TRUE;
 }
 
+#if !GTK_CHECK_VERSION(3, 0, 0)
 static gboolean gd_expose_event(GtkWidget *widget, GdkEventExpose *expose,
                                 void *opaque)
 {
@@ -453,6 +454,7 @@  static gboolean gd_expose_event(GtkWidget *widget, GdkEventExpose *expose,
 
     return ret;
 }
+#endif
 
 static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
                                 void *opaque)
@@ -1100,8 +1102,13 @@  static void gd_connect_signals(GtkDisplayState *s)
     g_signal_connect(s->window, "delete-event",
                      G_CALLBACK(gd_window_close), s);
 
+#if GTK_CHECK_VERSION(3, 0, 0)
+    g_signal_connect(s->drawing_area, "draw",
+                     G_CALLBACK(gd_draw_event), s);
+#else
     g_signal_connect(s->drawing_area, "expose-event",
                      G_CALLBACK(gd_expose_event), s);
+#endif
     g_signal_connect(s->drawing_area, "motion-notify-event",
                      G_CALLBACK(gd_motion_event), s);
     g_signal_connect(s->drawing_area, "button-press-event",