[virt-tools-list] [PATCH] ui: allow to set an empty password for graphics

Giuseppe Scrivano gscrivano at gnu.org
Wed Jul 31 00:03:28 UTC 2013


Now when the `password' field is empty and `allow empty password' is
selected the password is set to "".
The former behaviour (an empty `password' field unsets the password)
is maintained if the `allow empty password' is not selected.

Solves: https://bugzilla.redhat.com/show_bug.cgi?id=749718

Signed-off-by: Giuseppe Scrivano <gscrivano at gnu.org>
---
 ui/vmm-details.ui      | 183 +++++++++++++++++++++++++++++--------------------
 virtManager/details.py |  17 ++++-
 virtManager/domain.py  |   2 +-
 3 files changed, 124 insertions(+), 78 deletions(-)

diff --git a/ui/vmm-details.ui b/ui/vmm-details.ui
index ee5bc45..73b23a6 100644
--- a/ui/vmm-details.ui
+++ b/ui/vmm-details.ui
@@ -5216,7 +5216,7 @@ I/O:</property>
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="border_width">3</property>
-                                            <property name="n_rows">8</property>
+                                            <property name="n_rows">9</property>
                                             <property name="n_columns">2</property>
                                             <property name="column_spacing">8</property>
                                             <child>
@@ -5284,79 +5284,6 @@ I/O:</property>
                                               </packing>
                                             </child>
                                             <child>
-                                              <object class="GtkLabel" id="gfx-password-title">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">False</property>
-                                                <property name="xalign">1</property>
-                                                <property name="yalign">0</property>
-                                                <property name="ypad">7</property>
-                                                <property name="label" translatable="yes">_Password:</property>
-                                                <property name="use_underline">True</property>
-                                              </object>
-                                              <packing>
-                                                <property name="top_attach">6</property>
-                                                <property name="bottom_attach">7</property>
-                                                <property name="x_options">GTK_FILL</property>
-                                                <property name="y_options"/>
-                                              </packing>
-                                            </child>
-                                            <child>
-                                              <object class="GtkLabel" id="gfx-keymap-title">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">False</property>
-                                                <property name="xalign">1</property>
-                                                <property name="ypad">8</property>
-                                                <property name="label" translatable="yes">_Keymap:</property>
-                                                <property name="use_underline">True</property>
-                                                <property name="mnemonic_widget">gfx-keymap-combo</property>
-                                              </object>
-                                              <packing>
-                                                <property name="top_attach">7</property>
-                                                <property name="bottom_attach">8</property>
-                                                <property name="x_options">GTK_FILL</property>
-                                                <property name="y_options"/>
-                                              </packing>
-                                            </child>
-                                            <child>
-                                              <object class="GtkHBox" id="gfx-keymap-box">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">False</property>
-                                                <child>
-                                                  <object class="GtkComboBox" id="gfx-keymap-combo">
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">False</property>
-                                                    <signal name="changed" handler="on_vnc_keymap_combo_changed" swapped="no"/>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="expand">True</property>
-                                                    <property name="fill">True</property>
-                                                    <property name="position">0</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <object class="GtkLabel" id="gfx-keymap-label">
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">False</property>
-                                                    <property name="xalign">0</property>
-                                                    <property name="label">label</property>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="expand">True</property>
-                                                    <property name="fill">True</property>
-                                                    <property name="position">1</property>
-                                                  </packing>
-                                                </child>
-                                              </object>
-                                              <packing>
-                                                <property name="left_attach">1</property>
-                                                <property name="right_attach">2</property>
-                                                <property name="top_attach">7</property>
-                                                <property name="bottom_attach">8</property>
-                                                <property name="x_options">GTK_FILL</property>
-                                                <property name="y_options"/>
-                                              </packing>
-                                            </child>
-                                            <child>
                                               <object class="GtkLabel" id="gfx-display-title">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
@@ -5515,6 +5442,114 @@ I/O:</property>
                                                 <property name="y_options">GTK_FILL</property>
                                               </packing>
                                             </child>
+                                            <child>
+                                              <object class="GtkLabel" id="gfx-keymap-title">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <property name="xalign">1</property>
+                                                <property name="ypad">8</property>
+                                                <property name="label" translatable="yes">_Keymap:</property>
+                                                <property name="use_underline">True</property>
+                                              </object>
+                                              <packing>
+                                                <property name="top_attach">8</property>
+                                                <property name="bottom_attach">9</property>
+                                                <property name="x_options">GTK_FILL</property>
+                                                <property name="y_options"/>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <object class="GtkHBox" id="gfx-keymap-box">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <child>
+                                                  <object class="GtkComboBox" id="gfx-keymap-combo">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <signal name="changed" handler="on_vnc_keymap_combo_changed" swapped="no"/>
+                                                  </object>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">True</property>
+                                                    <property name="position">0</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <object class="GtkLabel" id="gfx-keymap-label">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="xalign">0</property>
+                                                    <property name="label">label</property>
+                                                  </object>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">True</property>
+                                                    <property name="position">1</property>
+                                                  </packing>
+                                                </child>
+                                              </object>
+                                              <packing>
+                                                <property name="left_attach">1</property>
+                                                <property name="right_attach">2</property>
+                                                <property name="top_attach">8</property>
+                                                <property name="bottom_attach">9</property>
+                                                <property name="x_options">GTK_FILL</property>
+                                                <property name="y_options"/>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <object class="GtkLabel" id="gfx-password-title">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <property name="xalign">1</property>
+                                                <property name="yalign">0</property>
+                                                <property name="ypad">7</property>
+                                                <property name="label" translatable="yes">_Password:</property>
+                                                <property name="use_underline">True</property>
+                                              </object>
+                                              <packing>
+                                                <property name="top_attach">6</property>
+                                                <property name="bottom_attach">7</property>
+                                                <property name="x_options">GTK_FILL</property>
+                                                <property name="y_options"/>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <object class="GtkLabel" id="gfx-empty-password-title">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <property name="xalign">1</property>
+                                                <property name="yalign">0</property>
+                                                <property name="ypad">7</property>
+                                                <property name="label" translatable="yes">_Allow Empty Password:</property>
+                                                <property name="use_underline">True</property>
+                                              </object>
+                                              <packing>
+                                                <property name="top_attach">7</property>
+                                                <property name="bottom_attach">8</property>
+                                                <property name="x_options">GTK_FILL</property>
+                                                <property name="y_options"/>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <object class="GtkCheckButton" id="gfx-empty-password">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="receives_default">False</property>
+                                                <property name="use_stock">True</property>
+                                                <property name="xalign">0</property>
+                                                <property name="draw_indicator">True</property>
+                                                <signal name="toggled" handler="on_vnc_empty_password_toggled" swapped="no"/>
+                                              </object>
+                                              <packing>
+                                                <property name="left_attach">1</property>
+                                                <property name="right_attach">2</property>
+                                                <property name="top_attach">7</property>
+                                                <property name="bottom_attach">8</property>
+                                                <property name="x_options">GTK_FILL</property>
+                                                <property name="y_options"/>
+                                              </packing>
+                                            </child>
                                           </object>
                                         </child>
                                       </object>
diff --git a/virtManager/details.py b/virtManager/details.py
index 597b1c4..c3a5a04 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -43,7 +43,7 @@ import virtinst
 
 
 # Parameters that can be editted in the details window
-EDIT_TOTAL = 38
+EDIT_TOTAL = 39
 (EDIT_NAME,
 EDIT_ACPI,
 EDIT_APIC,
@@ -83,6 +83,7 @@ EDIT_NET_VPORT,
 EDIT_NET_SOURCE,
 
 EDIT_GFX_PASSWD,
+EDIT_GFX_EMPTY_PASSWD,
 EDIT_GFX_TYPE,
 EDIT_GFX_KEYMAP,
 
@@ -488,6 +489,8 @@ class vmmDetails(vmmGObjectUI):
             "on_gfx_type_combo_changed": lambda *x: self.enable_apply(x, EDIT_GFX_TYPE),
             "on_vnc_keymap_combo_changed": lambda *x: self.enable_apply(x,
                                             EDIT_GFX_KEYMAP),
+
+            "on_vnc_empty_password_toggled": lambda *x: self.enable_apply(x, EDIT_GFX_EMPTY_PASSWD),
             "on_vnc_password_changed": lambda *x: self.enable_apply(x, EDIT_GFX_PASSWD),
 
             "on_sound_model_combo_changed": lambda *x: self.enable_apply(x,
@@ -2445,8 +2448,10 @@ class vmmDetails(vmmGObjectUI):
     def config_graphics_apply(self, dev_id_info):
         df, da, add_define, hf, ha, add_hotplug = self.make_apply_data()
 
-        if self.editted(EDIT_GFX_PASSWD):
-            passwd = self.get_text("gfx-password", strip=False) or None
+        if self.editted(EDIT_GFX_PASSWD) or self.editted(EDIT_GFX_EMPTY_PASSWD):
+            allow_empty_passwd = self.widget("gfx-empty-password").get_active()
+            passwd = self.get_text("gfx-password", strip=False)
+            if not allow_empty_passwd: passwd = passwd or None
             add_define(self.vm.define_graphics_password, dev_id_info, passwd)
             add_hotplug(self.vm.hotplug_graphics_password, dev_id_info,
                         passwd)
@@ -3124,6 +3129,10 @@ class vmmDetails(vmmGObjectUI):
             self.widget(base + "-title").show()
             self.widget(base + suffix).show()
 
+        def show_checkbox(widget_name, value):
+            show_row(widget_name)
+            self.widget("gfx-" + widget_name).set_active(value)
+
         def show_text(widget_name, text):
             show_row(widget_name)
             self.widget("gfx-" + widget_name).set_text(text)
@@ -3148,8 +3157,10 @@ class vmmDetails(vmmGObjectUI):
             address = (gfx.listen or "127.0.0.1")
             keymap  = (gfx.keymap or None)
             passwd  = gfx.passwd or ""
+            allow_empty_passwd = gfx.passwd == ""
 
             show_text("password", passwd)
+            show_checkbox("empty-password", allow_empty_passwd)
             show_text("port", port)
             show_text("address", address)
 
diff --git a/virtManager/domain.py b/virtManager/domain.py
index a054d4d..de0df8a 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -889,7 +889,7 @@ class vmmDomain(vmmLibvirtObject):
         self.attach_device(devobj)
 
     def hotplug_graphics_password(self, devobj, newval):
-        devobj.passwd = newval or None
+        devobj.passwd = newval
         self.update_device(devobj)
 
     def hotplug_description(self, desc):
-- 
1.8.3.1




More information about the virt-tools-list mailing list