mirror of
https://gitlab.com/virt-viewer/virt-viewer.git
synced 2025-02-01 05:47:06 +03:00
window: set sensitivity based on display capability
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@redhat.com> Acked-by: Victor Toso <victortoso@redhat.com>
This commit is contained in:
parent
ffd1f05c08
commit
8cdc91227d
@ -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);
|
||||
|
@ -1349,15 +1349,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
|
||||
|
Loading…
x
Reference in New Issue
Block a user