On Mon, Aug 03, 2015 at 04:10:51PM +0300, Kirill Moizik wrote:From: Kirill Moizik <kmoizik@xxxxxxxxxx>
--- src/usb-device-widget.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c index 4d66e12..fcafc92 100644 --- a/src/usb-device-widget.c +++ b/src/usb-device-widget.c @@ -366,33 +366,39 @@ static void check_can_redirect(GtkWidget *widget, gpointer user_data) SpiceUsbDevice *device; gboolean can_redirect; GError *err = NULL; + gboolean redirecting; + g_object_get(priv->manager, "redirecting", &redirecting, NULL);
device = get_usb_device(widget); if (!device) 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; + if (redirecting) { + // if we are at redirecting state, then there is at least one usb device + priv->device_count++; + can_redirect = FALSE;
Imo this should be handled byspice_usb_device_manager_can_redirect_device() (this can have a specialerror-code which is filtered out).
I tried to do like you suggested but didn’t like it because it makes interface of spice_usb_device_manager_can_redirect_device() ugly.
Also “is redirection in progress” is a temporary system property, not a permanent per-device one.
I’d leave this untouched. Christophe+ } else {
- priv->err_msg = g_strdup_printf("%s\n%s", priv->err_msg, - err->message); - g_free(old_err_msg); + priv->device_count++; + 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) @@ -455,9 +461,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
|