[virt-tools-list] [virt-viewer] build-sys: Make spice-controller optional

Christophe Fergeau cfergeau at redhat.com
Fri Mar 24 13:51:21 UTC 2017


The spice-controller integration code is only needed when a browser
plugin is in use. This has been deprecated in favour of .vv files for
several years now. This commit makes this code optional, if
spice-controller.pc cannot be found, the controller code is not going to
be built.
---
 configure.ac        | 11 +++++++++--
 src/remote-viewer.c | 50 ++++++++++++++++++++++++++------------------------
 2 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/configure.ac b/configure.ac
index 69e3708..312116c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -159,18 +159,25 @@ AC_ARG_WITH([spice-gtk],
 AS_IF([test "x$with_spice_gtk" != "xno" && test "x$with_spice_gtk" != "xyes"],
       [PKG_CHECK_EXISTS([spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
                          spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED
-                         spice-controller spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
+                         spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
                         [with_spice_gtk=yes], [with_spice_gtk=no])])
 
 AS_IF([test "x$with_spice_gtk" = "xyes"],
       [PKG_CHECK_MODULES(SPICE_GTK, [spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
                                      spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED])]
-      [PKG_CHECK_MODULES(SPICE_CONTROLLER, [spice-controller])]
       [PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol >= $SPICE_PROTOCOL_REQUIRED])]
       [AC_DEFINE([HAVE_SPICE_GTK], 1, [Have spice-gtk?])]
 )
 AM_CONDITIONAL([HAVE_SPICE_GTK], [test "x$with_spice_gtk" = "xyes"])
 
+AS_IF([test "x$with_spice_gtk" = "xyes"],
+      [PKG_CHECK_MODULES(SPICE_CONTROLLER, [spice-controller],
+                         [have_spice_controller=yes],
+                         [have_spice_controller=no])]
+)
+AS_IF([test "x$have_spice_controller" = "xyes"],
+      [AC_DEFINE([HAVE_SPICE_CONTROLLER], 1, [Have spice-controller])])
+
 AC_ARG_WITH([ovirt],
     AS_HELP_STRING([--without-ovirt], [Ignore presence of librest and disable oVirt support]))
 
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 451fb1d..b4bc40c 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -36,7 +36,9 @@
 #endif
 
 #ifdef HAVE_SPICE_GTK
+#ifdef HAVE_SPICE_CONTROLLER
 #include <spice-controller.h>
+#endif
 #include "virt-viewer-session-spice.h"
 #endif
 
@@ -53,7 +55,7 @@
 #endif
 
 struct _RemoteViewerPrivate {
-#ifdef HAVE_SPICE_GTK
+#ifdef HAVE_SPICE_CONTROLLER
     SpiceCtrlController *controller;
     SpiceCtrlForeignMenu *ctrl_foreign_menu;
 #endif
@@ -82,7 +84,7 @@ static OvirtVm * choose_vm(GtkWindow *main_window,
 #endif
 
 static gboolean remote_viewer_start(VirtViewerApp *self, GError **error);
-#ifdef HAVE_SPICE_GTK
+#ifdef HAVE_SPICE_CONTROLLER
 static gboolean remote_viewer_activate(VirtViewerApp *self, GError **error);
 static void remote_viewer_window_added(GtkApplication *app, GtkWindow *w);
 static void spice_foreign_menu_updated(RemoteViewer *self);
@@ -97,7 +99,7 @@ remote_viewer_dispose (GObject *object)
     RemoteViewerPrivate *priv = self->priv;
 #endif
 
-#ifdef HAVE_SPICE_GTK
+#ifdef HAVE_SPICE_CONTROLLER
     if (priv->controller) {
         g_object_unref(priv->controller);
         priv->controller = NULL;
@@ -188,7 +190,7 @@ remote_viewer_local_command_line (GApplication   *gapp,
         g_object_set(app, "guri", opt_args[0], NULL);
     }
 
-#ifdef HAVE_SPICE_GTK
+#ifdef HAVE_SPICE_CONTROLLER
     if (opt_controller) {
         if (opt_args) {
             g_printerr(_("\nError: extra arguments given while using Spice controller\n\n"));
@@ -259,7 +261,7 @@ remote_viewer_class_init (RemoteViewerClass *klass)
     app_class->start = remote_viewer_start;
     app_class->deactivated = remote_viewer_deactivated;
     app_class->add_option_entries = remote_viewer_add_option_entries;
-#ifdef HAVE_SPICE_GTK
+#ifdef HAVE_SPICE_CONTROLLER
     app_class->activate = remote_viewer_activate;
     gtk_app_class->window_added = remote_viewer_window_added;
 #else
@@ -292,7 +294,23 @@ remote_viewer_new(void)
                         NULL);
 }
 
-#ifdef HAVE_SPICE_GTK
+static SpiceSession *
+remote_viewer_get_spice_session(RemoteViewer *self)
+{
+    VirtViewerSession *vsession = NULL;
+    SpiceSession *session = NULL;
+
+    g_object_get(self, "session", &vsession, NULL);
+    g_return_val_if_fail(vsession != NULL, NULL);
+
+    g_object_get(vsession, "spice-session", &session, NULL);
+
+    g_object_unref(vsession);
+
+    return session;
+}
+
+#ifdef HAVE_SPICE_CONTROLLER
 static void
 foreign_menu_title_changed(SpiceCtrlForeignMenu *menu G_GNUC_UNUSED,
                            GParamSpec *pspec G_GNUC_UNUSED,
@@ -503,22 +521,6 @@ spice_foreign_menu_updated(RemoteViewer *self)
     g_list_foreach(windows, spice_foreign_menu_update_each, self);
 }
 
-static SpiceSession *
-remote_viewer_get_spice_session(RemoteViewer *self)
-{
-    VirtViewerSession *vsession = NULL;
-    SpiceSession *session = NULL;
-
-    g_object_get(self, "session", &vsession, NULL);
-    g_return_val_if_fail(vsession != NULL, NULL);
-
-    g_object_get(vsession, "spice-session", &session, NULL);
-
-    g_object_unref(vsession);
-
-    return session;
-}
-
 static void
 app_notified(VirtViewerApp *app,
              GParamSpec *pspec,
@@ -1092,7 +1094,7 @@ remote_viewer_start(VirtViewerApp *app, GError **err)
     gchar *type = NULL;
     GError *error = NULL;
 
-#ifdef HAVE_SPICE_GTK
+#ifdef HAVE_SPICE_CONTROLLER
     g_signal_connect(app, "notify", G_CALLBACK(app_notified), self);
 
     if (priv->controller) {
@@ -1183,7 +1185,7 @@ retry_dialog:
             }
             goto cleanup;
         }
-#ifdef HAVE_SPICE_GTK
+#ifdef HAVE_SPICE_CONTROLLER
     }
 #endif
 
-- 
2.9.3




More information about the virt-tools-list mailing list