error: Add helper confirm_unapplied_changes

For the common dialog we use to confirm changes
This commit is contained in:
Cole Robinson
2019-04-14 18:24:04 -04:00
parent f246895a66
commit f7ba2f2f99
5 changed files with 16 additions and 36 deletions
+1 -7
View File
@@ -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)
+12
View File
@@ -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
View File
@@ -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
+1 -7
View File
@@ -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
+1 -11
View File
@@ -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