[virt-tools-list] [PATCH 07/22] window: set sensitivity based on display capability
Marc-André Lureau
marcandre.lureau at redhat.com
Fri Aug 31 11:21:40 UTC 2018
Hi
On Fri, Aug 31, 2018 at 8:43 AM, Victor Toso <victortoso at redhat.com> wrote:
> 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?
Indeed, a following patch is adding a new display that won't have the
send_key() or screenshot() callbacks. Activating those menu/actions
would lead to crash. I chose to keep the UI consistent for all
display, but disable the menu sensitivy.
I'll update the commit message.
>> 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?
ok
>
>> 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
More information about the virt-tools-list
mailing list