[virt-tools-list] [PATCH 2/3] error: use helper function to embed customized widget into dialog
Leonardo Augusto Guimarães Garcia
lagarcia at linux.vnet.ibm.com
Wed Jun 26 18:43:22 UTC 2013
On 06/26/2013 11:13 AM, Guannan Ren wrote:
> ---
> virtManager/error.py | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/virtManager/error.py b/virtManager/error.py
> index e30d121..0efd035 100644
> --- a/virtManager/error.py
> +++ b/virtManager/error.py
> @@ -28,11 +28,15 @@ from virtManager.baseclass import vmmGObject
>
>
> def _launch_dialog(dialog, primary_text, secondary_text, title,
> - sync=True):
> + widget=None, sync=True):
> dialog.set_property("text", primary_text)
> dialog.format_secondary_text(secondary_text or None)
> dialog.set_title(title)
>
> + if widget:
> + # widget is of type Gtk.VBox
I still don't think this is a valid restriction (widget can be of other
types here, we are just not using them right now).
Even if you wish to keep this comment, ACK.
Best regards,
Leonardo Garcia
> + dialog.get_content_area().add(widget)
> +
> res = False
> if sync:
> res = dialog.run()
> @@ -92,7 +96,7 @@ class vmmErrorDialog(vmmGObject):
> ###################################
>
> def _simple_dialog(self, dialog_type, buttons, text1,
> - text2, title, async=False):
> + text2, title, widget=None, async=False):
>
> dialog = Gtk.MessageDialog(self.get_parent(),
> flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
> @@ -104,6 +108,7 @@ class vmmErrorDialog(vmmGObject):
>
> return _launch_dialog(self._simple,
> text1, text2 or "", title or "",
> + widget=widget,
> sync=not async)
>
> def val_err(self, text1, text2=None, title=_("Input Error"), async=True):
> @@ -121,13 +126,13 @@ class vmmErrorDialog(vmmGObject):
> self._simple_dialog(dtype, buttons,
> str(text1),
> text2 and str(text2) or "",
> - str(title), async)
> + str(title), None, async)
> 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
> 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
>
> def yes_no(self, text1, text2=None, title=None):
More information about the virt-tools-list
mailing list