<div dir="ltr">ack series<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 14, 2014 at 7:00 PM, Christophe Fergeau <span dir="ltr"><<a href="mailto:cfergeau@redhat.com" target="_blank">cfergeau@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There are gtk+ version checks in several source files to add<br>
compatibility implementations of gtk3 functions not available<br>
in gtk2. This commit gathers all of them in a gtk-compat.h header,<br>
similar to what is done for glib-compat.h<br>
---<br>
 gtk/Makefile.am          |  1 +<br>
 gtk/gtk-compat.h         | 57 ++++++++++++++++++++++++++++++++++++++++++++++++<br>
 gtk/spice-widget-cairo.c | 18 +--------------<br>
 gtk/spice-widget.c       | 21 +-----------------<br>
 gtk/vncdisplaykeymap.c   |  6 +----<br>
 5 files changed, 61 insertions(+), 42 deletions(-)<br>
 create mode 100644 gtk/gtk-compat.h<br>
<br>
diff --git a/gtk/Makefile.am b/gtk/Makefile.am<br>
index e28220c..8da1a11 100644<br>
--- a/gtk/Makefile.am<br>
+++ b/gtk/Makefile.am<br>
@@ -122,6 +122,7 @@ SPICE_GTK_LIBADD_COMMON =           \<br>
<br>
 SPICE_GTK_SOURCES_COMMON =             \<br>
        glib-compat.h                   \<br>
+       gtk-compat.h                    \<br>
        spice-util.c                    \<br>
        spice-util-priv.h               \<br>
        spice-gtk-session.c             \<br>
diff --git a/gtk/gtk-compat.h b/gtk/gtk-compat.h<br>
new file mode 100644<br>
index 0000000..686239d<br>
--- /dev/null<br>
+++ b/gtk/gtk-compat.h<br>
@@ -0,0 +1,57 @@<br>
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */<br>
+/*<br>
+   Copyright (C) 2012-2014 Red Hat, Inc.<br>
+   Copyright © 1998-2009 VLC authors and VideoLAN<br>
+<br>
+   This library is free software; you can redistribute it and/or<br>
+   modify it under the terms of the GNU Lesser General Public<br>
+   License as published by the Free Software Foundation; either<br>
+   version 2.1 of the License, or (at your option) any later version.<br>
+<br>
+   This library is distributed in the hope that it will be useful,<br>
+   but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<br>
+   Lesser General Public License for more details.<br>
+<br>
+   You should have received a copy of the GNU Lesser General Public<br>
+   License along with this library; if not, see <<a href="http://www.gnu.org/licenses/" target="_blank">http://www.gnu.org/licenses/</a>>.<br>
+*/<br>
+#ifndef GTK_COMPAT_H<br>
+#define GTK_COMPAT_H<br>
+<br>
+#include "config.h"<br>
+<br>
+#include <gtk/gtk.h><br>
+<br>
+#if !GTK_CHECK_VERSION (2, 91, 0)<br>
+#define GDK_IS_X11_DISPLAY(D) TRUE<br>
+#define gdk_window_get_display(W) gdk_drawable_get_display(GDK_DRAWABLE(W))<br>
+#endif<br>
+<br>
+#if GTK_CHECK_VERSION (2, 91, 0)<br>
+static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)<br>
+{<br>
+    *ww = gdk_window_get_width(w);<br>
+    *wh = gdk_window_get_height(w);<br>
+}<br>
+#endif<br>
+<br>
+#if !GTK_CHECK_VERSION(2, 20, 0)<br>
+static inline gboolean gtk_widget_get_realized(GtkWidget *widget)<br>
+{<br>
+    g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);<br>
+    return GTK_WIDGET_REALIZED(widget);<br>
+}<br>
+#endif<br>
+<br>
+#if !GTK_CHECK_VERSION (3, 0, 0)<br>
+#define cairo_rectangle_int_t GdkRectangle<br>
+#define cairo_region_t GdkRegion<br>
+#define cairo_region_create_rectangle gdk_region_rectangle<br>
+#define cairo_region_subtract_rectangle(_dest,_rect) { GdkRegion *_region = gdk_region_rectangle (_rect); gdk_region_subtract (_dest, _region); gdk_region_destroy (_region); }<br>
+#define cairo_region_destroy gdk_region_destroy<br>
+<br>
+#define gdk_window_get_display(W) gdk_drawable_get_display(GDK_DRAWABLE(W))<br>
+#endif<br>
+<br>
+#endif /* GTK_COMPAT_H */<br>
diff --git a/gtk/spice-widget-cairo.c b/gtk/spice-widget-cairo.c<br>
index 107b0dc..881cc5d 100644<br>
--- a/gtk/spice-widget-cairo.c<br>
+++ b/gtk/spice-widget-cairo.c<br>
@@ -17,18 +17,10 @@<br>
 */<br>
 #include "config.h"<br>
