[PATCH] Add 'fullscreen only' VNC scaling option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The attached patch adds an extra scaling option for a VM's VNC
connection: 'Fullscreen Only'. This required breaking out the UI into
radio buttons rather than a simple boolean checkbox.

Screenshot here:

http://fedorapeople.org/~crobinso/virt-manager/vmm-details-scale.png

Thanks,
Cole
# HG changeset patch
# User Cole Robinson <crobinso@xxxxxxxxxx>
# Date 1234829879 18000
# Node ID 65b6b36745edc39e2c4779a41d0ad35c814efb30
# Parent  dfc19539a91cd5b856e7f01afbbd1e0ba9f4683b
Change VNC scaling options to 'Always', 'Fullscreen only', or 'Never'

diff -r dfc19539a91c -r 65b6b36745ed src/virtManager/details.py
--- a/src/virtManager/details.py	Thu Feb 12 13:32:55 2009 -0500
+++ b/src/virtManager/details.py	Mon Feb 16 19:17:59 2009 -0500
@@ -40,6 +40,11 @@
 
 import virtinst
 
+# Different scaling values
+SCALE_ALWAYS = 0
+SCALE_FULLSCREEN = 1
+SCALE_NEVER = 2
+
 # Columns in hw list model
 HW_LIST_COL_LABEL = 0
 HW_LIST_COL_STOCK_ID = 1
@@ -68,6 +73,7 @@
 PAGE_AUTHENTICATE = 2
 PAGE_VNCVIEWER = 3
 
+# Main tab pages
 PAGE_CONSOLE = 0
 PAGE_DETAILS = 1
 PAGE_DYNAMIC_OFFSET = 2
@@ -223,8 +229,15 @@
             self.vncViewer.set_keyboard_grab(False)
         self.vncViewer.set_pointer_grab(True)
         if not topwin.is_composited():
-            self.vncViewer.set_scaling(True)
-            self.window.get_widget("details-menu-view-scale-display").set_active(True)
+            # XXX: When we have per VM prefs, this will need to be smarter
+            self.scale_type = SCALE_ALWAYS
+        else:
+            self.scale_type = SCALE_NEVER
+
+        self.window.get_widget("details-menu-view-scale-always").set_active(self.scale_type == SCALE_ALWAYS)
+        self.window.get_widget("details-menu-view-scale-never").set_active(self.scale_type == SCALE_NEVER)
+        self.window.get_widget("details-menu-view-scale-fullscreen").set_active(self.scale_type == SCALE_FULLSCREEN)
+        self.update_scaling()
 
         self.vncViewer.connect("vnc-pointer-grab", self.notify_grabbed)
         self.vncViewer.connect("vnc-pointer-ungrab", self.notify_ungrabbed)
@@ -300,7 +313,9 @@
 
             "on_details_menu_view_fullscreen_activate": self.toggle_fullscreen,
             "on_details_menu_view_toolbar_activate": self.toggle_toolbar,
-            "on_details_menu_view_scale_display_activate": self.scale_display,
+            "on_details_menu_view_scale_always_toggled": self.set_scale_type,
+            "on_details_menu_view_scale_fullscreen_toggled": self.set_scale_type,
+            "on_details_menu_view_scale_never_toggled": self.set_scale_type,
 
             "on_details_menu_send_cad_activate": self.send_key,
             "on_details_menu_send_cab_activate": self.send_key,
@@ -424,11 +439,29 @@
         else:
             self.vncViewer.set_keyboard_grab(False)
 
-    def scale_display(self, src):
-        if src.get_active():
+    def set_scale_type(self, src):
+        if not src.get_active():
+            return
+
+        if src == self.window.get_widget("details-menu-view-scale-always"):
+            self.scale_type = SCALE_ALWAYS
+        elif src == self.window.get_widget("details-menu-view-scale-fullscreen"):
+            self.scale_type = SCALE_FULLSCREEN
+        elif src == self.window.get_widget("details-menu-view-scale-never"):
+            self.scale_type = SCALE_NEVER
+
+        self.update_scaling()
+
+    def update_scaling(self):
+        curscale = self.vncViewer.get_scaling()
+        fs = self.window.get_widget("control-fullscreen").get_active()
+
+        if self.scale_type == SCALE_NEVER and curscale == True:
+            self.vncViewer.set_scaling(False)
+        elif self.scale_type == SCALE_ALWAYS and curscale == False:
             self.vncViewer.set_scaling(True)
-        else:
-            self.vncViewer.set_scaling(False)
+        elif self.scale_type == SCALE_FULLSCREEN and curscale != fs:
+            self.vncViewer.set_scaling(fs)
 
     def control_fullscreen(self, src):
         menu = self.window.get_widget("details-menu-view-fullscreen")
@@ -458,6 +491,7 @@
             tabs.set_border_width(6)
             if self.window.get_widget("details-menu-view-toolbar").get_active():
                 self.window.get_widget("details-toolbar").show()
+        self.update_scaling()
 
     def auth_login(self, ignore):
         self.set_password()
diff -r dfc19539a91c -r 65b6b36745ed src/vmm-details.glade
--- a/src/vmm-details.glade	Thu Feb 12 13:32:55 2009 -0500
+++ b/src/vmm-details.glade	Mon Feb 16 19:17:59 2009 -0500
@@ -3,6 +3,8 @@
 <!--*- mode: xml -*-->
 <glade-interface>
   <widget class="GtkWindow" id="vmm-details">
+    <property name="width_request">800</property>
+    <property name="height_request">600</property>
     <property name="title" translatable="yes">Virtual Machine</property>
     <property name="default_width">800</property>
     <property name="default_height">600</property>
@@ -175,11 +177,44 @@
                       </widget>
                     </child>
                     <child>
-                      <widget class="GtkCheckMenuItem" id="details-menu-view-scale-display">
+                      <widget class="GtkMenuItem" id="menuitem1">
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">Scale Display</property>
                         <property name="use_underline">True</property>
-                        <signal name="activate" handler="on_details_menu_view_scale_display_activate"/>
+                        <child>
+                          <widget class="GtkMenu" id="menu1">
+                            <property name="visible">True</property>
+                            <child>
+                              <widget class="GtkRadioMenuItem" id="details-menu-view-scale-always">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">Always</property>
+                                <property name="use_underline">True</property>
+                                <property name="active">True</property>
+                                <signal name="toggled" handler="on_details_menu_view_scale_always_toggled"/>
+                              </widget>
+                            </child>
+                            <child>
+                              <widget class="GtkRadioMenuItem" id="details-menu-view-scale-fullscreen">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">Only when Fullscreen</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_as_radio">True</property>
+                                <property name="group">details-menu-view-scale-always</property>
+                                <signal name="toggled" handler="on_details_menu_view_scale_fullscreen_toggled"/>
+                              </widget>
+                            </child>
+                            <child>
+                              <widget class="GtkRadioMenuItem" id="details-menu-view-scale-never">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">Never</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_as_radio">True</property>
+                                <property name="group">details-menu-view-scale-always</property>
+                                <signal name="toggled" handler="on_details_menu_view_scale_never_toggled"/>
+                              </widget>
+                            </child>
+                          </widget>
+                        </child>
                       </widget>
                     </child>
                     <child>
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux