[Spice-commits] 3 commits - configure.ac gtk/channel-usbredir.c gtk/glib-compat.c gtk/glib-compat.h gtk/Makefile.am gtk/spice-audio.c gtk/spice-client-glib-usb-acl-helper.c gtk/spice-session.c gtk/spice-widget.c gtk/usb-acl-helper.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Thu Jan 12 07:11:00 PST 2012


 configure.ac                           |    5 ++-
 gtk/Makefile.am                        |    3 ++
 gtk/channel-usbredir.c                 |    1 
 gtk/glib-compat.c                      |   49 +++++++++++++++++++++++++++++++++
 gtk/glib-compat.h                      |   40 ++++++++++++++++++++++++++
 gtk/spice-audio.c                      |    2 +
 gtk/spice-client-glib-usb-acl-helper.c |   17 +++++++++++
 gtk/spice-session.c                    |    1 
 gtk/spice-widget.c                     |   14 ++++++++-
 gtk/usb-acl-helper.c                   |    1 
 10 files changed, 130 insertions(+), 3 deletions(-)

New commits:
commit 99567e256b874792ec1f77048b946140beebafc5
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Jan 12 14:24:07 2012 +0100

    Lower our gtk+ requirement to 2.18, as we claim
    
    Needed to build on RHEL6

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 5ed2e10..1dd06f1 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -39,13 +39,15 @@
 #include "spice-gtk-session-priv.h"
 #include "vncdisplaykeymap.h"
 
+#include "glib-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);
+    *ww = gdk_window_get_width(w);
+    *wh = gdk_window_get_height(w);
 }
 
 #define GtkObject GtkWidget
@@ -54,6 +56,14 @@ static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
 
 #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
  * @short_description: a GTK display widget
commit 88784261f91bedf8930e71d2b313265193f86369
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Jan 12 13:45:48 2012 +0100

    Lower polkit requirement to 0.96

diff --git a/configure.ac b/configure.ac
index 98e0d5e..71f24ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -336,7 +336,7 @@ else
   if test "x$enable_polkit" = "xno"; then
     AM_CONDITIONAL(WITH_POLKIT, false)
   else
-    PKG_CHECK_MODULES(POLKIT, polkit-gobject-1)
+    PKG_CHECK_MODULES(POLKIT, polkit-gobject-1 >= 0.96)
     AC_CHECK_HEADER([acl/libacl.h],,
                     AC_MSG_ERROR([cannot find headers for libacl]))
     AC_CHECK_LIB([acl], [acl_get_file], [ACL_LIBS=-lacl] [AC_SUBST(ACL_LIBS)],
@@ -345,6 +345,9 @@ else
     AM_CONDITIONAL(WITH_POLKIT, true)
     POLICYDIR=`${PKG_CONFIG} polkit-gobject-1 --variable=policydir`
     AC_SUBST(POLICYDIR)
+    # Check for polkit_authority_get_sync()
+    AC_CHECK_LIB([polkit-gobject-1], [polkit_authority_get_sync], ac_have_pk_auth_get_sync="1", ac_have_pk_auth_get_sync="0")
+    AC_DEFINE_UNQUOTED(HAVE_POLKIT_AUTHORITY_GET_SYNC, $ac_have_pk_auth_get_sync, [Define if you have a polkit with polkit_authority_get_sync()])
   fi
 fi
 
diff --git a/gtk/spice-client-glib-usb-acl-helper.c b/gtk/spice-client-glib-usb-acl-helper.c
index 311404e..53f4e9a 100644
--- a/gtk/spice-client-glib-usb-acl-helper.c
+++ b/gtk/spice-client-glib-usb-acl-helper.c
@@ -257,6 +257,21 @@ static void stdin_read_complete(GObject *src, GAsyncResult *res, gpointer data)
     }
 }
 
+/* Fix for polkit 0.97 and later */
+#if !HAVE_POLKIT_AUTHORITY_GET_SYNC
+static PolkitAuthority *
+polkit_authority_get_sync (GCancellable *cancellable, GError **error)
+{
+    PolkitAuthority *authority;
+
+    authority = polkit_authority_get ();
+    if (!authority)
+        g_set_error (error, 0, 0, "failed to get the PolicyKit authority");
+
+    return authority;
+}
+#endif
+
 int main(void)
 {
     pid_t parent_pid;
commit 2c61fd3d806eb0b358de882c2c7db42d39b43b5f
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Jan 12 13:41:09 2012 +0100

    Lower our glib requirement to 2.22, as we claim
    
    Required to build on RHEL, even upcoming 6.3

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                                                       */


More information about the Spice-commits mailing list