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

[virt-tools-list] [virt-manager][PATCH 1/2] Add preference to ask for confirmation while deleting a running VM.



From: Leonardo Garcia <lagarcia br ibm com>

---
 data/org.virt-manager.virt-manager.gschema.xml |    6 ++++
 ui/vmm-preferences.ui                          |   31 ++++++++++++++++++++++++
 virtManager/config.py                          |    4 +++
 virtManager/preferences.py                     |    7 +++++
 4 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/data/org.virt-manager.virt-manager.gschema.xml b/data/org.virt-manager.virt-manager.gschema.xml
index d086a64..de8a2ef 100644
--- a/data/org.virt-manager.virt-manager.gschema.xml
+++ b/data/org.virt-manager.virt-manager.gschema.xml
@@ -264,6 +264,12 @@
       <description>Whether we require a confirmation on deleting storage</description>
     </key>
 
+	<key name="delete-running-vm" type="b">
+		<default>true</default>
+		<summary>Confirm deleting running VM</summary>
+		<description>Whether we require a confirmation on deleting a running a VM</description>
+	</key>
+
   </schema>
 
 </schemalist>
diff --git a/ui/vmm-preferences.ui b/ui/vmm-preferences.ui
index 61ba17b..e884bab 100644
--- a/ui/vmm-preferences.ui
+++ b/ui/vmm-preferences.ui
@@ -898,6 +898,37 @@
                                 <property name="y_options"/>
                               </packing>
                             </child>
+                            <child>
+                            	<object class="GtkLabel" id="label9">
+                            		<property name="visible">True</property>
+                            		<property name="can_focus">False</property>
+                            		<property name="xalign">0</property>
+                            		<property name="label" translatable="yes">Delete running VM:</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="prefs-confirm-delrunningvm">
+                            		<property name="visible">True</property>
+                            		<property name="can_focus">True</property>
+                            		<property name="receives_default">False</property>
+                            		<property name="xalign">0</property>
+                            		<property name="draw_indicator">True</property>
+                            		<signal name="toggled" handler="on_prefs_confirm_delrunningvm_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="y_options"/>
+                            	</packing>
+                            </child>
                           </object>
                         </child>
                       </object>
diff --git a/virtManager/config.py b/virtManager/config.py
index 52f4142..e163995 100644
--- a/virtManager/config.py
+++ b/virtManager/config.py
@@ -313,6 +313,8 @@ class vmmConfig(object):
         return self.conf.get("/confirm/unapplied-dev")
     def get_confirm_delstorage(self):
         return self.conf.get("/confirm/delete-storage")
+    def get_confirm_delrunningvm(self):
+        return self.conf.get("/confirm/delete-running-vm")
 
 
     def set_confirm_forcepoweroff(self, val):
@@ -329,6 +331,8 @@ class vmmConfig(object):
         self.conf.set("/confirm/unapplied-dev", val)
     def set_confirm_delstorage(self, val):
         self.conf.set("/confirm/delete-storage", val)
+    def set_confirm_delrunningvm(self, val):
+        self.conf.set("/confirm/delete-running-vm", val)
 
 
     # System tray visibility
diff --git a/virtManager/preferences.py b/virtManager/preferences.py
index 1c64f48..2255325 100644
--- a/virtManager/preferences.py
+++ b/virtManager/preferences.py
@@ -52,6 +52,7 @@ class vmmPreferences(vmmGObjectUI):
         self.refresh_confirm_interface()
         self.refresh_confirm_unapplied()
         self.refresh_confirm_delstorage()
+        self.refresh_confirm_delrunningvm()
 
         self.builder.connect_signals({
             "on_prefs_system_tray_toggled" : self.change_view_system_tray,
@@ -70,6 +71,7 @@ class vmmPreferences(vmmGObjectUI):
             "on_prefs_confirm_interface_toggled": self.change_confirm_interface,
             "on_prefs_confirm_unapplied_toggled": self.change_confirm_unapplied,
             "on_prefs_confirm_delstorage_toggled": self.change_confirm_delstorage,
+            "on_prefs_confirm_delrunningvm_toggled": self.change_confirm_delrunningvm,
             "on_prefs_btn_keys_define_clicked": self.change_grab_keys,
             "on_prefs_graphics_type_changed": self.change_graphics_type,
             "on_prefs_storage_format_changed": self.change_storage_format,
@@ -191,6 +193,9 @@ class vmmPreferences(vmmGObjectUI):
     def refresh_confirm_delstorage(self):
         self.widget("prefs-confirm-delstorage").set_active(
                                 self.config.get_confirm_delstorage())
+    def refresh_confirm_delrunningvm(self):
+        self.widget("prefs-confirm-delrunningvm").set_active(
+                                self.config.get_confirm_delrunningvm())
 
     def grabkeys_get_string(self, events):
         keystr = ""
@@ -280,6 +285,8 @@ class vmmPreferences(vmmGObjectUI):
         self.config.set_confirm_unapplied(src.get_active())
     def change_confirm_delstorage(self, src):
         self.config.set_confirm_delstorage(src.get_active())
+    def change_confirm_delrunningvm(self, src):
+        self.config.set_confirm_delrunningvm(src.get_active())
 
     def change_graphics_type(self, src):
         gtype = 'vnc'
-- 
1.7.1


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