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

[virt-tools-list] [PATCH 1 of 6] addhardware: add SPICE support



# HG changeset patch
# User Marc-André Lureau <marcandre lureau redhat com>
# Date 1292592962 -3600
# Node ID 4b25ae193e5ccdba7012a8e2d92b219532ecefd7
# Parent  87bb8375eb83d8f29acd14549a389694e8f7b2fd
addhardware: add SPICE support

diff -r 87bb8375eb83 -r 4b25ae193e5c src/virtManager/addhardware.py
--- a/src/virtManager/addhardware.py	Fri Nov 12 16:28:58 2010 +0100
+++ b/src/virtManager/addhardware.py	Fri Dec 17 14:36:02 2010 +0100
@@ -482,6 +482,7 @@
     def populate_graphics_model(self, model):
         model.clear()
         model.append([_("VNC server"), "vnc"])
+        model.append([_("SPICE server"), "spice"])
         model.append([_("Local SDL window"), "sdl"])
 
     def populate_host_device_type_model(self, model):
@@ -573,20 +574,27 @@
             return None
         return _type.get_model().get_value(_type.get_active_iter(), 1)
 
-    def get_config_vnc_port(self):
+    def get_config_graphics_port(self):
         port = self.window.get_widget("graphics-port")
         portAuto = self.window.get_widget("graphics-port-auto")
         if portAuto.get_active():
             return -1
         return int(port.get_value())
 
-    def get_config_vnc_address(self):
+    def get_config_graphics_tls_port(self):
+        port = self.window.get_widget("graphics-tls-port")
+        portAuto = self.window.get_widget("graphics-port-auto")
+        if portAuto.get_active():
+            return -1
+        return int(port.get_value())
+
+    def get_config_graphics_address(self):
         addr = self.window.get_widget("graphics-address")
         if addr.get_active():
             return "0.0.0.0"
         return "127.0.0.1"
 
-    def get_config_vnc_password(self):
+    def get_config_graphics_password(self):
         pw = self.window.get_widget("graphics-password")
         return pw.get_text()
 
@@ -789,20 +797,32 @@
         elif hwpage == PAGE_GRAPHICS:
             graphics = self.get_config_graphics()
             is_vnc = (graphics == virtinst.VirtualGraphics.TYPE_VNC)
+            is_spice = (graphics == virtinst.VirtualGraphics.TYPE_SPICE)
 
-            type_label = is_vnc and _("VNC server") or _("Local SDL window")
-            addr = is_vnc and self.get_config_vnc_address() or _("N/A")
+            type_label = {virtinst.VirtualGraphics.TYPE_VNC: _("VNC server"),
+                          virtinst.VirtualGraphics.TYPE_SDL: _("Local SDL window"),
+                          virtinst.VirtualGraphics.TYPE_SPICE: _("SPICE server")}[graphics]
+
+            addr = _("N/A")
             port_label = _("N/A")
+            tls_port_label = _("N/A")
             passwd_label = _("N/A")
             keymap_label = _("N/A")
 
-            if is_vnc:
-                port = self.get_config_vnc_port()
-                passwd = self.get_config_vnc_password()
+            if is_vnc or is_spice:
+                addr = self.get_config_graphics_address()
+                port = self.get_config_graphics_port()
+                tls_port = self.get_config_graphics_tls_port()
+                passwd = self.get_config_graphics_password()
                 keymap = self.get_config_keymap()
 
-                port_label = ((port == -1) and ("Automatically allocated")
-                                           or port)
+                def port_to_string(port):
+                    return ((port == -1) and _("Automatically allocated") or port)
+                port_label = port_to_string(port)
+                if is_spice:
+                    tls_port_label = port_to_string(tls_port)
+
+            if is_vnc:
                 passwd_label = passwd and _("Yes") or _("No")
                 keymap_label = keymap and keymap or _("Same as host")
 
@@ -810,6 +830,7 @@
                 (_("Type:"),    type_label),
                 (_("Address:"), addr),
                 (_("Port:"),    port_label),
+                (_("TLS port:"), tls_port_label),
                 (_("Password:"), passwd_label),
                 (_("Keymap:"),  keymap_label),
             ]
@@ -915,7 +936,7 @@
     # Graphics listeners
     def change_graphics_type(self,ignore=None):
         graphics = self.get_config_graphics()
