mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
error: use helper function to embed customized widget into dialog
This commit is contained in:
parent
dbdf6c0f43
commit
d6fc079ae8
@ -28,11 +28,14 @@ from virtManager.baseclass import vmmGObject
|
|||||||
|
|
||||||
|
|
||||||
def _launch_dialog(dialog, primary_text, secondary_text, title,
|
def _launch_dialog(dialog, primary_text, secondary_text, title,
|
||||||
sync=True):
|
widget=None, sync=True):
|
||||||
dialog.set_property("text", primary_text)
|
dialog.set_property("text", primary_text)
|
||||||
dialog.format_secondary_text(secondary_text or None)
|
dialog.format_secondary_text(secondary_text or None)
|
||||||
dialog.set_title(title)
|
dialog.set_title(title)
|
||||||
|
|
||||||
|
if widget:
|
||||||
|
dialog.get_content_area().add(widget)
|
||||||
|
|
||||||
res = False
|
res = False
|
||||||
if sync:
|
if sync:
|
||||||
res = dialog.run()
|
res = dialog.run()
|
||||||
@ -95,7 +98,7 @@ class vmmErrorDialog(vmmGObject):
|
|||||||
###################################
|
###################################
|
||||||
|
|
||||||
def _simple_dialog(self, dialog_type, buttons, text1,
|
def _simple_dialog(self, dialog_type, buttons, text1,
|
||||||
text2, title, async=False):
|
text2, title, widget=None, async=False):
|
||||||
|
|
||||||
dialog = Gtk.MessageDialog(self.get_parent(),
|
dialog = Gtk.MessageDialog(self.get_parent(),
|
||||||
flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
||||||
@ -107,6 +110,7 @@ class vmmErrorDialog(vmmGObject):
|
|||||||
|
|
||||||
return _launch_dialog(self._simple,
|
return _launch_dialog(self._simple,
|
||||||
text1, text2 or "", title or "",
|
text1, text2 or "", title or "",
|
||||||
|
widget=widget,
|
||||||
sync=not async)
|
sync=not async)
|
||||||
|
|
||||||
def val_err(self, text1, text2=None, title=_("Input Error"), async=True):
|
def val_err(self, text1, text2=None, title=_("Input Error"), async=True):
|
||||||
@ -124,13 +128,13 @@ class vmmErrorDialog(vmmGObject):
|
|||||||
self._simple_dialog(dtype, buttons,
|
self._simple_dialog(dtype, buttons,
|
||||||
str(text1),
|
str(text1),
|
||||||
text2 and str(text2) or "",
|
text2 and str(text2) or "",
|
||||||
str(title), async)
|
str(title), None, async)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def show_info(self, text1, text2=None, title="", async=True):
|
def show_info(self, text1, text2=None, title="", widget=None, async=True):
|
||||||
dtype = Gtk.MessageType.INFO
|
dtype = Gtk.MessageType.INFO
|
||||||
buttons = Gtk.ButtonsType.OK
|
buttons = Gtk.ButtonsType.OK
|
||||||
self._simple_dialog(dtype, buttons, text1, text2, title, async)
|
self._simple_dialog(dtype, buttons, text1, text2, title, widget, async)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def yes_no(self, text1, text2=None, title=None):
|
def yes_no(self, text1, text2=None, title=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user