[virt-tools-list] [PATCH v2 02/16] window: set sensitivity based on display capability

Victor Toso victortoso at redhat.com
Thu Dec 20 16:13:08 UTC 2018


Hi,

On Wed, Sep 26, 2018 at 07:26:25PM +0400, marcandre.lureau at redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau at redhat.com>
> 
> A following patch is adding a new display (VTE) that won't have the
> send_key() or screenshot() callbacks. Activating those menu/actions
> would lead to nothing or a crash. I chose to keep the UI consistent
> for all display, but disable the menu sensitivity.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
Acked-by: Victor Toso <victortoso 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..2de17db 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) \
> +    (display && (VIRT_VIEWER_DISPLAY_GET_CLASS(display)->get_pixbuf != NULL))
> +
> +#define VIRT_VIEWER_DISPLAY_CAN_SEND_KEYS(display) \
> +    (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 74afb32..e50ac54 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 &&
> +                             VIRT_VIEWER_DISPLAY_CAN_SCREENSHOT(self->priv->display));
>  
>      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 &&
> +            VIRT_VIEWER_DISPLAY_CAN_SEND_KEYS(self->priv->display);
>  
> -    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);
> +    }
>  }
>  
>  static void
> -- 
> 2.19.0.271.gfe8321ec05
> 
-------------- 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/20181220/927e119c/attachment.sig>


More information about the virt-tools-list mailing list