-        if graphics == "vnc":
+        if graphics in ["vnc", "spice"]:
             self.window.get_widget("graphics-port-auto").set_sensitive(True)
             self.window.get_widget("graphics-address").set_sensitive(True)
             self.window.get_widget("graphics-password").set_sensitive(True)
@@ -923,6 +944,7 @@
             self.change_port_auto()
         else:
             self.window.get_widget("graphics-port").set_sensitive(False)
+            self.window.get_widget("graphics-tls-port").set_sensitive(False)
             self.window.get_widget("graphics-port-auto").set_sensitive(False)
             self.window.get_widget("graphics-address").set_sensitive(False)
             self.window.get_widget("graphics-password").set_sensitive(False)
@@ -930,10 +952,15 @@
             self.window.get_widget("graphics-keymap").set_sensitive(False)
 
     def change_port_auto(self,ignore=None):
+        graphics = self.get_config_graphics()
+        tls_enable = graphics == "spice"
+
         if self.window.get_widget("graphics-port-auto").get_active():
             self.window.get_widget("graphics-port").set_sensitive(False)
+            self.window.get_widget("graphics-tls-port").set_sensitive(False)
         else:
             self.window.get_widget("graphics-port").set_sensitive(True)
+            self.window.get_widget("graphics-tls-port").set_sensitive(tls_enable)
 
     def change_keymap(self, ignore=None):
         if self.window.get_widget("graphics-keymap-chk").get_active():
@@ -1225,17 +1252,17 @@
 
     def validate_page_graphics(self):
         graphics = self.get_config_graphics()
-        if graphics == "vnc":
-            _type = virtinst.VirtualGraphics.TYPE_VNC
-        else:
-            _type = virtinst.VirtualGraphics.TYPE_SDL
+        _type = {"vnc": virtinst.VirtualGraphics.TYPE_VNC,
+                 "spice": virtinst.VirtualGraphics.TYPE_SPICE,
+                 "sdl": virtinst.VirtualGraphics.TYPE_SDL}[graphics]
 
         self._dev = virtinst.VirtualGraphics(type=_type,
                                              conn=self.vm.get_connection().vmm)
         try:
-            self._dev.port   = self.get_config_vnc_port()
-            self._dev.passwd = self.get_config_vnc_password()
-            self._dev.listen = self.get_config_vnc_address()
+            self._dev.port   = self.get_config_graphics_port()
+            self._dev.tlsPort = self.get_config_graphics_tls_port()
+            self._dev.passwd = self.get_config_graphics_password()
+            self._dev.listen = self.get_config_graphics_address()
             self._dev.keymap = self.get_config_keymap()
         except ValueError, e:
             self.err.val_err(_("Graphics device parameter error"), str(e))
diff -r 87bb8375eb83 -r 4b25ae193e5c src/vmm-add-hardware.glade
--- a/src/vmm-add-hardware.glade	Fri Nov 12 16:28:58 2010 +0100
+++ b/src/vmm-add-hardware.glade	Fri Dec 17 14:36:02 2010 +0100
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <glade-interface>
   <!-- interface-requires gtk+ 2.6 -->
   <!-- interface-naming-policy toplevel-contextual -->
@@ -280,7 +280,7 @@
                                               <widget class="GtkSpinButton" id="config-storage-size">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">True</property>
-                                                <property name="invisible_char">&#x25CF;</property>
+                                                <property name="invisible_char">●</property>
                                                 <property name="width_chars">5</property>
                                                 <property name="xalign">1</property>
                                                 <property name="adjustment">0 0 1000000 0.10000000000000001 10 0</property>
@@ -418,7 +418,7 @@
                                         <property name="width_request">335</property>
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
-                                        <property name="invisible_char">&#x25CF;</property>
+                                        <property name="invisible_char">●</property>
                                       </widget>
                                       <packing>
                                         <property name="expand">False</property>
@@ -638,7 +638,7 @@
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="max_length">17</property>
-                                    <property name="invisible_char">&#x25CF;</property>
+                                    <property name="invisible_char">●</property>
                                     <property name="text" translatable="yes">aa:bb:cc:dd:ee:ff</property>
                                     <accessibility>
                                       <atkproperty name="AtkObject::accessible-name" translatable="yes">MAC Address Field</atkproperty>
