[PATCH v2 3/6] UsbWidget update widget on redirection flow

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

 



expose functions to control usb widget sensitivity during  redirection flow

Signed-off-by: Kirill Moizik <kmoizik@xxxxxxxxxx>
---
 src/usb-device-widget.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index 1ec30e3..72f3b34 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -52,6 +52,11 @@ static gboolean spice_usb_device_widget_update_status(gpointer user_data);
 /* ------------------------------------------------------------------ */
 /* gobject glue                                                       */
 
+
+#ifdef USE_USBREDIR
+static void set_sensitive_all(GtkWidget *widget, gpointer user_data);
+#endif
+
 #define SPICE_USB_DEVICE_WIDGET_GET_PRIVATE(obj) \
     (G_TYPE_INSTANCE_GET_PRIVATE((obj), SPICE_TYPE_USB_DEVICE_WIDGET, \
                                  SpiceUsbDeviceWidgetPrivate))
@@ -425,6 +430,29 @@ typedef struct _connect_cb_data {
     SpiceUsbDeviceWidget *self;
 } connect_cb_data;
 
+static void set_redirecting(SpiceUsbDeviceWidget *self, gboolean val)
+{
+#ifdef USE_USBREDIR
+    g_object_set(self->priv->manager,"redirecting", val, NULL);
+#ifndef USE_LIBUSB_HOTPLUG
+    spice_g_udev_set_redirecting(val);
+#endif
+    gboolean sensitive = !val;
+    if (val == TRUE) {
+        spice_usb_device_widget_show_info_bar(self, _("Redirecting Usb Device"),
+                                     GTK_MESSAGE_INFO,
+                                     GTK_STOCK_DIALOG_INFO);
+    } else {
+#ifndef USE_LIBUSB_HOTPLUG
+        spice_g_udev_handle_device_change();
+#endif
+        spice_usb_device_widget_hide_info_bar(self);
+    }
+    gtk_container_foreach(GTK_CONTAINER(self),
+                          set_sensitive_all, (gpointer) &sensitive);
+#endif
+}
+
 static void connect_cb(GObject *gobject, GAsyncResult *res, gpointer user_data)
 {
     SpiceUsbDeviceManager *manager = SPICE_USB_DEVICE_MANAGER(gobject);
@@ -435,6 +463,7 @@ static void connect_cb(GObject *gobject, GAsyncResult *res, gpointer user_data)
     GError *err = NULL;
     gchar *desc;
 
+    set_redirecting (self,FALSE);
     spice_usb_device_manager_connect_device_finish(manager, res, &err);
     if (err) {
         device = g_object_get_data(G_OBJECT(data->check), "usb-device");
@@ -502,6 +531,10 @@ static void device_added_cb(SpiceUsbDeviceManager *manager,
                                                      device))
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE);
 
+
+    if (redirecting) {
+        gtk_widget_set_sensitive(check, FALSE);
+    }
     g_object_set_data_full(
             G_OBJECT(check), "usb-device",
             g_boxed_copy(spice_usb_device_get_type(), device),
@@ -542,6 +575,21 @@ static void set_inactive_by_usb_device(GtkWidget *widget, gpointer user_data)
     }
 }
 
+#ifdef USE_USBREDIR
+static void set_sensitive_all(GtkWidget *widget, gpointer user_data)
+{
+    gboolean sensitive = *((gboolean *)user_data);
+    SpiceUsbDevice *device;
+    if (GTK_IS_BIN(widget)) {
+        GtkWidget *check = gtk_bin_get_child(GTK_BIN(widget));
+        device = get_usb_device(widget);
+        if (!device)
+            return; /* Non device widget, ie the info_bar */
+        gtk_widget_set_sensitive(check, sensitive);
+    }
+}
+#endif
+
 static void device_error_cb(SpiceUsbDeviceManager *manager,
     SpiceUsbDevice *device, GError *err, gpointer user_data)
 {
-- 
2.1.0

_______________________________________________
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]