mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0110-p2v-Add-a-dialog-confirming-the-user-really-means-to.patch

e76f14
From eabb2aee8770ca07282138ea23f66b3c9e56f85b Mon Sep 17 00:00:00 2001
e76f14
From: "Richard W.M. Jones" <rjones@redhat.com>
e76f14
Date: Sat, 18 Jun 2016 09:19:10 +0100
e76f14
Subject: [PATCH] p2v: Add a dialog confirming the user really means to cancel
e76f14
 (RHBZ#1340464).
e76f14
e76f14
Thanks: Kean Li
e76f14
(cherry picked from commit 4f4f0f1fe98dbc82227c3a393d76498b6624a400)
e76f14
---
e76f14
 p2v/gui.c | 34 ++++++++++++++++++++++++++++------
e76f14
 1 file changed, 28 insertions(+), 6 deletions(-)
e76f14
e76f14
diff --git a/p2v/gui.c b/p2v/gui.c
e76f14
index 93b086a..142d2eb 100644
e76f14
--- a/p2v/gui.c
e76f14
+++ b/p2v/gui.c
e76f14
@@ -1409,7 +1409,7 @@ static void set_status (const char *msg);
e76f14
 static void add_v2v_output (const char *msg);
e76f14
 static void add_v2v_output_2 (const char *msg, size_t len);
e76f14
 static void *start_conversion_thread (void *data);
e76f14
-static void cancel_conversion_clicked (GtkWidget *w, gpointer data);
e76f14
+static void cancel_conversion_dialog (GtkWidget *w, gpointer data);
e76f14
 static void reboot_clicked (GtkWidget *w, gpointer data);
e76f14
 static gboolean close_running_dialog (GtkWidget *w, GdkEvent *event, gpointer data);
e76f14
 
e76f14
@@ -1447,7 +1447,7 @@ create_running_dialog (void)
e76f14
 
e76f14
   /* Buttons. */
e76f14
   gtk_dialog_add_buttons (GTK_DIALOG (run_dlg),
e76f14
-                          _("Cancel conversion"), 1,
e76f14
+                          _("Cancel conversion ..."), 1,
e76f14
                           _("Reboot"), 2,
e76f14
                           NULL);
e76f14
   cancel_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (run_dlg), 1);
e76f14
@@ -1461,7 +1461,7 @@ create_running_dialog (void)
e76f14
   g_signal_connect_swapped (G_OBJECT (run_dlg), "destroy",
e76f14
                             G_CALLBACK (gtk_main_quit), NULL);
e76f14
   g_signal_connect (G_OBJECT (cancel_button), "clicked",
e76f14
-                    G_CALLBACK (cancel_conversion_clicked), NULL);
e76f14
+                    G_CALLBACK (cancel_conversion_dialog), NULL);
e76f14
   g_signal_connect (G_OBJECT (reboot_button), "clicked",
e76f14
                     G_CALLBACK (reboot_clicked), NULL);
e76f14
 }
e76f14
@@ -1753,11 +1753,33 @@ close_running_dialog (GtkWidget *w, GdkEvent *event, gpointer data)
e76f14
     return FALSE;
e76f14
 }
e76f14
 
e76f14
+/**
e76f14
+ * This is called when the user clicks on the "Cancel conversion"
e76f14
+ * button.  Since conversions can run for a long time, and cancelling
e76f14
+ * the conversion is non-recoverable, this function displays a
e76f14
+ * confirmation dialog before cancelling the conversion.
e76f14
+ */
e76f14
 static void
e76f14
-cancel_conversion_clicked (GtkWidget *w, gpointer data)
e76f14
+cancel_conversion_dialog (GtkWidget *w, gpointer data)
e76f14
 {
e76f14
-  /* This makes start_conversion return an error (eventually). */
e76f14
-  cancel_conversion ();
e76f14
+  GtkWidget *dlg;
e76f14
+
e76f14
+  if (!conversion_is_running ())
e76f14
+    return;
e76f14
+
e76f14
+  dlg = gtk_message_dialog_new (GTK_WINDOW (run_dlg),
e76f14
+                                GTK_DIALOG_DESTROY_WITH_PARENT,
e76f14
+                                GTK_MESSAGE_QUESTION,
e76f14
+                                GTK_BUTTONS_YES_NO,
e76f14
+                                _("Really cancel the conversion? "
e76f14
+                                  "To convert this machine you will need to "
e76f14
+                                  "re-run the conversion from the beginning."));
e76f14
+  gtk_window_set_title (GTK_WINDOW (dlg), _("Cancel the conversion"));
e76f14
+  if (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_YES)
e76f14
+    /* This makes start_conversion return an error (eventually). */
e76f14
+    cancel_conversion ();
e76f14
+
e76f14
+  gtk_widget_destroy (dlg);
e76f14
 }
e76f14
 
e76f14
 static void
e76f14
-- 
e76f14
1.8.3.1
e76f14