[virt-tools-list] [PATCH virt-viewer 2/3] window: add View/Scale display menu

Marc-André Lureau marcandre.lureau at gmail.com
Thu Feb 27 15:26:22 UTC 2014


Allow to enable/disable scaling from display window menu.

When scaling is disabled, zoom_level can't be used, so disable the
submenu.
---
 src/virt-viewer-window.c | 14 ++++++++++++++
 src/virt-viewer.xml      | 29 +++++++++++++++++++----------
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 05d5fe7..ce92aa0 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -873,6 +873,20 @@ virt_viewer_window_menu_view_fullscreen(GtkWidget *menu,
 }
 
 G_MODULE_EXPORT void
+virt_viewer_window_menu_view_scale(GtkWidget *menu,
+                                   VirtViewerWindow *self)
+{
+    VirtViewerWindowPrivate *priv = self->priv;
+    gboolean scale;
+
+    scale = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu));
+    g_object_set(priv->display, "scale", scale, NULL);
+
+    menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-view-zoom"));
+    gtk_widget_set_sensitive(menu, scale);
+}
+
+G_MODULE_EXPORT void
 virt_viewer_window_menu_view_resize(GtkWidget *menu,
                                     VirtViewerWindow *self)
 {
diff --git a/src/virt-viewer.xml b/src/virt-viewer.xml
index 4917201..a389132 100644
--- a/src/virt-viewer.xml
+++ b/src/virt-viewer.xml
@@ -114,6 +114,25 @@
                       </object>
                     </child>
                     <child>
+                      <object class="GtkCheckMenuItem" id="menu-view-resize">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Resize display</property>
+                        <property name="use_underline">True</property>
+                        <signal name="toggled" handler="virt_viewer_window_menu_view_resize" swapped="no"/>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkCheckMenuItem" id="menu-view-scale">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Scale display</property>
+                        <property name="use_underline">True</property>
+                        <property name="active">True</property>
+                        <signal name="toggled" handler="virt_viewer_window_menu_view_scale" swapped="no"/>
+                      </object>
+                    </child>
+                    <child>
                       <object class="GtkMenuItem" id="menu-view-zoom">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
@@ -172,16 +191,6 @@
                       </object>
                     </child>
                     <child>
-                      <object class="GtkCheckMenuItem" id="menu-view-resize">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="label" translatable="yes">Automatically resize</property>
-                        <property name="use_underline">True</property>
-                        <signal name="toggled" handler="virt_viewer_window_menu_view_resize" swapped="no"/>
-                      </object>
-                    </child>
-                    <child>
                       <object class="GtkMenuItem" id="menu-displays">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-- 
1.8.5.3




More information about the virt-tools-list mailing list