diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2012-01-12 13:41:09 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2012-01-12 16:10:37 +0100 |
commit | 2c61fd3d806eb0b358de882c2c7db42d39b43b5f (patch) | |
tree | 4a32386c4a6c9385abcc4c5f17e786732b02a535 | |
parent | 6f37c55b5baf27e247d25f0fde9a634e335afe48 (diff) | |
download | spice-gtk-2c61fd3d806eb0b358de882c2c7db42d39b43b5f.tar.gz spice-gtk-2c61fd3d806eb0b358de882c2c7db42d39b43b5f.tar.xz spice-gtk-2c61fd3d806eb0b358de882c2c7db42d39b43b5f.zip |
Lower our glib requirement to 2.22, as we claim
Required to build on RHEL, even upcoming 6.3
-rw-r--r-- | gtk/Makefile.am | 3 | ||||
-rw-r--r-- | gtk/channel-usbredir.c | 1 | ||||
-rw-r--r-- | gtk/glib-compat.c | 49 | ||||
-rw-r--r-- | gtk/glib-compat.h | 40 | ||||
-rw-r--r-- | gtk/spice-audio.c | 2 | ||||
-rw-r--r-- | gtk/spice-client-glib-usb-acl-helper.c | 2 | ||||
-rw-r--r-- | gtk/spice-session.c | 1 | ||||
-rw-r--r-- | gtk/usb-acl-helper.c | 1 |
8 files changed, 99 insertions, 0 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 85a78a6..8279846 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -185,6 +185,7 @@ USB_ACL_HELPER_SRCS = endif libspice_client_glib_2_0_la_SOURCES = \ + glib-compat.c \ glib-compat.h \ spice-audio.c \ spice-audio-priv.h \ @@ -366,6 +367,8 @@ spicy_CPPFLAGS = \ if WITH_POLKIT spice_client_glib_usb_acl_helper_SOURCES = \ + glib-compat.c \ + glib-compat.h \ spice-client-glib-usb-acl-helper.c \ $(NULL) diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c index 5f0f409..10d266c 100644 --- a/gtk/channel-usbredir.c +++ b/gtk/channel-usbredir.c @@ -34,6 +34,7 @@ #include "spice-common.h" #include "spice-channel-priv.h" +#include "glib-compat.h" /** * SECTION:channel-usbredir diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c new file mode 100644 index 0000000..7bb906c --- /dev/null +++ b/gtk/glib-compat.c @@ -0,0 +1,49 @@ +/* -*- 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/>. +*/ + +#include "glib-compat.h" + +#if !GLIB_CHECK_VERSION(2,26,0) +G_DEFINE_BOXED_TYPE (GError, spice_error, g_error_copy, g_error_free) +#endif + +#if !GLIB_CHECK_VERSION(2,28,0) +/** + * spice_simple_async_result_take_error: (skip) + * @simple: a #GSimpleAsyncResult + * @error: a #GError + * + * Sets the result from @error, and takes over the caller's ownership + * of @error, so the caller does not need to free it any more. + * + * Since: 2.28 + **/ +G_GNUC_INTERNAL void +g_simple_async_result_take_error (GSimpleAsyncResult *simple, + GError *error) +{ + /* this code is different from upstream */ + /* we can't avoid extra copy/free, since the simple struct is + opaque */ + g_simple_async_result_set_from_error (simple, error); + g_error_free (error); +} +#endif + +#if !GLIB_CHECK_VERSION(2,30,0) +G_DEFINE_BOXED_TYPE (GMainContext, spice_main_context, g_main_context_ref, g_main_context_unref) +#endif + diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h index 2766de0..bd8f3de 100644 --- a/gtk/glib-compat.h +++ b/gtk/glib-compat.h @@ -17,6 +17,7 @@ #define GLIB_COMPAT_H #include <glib-object.h> +#include <gio/gio.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, {}) @@ -60,8 +61,47 @@ type_name##_get_type (void) \ (GBoxedFreeFunc) free_func); \ { /* custom code follows */ #endif /* __GNUC__ */ + +#define g_source_set_name(source, name) G_STMT_START { } G_STMT_END + +#define G_TYPE_ERROR (spice_error_get_type ()) +GType spice_error_get_type (void) G_GNUC_CONST; + +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +#define G_GNUC_DEPRECATED_FOR(f) \ + __attribute__((deprecated("Use " #f " instead"))) +#else +#define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED +#endif /* __GNUC__ */ + +#define G_PARAM_DEPRECATED (1 << 31) #endif /* glib 2.26 */ +#if !GLIB_CHECK_VERSION(2,28,0) +#define g_clear_object(object_ptr) \ + G_STMT_START { \ + /* Only one access, please */ \ + gpointer *_p = (gpointer) (object_ptr); \ + gpointer _o; \ + \ + do \ + _o = g_atomic_pointer_get (_p); \ + while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (_p, _o, NULL));\ + \ + if (_o) \ + g_object_unref (_o); \ + } G_STMT_END + +void +g_simple_async_result_take_error(GSimpleAsyncResult *simple, + GError *error); +#endif /* glib 2.28 */ + +#if !GLIB_CHECK_VERSION(2,30,0) +#define G_TYPE_MAIN_CONTEXT (spice_main_context_get_type ()) +GType spice_main_context_get_type (void) G_GNUC_CONST; +#endif + #if !GLIB_CHECK_VERSION(2,32,0) # define G_SIGNAL_DEPRECATED (1 << 9) #endif diff --git a/gtk/spice-audio.c b/gtk/spice-audio.c index b9d1011..f58a81e 100644 --- a/gtk/spice-audio.c +++ b/gtk/spice-audio.c @@ -51,6 +51,8 @@ #include "spice-gstaudio.h" #endif +#include "glib-compat.h" + #define SPICE_AUDIO_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SPICE_TYPE_AUDIO, SpiceAudioPrivate)) diff --git a/gtk/spice-client-glib-usb-acl-helper.c b/gtk/spice-client-glib-usb-acl-helper.c index 698820b..311404e 100644 --- a/gtk/spice-client-glib-usb-acl-helper.c +++ b/gtk/spice-client-glib-usb-acl-helper.c @@ -33,6 +33,8 @@ #include <polkit/polkit.h> #include <acl/libacl.h> +#include "glib-compat.h" + #define FATAL_ERROR(...) \ do { \ /* We print the error both to stdout, for the app invoking us and \ diff --git a/gtk/spice-session.c b/gtk/spice-session.c index be6753a..ef4f3c1 100644 --- a/gtk/spice-session.c +++ b/gtk/spice-session.c @@ -28,6 +28,7 @@ #include "ring.h" #include "gio-coroutine.h" +#include "glib-compat.h" struct channel { SpiceChannel *channel; diff --git a/gtk/usb-acl-helper.c b/gtk/usb-acl-helper.c index 7fe8404..b79e122 100644 --- a/gtk/usb-acl-helper.c +++ b/gtk/usb-acl-helper.c @@ -26,6 +26,7 @@ #include <string.h> #include "usb-acl-helper.h" +#include "glib-compat.h" /* ------------------------------------------------------------------ */ /* gobject glue */ |