[Spice-devel] [PATCH v5 10/13] UsbDeviceWidget: Show info bar during redirection flows
Jonathon Jongsma
jjongsma at redhat.com
Wed Feb 10 22:52:05 UTC 2016
On Thu, 2015-10-29 at 17:27 +0200, Dmitry Fleytman wrote:
> 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 | 8 ++++++++
> 4 files changed, 34 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 d927ecd..c697697 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
>
> +/**
> +* spcie_usb_device_manager_is_redirecting:
typo: spcie -> spice
> +* @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..f88573a 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);
> @@ -419,6 +422,11 @@ static gboolean
> spice_usb_device_widget_update_status(gpointer user_data)
> spice_usb_device_widget_show_info_bar(self, _("No USB devices
> detected"),
> GTK_MESSAGE_INFO,
> GTK_STOCK_DIALOG_INFO);
> + if (redirecting == TRUE) {
> + spice_usb_device_widget_show_info_bar(self, _("Redirecting USB
> Device..."),
> + GTK_MESSAGE_INFO,
> + GTK_STOCK_DIALOG_INFO);
> + }
This will potentially overwrite any info bars that we just showed, such as error
messagese. I think it would probably be better to put this case into the 'else'
clause a few lines above where priv->err_msg is NULL.
> return FALSE;
> }
>
Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com>
More information about the Spice-devel
mailing list