[virt-tools-list] [PATCH virt-viewer 1/2] app: add virt_viewer_app_make_dialog()

Jonathon Jongsma jjongsma at redhat.com
Thu Jul 3 21:35:43 UTC 2014


ACK, but perhaps changing the name to _make_message_dialog() would indicate more clearly that it's a GtkMessageDialog rather than a plain GtkDialog?

----- Original Message -----
> From: "Marc-André Lureau" <marcandre.lureau at gmail.com>
> To: virt-tools-list at redhat.com
> Sent: Thursday, July 3, 2014 11:50:13 AM
> Subject: [virt-tools-list] [PATCH virt-viewer 1/2] app: add	virt_viewer_app_make_dialog()
> 
> Add a function to create an application dialog. In the following
> commit, we will add more details for connection failures.
> ---
>  src/virt-viewer-app.c | 37 +++++++++++++++++++++++++++----------
>  1 file changed, 27 insertions(+), 10 deletions(-)
> 
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index 6cf2747..7458acc 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -197,20 +197,18 @@ virt_viewer_app_set_debug(gboolean debug)
>      doDebug = debug;
>  }
>  
> -void
> -virt_viewer_app_simple_message_dialog(VirtViewerApp *self,
> -                                      const char *fmt, ...)
> +static GtkWidget*
> +virt_viewer_app_make_dialog(VirtViewerApp *self,
> +                            const char *fmt, ...)
>  {
> -    g_return_if_fail(VIRT_VIEWER_IS_APP(self));
> +    g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), NULL);
>      GtkWindow *window =
>      GTK_WINDOW(virt_viewer_window_get_window(self->priv->main_window));
>      GtkWidget *dialog;
>      char *msg;
>      va_list vargs;
>  
>      va_start(vargs, fmt);
> -
>      msg = g_strdup_vprintf(fmt, vargs);
> -
>      va_end(vargs);
>  
>      dialog = gtk_message_dialog_new(window,
> @@ -221,8 +219,25 @@ virt_viewer_app_simple_message_dialog(VirtViewerApp
> *self,
>                                      "%s",
>                                      msg);
>  
> -    gtk_dialog_run(GTK_DIALOG(dialog));
> +    g_free(msg);
> +
> +    return dialog;
> +}
> +
> +void
> +virt_viewer_app_simple_message_dialog(VirtViewerApp *self,
> +                                      const char *fmt, ...)
> +{
> +    GtkWidget *dialog;
> +    char *msg;
> +    va_list vargs;
>  
> +    va_start(vargs, fmt);
> +    msg = g_strdup_vprintf(fmt, vargs);
> +    va_end(vargs);
> +
> +    dialog = virt_viewer_app_make_dialog(self, msg);
> +    gtk_dialog_run(GTK_DIALOG(dialog));
>      gtk_widget_destroy(dialog);
>  
>      g_free(msg);
> @@ -1324,9 +1339,11 @@ virt_viewer_app_disconnected(VirtViewerSession
> *session G_GNUC_UNUSED,
>          gtk_main_quit();
>  
>      if (connect_error) {
> -        virt_viewer_app_simple_message_dialog(self,
> -                                              _("Unable to connect to the
> graphic server %s"),
> -                                              priv->pretty_address);
> +        GtkWidget *dialog = virt_viewer_app_make_dialog(self,
> +            _("Unable to connect to the graphic server %s"),
> priv->pretty_address);
> +
> +        gtk_dialog_run(GTK_DIALOG(dialog));
> +        gtk_widget_destroy(dialog);
>      }
>      virt_viewer_app_set_usb_options_sensitive(self, FALSE);
>      virt_viewer_app_deactivate(self, connect_error);
> --
> 1.9.3
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
> 




More information about the virt-tools-list mailing list