[virt-tools-list] [PATCH virt-viewer 20/25] Make the display submenu insensitive if display can't be selected
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Jul 17 19:25:02 UTC 2012
---
src/virt-viewer-app.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 3d7ff68..a88264b 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -1635,15 +1635,31 @@ window_update_menu_displays_cb(gpointer key G_GNUC_UNUSED,
while (tmp) {
int *nth = tmp->data;
VirtViewerWindow *vwin = VIRT_VIEWER_WINDOW(g_hash_table_lookup(self->priv->windows, nth));
+ VirtViewerDisplay *display = virt_viewer_window_get_display(vwin);
GtkWidget *item;
- gboolean visible;
+ gboolean visible, sensitive = FALSE;
gchar *label;
label = g_strdup_printf(_("Display %d"), *nth + 1);
item = gtk_check_menu_item_new_with_label(label);
g_free(label);
+
visible = gtk_widget_get_visible(GTK_WIDGET(virt_viewer_window_get_window(vwin)));
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), visible);
+
+ if (display) {
+ guint hint = virt_viewer_display_get_show_hint(display);
+
+ if (hint & VIRT_VIEWER_DISPLAY_SHOW_HINT_READY)
+ sensitive = TRUE;
+
+ if ((hint & VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED) &&
+ virt_viewer_display_get_selectable(display))
+ sensitive = TRUE;
+ }
+
+ gtk_widget_set_sensitive(item, sensitive);
+
g_signal_connect(G_OBJECT(item),
"toggled", G_CALLBACK(menu_display_visible_toggled_cb), vwin);
gtk_menu_shell_append(submenu, item);
--
1.7.10.4
More information about the virt-tools-list
mailing list