<br>
+#include "gtk-compat.h"<br>
 #include "spice-widget.h"<br>
 #include "spice-widget-priv.h"<br>
<br>
-/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */<br>
-#if GTK_CHECK_VERSION (2, 91, 0)<br>
-<br>
-static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)<br>
-{<br>
-       *ww = gdk_window_get_width(w);<br>
-       *wh = gdk_window_get_height(w);<br>
-}<br>
-#endif<br>
<br>
 G_GNUC_INTERNAL<br>
 int spicex_image_create(SpiceDisplay *display)<br>
@@ -72,14 +64,6 @@ void spicex_image_destroy(SpiceDisplay *display)<br>
     d->convert = FALSE;<br>
 }<br>
<br>
-#if !GTK_CHECK_VERSION (3, 0, 0)<br>
-#define cairo_rectangle_int_t GdkRectangle<br>
-#define cairo_region_t GdkRegion<br>
-#define cairo_region_create_rectangle gdk_region_rectangle<br>
-#define cairo_region_subtract_rectangle(_dest,_rect) { GdkRegion *_region = gdk_region_rectangle (_rect); gdk_region_subtract (_dest, _region); gdk_region_destroy (_region); }<br>
-#define cairo_region_destroy gdk_region_destroy<br>
-#endif<br>
-<br>
 G_GNUC_INTERNAL<br>
 void spicex_draw_event(SpiceDisplay *display, cairo_t *cr)<br>
 {<br>
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c<br>
index 2044513..9b835f0 100644<br>
--- a/gtk/spice-widget.c<br>
+++ b/gtk/spice-widget.c<br>
@@ -41,28 +41,9 @@<br>
 #include "vncdisplaykeymap.h"<br>
<br>
 #include "glib-compat.h"<br>
+#include "gtk-compat.h"<br>
<br>
 /* Some compatibility defines to let us build on both Gtk2 and Gtk3 */<br>
-#if GTK_CHECK_VERSION (2, 91, 0)<br>
-static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)<br>
-{<br>
-    *ww = gdk_window_get_width(w);<br>
-    *wh = gdk_window_get_height(w);<br>
-}<br>
-#endif<br>
-<br>
-#if !GTK_CHECK_VERSION (2, 91, 0)<br>
-#define GDK_IS_X11_DISPLAY(D) TRUE<br>
-#define gdk_window_get_display(W) gdk_drawable_get_display(GDK_DRAWABLE(W))<br>
-#endif<br>
-<br>
-#if !GTK_CHECK_VERSION(2, 20, 0)<br>
-static gboolean gtk_widget_get_realized(GtkWidget *widget)<br>
-{<br>
-    g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);<br>
-    return GTK_WIDGET_REALIZED(widget);<br>
-}<br>
-#endif<br>
<br>
 /**<br>
  * SECTION:spice-widget<br>
diff --git a/gtk/vncdisplaykeymap.c b/gtk/vncdisplaykeymap.c<br>
index 22c6b07..b2da5e5 100644<br>
--- a/gtk/vncdisplaykeymap.c<br>
+++ b/gtk/vncdisplaykeymap.c<br>
@@ -12,6 +12,7 @@<br>
 #include <gtk/gtk.h><br>
 #include <gdk/gdk.h><br>
 #include <gdk/gdkkeysyms.h><br>
+#include "gtk-compat.h"<br>
 #include "vncdisplaykeymap.h"<br>
<br>
 #include "spice-util.h"<br>
@@ -50,11 +51,6 @@<br>
 #define GDK_Tab GDK_KEY_Tab<br>
 #endif<br>
<br>
-#if !GTK_CHECK_VERSION(3,0,0)<br>
-#define gdk_window_get_display(W) gdk_drawable_get_display(GDK_DRAWABLE(W))<br>
-#endif<br>
-<br>
-<br>
 /* keycode translation for sending ISO_Left_Send<br>
  * to vncserver<br>
  */<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.0<br>
<br>
_______________________________________________<br>
Spice-devel mailing list<br>
<a href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/spice-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/spice-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Marc-André Lureau
</div>