[virt-tools-list] [PATCH 07/22] window: set sensitivity based on display capability

Victor Toso victortoso at redhat.com
Fri Aug 31 06:43:57 UTC 2018


Hi,

On Tue, Jul 31, 2018 at 03:41:10PM +0200, marcandre.lureau at redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau at redhat.com>

I take this is a preparatory patch for VTE, could you please add
some rationale in the commit log on why this was needed?

> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> ---
>  src/virt-viewer-display.h |  6 ++++++
>  src/virt-viewer-window.c  | 14 ++++++++++----
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
> index 7016a85..eadc333 100644
> --- a/src/virt-viewer-display.h
> +++ b/src/virt-viewer-display.h
> @@ -86,6 +86,12 @@ struct _VirtViewerDisplayClass {
>      void (*disable)(VirtViewerDisplay *display);
>  };
>  
> +#define VIRT_VIEWER_DISPLAY_CAN_SCREENSHOT(display) \
> +    (VIRT_VIEWER_DISPLAY_GET_CLASS(display)->get_pixbuf != NULL)
> +
> +#define VIRT_VIEWER_DISPLAY_CAN_SEND_KEYS(display) \
> +    (VIRT_VIEWER_DISPLAY_GET_CLASS(display)->send_keys != NULL)
> +
>  GType virt_viewer_display_get_type(void);
>  
>  GtkWidget *virt_viewer_display_new(void);
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index b9b8ce9..ec9bae6 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -1339,15 +1339,21 @@ virt_viewer_window_set_menus_sensitive(VirtViewerWindow *self, gboolean sensitiv
>      gtk_widget_set_sensitive(menu, sensitive);
>  
>      menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-file-screenshot"));
> -    gtk_widget_set_sensitive(menu, sensitive);
> +    gtk_widget_set_sensitive(menu, sensitive && self->priv->display != NULL &&
> +                             VIRT_VIEWER_DISPLAY_CAN_SCREENSHOT(self->priv->display));

Why not moving the display != NULL check into the macro?

>      menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-view-zoom"));
>      gtk_widget_set_sensitive(menu, sensitive);
>  
> -    menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send"));
> -    gtk_widget_set_sensitive(menu, sensitive);
> +    {
> +        gboolean can_send = sensitive && self->priv->display != NULL &&
> +            VIRT_VIEWER_DISPLAY_CAN_SEND_KEYS(self->priv->display);

Ditto.

>  
> -    gtk_widget_set_sensitive(self->priv->toolbar_send_key, sensitive);
> +        menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send"));
> +        gtk_widget_set_sensitive(menu, can_send);
> +
> +        gtk_widget_set_sensitive(self->priv->toolbar_send_key, can_send);
> +    }
>  }

Cheers,
Victor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20180831/c9e134b3/attachment.sig>


More information about the virt-tools-list mailing list