@@ -770,7 +770,7 @@
                                           <widget class="GtkEntry" id="net-bridge">
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
-                                            <property name="invisible_char">&#x25CF;</property>
+                                            <property name="invisible_char">●</property>
                                           </widget>
                                           <packing>
                                             <property name="expand">False</property>
@@ -1123,57 +1123,11 @@
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkHBox" id="hbox68">
-                                <property name="visible">True</property>
-                                <property name="spacing">6</property>
-                                <child>
-                                  <widget class="GtkSpinButton" id="graphics-port">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="invisible_char">&#x25CF;</property>
-                                    <property name="adjustment">5900 5900 5999 1 10 0</property>
-                                    <property name="climb_rate">1</property>
-                                    <property name="snap_to_ticks">True</property>
-                                    <property name="numeric">True</property>
-                                    <property name="update_policy">if-valid</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="position">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <widget class="GtkCheckButton" id="graphics-port-auto">
-                                    <property name="label" translatable="yes">A_utomatically allocated</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">False</property>
-                                    <property name="use_underline">True</property>
-                                    <property name="draw_indicator">True</property>
-                                    <signal name="toggled" handler="on_graphics_port_auto_toggled"/>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
-                              </widget>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">3</property>
-                                <property name="bottom_attach">4</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
                               <widget class="GtkEntry" id="graphics-password">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="visibility">False</property>
-                                <property name="invisible_char">&#x25CF;</property>
+                                <property name="invisible_char">●</property>
                               </widget>
                               <packing>
                                 <property name="left_attach">1</property>
@@ -1207,7 +1161,7 @@
                                       <widget class="GtkLabel" id="label428">
                                         <property name="visible">True</property>
                                         <property name="xpad">7</property>
-                                        <property name="label" translatable="yes">&lt;small&gt;&lt;b&gt;Tip:&lt;/b&gt; VNC server is strongly recommended because it allows the virtual display to be embedded inside this application. It may also be used to allow access to the virtual display from a remote system.&lt;/small&gt;</property>
+                                        <property name="label" translatable="yes">&lt;small&gt;&lt;b&gt;Tip:&lt;/b&gt; VNC or SPICE server is strongly recommended because it allows the virtual display to be embedded inside this application. It may also be used to allow access to the virtual display from a remote system.&lt;/small&gt;</property>
                                         <property name="use_markup">True</property>
                                         <property name="wrap">True</property>
                                       </widget>
@@ -1360,7 +1314,7 @@
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="invisible_char">&#x25CF;</property>
+                                    <property name="invisible_char">●</property>
                                   </widget>
                                   <packing>
                                     <property name="left_attach">3</property>
@@ -1403,6 +1357,76 @@
                                 <property name="x_options">GTK_FILL</property>
                               </packing>
                             </child>
+                            <child>
+                              <widget class="GtkTable" id="table8">
+                                <property name="visible">True</property>
+                                <property name="n_columns">4</property>
+                                <property name="column_spacing">6</property>
+                                <child>
+                                  <widget class="GtkLabel" id="label29">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">1</property>
+                                    <property name="label" translatable="yes">_TLS port:</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="mnemonic_widget">graphics-port</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="y_options"></property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkSpinButton" id="graphics-port">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">●</property>
+                                    <property name="adjustment">5900 5900 5999 1 10 0</property>
+                                    <property name="climb_rate">1</property>
+                                    <property name="snap_to_ticks">True</property>
+                                    <property name="numeric">True</property>
+                                    <property name="update_policy">if-valid</property>
+                                  </widget>
+                                </child>
+                                <child>
+                                  <widget class="GtkCheckButton" id="graphics-port-auto">
+                                    <property name="label" translatable="yes">A_utomatically allocated</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="on_graphics_port_auto_toggled"/>
+                                  </widget>
+                                  <packing>
+                                    <property name="left_attach">3</property>
+                                    <property name="right_attach">4</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkSpinButton" id="graphics-tls-port">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">●</property>
+                                    <property name="adjustment">5901 5900 5999 1 10 0</property>
+                                    <property name="climb_rate">1</property>
+                                    <property name="snap_to_ticks">True</property>
+                                    <property name="numeric">True</property>
+                                    <property name="update_policy">if-valid</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">3</property>
+                                <property name="bottom_attach">4</property>
+                              </packing>
+                            </child>
                           </widget>
                         </child>
                       </widget>


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