diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-06-14 22:48:08 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-06-14 22:50:53 -0400 |
| commit | e857f27f62317e180dd583f8b6e1b76d97ffaaec (patch) | |
| tree | 4d89fa062232672919e8df15df7411162df09e4b | |
| parent | 5ac686adcc2482ab5638fe4714b55818d2c5f82a (diff) | |
kernelshark: Have stop dialog close when command is finished
When the trace-cmd record command finishes, close the stop dialog.
Luckily we know when it finishes because the command will close
the pipe which will cause the monitor_pipes thread to detect
it. Then it will close the dialog box by emitting the delete-event
signal to it.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-capture.c | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/trace-capture.c b/trace-capture.c index 47b1a30..65cd4b9 100644 --- a/trace-capture.c +++ b/trace-capture.c | |||
| @@ -51,6 +51,7 @@ struct trace_capture { | |||
| 51 | GtkTextBuffer *output_buffer; | 51 | GtkTextBuffer *output_buffer; |
| 52 | GtkWidget *output_dialog; | 52 | GtkWidget *output_dialog; |
| 53 | GtkWidget *plugin_combo; | 53 | GtkWidget *plugin_combo; |
| 54 | GtkWidget *stop_dialog; | ||
| 54 | pthread_t thread; | 55 | pthread_t thread; |
| 55 | gboolean all_events; | 56 | gboolean all_events; |
| 56 | gboolean kill_thread; | 57 | gboolean kill_thread; |
| @@ -153,6 +154,7 @@ static void close_command_display(struct trace_capture *cap) | |||
| 153 | { | 154 | { |
| 154 | gtk_widget_destroy(cap->output_dialog); | 155 | gtk_widget_destroy(cap->output_dialog); |
| 155 | cap->output_dialog = NULL; | 156 | cap->output_dialog = NULL; |
| 157 | cap->stop_dialog = NULL; | ||
| 156 | } | 158 | } |
| 157 | 159 | ||
| 158 | static void display_command_close(GtkWidget *widget, gint id, gpointer data) | 160 | static void display_command_close(GtkWidget *widget, gint id, gpointer data) |
| @@ -404,6 +406,36 @@ static void execute_command(struct trace_capture *cap) | |||
| 404 | g_free(cap->plugin); | 406 | g_free(cap->plugin); |
| 405 | } | 407 | } |
| 406 | 408 | ||
| 409 | static gint | ||
| 410 | delete_stop_dialog(GtkWidget *widget, GdkEvent *event, gpointer data) | ||
| 411 | { | ||
| 412 | struct trace_capture *cap = data; | ||
| 413 | GtkWidget *dialog = cap->stop_dialog; | ||
| 414 | |||
| 415 | cap->stop_dialog = NULL; | ||
| 416 | if (!dialog) | ||
| 417 | return TRUE; | ||
| 418 | |||
| 419 | end_capture(cap); | ||
| 420 | gtk_widget_destroy(dialog); | ||
| 421 | |||
| 422 | return TRUE; | ||
| 423 | } | ||
| 424 | |||
| 425 | void end_stop_dialog(struct trace_capture *cap) | ||
| 426 | { | ||
| 427 | GdkEvent dummy_event; | ||
| 428 | gboolean dummy_retval; | ||
| 429 | guint sigid; | ||
| 430 | |||
| 431 | if (!cap->stop_dialog) | ||
| 432 | return; | ||
| 433 | |||
| 434 | sigid = g_signal_lookup("delete-event", G_OBJECT_TYPE(cap->stop_dialog)); | ||
| 435 | g_signal_emit(cap->stop_dialog, sigid, 0, | ||
| 436 | cap->stop_dialog, &dummy_event , cap, &dummy_retval); | ||
| 437 | } | ||
| 438 | |||
| 407 | static void *monitor_pipes(void *data) | 439 | static void *monitor_pipes(void *data) |
| 408 | { | 440 | { |
| 409 | struct trace_capture *cap = data; | 441 | struct trace_capture *cap = data; |
| @@ -436,6 +468,12 @@ static void *monitor_pipes(void *data) | |||
| 436 | } | 468 | } |
| 437 | } while (!cap->capture_done && !eof); | 469 | } while (!cap->capture_done && !eof); |
| 438 | 470 | ||
| 471 | if (eof) { | ||
| 472 | gdk_threads_enter(); | ||
| 473 | end_stop_dialog(cap); | ||
| 474 | gdk_threads_leave(); | ||
| 475 | } | ||
| 476 | |||
| 439 | pthread_exit(NULL); | 477 | pthread_exit(NULL); |
| 440 | } | 478 | } |
| 441 | 479 | ||
| @@ -602,15 +640,20 @@ static void execute_button_clicked(GtkWidget *widget, gpointer data) | |||
| 602 | "Stop", | 640 | "Stop", |
| 603 | GTK_RESPONSE_ACCEPT, | 641 | GTK_RESPONSE_ACCEPT, |
| 604 | NULL); | 642 | NULL); |
| 643 | |||
| 644 | cap->stop_dialog = dialog; | ||
| 645 | |||
| 605 | label = gtk_label_new("Hit Stop to end execution"); | 646 | label = gtk_label_new("Hit Stop to end execution"); |
| 606 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0); | 647 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0); |
| 607 | gtk_widget_show(label); | 648 | gtk_widget_show(label); |
| 608 | 649 | ||
| 609 | gtk_dialog_run(GTK_DIALOG(dialog)); | 650 | gtk_signal_connect(GTK_OBJECT (dialog), "delete_event", |
| 651 | (GtkSignalFunc)delete_stop_dialog, | ||
| 652 | (gpointer)cap); | ||
| 610 | 653 | ||
| 611 | end_capture(cap); | 654 | gtk_dialog_run(GTK_DIALOG(dialog)); |
| 612 | 655 | ||
| 613 | gtk_widget_destroy(dialog); | 656 | end_stop_dialog(cap); |
| 614 | } | 657 | } |
| 615 | 658 | ||
| 616 | static GtkTreeModel *create_plugin_combo_model(gpointer data) | 659 | static GtkTreeModel *create_plugin_combo_model(gpointer data) |
