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