[Xfce4-commits] <xfce4-taskmanager:master> Ask for confirmation to terminate/kill a task

Mike Massonnet noreply at xfce.org
Mon May 10 22:36:01 CEST 2010


Updating branch refs/heads/master
         to a21b1bfca8ea00a452516d170b78b50a1e6cd752 (commit)
       from 7239d4bbb0e9ecf5a3d800632ca3dedc885e1595 (commit)

commit a21b1bfca8ea00a452516d170b78b50a1e6cd752
Author: Mike Massonnet <mmassonnet at gmail.com>
Date:   Mon May 10 22:11:56 2010 +0200

    Ask for confirmation to terminate/kill a task

 src/process-tree-view.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/process-tree-view.c b/src/process-tree-view.c
index bb5a258..28943a2 100644
--- a/src/process-tree-view.c
+++ b/src/process-tree-view.c
@@ -202,14 +202,30 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
 static void
 cb_send_signal (GtkMenuItem *mi, gpointer user_data)
 {
+	GtkWidget *dialog;
 	guint pid = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (mi), "pid"));
 	gint signal = GPOINTER_TO_INT (user_data);
 
+	if (signal == XTM_SIGNAL_TERMINATE || signal == XTM_SIGNAL_KILL)
+	{
+		gint res;
+		dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+			(signal == XTM_SIGNAL_TERMINATE) ? _("Terminate task") : _("Kill task"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+			_("Are you sure you want to send a signal to the PID %d?"), pid);
+		gtk_window_set_title (GTK_WINDOW (dialog), _("Task Manager"));
+		res = gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+		if (res != GTK_RESPONSE_YES)
+			return;
+	}
+
 	if (!send_signal_to_pid (pid, signal))
 	{
-		GtkWidget *dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+		dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
 			_("Error sending signal"));
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("An error was encountered by sending a signal to the PID %d. "
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+			_("An error was encountered by sending a signal to the PID %d. "
 			"It is likely you don't have the required privileges."), pid);
 		gtk_window_set_title (GTK_WINDOW (dialog), _("Task Manager"));
 		gtk_dialog_run (GTK_DIALOG (dialog));



More information about the Xfce4-commits mailing list