[Spice-devel] [PATCH v6 11/14] UsbDeviceWidget: Show info bar during redirection flows

Dmitry Fleytman dmitry at daynix.com
Sun Feb 28 09:54:21 UTC 2016


From: Kirill Moizik <kmoizik at redhat.com>

Signed-off-by: Kirill Moizik <kmoizik at redhat.com>
Signed-off-by: Dmitry Fleytman <dfleytma at redhat.com>
---
 src/map-file             |  1 +
 src/usb-device-manager.c | 23 +++++++++++++++++++++++
 src/usb-device-manager.h |  2 ++
 src/usb-device-widget.c  |  7 +++++++
 4 files changed, 33 insertions(+)

diff --git a/src/map-file b/src/map-file
index 1f7755b..b9ba950 100644
--- a/src/map-file
+++ b/src/map-file
@@ -128,6 +128,7 @@ spice_usb_device_manager_connect_device_async;
 spice_usb_device_manager_connect_device_finish;
 spice_usb_device_manager_disconnect_device;
 spice_usb_device_manager_disconnect_device_async;
+spice_usb_device_manager_is_redirecting;
 spice_usb_device_manager_get;
 spice_usb_device_manager_get_devices;
 spice_usb_device_manager_get_devices_with_filter;
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 7a90a2a..c51cdba 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -232,6 +232,29 @@ _set_redirecting(SpiceUsbDeviceManager *self, gboolean is_redirecting)
 G_DEFINE_BOXED_TYPE(SpiceUsbDevice, spice_usb_device, g_object_ref, g_object_unref)
 #endif
 
+/**
+* spice_usb_device_manager_is_redirecting:
+* @manager: the #SpiceUsbDeviceManager manager
+*
+* Returns: %TRUE if device redirection negotiation flow is in progress
+*/
+gboolean spice_usb_device_manager_is_redirecting(SpiceUsbDeviceManager *self)
+{
+#ifdef USE_USBREDIR
+
+#ifdef USE_GUDEV
+    gboolean redirecting;
+    g_object_get(self->priv->udev, "redirecting", &redirecting, NULL);
+    return redirecting;
+#else
+    return self->priv->redirecting;
+#endif
+
+#else
+    return FALSE;
+#endif
+}
+
 static void spice_usb_device_manager_initable_iface_init(GInitableIface *iface);
 
 static guint signals[LAST_SIGNAL] = { 0, };
diff --git a/src/usb-device-manager.h b/src/usb-device-manager.h
index d705e74..814af2e 100644
--- a/src/usb-device-manager.h
+++ b/src/usb-device-manager.h
@@ -135,6 +135,8 @@ spice_usb_device_manager_can_redirect_device(SpiceUsbDeviceManager  *self,
                                              SpiceUsbDevice         *device,
                                              GError                **err);
 
+gboolean spice_usb_device_manager_is_redirecting(SpiceUsbDeviceManager *self);
+
 G_END_DECLS
 
 #endif /* __SPICE_USB_DEVICE_MANAGER_H__ */
diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index fe983c9..9409036 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -401,6 +401,9 @@ static gboolean spice_usb_device_widget_update_status(gpointer user_data)
 {
     SpiceUsbDeviceWidget *self = SPICE_USB_DEVICE_WIDGET(user_data);
     SpiceUsbDeviceWidgetPrivate *priv = self->priv;
+    gboolean redirecting;
+
+    redirecting = spice_usb_device_manager_is_redirecting(priv->manager);
 
     priv->device_count = 0;
     gtk_container_foreach(GTK_CONTAINER(self), check_can_redirect, self);
@@ -411,6 +414,10 @@ static gboolean spice_usb_device_widget_update_status(gpointer user_data)
                                               GTK_STOCK_DIALOG_WARNING);
         g_free(priv->err_msg);
         priv->err_msg = NULL;
+    } else if (redirecting) {
+        spice_usb_device_widget_show_info_bar(self, _("Redirecting USB Device..."),
+                                              GTK_MESSAGE_INFO,
+                                              GTK_STOCK_DIALOG_INFO);
     } else {
         spice_usb_device_widget_hide_info_bar(self);
     }
-- 
2.5.0



More information about the Spice-devel mailing list