virt-manager
changeset 1362:f65a210898c4
details: Confirm with user before removing a device
Allow this removal to be skipped using a similar 'Don't show this again'
option as the previous commit.
Allow this removal to be skipped using a similar 'Don't show this again'
option as the previous commit.
| author | Cole Robinson <crobinso@redhat.com> |
|---|---|
| date | Wed Nov 18 16:46:36 2009 -0500 (2009-11-18) |
| parents | 958d7ff99a5b |
| children | 77a1cae1067a |
| files | src/virt-manager.schemas.in src/virtManager/config.py src/virtManager/details.py src/virtManager/preferences.py src/vmm-preferences.glade |
line diff
1.1 --- a/src/virt-manager.schemas.in Wed Nov 18 16:11:17 2009 -0500 1.2 +++ b/src/virt-manager.schemas.in Wed Nov 18 16:46:36 2009 -0500 1.3 @@ -311,5 +311,18 @@ 1.4 <long>Whether we require confirmation to pause a VM</long> 1.5 </locale> 1.6 </schema> 1.7 + 1.8 + <schema> 1.9 + <key>/schemas/apps/::PACKAGE::/confirm/removedev</key> 1.10 + <applyto>/apps/::PACKAGE::/confirm/removedev</applyto> 1.11 + <owner>::PACKAGE::</owner> 1.12 + <type>bool</type> 1.13 + <default>1</default> 1.14 + 1.15 + <locale name="C"> 1.16 + <short>Confirm device removal request</short> 1.17 + <long>Whether we require confirmation to remove a virtual device</long> 1.18 + </locale> 1.19 + </schema> 1.20 </schemalist> 1.21 </gconfschemafile>
2.1 --- a/src/virtManager/config.py Wed Nov 18 16:11:17 2009 -0500 2.2 +++ b/src/virtManager/config.py Wed Nov 18 16:46:36 2009 -0500 2.3 @@ -294,6 +294,8 @@ 2.4 return self.conf.get_bool(self.conf_dir + "/confirm/poweroff") 2.5 def get_confirm_pause(self): 2.6 return self.conf.get_bool(self.conf_dir + "/confirm/pause") 2.7 + def get_confirm_removedev(self): 2.8 + return self.conf.get_bool(self.conf_dir + "/confirm/removedev") 2.9 2.10 def set_confirm_forcepoweroff(self, val): 2.11 self.conf.set_bool(self.conf_dir + "/confirm/forcepoweroff", val) 2.12 @@ -301,6 +303,8 @@ 2.13 self.conf.set_bool(self.conf_dir + "/confirm/poweroff", val) 2.14 def set_confirm_pause(self, val): 2.15 self.conf.set_bool(self.conf_dir + "/confirm/pause", val) 2.16 + def set_confirm_removedev(self, val): 2.17 + self.conf.set_bool(self.conf_dir + "/confirm/removedev", val) 2.18 2.19 def on_confirm_forcepoweroff_changed(self, cb): 2.20 self.conf.notify_add(self.conf_dir + "/confirm/forcepoweroff", cb) 2.21 @@ -308,6 +312,8 @@ 2.22 self.conf.notify_add(self.conf_dir + "/confirm/poweroff", cb) 2.23 def on_confirm_pause_changed(self, cb): 2.24 self.conf.notify_add(self.conf_dir + "/confirm/pause", cb) 2.25 + def on_confirm_removedev_changed(self, cb): 2.26 + self.conf.notify_add(self.conf_dir + "/confirm/removedev", cb) 2.27 2.28 2.29 # System tray visibility
3.1 --- a/src/virtManager/details.py Wed Nov 18 16:11:17 2009 -0500 3.2 +++ b/src/virtManager/details.py Wed Nov 18 16:46:36 2009 -0500 3.3 @@ -1098,6 +1098,18 @@ 3.4 # Device removal 3.5 def remove_device(self, dev_type, dev_id_info): 3.6 logging.debug("Removing device: %s %s" % (dev_type, dev_id_info)) 3.7 + do_prompt = self.config.get_confirm_removedev() 3.8 + 3.9 + if do_prompt: 3.10 + res = self.err.warn_chkbox( 3.11 + text1=(_("Are you sure you want to remove this device?")), 3.12 + chktext=_("Don't ask me again."), 3.13 + buttons=gtk.BUTTONS_YES_NO) 3.14 + 3.15 + response, skip_prompt = res 3.16 + if not response: 3.17 + return 3.18 + self.config.set_confirm_removedev(not skip_prompt) 3.19 3.20 detach_err = False 3.21 devxml = self.vm.get_device_xml(dev_type, dev_id_info) 3.22 @@ -1109,20 +1121,17 @@ 3.23 logging.debug("Device could not be hotUNplugged: %s" % str(e)) 3.24 detach_err = True 3.25 3.26 - if detach_err: 3.27 - if not self.err.yes_no(_("Are you sure you want to remove this " 3.28 - "device?"), 3.29 - _("This device could not be removed from " 3.30 - "the running machine. Would you like to " 3.31 - "remove the device after the next VM " 3.32 - "shutdown?")): 3.33 - return 3.34 - 3.35 try: 3.36 self.vm.remove_device(dev_type, dev_id_info) 3.37 except Exception, e: 3.38 self.err.show_err(_("Error Removing Device: %s" % str(e)), 3.39 "".join(traceback.format_exc())) 3.40 + return 3.41 + 3.42 + if detach_err: 3.43 + self.err.show_info( 3.44 + _("Device could not be removed from the running machine."), 3.45 + _("This change will take effect after the next VM reboot")) 3.46 3.47 # Generic config change helpers 3.48 def _change_config_helper(self,
4.1 --- a/src/virtManager/preferences.py Wed Nov 18 16:11:17 2009 -0500 4.2 +++ b/src/virtManager/preferences.py Wed Nov 18 16:46:36 2009 -0500 4.3 @@ -51,6 +51,7 @@ 4.4 self.config.on_confirm_forcepoweroff_changed(self.refresh_confirm_forcepoweroff) 4.5 self.config.on_confirm_poweroff_changed(self.refresh_confirm_poweroff) 4.6 self.config.on_confirm_pause_changed(self.refresh_confirm_pause) 4.7 + self.config.on_confirm_removedev_changed(self.refresh_confirm_removedev) 4.8 4.9 self.refresh_view_system_tray() 4.10 self.refresh_update_interval() 4.11 @@ -65,6 +66,7 @@ 4.12 self.refresh_confirm_forcepoweroff() 4.13 self.refresh_confirm_poweroff() 4.14 self.refresh_confirm_pause() 4.15 + self.refresh_confirm_removedev() 4.16 4.17 self.window.signal_autoconnect({ 4.18 "on_prefs_system_tray_toggled" : self.change_view_system_tray, 4.19 @@ -83,6 +85,7 @@ 4.20 "on_prefs_confirm_forcepoweroff_toggled": self.change_confirm_forcepoweroff, 4.21 "on_prefs_confirm_poweroff_toggled": self.change_confirm_poweroff, 4.22 "on_prefs_confirm_pause_toggled": self.change_confirm_pause, 4.23 + "on_prefs_confirm_removedev_toggled": self.change_confirm_removedev, 4.24 }) 4.25 4.26 # XXX: Help docs useless/out of date 4.27 @@ -146,6 +149,9 @@ 4.28 def refresh_confirm_pause(self, ignore1=None, ignore2=None, 4.29 ignore3=None, ignore4=None): 4.30 self.window.get_widget("prefs-confirm-pause").set_active(self.config.get_confirm_pause()) 4.31 + def refresh_confirm_removedev(self, ignore1=None, ignore2=None, 4.32 + ignore3=None, ignore4=None): 4.33 + self.window.get_widget("prefs-confirm-removedev").set_active(self.config.get_confirm_removedev()) 4.34 4.35 def change_view_system_tray(self, src): 4.36 self.config.set_view_system_tray(src.get_active()) 4.37 @@ -178,6 +184,8 @@ 4.38 self.config.set_confirm_poweroff(src.get_active()) 4.39 def change_confirm_pause(self, src): 4.40 self.config.set_confirm_pause(src.get_active()) 4.41 + def change_confirm_removedev(self, src): 4.42 + self.config.set_confirm_removedev(src.get_active()) 4.43 4.44 def show_help(self, src): 4.45 # From the Preferences window, show the help document from
5.1 --- a/src/vmm-preferences.glade Wed Nov 18 16:11:17 2009 -0500 5.2 +++ b/src/vmm-preferences.glade Wed Nov 18 16:46:36 2009 -0500 5.3 @@ -544,7 +544,7 @@ 5.4 <child> 5.5 <widget class="GtkTable" id="table6"> 5.6 <property name="visible">True</property> 5.7 - <property name="n_rows">3</property> 5.8 + <property name="n_rows">5</property> 5.9 <property name="n_columns">2</property> 5.10 <property name="column_spacing">12</property> 5.11 <property name="row_spacing">6</property> 5.12 @@ -558,6 +558,7 @@ 5.13 </widget> 5.14 <packing> 5.15 <property name="x_options">GTK_FILL</property> 5.16 + <property name="y_options"></property> 5.17 </packing> 5.18 </child> 5.19 <child> 5.20 @@ -571,6 +572,7 @@ 5.21 <packing> 5.22 <property name="left_attach">1</property> 5.23 <property name="right_attach">2</property> 5.24 + <property name="y_options"></property> 5.25 </packing> 5.26 </child> 5.27 <child> 5.28 @@ -585,6 +587,7 @@ 5.29 <property name="top_attach">1</property> 5.30 <property name="bottom_attach">2</property> 5.31 <property name="x_options">GTK_FILL</property> 5.32 + <property name="y_options"></property> 5.33 </packing> 5.34 </child> 5.35 <child> 5.36 @@ -599,6 +602,7 @@ 5.37 <property name="top_attach">2</property> 5.38 <property name="bottom_attach">3</property> 5.39 <property name="x_options">GTK_FILL</property> 5.40 + <property name="y_options"></property> 5.41 </packing> 5.42 </child> 5.43 <child> 5.44 @@ -614,6 +618,7 @@ 5.45 <property name="right_attach">2</property> 5.46 <property name="top_attach">1</property> 5.47 <property name="bottom_attach">2</property> 5.48 + <property name="y_options"></property> 5.49 </packing> 5.50 </child> 5.51 <child> 5.52 @@ -629,6 +634,54 @@ 5.53 <property name="right_attach">2</property> 5.54 <property name="top_attach">2</property> 5.55 <property name="bottom_attach">3</property> 5.56 + <property name="y_options"></property> 5.57 + </packing> 5.58 + </child> 5.59 + <child> 5.60 + <placeholder/> 5.61 + </child> 5.62 + <child> 5.63 + <widget class="GtkLabel" id="label22"> 5.64 + <property name="visible">True</property> 5.65 + <property name="xalign">0</property> 5.66 + <property name="label" translatable="yes">Device re_moval:</property> 5.67 + <property name="use_underline">True</property> 5.68 + <property name="mnemonic_widget">prefs-confirm-removedev</property> 5.69 + </widget> 5.70 + <packing> 5.71 + <property name="top_attach">4</property> 5.72 + <property name="bottom_attach">5</property> 5.73 + <property name="x_options">GTK_FILL</property> 5.74 + <property name="y_options"></property> 5.75 + </packing> 5.76 + </child> 5.77 + <child> 5.78 + <widget class="GtkAlignment" id="alignment8"> 5.79 + <property name="visible">True</property> 5.80 + <child> 5.81 + <placeholder/> 5.82 + </child> 5.83 + </widget> 5.84 + <packing> 5.85 + <property name="top_attach">3</property> 5.86 + <property name="bottom_attach">4</property> 5.87 + <property name="x_options">GTK_FILL</property> 5.88 + </packing> 5.89 + </child> 5.90 + <child> 5.91 + <widget class="GtkCheckButton" id="prefs-confirm-removedev"> 5.92 + <property name="visible">True</property> 5.93 + <property name="can_focus">True</property> 5.94 + <property name="receives_default">False</property> 5.95 + <property name="draw_indicator">True</property> 5.96 + <signal name="toggled" handler="on_prefs_confirm_removedev_toggled"/> 5.97 + </widget> 5.98 + <packing> 5.99 + <property name="left_attach">1</property> 5.100 + <property name="right_attach">2</property> 5.101 + <property name="top_attach">4</property> 5.102 + <property name="bottom_attach">5</property> 5.103 + <property name="x_options">GTK_FILL</property> 5.104 </packing> 5.105 </child> 5.106 </widget>
