host: Confirm before starting/stopping interfaces
This commit is contained in:
parent
5aaae5db86
commit
a6573e402f
|
@ -325,6 +325,19 @@
|
|||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/::PACKAGE::/confirm/interface_power</key>
|
||||
<applyto>/apps/::PACKAGE::/confirm/interface_power</applyto>
|
||||
<owner>::PACKAGE::</owner>
|
||||
<type>bool</type>
|
||||
<default>1</default>
|
||||
|
||||
<locale name="C">
|
||||
<short>Confirm device interface start and stop</short>
|
||||
<long>Whether we require confirmation to start or stop a libvirt virtual interface</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/::PACKAGE::/manager_window_height</key>
|
||||
<applyto>/apps/::PACKAGE::/manager_window_height</applyto>
|
||||
|
|
|
@ -298,6 +298,9 @@ class vmmConfig:
|
|||
return self.conf.get_bool(self.conf_dir + "/confirm/pause")
|
||||
def get_confirm_removedev(self):
|
||||
return self.conf.get_bool(self.conf_dir + "/confirm/removedev")
|
||||
def get_confirm_interface(self):
|
||||
return self.conf.get_bool(self.conf_dir + "/confirm/interface_power")
|
||||
|
||||
|
||||
def set_confirm_forcepoweroff(self, val):
|
||||
self.conf.set_bool(self.conf_dir + "/confirm/forcepoweroff", val)
|
||||
|
@ -307,6 +310,8 @@ class vmmConfig:
|
|||
self.conf.set_bool(self.conf_dir + "/confirm/pause", val)
|
||||
def set_confirm_removedev(self, val):
|
||||
self.conf.set_bool(self.conf_dir + "/confirm/removedev", val)
|
||||
def set_confirm_interface(self, val):
|
||||
self.conf.set_bool(self.conf_dir + "/confirm/interface_power", val)
|
||||
|
||||
def on_confirm_forcepoweroff_changed(self, cb):
|
||||
self.conf.notify_add(self.conf_dir + "/confirm/forcepoweroff", cb)
|
||||
|
@ -316,6 +321,8 @@ class vmmConfig:
|
|||
self.conf.notify_add(self.conf_dir + "/confirm/pause", cb)
|
||||
def on_confirm_removedev_changed(self, cb):
|
||||
self.conf.notify_add(self.conf_dir + "/confirm/removedev", cb)
|
||||
def on_confirm_interface_changed(self, cb):
|
||||
self.conf.notify_add(self.conf_dir + "/confirm/interface_power", cb)
|
||||
|
||||
|
||||
# System tray visibility
|
||||
|
|
|
@ -39,9 +39,6 @@ from virtManager.graphwidgets import Sparkline
|
|||
INTERFACE_PAGE_INFO = 0
|
||||
INTERFACE_PAGE_ERROR = 1
|
||||
|
||||
# TODO: Improve no interface support and no interface selected sensitivity
|
||||
# Do the same for storage a networks
|
||||
|
||||
class vmmHost(gobject.GObject):
|
||||
__gsignals__ = {
|
||||
"action-show-help": (gobject.SIGNAL_RUN_FIRST,
|
||||
|
@ -771,6 +768,20 @@ class vmmHost(gobject.GObject):
|
|||
if interface is None:
|
||||
return
|
||||
|
||||
do_prompt = self.config.get_confirm_interface()
|
||||
|
||||
if do_prompt:
|
||||
res = self.err.warn_chkbox(
|
||||
text1=_("Are you sure you want to stop the interface "
|
||||
"'%s'?" % interface.get_name()),
|
||||
chktext=_("Don't ask me again for interface start/stop."),
|
||||
buttons=gtk.BUTTONS_YES_NO)
|
||||
|
||||
response, skip_prompt = res
|
||||
if not response:
|
||||
return
|
||||
self.config.set_confirm_interface(not skip_prompt)
|
||||
|
||||
try:
|
||||
interface.stop()
|
||||
except Exception, e:
|
||||
|
@ -783,6 +794,20 @@ class vmmHost(gobject.GObject):
|
|||
if interface is None:
|
||||
return
|
||||
|
||||
do_prompt = self.config.get_confirm_interface()
|
||||
|
||||
if do_prompt:
|
||||
res = self.err.warn_chkbox(
|
||||
text1=_("Are you sure you want to start the interface "
|
||||
"'%s'?" % interface.get_name()),
|
||||
chktext=_("Don't ask me again for interface start/stop."),
|
||||
buttons=gtk.BUTTONS_YES_NO)
|
||||
|
||||
response, skip_prompt = res
|
||||
if not response:
|
||||
return
|
||||
self.config.set_confirm_interface(not skip_prompt)
|
||||
|
||||
try:
|
||||
interface.start()
|
||||
except Exception, e:
|
||||
|
|
|
@ -54,6 +54,7 @@ class vmmPreferences(gobject.GObject):
|
|||
self.config.on_confirm_poweroff_changed(self.refresh_confirm_poweroff)
|
||||
self.config.on_confirm_pause_changed(self.refresh_confirm_pause)
|
||||
self.config.on_confirm_removedev_changed(self.refresh_confirm_removedev)
|
||||
self.config.on_confirm_interface_changed(self.refresh_confirm_interface)
|
||||
|
||||
self.refresh_view_system_tray()
|
||||
self.refresh_update_interval()
|
||||
|
@ -69,6 +70,7 @@ class vmmPreferences(gobject.GObject):
|
|||
self.refresh_confirm_poweroff()
|
||||
self.refresh_confirm_pause()
|
||||
self.refresh_confirm_removedev()
|
||||
self.refresh_confirm_interface()
|
||||
|
||||
self.window.signal_autoconnect({
|
||||
"on_prefs_system_tray_toggled" : self.change_view_system_tray,
|
||||
|
@ -88,6 +90,7 @@ class vmmPreferences(gobject.GObject):
|
|||
"on_prefs_confirm_poweroff_toggled": self.change_confirm_poweroff,
|
||||
"on_prefs_confirm_pause_toggled": self.change_confirm_pause,
|
||||
"on_prefs_confirm_removedev_toggled": self.change_confirm_removedev,
|
||||
"on_prefs_confirm_interface_toggled": self.change_confirm_interface,
|
||||
})
|
||||
util.bind_escape_key_close(self)
|
||||
|
||||
|
@ -155,6 +158,9 @@ class vmmPreferences(gobject.GObject):
|
|||
def refresh_confirm_removedev(self, ignore1=None, ignore2=None,
|
||||
ignore3=None, ignore4=None):
|
||||
self.window.get_widget("prefs-confirm-removedev").set_active(self.config.get_confirm_removedev())
|
||||
def refresh_confirm_interface(self, ignore1=None, ignore2=None,
|
||||
ignore3=None, ignore4=None):
|
||||
self.window.get_widget("prefs-confirm-interface").set_active(self.config.get_confirm_interface())
|
||||
|
||||
def change_view_system_tray(self, src):
|
||||
self.config.set_view_system_tray(src.get_active())
|
||||
|
@ -189,6 +195,8 @@ class vmmPreferences(gobject.GObject):
|
|||
self.config.set_confirm_pause(src.get_active())
|
||||
def change_confirm_removedev(self, src):
|
||||
self.config.set_confirm_removedev(src.get_active())
|
||||
def change_confirm_interface(self, src):
|
||||
self.config.set_confirm_interface(src.get_active())
|
||||
|
||||
def show_help(self, src):
|
||||
# From the Preferences window, show the help document from
|
||||
|
|
|
@ -637,34 +637,6 @@ For all domains</property>
|
|||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label22">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Device re_moval:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">prefs-confirm-removedev</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment8">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="prefs-confirm-removedev">
|
||||
<property name="visible">True</property>
|
||||
|
@ -682,7 +654,47 @@ For all domains</property>
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<widget class="GtkLabel" id="label22">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Device re_moval:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">prefs-confirm-removedev</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label23">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">_Interface start/stop:</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="prefs-confirm-interface">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<signal name="toggled" handler="on_prefs_confirm_interface_toggled"/>
|
||||
</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>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
|
Loading…
Reference in New Issue