[virt-tools-list] [PATCH 08/12] Add spice_get_option_group()

Marc-André Lureau marcandre.lureau at gmail.com
Tue Dec 13 19:35:06 UTC 2011


---
 configure.ac                    |    2 +-
 src/remote-viewer-main.c        |    3 +++
 src/virt-viewer-main.c          |   22 +++++++++++++---------
 src/virt-viewer-session-spice.c |    6 +++++-
 4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index b2d7e8f..77838fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ LIBVIRT_REQUIRED="0.6.0"
 GTK2_REQUIRED="2.12.0"
 GTK3_REQUIRED="3.0"
 GTK_VNC_REQUIRED="0.4.3"
-SPICE_GTK_REQUIRED="0.6"
+SPICE_GTK_REQUIRED="0.6.174"
 
 AC_PROG_CC
 AM_PROG_CC_C_O
diff --git a/src/remote-viewer-main.c b/src/remote-viewer-main.c
index 2256528..89ef25f 100644
--- a/src/remote-viewer-main.c
+++ b/src/remote-viewer-main.c
@@ -91,6 +91,9 @@ main(int argc, char **argv)
 #ifdef HAVE_GTK_VNC
 	g_option_context_add_group (context, vnc_display_get_option_group ());
 #endif
+#ifdef HAVE_SPICE_GTK
+	g_option_context_add_group (context, spice_get_option_group ());
+#endif
 	g_option_context_parse (context, &argc, &argv, &error);
 	if (error) {
 		g_printerr("%s\n%s\n",
diff --git a/src/virt-viewer-main.c b/src/virt-viewer-main.c
index 7e2886b..c8e1082 100644
--- a/src/virt-viewer-main.c
+++ b/src/virt-viewer-main.c
@@ -25,11 +25,12 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 #include <stdlib.h>
-
 #ifdef HAVE_GTK_VNC
 #include <vncdisplay.h>
 #endif
-
+#ifdef HAVE_SPICE_GTK
+#include <spice-option.h>
+#endif
 #include "virt-viewer.h"
 
 static void virt_viewer_version(void)
@@ -58,21 +59,21 @@ int main(int argc, char **argv)
 	const char *help_msg = N_("Run '" PACKAGE " --help' to see a full list of available command line options");
 	const GOptionEntry options [] = {
 		{ "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
-		  virt_viewer_version, N_("display version information"), NULL },
+		  virt_viewer_version, N_("Display version information"), NULL },
 		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
-		  N_("display verbose information"), NULL },
+		  N_("Display verbose information"), NULL },
 		{ "direct", 'd', 0, G_OPTION_ARG_NONE, &direct,
-		  N_("direct connection with no automatic tunnels"), NULL },
+		  N_("Direct connection with no automatic tunnels"), NULL },
 		{ "connect", 'c', 0, G_OPTION_ARG_STRING, &uri,
-		  N_("connect to hypervisor"), "URI"},
+		  N_("Connect to hypervisor"), "URI"},
 		{ "wait", 'w', 0, G_OPTION_ARG_NONE, &waitvm,
-		  N_("wait for domain to start"), NULL },
+		  N_("Wait for domain to start"), NULL },
 		{ "reconnect", 'r', 0, G_OPTION_ARG_NONE, &reconnect,
-		  N_("reconnect to domain upon restart"), NULL },
+		  N_("Reconnect to domain upon restart"), NULL },
 		{ "zoom", 'z', 0, G_OPTION_ARG_INT, &zoom,
 		  N_("Zoom level of window, in percentage"), "ZOOM" },
 		{ "debug", '\0', 0, G_OPTION_ARG_NONE, &debug,
-		  N_("display debugging information"), NULL },
+		  N_("Display debugging information"), NULL },
 		{ "full-screen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen,
 		  N_("Open in full screen mode"), NULL },
 		{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
@@ -94,6 +95,9 @@ int main(int argc, char **argv)
 #ifdef HAVE_GTK_VNC
 	g_option_context_add_group (context, vnc_display_get_option_group ());
 #endif
+#ifdef HAVE_SPICE_GTK
+	g_option_context_add_group (context, spice_get_option_group ());
+#endif
 	g_option_context_parse (context, &argc, &argv, &error);
 	if (error) {
 		g_printerr("%s\n%s\n",
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index f89d042..de2da3d 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -23,9 +23,9 @@
  */
 
 #include <spice-audio.h>
-
 #include <glib/gi18n.h>
 
+#include <spice-option.h>
 #include "virt-viewer-util.h"
 #include "virt-viewer-session-spice.h"
 #include "virt-viewer-display-spice.h"
@@ -154,7 +154,9 @@ virt_viewer_session_spice_close(VirtViewerSession *session)
 		self->priv->audio = NULL;
 	}
 
+	/* FIXME: version 0.7 of spice-gtk allows reuse of session */
 	self->priv->session = spice_session_new();
+	spice_set_session_option(self->priv->session);
 	g_signal_connect(self->priv->session, "channel-new",
 			 G_CALLBACK(virt_viewer_session_spice_channel_new), self);
 	g_signal_connect(self->priv->session, "channel-destroy",
@@ -351,6 +353,8 @@ virt_viewer_session_spice_new(void)
 	self = g_object_new(VIRT_VIEWER_TYPE_SESSION_SPICE, NULL);
 
 	self->priv->session = spice_session_new();
+	spice_set_session_option(self->priv->session);
+
 	g_signal_connect(self->priv->session, "channel-new",
 			 G_CALLBACK(virt_viewer_session_spice_channel_new), self);
 	g_signal_connect(self->priv->session, "channel-destroy",
-- 
1.7.7.3




More information about the virt-tools-list mailing list