[PATCH v4 14/16] UsbDeviceWidget: Consider asynchronous redirection flows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kirill Moizik <kmoizik@xxxxxxxxxx>

Gray out redirection controls while there are
asynchronous redirection flows in progress.

Signed-off-by: Kirill Moizik <kmoizik@xxxxxxxxxx>
Signed-off-by: Dmitry Fleytman <dfleytma@xxxxxxxxxx>
---
 src/usb-device-widget.c | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index 1f762fb..4d986c6 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -372,27 +372,29 @@ static void check_can_redirect(GtkWidget *widget, gpointer user_data)
         return; /* Non device widget, ie the info_bar */
 
     priv->device_count++;
-    can_redirect = spice_usb_device_manager_can_redirect_device(priv->manager,
-                                                                device, &err);
-    gtk_widget_set_sensitive(widget, can_redirect);
-
-    /* If we cannot redirect this device, append the error message to
-       err_msg, but only if it is *not* already there! */
-    if (!can_redirect) {
-        if (priv->err_msg) {
-            if (!strstr(priv->err_msg, err->message)) {
-                gchar *old_err_msg = priv->err_msg;
 
-                priv->err_msg = g_strdup_printf("%s\n%s", priv->err_msg,
-                                                err->message);
-                g_free(old_err_msg);
+    if (spice_usb_device_manager_is_redirecting(priv->manager)) {
+        can_redirect = FALSE;
+    } else {
+        can_redirect = spice_usb_device_manager_can_redirect_device(priv->manager,
+                                                                    device, &err);
+        /* If we cannot redirect this device, append the error message to
+           err_msg, but only if it is *not* already there! */
+        if (!can_redirect) {
+            if (priv->err_msg) {
+                if (!strstr(priv->err_msg, err->message)) {
+                    gchar *old_err_msg = priv->err_msg;
+                    priv->err_msg = g_strdup_printf("%s\n%s", priv->err_msg,
+                                                    err->message);
+                    g_free(old_err_msg);
+                }
+            } else {
+                priv->err_msg = g_strdup(err->message);
             }
-        } else {
-            priv->err_msg = g_strdup(err->message);
         }
+        g_clear_error(&err);
     }
-
-    g_clear_error(&err);
+    gtk_widget_set_sensitive(widget, can_redirect);
 }
 
 static gboolean spice_usb_device_widget_update_status(gpointer user_data)
@@ -456,9 +458,9 @@ static void connect_cb(GObject *gobject, GAsyncResult *res, gpointer user_data)
         g_error_free(err);
 
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->check), FALSE);
-        spice_usb_device_widget_update_status(self);
-    }
 
+    }
+    spice_usb_device_widget_update_status(self);
     g_object_unref(data->check);
     g_object_unref(data->self);
     g_free(data);
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]