|
|
1efd99 |
From cfcf554c54965761772afe10fba950e5f2fed536 Mon Sep 17 00:00:00 2001
|
|
|
1efd99 |
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
|
1efd99 |
Date: Fri, 23 Jun 2017 17:25:07 +0200
|
|
|
1efd99 |
Subject: [PATCH] remote-viewer: remove --spice-controller
|
|
|
1efd99 |
MIME-Version: 1.0
|
|
|
1efd99 |
Content-Type: text/plain; charset=UTF-8
|
|
|
1efd99 |
Content-Transfer-Encoding: 8bit
|
|
|
1efd99 |
|
|
|
1efd99 |
spice controller interface is being removed from spice-gtk.
|
|
|
1efd99 |
|
|
|
1efd99 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
1efd99 |
Reviewed-by: Victor Toso <victortoso@redhat.com>
|
|
|
1efd99 |
Signed-off-by: Victor Toso <victortoso@redhat.com>
|
|
|
1efd99 |
---
|
|
|
1efd99 |
configure.ac | 3 +-
|
|
|
1efd99 |
data/Makefile.am | 1 -
|
|
|
1efd99 |
data/spice-xpi-client-remote-viewer | 6 -
|
|
|
1efd99 |
data/virt-viewer.wxs.in | 11 -
|
|
|
1efd99 |
man/remote-viewer.pod | 6 -
|
|
|
1efd99 |
src/Makefile.am | 2 -
|
|
|
1efd99 |
src/remote-viewer.c | 448 +---------------------------
|
|
|
1efd99 |
7 files changed, 5 insertions(+), 472 deletions(-)
|
|
|
1efd99 |
delete mode 100644 data/spice-xpi-client-remote-viewer
|
|
|
1efd99 |
|
|
|
1efd99 |
diff --git a/configure.ac b/configure.ac
|
|
|
1efd99 |
index 6ed5f8a..abdbdaf 100644
|
|
|
1efd99 |
--- a/configure.ac
|
|
|
1efd99 |
+++ b/configure.ac
|
|
|
1efd99 |
@@ -159,13 +159,12 @@ AC_ARG_WITH([spice-gtk],
|
|
|
1efd99 |
AS_IF([test "x$with_spice_gtk" != "xno" && test "x$with_spice_gtk" != "xyes"],
|
|
|
1efd99 |
[PKG_CHECK_EXISTS([spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
|
|
|
1efd99 |
spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED
|
|
|
1efd99 |
- spice-controller spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
|
|
|
1efd99 |
+ spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
|
|
|
1efd99 |
[with_spice_gtk=yes], [with_spice_gtk=no])])
|
|
|
1efd99 |
|
|
|
1efd99 |
AS_IF([test "x$with_spice_gtk" = "xyes"],
|
|
|
1efd99 |
[PKG_CHECK_MODULES(SPICE_GTK, [spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
|
|
|
1efd99 |
spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED])]
|
|
|
1efd99 |
- [PKG_CHECK_MODULES(SPICE_CONTROLLER, [spice-controller])]
|
|
|
1efd99 |
[PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol >= $SPICE_PROTOCOL_REQUIRED])]
|
|
|
1efd99 |
[AC_DEFINE([HAVE_SPICE_GTK], 1, [Have spice-gtk?])]
|
|
|
1efd99 |
)
|
|
|
1efd99 |
diff --git a/data/Makefile.am b/data/Makefile.am
|
|
|
1efd99 |
index 55718d9..54be2b1 100644
|
|
|
1efd99 |
--- a/data/Makefile.am
|
|
|
1efd99 |
+++ b/data/Makefile.am
|
|
|
1efd99 |
@@ -3,7 +3,6 @@ CLEANFILES =
|
|
|
1efd99 |
MANUFACTURER = Virt Manager Project
|
|
|
1efd99 |
|
|
|
1efd99 |
EXTRA_DIST = \
|
|
|
1efd99 |
- spice-xpi-client-remote-viewer \
|
|
|
1efd99 |
virt-viewer.wxs.in \
|
|
|
1efd99 |
$(NULL)
|
|
|
1efd99 |
|
|
|
1efd99 |
diff --git a/data/spice-xpi-client-remote-viewer b/data/spice-xpi-client-remote-viewer
|
|
|
1efd99 |
deleted file mode 100644
|
|
|
1efd99 |
index 3109c66..0000000
|
|
|
1efd99 |
--- a/data/spice-xpi-client-remote-viewer
|
|
|
1efd99 |
+++ /dev/null
|
|
|
1efd99 |
@@ -1,6 +0,0 @@
|
|
|
1efd99 |
-#!/bin/sh
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-logger -t spice "starting remote-viewer --spice-controller $@..."
|
|
|
1efd99 |
-env | logger -t spice
|
|
|
1efd99 |
-exec remote-viewer --spice-controller "$@" 2>&1 | logger -t spice
|
|
|
1efd99 |
-logger -t spice "remote-viewer execution failed"
|
|
|
1efd99 |
diff --git a/data/virt-viewer.wxs.in b/data/virt-viewer.wxs.in
|
|
|
1efd99 |
index 9838265..2047720 100644
|
|
|
1efd99 |
--- a/data/virt-viewer.wxs.in
|
|
|
1efd99 |
+++ b/data/virt-viewer.wxs.in
|
|
|
1efd99 |
@@ -55,16 +55,6 @@
|
|
|
1efd99 |
<Condition Message="VirtViewer is already installed.">NOT NEWERVERSIONDETECTED</Condition>
|
|
|
1efd99 |
|
|
|
1efd99 |
<DirectoryRef Id="TARGETDIR">
|
|
|
1efd99 |
- <Component Id="CRegistryEntries" Guid="*">
|
|
|
1efd99 |
- <RegistryKey Root='HKLM' Key='Software\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{96190E9D-6FBB-64DB-9095-29F6FDE0B897}'>
|
|
|
1efd99 |
- <RegistryValue Type='string' Name='AppPath' Value='[INSTALLDIR]\bin'/>
|
|
|
1efd99 |
- <RegistryValue Type='string' Name='AppName' Value='remote-viewer.exe'/>
|
|
|
1efd99 |
- <RegistryValue Type='integer' Name='Policy' Value='3'/>
|
|
|
1efd99 |
- </RegistryKey>
|
|
|
1efd99 |
- <RegistryKey Root='HKLM' Key='Software\spice-space.org\spicex'>
|
|
|
1efd99 |
- <RegistryValue Type='string' Name='client' Value='[INSTALLDIR]\bin\remote-viewer.exe --spice-controller'/>
|
|
|
1efd99 |
- </RegistryKey>
|
|
|
1efd99 |
- </Component>
|
|
|
1efd99 |
<Component Id="CProgIds" Guid="89D6F46D-9C5E-4D65-8456-58FC361E553E">
|
|
|
1efd99 |
<ProgId Id='VirtViewer.vvfile' Description='VirtViewer connection file'>
|
|
|
1efd99 |
<Extension Id='vv' ContentType='application/x-virt-viewer'>
|
|
|
1efd99 |
@@ -129,7 +119,6 @@
|
|
|
1efd99 |
<ComponentGroupRef Id="CG.virt-viewer"/>
|
|
|
1efd99 |
<ComponentRef Id="CDepsFile"/>
|
|
|
1efd99 |
<ComponentRef Id="CShortcut"/>
|
|
|
1efd99 |
- <ComponentRef Id="CRegistryEntries"/>
|
|
|
1efd99 |
<ComponentRef Id="CProgIds"/>
|
|
|
1efd99 |
<ComponentRef Id="CHwdataUSB"/>
|
|
|
1efd99 |
</Feature>
|
|
|
1efd99 |
diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
|
|
|
1efd99 |
index 560f73f..e26aee7 100644
|
|
|
1efd99 |
--- a/man/remote-viewer.pod
|
|
|
1efd99 |
+++ b/man/remote-viewer.pod
|
|
|
1efd99 |
@@ -55,12 +55,6 @@ CONFIGURATION section below.
|
|
|
1efd99 |
|
|
|
1efd99 |
Set the window title to B<TITLE>
|
|
|
1efd99 |
|
|
|
1efd99 |
-=item --spice-controller
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-Use the SPICE controller to initialize the connection with the SPICE
|
|
|
1efd99 |
-server. This option is used by the SPICE browser addons to allow web
|
|
|
1efd99 |
-page to start a client.
|
|
|
1efd99 |
-
|
|
|
1efd99 |
=item --debug
|
|
|
1efd99 |
|
|
|
1efd99 |
Print debugging information
|
|
|
1efd99 |
diff --git a/src/Makefile.am b/src/Makefile.am
|
|
|
1efd99 |
index b3eea67..6f2b7a1 100644
|
|
|
1efd99 |
--- a/src/Makefile.am
|
|
|
1efd99 |
+++ b/src/Makefile.am
|
|
|
1efd99 |
@@ -180,11 +180,9 @@ remote_viewer_SOURCES = \
|
|
|
1efd99 |
$(NULL)
|
|
|
1efd99 |
remote_viewer_LDFLAGS = \
|
|
|
1efd99 |
$(COMMON_LIBS) \
|
|
|
1efd99 |
- $(SPICE_CONTROLLER_LIBS) \
|
|
|
1efd99 |
$(NULL)
|
|
|
1efd99 |
remote_viewer_CFLAGS = \
|
|
|
1efd99 |
$(COMMON_CFLAGS) \
|
|
|
1efd99 |
- $(SPICE_CONTROLLER_CFLAGS) \
|
|
|
1efd99 |
$(NULL)
|
|
|
1efd99 |
remote_viewer_LDADD = \
|
|
|
1efd99 |
libvirt-viewer-util.la \
|
|
|
1efd99 |
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
|
|
|
1efd99 |
index 429f38c..a920aa0 100644
|
|
|
1efd99 |
--- a/src/remote-viewer.c
|
|
|
1efd99 |
+++ b/src/remote-viewer.c
|
|
|
1efd99 |
@@ -36,7 +36,6 @@
|
|
|
1efd99 |
#endif
|
|
|
1efd99 |
|
|
|
1efd99 |
#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
-#include <spice-controller.h>
|
|
|
1efd99 |
#include "virt-viewer-session-spice.h"
|
|
|
1efd99 |
#endif
|
|
|
1efd99 |
|
|
|
1efd99 |
@@ -53,10 +52,6 @@
|
|
|
1efd99 |
#endif
|
|
|
1efd99 |
|
|
|
1efd99 |
struct _RemoteViewerPrivate {
|
|
|
1efd99 |
-#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
- SpiceCtrlController *controller;
|
|
|
1efd99 |
- SpiceCtrlForeignMenu *ctrl_foreign_menu;
|
|
|
1efd99 |
-#endif
|
|
|
1efd99 |
#ifdef HAVE_OVIRT
|
|
|
1efd99 |
OvirtForeignMenu *ovirt_foreign_menu;
|
|
|
1efd99 |
#endif
|
|
|
1efd99 |
@@ -82,33 +77,15 @@ static OvirtVm * choose_vm(GtkWindow *main_window,
|
|
|
1efd99 |
#endif
|
|
|
1efd99 |
|
|
|
1efd99 |
static gboolean remote_viewer_start(VirtViewerApp *self, GError **error);
|
|
|
1efd99 |
-#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
-static gboolean remote_viewer_activate(VirtViewerApp *self, GError **error);
|
|
|
1efd99 |
-static void remote_viewer_window_added(GtkApplication *app, GtkWindow *w);
|
|
|
1efd99 |
-static void spice_foreign_menu_updated(RemoteViewer *self);
|
|
|
1efd99 |
-static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, GParamSpec *pspec, RemoteViewer *self);
|
|
|
1efd99 |
-#endif
|
|
|
1efd99 |
|
|
|
1efd99 |
static void
|
|
|
1efd99 |
remote_viewer_dispose (GObject *object)
|
|
|
1efd99 |
{
|
|
|
1efd99 |
-#if defined(HAVE_SPICE_GTK) || defined(HAVE_OVIRT)
|
|
|
1efd99 |
+#if defined(HAVE_OVIRT)
|
|
|
1efd99 |
RemoteViewer *self = REMOTE_VIEWER(object);
|
|
|
1efd99 |
RemoteViewerPrivate *priv = self->priv;
|
|
|
1efd99 |
#endif
|
|
|
1efd99 |
|
|
|
1efd99 |
-#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
- if (priv->controller) {
|
|
|
1efd99 |
- g_object_unref(priv->controller);
|
|
|
1efd99 |
- priv->controller = NULL;
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (priv->ctrl_foreign_menu) {
|
|
|
1efd99 |
- g_object_unref(priv->ctrl_foreign_menu);
|
|
|
1efd99 |
- priv->ctrl_foreign_menu = NULL;
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-#endif
|
|
|
1efd99 |
-
|
|
|
1efd99 |
#ifdef HAVE_OVIRT
|
|
|
1efd99 |
if (priv->ovirt_foreign_menu) {
|
|
|
1efd99 |
g_object_unref(priv->ovirt_foreign_menu);
|
|
|
1efd99 |
@@ -136,7 +113,6 @@ remote_viewer_deactivated(VirtViewerApp *app, gboolean connect_error)
|
|
|
1efd99 |
|
|
|
1efd99 |
static gchar **opt_args = NULL;
|
|
|
1efd99 |
static char *opt_title = NULL;
|
|
|
1efd99 |
-static gboolean opt_controller = FALSE;
|
|
|
1efd99 |
|
|
|
1efd99 |
static void
|
|
|
1efd99 |
remote_viewer_add_option_entries(VirtViewerApp *self, GOptionContext *context, GOptionGroup *group)
|
|
|
1efd99 |
@@ -144,10 +120,6 @@ remote_viewer_add_option_entries(VirtViewerApp *self, GOptionContext *context, G
|
|
|
1efd99 |
static const GOptionEntry options[] = {
|
|
|
1efd99 |
{ "title", 't', 0, G_OPTION_ARG_STRING, &opt_title,
|
|
|
1efd99 |
N_("Set window title"), NULL },
|
|
|
1efd99 |
-#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
- { "spice-controller", '\0', 0, G_OPTION_ARG_NONE, &opt_controller,
|
|
|
1efd99 |
- N_("Open connection using Spice controller communication"), NULL },
|
|
|
1efd99 |
-#endif
|
|
|
1efd99 |
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &opt_args,
|
|
|
1efd99 |
NULL, "URI|VV-FILE" },
|
|
|
1efd99 |
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
|
|
|
1efd99 |
@@ -188,27 +160,7 @@ remote_viewer_local_command_line (GApplication *gapp,
|
|
|
1efd99 |
g_object_set(app, "guri", opt_args[0], NULL);
|
|
|
1efd99 |
}
|
|
|
1efd99 |
|
|
|
1efd99 |
-#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
- if (opt_controller) {
|
|
|
1efd99 |
- if (opt_args) {
|
|
|
1efd99 |
- g_printerr(_("\nError: extra arguments given while using Spice controller\n\n"));
|
|
|
1efd99 |
- ret = TRUE;
|
|
|
1efd99 |
- *status = 1;
|
|
|
1efd99 |
- goto end;
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- self->priv->controller = spice_ctrl_controller_new();
|
|
|
1efd99 |
- self->priv->ctrl_foreign_menu = spice_ctrl_foreign_menu_new();
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_object_set(self, "guest-name", "defined by Spice controller", NULL);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_signal_connect(self->priv->ctrl_foreign_menu, "notify::title",
|
|
|
1efd99 |
- G_CALLBACK(foreign_menu_title_changed),
|
|
|
1efd99 |
- self);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-#endif
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (opt_title && !opt_controller)
|
|
|
1efd99 |
+ if (opt_title)
|
|
|
1efd99 |
g_object_set(app, "title", opt_title, NULL);
|
|
|
1efd99 |
|
|
|
1efd99 |
end:
|
|
|
1efd99 |
@@ -245,7 +197,6 @@ static void
|
|
|
1efd99 |
remote_viewer_class_init (RemoteViewerClass *klass)
|
|
|
1efd99 |
{
|
|
|
1efd99 |
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
1efd99 |
- GtkApplicationClass *gtk_app_class = GTK_APPLICATION_CLASS(klass);
|
|
|
1efd99 |
VirtViewerAppClass *app_class = VIRT_VIEWER_APP_CLASS (klass);
|
|
|
1efd99 |
GApplicationClass *g_app_class = G_APPLICATION_CLASS(klass);
|
|
|
1efd99 |
|
|
|
1efd99 |
@@ -259,12 +210,6 @@ remote_viewer_class_init (RemoteViewerClass *klass)
|
|
|
1efd99 |
app_class->start = remote_viewer_start;
|
|
|
1efd99 |
app_class->deactivated = remote_viewer_deactivated;
|
|
|
1efd99 |
app_class->add_option_entries = remote_viewer_add_option_entries;
|
|
|
1efd99 |
-#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
- app_class->activate = remote_viewer_activate;
|
|
|
1efd99 |
- gtk_app_class->window_added = remote_viewer_window_added;
|
|
|
1efd99 |
-#else
|
|
|
1efd99 |
- (void) gtk_app_class;
|
|
|
1efd99 |
-#endif
|
|
|
1efd99 |
|
|
|
1efd99 |
#ifdef HAVE_OVIRT
|
|
|
1efd99 |
g_object_class_install_property(object_class,
|
|
|
1efd99 |
@@ -292,217 +237,7 @@ remote_viewer_new(void)
|
|
|
1efd99 |
NULL);
|
|
|
1efd99 |
}
|
|
|
1efd99 |
|
|
|
1efd99 |
-#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-foreign_menu_title_changed(SpiceCtrlForeignMenu *menu G_GNUC_UNUSED,
|
|
|
1efd99 |
- GParamSpec *pspec G_GNUC_UNUSED,
|
|
|
1efd99 |
- RemoteViewer *self)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- gboolean has_focus;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_object_get(G_OBJECT(self), "has-focus", &has_focus, NULL);
|
|
|
1efd99 |
- /* FIXME: use a proper "new client connected" event
|
|
|
1efd99 |
- ** a foreign menu client set the title when connecting,
|
|
|
1efd99 |
- ** inform of focus state at that time.
|
|
|
1efd99 |
- */
|
|
|
1efd99 |
- spice_ctrl_foreign_menu_app_activated_msg(self->priv->ctrl_foreign_menu, has_focus);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- /* update menu title */
|
|
|
1efd99 |
- spice_foreign_menu_updated(self);
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_ctrl_do_connect(SpiceCtrlController *ctrl G_GNUC_UNUSED,
|
|
|
1efd99 |
- VirtViewerApp *self)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- GError *error = NULL;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (!virt_viewer_app_initial_connect(self, &error)) {
|
|
|
1efd99 |
- const gchar *msg = error ? error->message :
|
|
|
1efd99 |
- _("Failed to initiate connection");
|
|
|
1efd99 |
- virt_viewer_app_simple_message_dialog(self, msg);
|
|
|
1efd99 |
- g_clear_error(&error);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_ctrl_show(SpiceCtrlController *ctrl G_GNUC_UNUSED, RemoteViewer *self)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- virt_viewer_app_show_display(VIRT_VIEWER_APP(self));
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_ctrl_hide(SpiceCtrlController *ctrl G_GNUC_UNUSED, RemoteViewer *self)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- virt_viewer_app_show_status(VIRT_VIEWER_APP(self), _("Display disabled by controller"));
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_menuitem_activate_cb(GtkMenuItem *mi, GObject *ctrl)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- SpiceCtrlMenuItem *menuitem = g_object_get_data(G_OBJECT(mi), "spice-menuitem");
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_return_if_fail(menuitem != NULL);
|
|
|
1efd99 |
- if (gtk_menu_item_get_submenu(mi))
|
|
|
1efd99 |
- return;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (SPICE_CTRL_IS_CONTROLLER(ctrl))
|
|
|
1efd99 |
- spice_ctrl_controller_menu_item_click_msg(SPICE_CTRL_CONTROLLER(ctrl), menuitem->id);
|
|
|
1efd99 |
- else if (SPICE_CTRL_IS_FOREIGN_MENU(ctrl))
|
|
|
1efd99 |
- spice_ctrl_foreign_menu_menu_item_click_msg(SPICE_CTRL_FOREIGN_MENU(ctrl), menuitem->id);
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static GtkWidget *
|
|
|
1efd99 |
-ctrlmenu_to_gtkmenu (RemoteViewer *self, SpiceCtrlMenu *ctrlmenu, GObject *ctrl)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- GList *l;
|
|
|
1efd99 |
- GtkWidget *menu = gtk_menu_new();
|
|
|
1efd99 |
- guint n = 0;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- for (l = ctrlmenu->items; l != NULL; l = l->next) {
|
|
|
1efd99 |
- SpiceCtrlMenuItem *menuitem = l->data;
|
|
|
1efd99 |
- GtkWidget *item;
|
|
|
1efd99 |
- char *s;
|
|
|
1efd99 |
- if (menuitem->text == NULL) {
|
|
|
1efd99 |
- g_warn_if_reached();
|
|
|
1efd99 |
- continue;
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- for (s = menuitem->text; *s; s++)
|
|
|
1efd99 |
- if (*s == '&')
|
|
|
1efd99 |
- *s = '_';
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (g_str_equal(menuitem->text, "-")) {
|
|
|
1efd99 |
- item = gtk_separator_menu_item_new();
|
|
|
1efd99 |
- } else if (menuitem->flags & CONTROLLER_MENU_FLAGS_CHECKED) {
|
|
|
1efd99 |
- item = gtk_check_menu_item_new_with_mnemonic(menuitem->text);
|
|
|
1efd99 |
- g_object_set(item, "active", TRUE, NULL);
|
|
|
1efd99 |
- } else {
|
|
|
1efd99 |
- item = gtk_menu_item_new_with_mnemonic(menuitem->text);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (menuitem->flags & (CONTROLLER_MENU_FLAGS_GRAYED | CONTROLLER_MENU_FLAGS_DISABLED))
|
|
|
1efd99 |
- gtk_widget_set_sensitive(item, FALSE);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_object_set_data_full(G_OBJECT(item), "spice-menuitem",
|
|
|
1efd99 |
- g_object_ref(menuitem), g_object_unref);
|
|
|
1efd99 |
- g_signal_connect(item, "activate", G_CALLBACK(spice_menuitem_activate_cb), ctrl);
|
|
|
1efd99 |
- gtk_menu_attach(GTK_MENU (menu), item, 0, 1, n, n + 1);
|
|
|
1efd99 |
- n += 1;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (menuitem->submenu) {
|
|
|
1efd99 |
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
|
|
|
1efd99 |
- ctrlmenu_to_gtkmenu(self, menuitem->submenu, ctrl));
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (n == 0) {
|
|
|
1efd99 |
- g_object_ref_sink(menu);
|
|
|
1efd99 |
- g_object_unref(menu);
|
|
|
1efd99 |
- menu = NULL;
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- gtk_widget_show_all(menu);
|
|
|
1efd99 |
- return menu;
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_menu_update(RemoteViewer *self, VirtViewerWindow *win)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- GtkWidget *menuitem = g_object_get_data(G_OBJECT(win), "spice-menu");
|
|
|
1efd99 |
- SpiceCtrlMenu *menu;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (self->priv->controller == NULL)
|
|
|
1efd99 |
- return;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (menuitem != NULL)
|
|
|
1efd99 |
- gtk_widget_destroy(menuitem);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- {
|
|
|
1efd99 |
- GtkMenuShell *shell = GTK_MENU_SHELL(gtk_builder_get_object(virt_viewer_window_get_builder(win), "top-menu"));
|
|
|
1efd99 |
- menuitem = gtk_menu_item_new_with_label("Spice");
|
|
|
1efd99 |
- gtk_menu_shell_append(shell, menuitem);
|
|
|
1efd99 |
- g_object_set_data(G_OBJECT(win), "spice-menu", menuitem);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_object_get(self->priv->controller, "menu", &menu, NULL);
|
|
|
1efd99 |
- if (menu == NULL || g_list_length(menu->items) == 0) {
|
|
|
1efd99 |
- gtk_widget_set_visible(menuitem, FALSE);
|
|
|
1efd99 |
- } else {
|
|
|
1efd99 |
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),
|
|
|
1efd99 |
- ctrlmenu_to_gtkmenu(self, menu, G_OBJECT(self->priv->controller)));
|
|
|
1efd99 |
- gtk_widget_set_visible(menuitem, TRUE);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (menu != NULL)
|
|
|
1efd99 |
- g_object_unref(menu);
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_menu_update_each(gpointer value,
|
|
|
1efd99 |
- gpointer user_data)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- spice_menu_update(REMOTE_VIEWER(user_data), VIRT_VIEWER_WINDOW(value));
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_ctrl_menu_updated(RemoteViewer *self)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- GList *windows = virt_viewer_app_get_windows(VIRT_VIEWER_APP(self));
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_debug("Spice controller menu updated");
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_list_foreach(windows, spice_menu_update_each, self);
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_foreign_menu_update(RemoteViewer *self, VirtViewerWindow *win)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- GtkWidget *menuitem = g_object_get_data(G_OBJECT(win), "foreign-menu");
|
|
|
1efd99 |
- SpiceCtrlMenu *menu;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (self->priv->ctrl_foreign_menu == NULL)
|
|
|
1efd99 |
- return;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (menuitem != NULL)
|
|
|
1efd99 |
- gtk_widget_destroy(menuitem);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- {
|
|
|
1efd99 |
- GtkMenuShell *shell = GTK_MENU_SHELL(gtk_builder_get_object(virt_viewer_window_get_builder(win), "top-menu"));
|
|
|
1efd99 |
- const gchar *title = spice_ctrl_foreign_menu_get_title(self->priv->ctrl_foreign_menu);
|
|
|
1efd99 |
- menuitem = gtk_menu_item_new_with_label(title);
|
|
|
1efd99 |
- gtk_menu_shell_append(shell, menuitem);
|
|
|
1efd99 |
- g_object_set_data(G_OBJECT(win), "foreign-menu", menuitem);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_object_get(self->priv->ctrl_foreign_menu, "menu", &menu, NULL);
|
|
|
1efd99 |
- if (menu == NULL || g_list_length(menu->items) == 0) {
|
|
|
1efd99 |
- gtk_widget_set_visible(menuitem, FALSE);
|
|
|
1efd99 |
- } else {
|
|
|
1efd99 |
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),
|
|
|
1efd99 |
- ctrlmenu_to_gtkmenu(self, menu, G_OBJECT(self->priv->ctrl_foreign_menu)));
|
|
|
1efd99 |
- gtk_widget_set_visible(menuitem, TRUE);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
- g_object_unref(menu);
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_foreign_menu_update_each(gpointer value,
|
|
|
1efd99 |
- gpointer user_data)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- spice_foreign_menu_update(REMOTE_VIEWER(user_data), VIRT_VIEWER_WINDOW(value));
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_foreign_menu_updated(RemoteViewer *self)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- GList *windows = virt_viewer_app_get_windows(VIRT_VIEWER_APP(self));
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_debug("Spice foreign menu updated");
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_list_foreach(windows, spice_foreign_menu_update_each, self);
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
+#if defined(HAVE_SPICE_GTK) && defined(HAVE_OVIRT)
|
|
|
1efd99 |
static SpiceSession *
|
|
|
1efd99 |
remote_viewer_get_spice_session(RemoteViewer *self)
|
|
|
1efd99 |
{
|
|
|
1efd99 |
@@ -518,158 +253,6 @@ remote_viewer_get_spice_session(RemoteViewer *self)
|
|
|
1efd99 |
|
|
|
1efd99 |
return session;
|
|
|
1efd99 |
}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-app_notified(VirtViewerApp *app,
|
|
|
1efd99 |
- GParamSpec *pspec,
|
|
|
1efd99 |
- RemoteViewer *self)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- GValue value = G_VALUE_INIT;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_value_init(&value, pspec->value_type);
|
|
|
1efd99 |
- g_object_get_property(G_OBJECT(app), pspec->name, &value);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (g_str_equal(pspec->name, "has-focus")) {
|
|
|
1efd99 |
- if (self->priv->ctrl_foreign_menu)
|
|
|
1efd99 |
- spice_ctrl_foreign_menu_app_activated_msg(self->priv->ctrl_foreign_menu, g_value_get_boolean(&value));
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_value_unset(&value);
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_ctrl_notified(SpiceCtrlController *ctrl,
|
|
|
1efd99 |
- GParamSpec *pspec,
|
|
|
1efd99 |
- RemoteViewer *self)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- SpiceSession *session = remote_viewer_get_spice_session(self);
|
|
|
1efd99 |
- GValue value = G_VALUE_INIT;
|
|
|
1efd99 |
- VirtViewerApp *app = VIRT_VIEWER_APP(self);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_return_if_fail(session != NULL);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_value_init(&value, pspec->value_type);
|
|
|
1efd99 |
- g_object_get_property(G_OBJECT(ctrl), pspec->name, &value);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (g_str_equal(pspec->name, "host") ||
|
|
|
1efd99 |
- g_str_equal(pspec->name, "port") ||
|
|
|
1efd99 |
- g_str_equal(pspec->name, "password") ||
|
|
|
1efd99 |
- g_str_equal(pspec->name, "ca-file") ||
|
|
|
1efd99 |
- g_str_equal(pspec->name, "enable-smartcard") ||
|
|
|
1efd99 |
- g_str_equal(pspec->name, "color-depth") ||
|
|
|
1efd99 |
- g_str_equal(pspec->name, "disable-effects") ||
|
|
|
1efd99 |
- g_str_equal(pspec->name, "enable-usbredir") ||
|
|
|
1efd99 |
- g_str_equal(pspec->name, "secure-channels") ||
|
|
|
1efd99 |
- g_str_equal(pspec->name, "proxy")) {
|
|
|
1efd99 |
- g_object_set_property(G_OBJECT(session), pspec->name, &value);
|
|
|
1efd99 |
- } else if (g_str_equal(pspec->name, "sport")) {
|
|
|
1efd99 |
- g_object_set_property(G_OBJECT(session), "tls-port", &value);
|
|
|
1efd99 |
- } else if (g_str_equal(pspec->name, "tls-ciphers")) {
|
|
|
1efd99 |
- g_object_set_property(G_OBJECT(session), "ciphers", &value);
|
|
|
1efd99 |
- } else if (g_str_equal(pspec->name, "host-subject")) {
|
|
|
1efd99 |
- g_object_set_property(G_OBJECT(session), "cert-subject", &value);
|
|
|
1efd99 |
- } else if (g_str_equal(pspec->name, "enable-usb-autoshare")) {
|
|
|
1efd99 |
- VirtViewerSession *vsession = NULL;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_object_get(self, "session", &vsession, NULL);
|
|
|
1efd99 |
- g_object_set_property(G_OBJECT(vsession), "auto-usbredir", &value);
|
|
|
1efd99 |
- g_object_unref(G_OBJECT(vsession));
|
|
|
1efd99 |
- } else if (g_str_equal(pspec->name, "usb-filter")) {
|
|
|
1efd99 |
- SpiceUsbDeviceManager *manager;
|
|
|
1efd99 |
- manager = spice_usb_device_manager_get(session, NULL);
|
|
|
1efd99 |
- if (manager != NULL) {
|
|
|
1efd99 |
- g_object_set_property(G_OBJECT(manager),
|
|
|
1efd99 |
- "auto-connect-filter",
|
|
|
1efd99 |
- &value);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
- } else if (g_str_equal(pspec->name, "title")) {
|
|
|
1efd99 |
- g_object_set(app, "title", g_value_get_string(&value), NULL);
|
|
|
1efd99 |
- } else if (g_str_equal(pspec->name, "display-flags")) {
|
|
|
1efd99 |
- guint flags = g_value_get_uint(&value);
|
|
|
1efd99 |
- gboolean fullscreen = !!(flags & CONTROLLER_SET_FULL_SCREEN);
|
|
|
1efd99 |
- g_object_set(G_OBJECT(self), "fullscreen", fullscreen, NULL);
|
|
|
1efd99 |
- } else if (g_str_equal(pspec->name, "menu")) {
|
|
|
1efd99 |
- spice_ctrl_menu_updated(self);
|
|
|
1efd99 |
- } else if (g_str_equal(pspec->name, "hotkeys")) {
|
|
|
1efd99 |
- virt_viewer_app_set_hotkeys(app, g_value_get_string(&value));
|
|
|
1efd99 |
- } else {
|
|
|
1efd99 |
- gchar *content = g_strdup_value_contents(&value);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_debug("unimplemented property: %s=%s", pspec->name, content);
|
|
|
1efd99 |
- g_free(content);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_object_unref(session);
|
|
|
1efd99 |
- g_value_unset(&value);
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_ctrl_foreign_menu_notified(SpiceCtrlForeignMenu *ctrl_foreign_menu G_GNUC_UNUSED,
|
|
|
1efd99 |
- GParamSpec *pspec,
|
|
|
1efd99 |
- RemoteViewer *self)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- if (g_str_equal(pspec->name, "menu")) {
|
|
|
1efd99 |
- spice_foreign_menu_updated(self);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-spice_ctrl_listen_async_cb(GObject *object,
|
|
|
1efd99 |
- GAsyncResult *res,
|
|
|
1efd99 |
- gpointer user_data)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- GError *error = NULL;
|
|
|
1efd99 |
- VirtViewerApp *app = VIRT_VIEWER_APP(user_data);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (SPICE_CTRL_IS_CONTROLLER(object))
|
|
|
1efd99 |
- spice_ctrl_controller_listen_finish(SPICE_CTRL_CONTROLLER(object), res, &error);
|
|
|
1efd99 |
- else if (SPICE_CTRL_IS_FOREIGN_MENU(object)) {
|
|
|
1efd99 |
- spice_ctrl_foreign_menu_listen_finish(SPICE_CTRL_FOREIGN_MENU(object), res, &error);
|
|
|
1efd99 |
- } else
|
|
|
1efd99 |
- g_warn_if_reached();
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (error != NULL) {
|
|
|
1efd99 |
- virt_viewer_app_simple_message_dialog(app,
|
|
|
1efd99 |
- _("Controller connection failed: %s"),
|
|
|
1efd99 |
- error->message);
|
|
|
1efd99 |
- g_clear_error(&error);
|
|
|
1efd99 |
- exit(EXIT_FAILURE); /* TODO: make start async? */
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static gboolean
|
|
|
1efd99 |
-remote_viewer_activate(VirtViewerApp *app, GError **error)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- RemoteViewer *self;
|
|
|
1efd99 |
- gboolean ret = FALSE;
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_return_val_if_fail(REMOTE_VIEWER_IS(app), FALSE);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- self = REMOTE_VIEWER(app);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (self->priv->controller) {
|
|
|
1efd99 |
- SpiceSession *session = remote_viewer_get_spice_session(self);
|
|
|
1efd99 |
- ret = spice_session_connect(session);
|
|
|
1efd99 |
- g_object_unref(session);
|
|
|
1efd99 |
- } else {
|
|
|
1efd99 |
- ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->activate(app, error);
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- return ret;
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
-
|
|
|
1efd99 |
-static void
|
|
|
1efd99 |
-remote_viewer_window_added(GtkApplication *app,
|
|
|
1efd99 |
- GtkWindow *w)
|
|
|
1efd99 |
-{
|
|
|
1efd99 |
- VirtViewerWindow *win = VIRT_VIEWER_WINDOW(
|
|
|
1efd99 |
- g_object_get_data(G_OBJECT(w), "virt-viewer-window"));
|
|
|
1efd99 |
- spice_menu_update(REMOTE_VIEWER(app), win);
|
|
|
1efd99 |
- spice_foreign_menu_update(REMOTE_VIEWER(app), win);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- GTK_APPLICATION_CLASS(remote_viewer_parent_class)->window_added(app, w);
|
|
|
1efd99 |
-}
|
|
|
1efd99 |
#endif
|
|
|
1efd99 |
|
|
|
1efd99 |
#ifdef HAVE_OVIRT
|
|
|
1efd99 |
@@ -1101,29 +684,8 @@ remote_viewer_start(VirtViewerApp *app, GError **err)
|
|
|
1efd99 |
gchar *type = NULL;
|
|
|
1efd99 |
GError *error = NULL;
|
|
|
1efd99 |
|
|
|
1efd99 |
-#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
- g_signal_connect(app, "notify", G_CALLBACK(app_notified), self);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- if (priv->controller) {
|
|
|
1efd99 |
- if (!virt_viewer_app_create_session(app, "spice", &error)) {
|
|
|
1efd99 |
- g_debug("Couldn't create a Spice session");
|
|
|
1efd99 |
- goto cleanup;
|
|
|
1efd99 |
- }
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_signal_connect(priv->controller, "notify", G_CALLBACK(spice_ctrl_notified), self);
|
|
|
1efd99 |
- g_signal_connect(priv->controller, "do_connect", G_CALLBACK(spice_ctrl_do_connect), self);
|
|
|
1efd99 |
- g_signal_connect(priv->controller, "show", G_CALLBACK(spice_ctrl_show), self);
|
|
|
1efd99 |
- g_signal_connect(priv->controller, "hide", G_CALLBACK(spice_ctrl_hide), self);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- spice_ctrl_controller_listen(priv->controller, NULL, spice_ctrl_listen_async_cb, self);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- g_signal_connect(priv->ctrl_foreign_menu, "notify", G_CALLBACK(spice_ctrl_foreign_menu_notified), self);
|
|
|
1efd99 |
- spice_ctrl_foreign_menu_listen(priv->ctrl_foreign_menu, NULL, spice_ctrl_listen_async_cb, self);
|
|
|
1efd99 |
-
|
|
|
1efd99 |
- virt_viewer_app_show_status(VIRT_VIEWER_APP(self), _("Setting up Spice session..."));
|
|
|
1efd99 |
- } else {
|
|
|
1efd99 |
-#endif
|
|
|
1efd99 |
retry_dialog:
|
|
|
1efd99 |
+ {
|
|
|
1efd99 |
if (priv->open_recent_dialog) {
|
|
|
1efd99 |
VirtViewerWindow *main_window = virt_viewer_app_get_main_window(app);
|
|
|
1efd99 |
if (!remote_viewer_connect_dialog(virt_viewer_window_get_window(main_window), &guri)) {
|
|
|
1efd99 |
@@ -1193,9 +755,7 @@ retry_dialog:
|
|
|
1efd99 |
}
|
|
|
1efd99 |
goto cleanup;
|
|
|
1efd99 |
}
|
|
|
1efd99 |
-#ifdef HAVE_SPICE_GTK
|
|
|
1efd99 |
}
|
|
|
1efd99 |
-#endif
|
|
|
1efd99 |
|
|
|
1efd99 |
ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app, &error);
|
|
|
1efd99 |
|
|
|
1efd99 |
--
|
|
|
1efd99 |
2.17.1
|
|
|
1efd99 |
|