|
|
0d20ef |
From de9b7e8c97904533f429ede5d1348c9e2219d175 Mon Sep 17 00:00:00 2001
|
|
|
0d20ef |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
0d20ef |
Date: Thu, 20 Nov 2014 15:59:50 +0000
|
|
|
0d20ef |
Subject: [PATCH] p2v: Add 'Reboot' button to the GUI (RHBZ#1165564).
|
|
|
0d20ef |
|
|
|
0d20ef |
(cherry picked from commit 141832e2b22267f8369693d5f4afb27747668889)
|
|
|
0d20ef |
---
|
|
|
0d20ef |
p2v/gui.c | 22 +++++++++++++++++++++-
|
|
|
0d20ef |
1 file changed, 21 insertions(+), 1 deletion(-)
|
|
|
0d20ef |
|
|
|
0d20ef |
diff --git a/p2v/gui.c b/p2v/gui.c
|
|
|
0d20ef |
index aa483db..72838ea 100644
|
|
|
0d20ef |
--- a/p2v/gui.c
|
|
|
0d20ef |
+++ b/p2v/gui.c
|
|
|
0d20ef |
@@ -34,6 +34,8 @@
|
|
|
0d20ef |
#pragma GCC diagnostic ignored "-Wstrict-prototypes" /* error in <gtk.h> */
|
|
|
0d20ef |
#include <gtk/gtk.h>
|
|
|
0d20ef |
|
|
|
0d20ef |
+#include "ignore-value.h"
|
|
|
0d20ef |
+
|
|
|
0d20ef |
#include "p2v.h"
|
|
|
0d20ef |
|
|
|
0d20ef |
/* Interactive GUI configuration. */
|
|
|
0d20ef |
@@ -65,7 +67,7 @@ static GtkWidget *conv_dlg,
|
|
|
0d20ef |
/* The running dialog which is displayed when virt-v2v is running. */
|
|
|
0d20ef |
static GtkWidget *run_dlg,
|
|
|
0d20ef |
*v2v_output_sw, *v2v_output, *log_label, *status_label,
|
|
|
0d20ef |
- *cancel_button;
|
|
|
0d20ef |
+ *cancel_button, *reboot_button;
|
|
|
0d20ef |
|
|
|
0d20ef |
/* The entry point from the main program.
|
|
|
0d20ef |
* Note that gtk_init etc have already been called in main().
|
|
|
0d20ef |
@@ -1056,6 +1058,7 @@ static void set_log_dir (const char *remote_dir);
|
|
|
0d20ef |
static void set_status (const char *msg);
|
|
|
0d20ef |
static void add_v2v_output (const char *msg);
|
|
|
0d20ef |
static void *start_conversion_thread (void *data);
|
|
|
0d20ef |
+static void reboot_clicked (GtkWidget *w, gpointer data);
|
|
|
0d20ef |
|
|
|
0d20ef |
static void
|
|
|
0d20ef |
create_running_dialog (void)
|
|
|
0d20ef |
@@ -1092,13 +1095,18 @@ create_running_dialog (void)
|
|
|
0d20ef |
/* Buttons. */
|
|
|
0d20ef |
gtk_dialog_add_buttons (GTK_DIALOG (run_dlg),
|
|
|
0d20ef |
_("Cancel conversion"), 1,
|
|
|
0d20ef |
+ _("Reboot"), 2,
|
|
|
0d20ef |
NULL);
|
|
|
0d20ef |
cancel_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (run_dlg), 1);
|
|
|
0d20ef |
gtk_widget_set_sensitive (cancel_button, FALSE);
|
|
|
0d20ef |
+ reboot_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (run_dlg), 2);
|
|
|
0d20ef |
+ gtk_widget_set_sensitive (reboot_button, FALSE);
|
|
|
0d20ef |
|
|
|
0d20ef |
/* Signals. */
|
|
|
0d20ef |
g_signal_connect_swapped (G_OBJECT (run_dlg), "destroy",
|
|
|
0d20ef |
G_CALLBACK (gtk_main_quit), NULL);
|
|
|
0d20ef |
+ g_signal_connect (G_OBJECT (reboot_button), "clicked",
|
|
|
0d20ef |
+ G_CALLBACK (reboot_clicked), NULL);
|
|
|
0d20ef |
}
|
|
|
0d20ef |
|
|
|
0d20ef |
static void
|
|
|
0d20ef |
@@ -1111,6 +1119,7 @@ show_running_dialog (void)
|
|
|
0d20ef |
/* Show the running dialog. */
|
|
|
0d20ef |
gtk_widget_show_all (run_dlg);
|
|
|
0d20ef |
gtk_widget_set_sensitive (cancel_button, FALSE);
|
|
|
0d20ef |
+ gtk_widget_set_sensitive (reboot_button, FALSE);
|
|
|
0d20ef |
}
|
|
|
0d20ef |
|
|
|
0d20ef |
static void
|
|
|
0d20ef |
@@ -1315,6 +1324,9 @@ start_conversion_thread (void *data)
|
|
|
0d20ef |
gtk_widget_destroy (dlg);
|
|
|
0d20ef |
}
|
|
|
0d20ef |
|
|
|
0d20ef |
+ /* Enable the reboot button. */
|
|
|
0d20ef |
+ gtk_widget_set_sensitive (reboot_button, TRUE);
|
|
|
0d20ef |
+
|
|
|
0d20ef |
gdk_threads_leave ();
|
|
|
0d20ef |
|
|
|
0d20ef |
/* Thread is detached anyway, so no one is waiting for the status. */
|
|
|
0d20ef |
@@ -1347,3 +1359,11 @@ notify_ui_callback (int type, const char *data)
|
|
|
0d20ef |
|
|
|
0d20ef |
gdk_threads_leave ();
|
|
|
0d20ef |
}
|
|
|
0d20ef |
+
|
|
|
0d20ef |
+static void
|
|
|
0d20ef |
+reboot_clicked (GtkWidget *w, gpointer data)
|
|
|
0d20ef |
+{
|
|
|
0d20ef |
+ sync ();
|
|
|
0d20ef |
+ sleep (2);
|
|
|
0d20ef |
+ ignore_value (system ("/sbin/reboot"));
|
|
|
0d20ef |
+}
|
|
|
0d20ef |
--
|
|
|
0d20ef |
1.8.3.1
|
|
|
0d20ef |
|