[virt-tools-list] [PATCH virt-viewer 3/3] window: disable view/resize guest menu

Marc-André Lureau marcandre.lureau at gmail.com
Wed Mar 12 16:42:04 UTC 2014


Set the sensitivity of the menu based on the capability of the display.

https://bugzilla.redhat.com/show_bug.cgi?id=1007649
---
 src/virt-viewer-window.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 05d5fe7..50b8d55 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -287,7 +287,6 @@ virt_viewer_window_init (VirtViewerWindow *self)
 {
     VirtViewerWindowPrivate *priv;
     GtkWidget *vbox;
-    GtkWidget *menu;
     GdkColor color;
     GSList *accels;
 
@@ -301,10 +300,9 @@ virt_viewer_window_init (VirtViewerWindow *self)
     priv->notebook = virt_viewer_notebook_new();
     priv->builder = virt_viewer_util_load_ui("virt-viewer.xml");
 
-    menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-view-resize"));
-    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
-    gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-send")), FALSE);
-    gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-file-screenshot")), FALSE);
+    gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-view-resize")), FALSE);
+    gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send")), FALSE);
+    gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-file-screenshot")), FALSE);
 
     gtk_builder_connect_signals(priv->builder, self);
 
@@ -1242,6 +1240,9 @@ virt_viewer_window_set_display(VirtViewerWindow *self, VirtViewerDisplay *displa
         gtk_notebook_remove_page(GTK_NOTEBOOK(priv->notebook), 1);
         g_object_unref(priv->display);
         priv->display = NULL;
+    } else {
+        /* set auto-resize active by default, if display can */
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_builder_get_object(self->priv->builder, "menu-view-resize")), virt_viewer_display_can_auto_resize(display));
     }
 
     if (display != NULL) {
@@ -1252,6 +1253,9 @@ virt_viewer_window_set_display(VirtViewerWindow *self, VirtViewerDisplay *displa
         virt_viewer_display_set_monitor(VIRT_VIEWER_DISPLAY(priv->display), priv->fullscreen_monitor);
         virt_viewer_display_set_fullscreen(VIRT_VIEWER_DISPLAY(priv->display), priv->fullscreen);
 
+        gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-view-resize")),
+                                 virt_viewer_display_can_auto_resize(display));
+
         gtk_widget_show_all(GTK_WIDGET(display));
         gtk_notebook_append_page(GTK_NOTEBOOK(priv->notebook), GTK_WIDGET(display), NULL);
         gtk_widget_realize(GTK_WIDGET(display));
-- 
1.8.5.3




More information about the virt-tools-list mailing list