mirror of
https://github.com/virt-manager/virt-manager.git
synced 2026-08-04 18:33:33 -05:00
error: Add helper confirm_unapplied_changes
For the common dialog we use to confirm changes
This commit is contained in:
@@ -1178,13 +1178,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
if not self.widget("config-apply").get_sensitive():
|
||||
return False
|
||||
|
||||
if not self.err.chkbox_helper(
|
||||
self.config.get_confirm_unapplied,
|
||||
self.config.set_confirm_unapplied,
|
||||
text1=(_("There are unapplied changes. Would you like to apply "
|
||||
"them now?")),
|
||||
chktext=_("Don't warn me again."),
|
||||
default=False):
|
||||
if not self.err.confirm_unapplied_changes():
|
||||
return False
|
||||
|
||||
return not self.config_apply(row=row)
|
||||
|
||||
@@ -157,6 +157,18 @@ class vmmErrorDialog(vmmGObject):
|
||||
buttons = Gtk.ButtonsType.OK
|
||||
return self._simple_dialog(dtype, buttons, text1, text2, title)
|
||||
|
||||
def confirm_unapplied_changes(self):
|
||||
"""
|
||||
Helper function for confirming whether to apply unapplied changes
|
||||
"""
|
||||
return self.chkbox_helper(
|
||||
self.config.get_confirm_unapplied,
|
||||
self.config.set_confirm_unapplied,
|
||||
text1=(_("There are unapplied changes. "
|
||||
"Would you like to apply them now?")),
|
||||
chktext=_("Don't warn me again."),
|
||||
default=False)
|
||||
|
||||
|
||||
##########################################
|
||||
# One shot dialog with a checkbox prompt #
|
||||
|
||||
+1
-11
@@ -450,18 +450,8 @@ class vmmHostNets(vmmGObjectUI):
|
||||
self._active_edits.add(edittype)
|
||||
|
||||
def _confirm_changes(self):
|
||||
if not self._active_edits:
|
||||
return True
|
||||
|
||||
if self.err.chkbox_helper(
|
||||
self.config.get_confirm_unapplied,
|
||||
self.config.set_confirm_unapplied,
|
||||
text1=(_("There are unapplied changes. "
|
||||
"Would you like to apply them now?")),
|
||||
chktext=_("Don't warn me again."),
|
||||
default=False):
|
||||
if self._active_edits and self.err.confirm_unapplied_changes():
|
||||
self._net_apply()
|
||||
|
||||
self._active_edits = set()
|
||||
return True
|
||||
|
||||
|
||||
@@ -358,13 +358,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||
if not self._unapplied_changes or not path_selected:
|
||||
return True
|
||||
|
||||
if self.err.chkbox_helper(
|
||||
self.config.get_confirm_unapplied,
|
||||
self.config.set_confirm_unapplied,
|
||||
text1=(_("There are unapplied changes. "
|
||||
"Would you like to apply them now?")),
|
||||
chktext=_("Don't warn me again."),
|
||||
default=False):
|
||||
if self.err.confirm_unapplied_changes():
|
||||
self._apply()
|
||||
|
||||
return True
|
||||
|
||||
@@ -584,18 +584,8 @@ class vmmStorageList(vmmGObjectUI):
|
||||
self.widget("pool-apply").set_sensitive(False)
|
||||
|
||||
def _confirm_changes(self):
|
||||
if not self._active_edits:
|
||||
return True
|
||||
|
||||
if self.err.chkbox_helper(
|
||||
self.config.get_confirm_unapplied,
|
||||
self.config.set_confirm_unapplied,
|
||||
text1=(_("There are unapplied changes. "
|
||||
"Would you like to apply them now?")),
|
||||
chktext=_("Don't warn me again."),
|
||||
default=False):
|
||||
if self._active_edits and self.err.confirm_unapplied_changes():
|
||||
self._pool_apply()
|
||||
|
||||
self._active_edits = set()
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user