ACK

On 09/23/2011 01:22 AM, Marc-André Lureau wrote:
---
  gtk/Makefile.am          |    2 +
  gtk/display/gnome-rr.c   |   46 +-------------------------------
  gtk/glib-compat.h        |   65 ++++++++++++++++++++++++++++++++++++++++++++++
  gtk/smartcard-manager.c  |    2 +
  gtk/usb-device-manager.c |    2 +
  5 files changed, 73 insertions(+), 44 deletions(-)
  create mode 100644 gtk/glib-compat.h

diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 31e2a77..43da8d2 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -186,6 +186,7 @@ GUSB_SRCS =
  endif

  libspice_client_glib_2_0_la_SOURCES = \
+       glib-compat.h                   \
        spice-audio.c                   \
        spice-common.h                  \
        spice-util.c                    \
@@ -317,6 +318,7 @@ libspice_client_glib_2_0_la_LIBADD += $(GTHREAD_LIBS)
  endif

  displaysrc = \
+       glib-compat.h                           \
        display/edid.h                          \
        display/edid-parse.c                    \
        display/display-name.c                  \
diff --git a/gtk/display/gnome-rr.c b/gtk/display/gnome-rr.c
index 71902bd..5de86dd 100644
--- a/gtk/display/gnome-rr.c
+++ b/gtk/display/gnome-rr.c
@@ -30,6 +30,8 @@

  #include<gtk/gtk.h>

+#include "../glib-compat.h"
+
  #if defined(HAVE_X11)
  #include<X11/Xlib.h>
  #include<gdk/gdkx.h>
@@ -77,50 +79,6 @@ static void gnome_rr_screen_initable_iface_init 
(GInitableIface *iface);
  G_DEFINE_TYPE_WITH_CODE (GnomeRRScreen, gnome_rr_screen, G_TYPE_OBJECT,
          G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, 
gnome_rr_screen_initable_iface_init))

-#if !GLIB_CHECK_VERSION(2,26,0)
-#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) 
G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {})
-#define G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName, type_name, copy_func, 
free_func, _C_) _G_DEFINE_BOXED_TYPE_BEGIN (TypeName, type_name, copy_func, 
free_func) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
-#if __GNUC__>  2 || (__GNUC__ == 2&&  __GNUC_MINOR__>= 7)
-#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
-GType \
-type_name##_get_type (void) \
-{ \
-  static volatile gsize g_define_type_id__volatile = 0; \
-  if (g_once_init_enter (&g_define_type_id__volatile))  \
-    { \
-      GType (* _g_register_boxed) \
-        (const gchar *, \
-         union \
-           { \
-             TypeName * (*do_copy_type) (TypeName *); \
-             TypeName * (*do_const_copy_type) (const TypeName *); \
-             GBoxedCopyFunc do_copy_boxed; \
-           } __attribute__((__transparent_union__)), \
-         union \
-           { \
-             void (* do_free_type) (TypeName *); \
-             GBoxedFreeFunc do_free_boxed; \
-           } __attribute__((__transparent_union__)) \
-        ) = g_boxed_type_register_static; \
-      GType g_define_type_id = \
-        _g_register_boxed (g_intern_static_string (#TypeName), copy_func, 
free_func); \
-      { /* custom code follows */
-#else
-#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
-GType \
-type_name##_get_type (void) \
-{ \
-  static volatile gsize g_define_type_id__volatile = 0; \
-  if (g_once_init_enter (&g_define_type_id__volatile))  \
-    { \
-      GType g_define_type_id = \
-        g_boxed_type_register_static (g_intern_static_string (#TypeName), \
-                                      (GBoxedCopyFunc) copy_func, \
-                                      (GBoxedFreeFunc) free_func); \
-      { /* custom code follows */
-#endif /* __GNUC__ */
-#endif /* glib 2.26 */
-
  G_DEFINE_BOXED_TYPE (GnomeRRCrtc, gnome_rr_crtc, crtc_copy, crtc_free)
  G_DEFINE_BOXED_TYPE (GnomeRROutput, gnome_rr_output, output_copy, output_free)
  G_DEFINE_BOXED_TYPE (GnomeRRMode, gnome_rr_mode, mode_copy, mode_free)
diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
new file mode 100644
index 0000000..b111c91
--- /dev/null
+++ b/gtk/glib-compat.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   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 GLIB_COMPAT_H
+#define GLIB_COMPAT_H
+
+#include<glib-object.h>
+
+#if !GLIB_CHECK_VERSION(2,26,0)
+#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) 
G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {})
+#define G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName, type_name, copy_func, 
free_func, _C_) _G_DEFINE_BOXED_TYPE_BEGIN (TypeName, type_name, copy_func, 
free_func) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
+#if __GNUC__>  2 || (__GNUC__ == 2&&  __GNUC_MINOR__>= 7)
+#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
+GType \
+type_name##_get_type (void) \
+{ \
+  static volatile gsize g_define_type_id__volatile = 0; \
+  if (g_once_init_enter (&g_define_type_id__volatile))  \
+    { \
+      GType (* _g_register_boxed) \
+        (const gchar *, \
+         union \
+           { \
+             TypeName * (*do_copy_type) (TypeName *); \
+             TypeName * (*do_const_copy_type) (const TypeName *); \
+             GBoxedCopyFunc do_copy_boxed; \
+           } __attribute__((__transparent_union__)), \
+         union \
+           { \
+             void (* do_free_type) (TypeName *); \
+             GBoxedFreeFunc do_free_boxed; \
+           } __attribute__((__transparent_union__)) \
+        ) = g_boxed_type_register_static; \
+      GType g_define_type_id = \
+        _g_register_boxed (g_intern_static_string (#TypeName), copy_func, 
free_func); \
+      { /* custom code follows */
+#else
+#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
+GType \
+type_name##_get_type (void) \
+{ \
+  static volatile gsize g_define_type_id__volatile = 0; \
+  if (g_once_init_enter (&g_define_type_id__volatile))  \
+    { \
+      GType g_define_type_id = \
+        g_boxed_type_register_static (g_intern_static_string (#TypeName), \
+                                      (GBoxedCopyFunc) copy_func, \
+                                      (GBoxedFreeFunc) free_func); \
+      { /* custom code follows */
+#endif /* __GNUC__ */
+#endif /* glib 2.26 */
+
+#endif /* GLIB_COMPAT_H */
diff --git a/gtk/smartcard-manager.c b/gtk/smartcard-manager.c
index 806aee5..df29088 100644
--- a/gtk/smartcard-manager.c
+++ b/gtk/smartcard-manager.c
@@ -20,6 +20,8 @@
  #include<glib-object.h>
  #include<string.h>

+#include "glib-compat.h"
+
  #ifdef USE_SMARTCARD
  #include<vcard_emul.h>
  #include<vevent.h>
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index b14369a..f2dbf90 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -24,6 +24,8 @@
  #include<glib-object.h>
  #include<gio/gio.h>  /* For GInitable */

+#include "glib-compat.h"
+
  #ifdef USE_USBREDIR
  #include<gusb/gusb-source.h>
  #include<gusb/gusb-device-list.h>
_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to