[virt-tools-list] [PATCH virt-viewer 7/9] Report error in dialog

Marc-André Lureau marcandre.lureau at gmail.com
Thu Nov 13 17:20:43 UTC 2014


Use a UI dialog to inform of connection error.
---
 src/virt-viewer.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index c1d2765..517aab8 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -839,9 +839,17 @@ virt_viewer_connect(VirtViewerApp *app)
     }
 
     if (!virt_viewer_app_initial_connect(app, &error)) {
-        if (error != NULL)
-            g_warning("%s", error->message);
-        g_clear_error(&error);
+        if (error != NULL) {
+            GtkWidget *dialog = gtk_message_dialog_new(NULL,
+                                                       GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                       GTK_MESSAGE_ERROR,
+                                                       GTK_BUTTONS_CLOSE,
+                                                       "Failed to connect: %s",
+                                                       error->message);
+            gtk_dialog_run(GTK_DIALOG(dialog));
+            gtk_widget_destroy(GTK_WIDGET(dialog));
+            g_clear_error(&error);
+        }
         return -1;
     }
 
-- 
1.9.3




More information about the virt-tools-list mailing list