diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-06-22 19:51:37 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-06-22 19:59:37 -0400 |
| commit | bbbed2d598416cacbe33422b6693589b82db5a68 (patch) | |
| tree | 2baf50596d107f12578bdc55dcb6d48bf9a66c89 | |
| parent | bda864171078cc6c0165367bc8355ffefc898788 (diff) | |
kernelshark: Have capture "Run" button also be "Stop" button
Instead of popping up another dialog to stop the run, have
the "Run" button simply change to "Stop". This makes it a lot nicer.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-capture.c | 81 |
1 files changed, 23 insertions, 58 deletions
diff --git a/trace-capture.c b/trace-capture.c index 0c0a52e..09af35b 100644 --- a/trace-capture.c +++ b/trace-capture.c | |||
| @@ -50,6 +50,8 @@ | |||
| 50 | #define DIALOG_WIDTH 820 | 50 | #define DIALOG_WIDTH 820 |
| 51 | #define DIALOG_HEIGHT 600 | 51 | #define DIALOG_HEIGHT 600 |
| 52 | 52 | ||
| 53 | #define CAP_STOP "Stop" | ||
| 54 | |||
| 53 | struct trace_capture { | 55 | struct trace_capture { |
| 54 | struct pevent *pevent; | 56 | struct pevent *pevent; |
| 55 | struct shark_info *info; | 57 | struct shark_info *info; |
| @@ -61,7 +63,7 @@ struct trace_capture { | |||
| 61 | GtkWidget *event_view; | 63 | GtkWidget *event_view; |
| 62 | GtkWidget *plugin_combo; | 64 | GtkWidget *plugin_combo; |
| 63 | GtkWidget *settings_combo; | 65 | GtkWidget *settings_combo; |
| 64 | GtkWidget *stop_dialog; | 66 | GtkWidget *run_button; |
| 65 | pthread_t thread; | 67 | pthread_t thread; |
| 66 | gboolean kill_thread; | 68 | gboolean kill_thread; |
| 67 | gboolean capture_done; | 69 | gboolean capture_done; |
| @@ -229,11 +231,18 @@ void kernel_shark_clear_capture(struct shark_info *info) | |||
| 229 | info->cap_file = NULL; | 231 | info->cap_file = NULL; |
| 230 | } | 232 | } |
| 231 | 233 | ||
| 232 | static void end_capture(struct trace_capture *cap) | 234 | static gboolean end_capture(struct trace_capture *cap) |
| 233 | { | 235 | { |
| 234 | const char *filename; | 236 | const char *filename; |
| 237 | const char *val; | ||
| 235 | int pid; | 238 | int pid; |
| 236 | 239 | ||
| 240 | val = gtk_button_get_label(GTK_BUTTON(cap->run_button)); | ||
| 241 | if (strcmp(val, CAP_STOP) != 0) | ||
| 242 | return FALSE; | ||
| 243 | |||
| 244 | gtk_button_set_label(GTK_BUTTON(cap->run_button), "Run"); | ||
| 245 | |||
| 237 | cap->capture_done = TRUE; | 246 | cap->capture_done = TRUE; |
| 238 | 247 | ||
| 239 | pid = cap->command_pid; | 248 | pid = cap->command_pid; |
| @@ -267,6 +276,8 @@ static void end_capture(struct trace_capture *cap) | |||
| 267 | kernelshark_load_file(cap->info, filename); | 276 | kernelshark_load_file(cap->info, filename); |
| 268 | cap->load_file = FALSE; | 277 | cap->load_file = FALSE; |
| 269 | } | 278 | } |
| 279 | |||
| 280 | return TRUE; | ||
| 270 | } | 281 | } |
| 271 | 282 | ||
| 272 | static char *get_tracing_dir(void) | 283 | static char *get_tracing_dir(void) |
| @@ -609,36 +620,6 @@ static void execute_command(struct trace_capture *cap) | |||
| 609 | g_free(cap->info->cap_plugin); | 620 | g_free(cap->info->cap_plugin); |
| 610 | } | 621 | } |
| 611 | 622 | ||
| 612 | static gint | ||
| 613 | delete_stop_dialog(GtkWidget *widget, GdkEvent *event, gpointer data) | ||
| 614 | { | ||
| 615 | struct trace_capture *cap = data; | ||
| 616 | GtkWidget *dialog = cap->stop_dialog; | ||
| 617 | |||
| 618 | cap->stop_dialog = NULL; | ||
| 619 | if (!dialog) | ||
| 620 | return TRUE; | ||
| 621 | |||
| 622 | end_capture(cap); | ||
| 623 | gtk_widget_destroy(dialog); | ||
| 624 | |||
| 625 | return TRUE; | ||
| 626 | } | ||
| 627 | |||
| 628 | void end_stop_dialog(struct trace_capture *cap) | ||
| 629 | { | ||
| 630 | GdkEvent dummy_event; | ||
| 631 | gboolean dummy_retval; | ||
| 632 | guint sigid; | ||
| 633 | |||
| 634 | if (!cap->stop_dialog) | ||
| 635 | return; | ||
| 636 | |||
| 637 | sigid = g_signal_lookup("delete-event", G_OBJECT_TYPE(cap->stop_dialog)); | ||
| 638 | g_signal_emit(cap->stop_dialog, sigid, 0, | ||
| 639 | cap->stop_dialog, &dummy_event , cap, &dummy_retval); | ||
| 640 | } | ||
| 641 | |||
| 642 | static void *monitor_pipes(void *data) | 623 | static void *monitor_pipes(void *data) |
| 643 | { | 624 | { |
| 644 | struct trace_capture *cap = data; | 625 | struct trace_capture *cap = data; |
| @@ -673,7 +654,7 @@ static void *monitor_pipes(void *data) | |||
| 673 | 654 | ||
| 674 | if (eof) { | 655 | if (eof) { |
| 675 | gdk_threads_enter(); | 656 | gdk_threads_enter(); |
| 676 | end_stop_dialog(cap); | 657 | end_capture(cap); |
| 677 | gdk_threads_leave(); | 658 | gdk_threads_leave(); |
| 678 | } | 659 | } |
| 679 | 660 | ||
| @@ -785,11 +766,12 @@ static void execute_button_clicked(struct trace_capture *cap) | |||
| 785 | { | 766 | { |
| 786 | struct stat st; | 767 | struct stat st; |
| 787 | GtkResponseType ret; | 768 | GtkResponseType ret; |
| 788 | GtkWidget *dialog; | ||
| 789 | GtkWidget *label; | ||
| 790 | const char *filename; | 769 | const char *filename; |
| 791 | char *tracecmd; | 770 | char *tracecmd; |
| 792 | 771 | ||
| 772 | if (end_capture(cap)) | ||
| 773 | return; | ||
| 774 | |||
| 793 | tracecmd = find_tracecmd(); | 775 | tracecmd = find_tracecmd(); |
| 794 | if (!tracecmd) { | 776 | if (!tracecmd) { |
| 795 | warning("trace-cmd not found in path"); | 777 | warning("trace-cmd not found in path"); |
| @@ -808,28 +790,8 @@ static void execute_button_clicked(struct trace_capture *cap) | |||
| 808 | return; | 790 | return; |
| 809 | } | 791 | } |
| 810 | 792 | ||
| 793 | gtk_button_set_label(GTK_BUTTON(cap->run_button), CAP_STOP); | ||
| 811 | run_command(cap); | 794 | run_command(cap); |
| 812 | |||
| 813 | dialog = gtk_dialog_new_with_buttons("Stop Execution", | ||
| 814 | NULL, | ||
| 815 | GTK_DIALOG_MODAL, | ||
| 816 | "Stop", | ||
| 817 | GTK_RESPONSE_ACCEPT, | ||
| 818 | NULL); | ||
| 819 | |||
| 820 | cap->stop_dialog = dialog; | ||
| 821 | |||
| 822 | label = gtk_label_new("Hit Stop to end execution"); | ||
| 823 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, FALSE, 0); | ||
| 824 | gtk_widget_show(label); | ||
| 825 | |||
| 826 | gtk_signal_connect(GTK_OBJECT (dialog), "delete_event", | ||
| 827 | (GtkSignalFunc)delete_stop_dialog, | ||
| 828 | (gpointer)cap); | ||
| 829 | |||
| 830 | gtk_dialog_run(GTK_DIALOG(dialog)); | ||
| 831 | |||
| 832 | end_stop_dialog(cap); | ||
| 833 | } | 795 | } |
| 834 | 796 | ||
| 835 | static int load_events(struct trace_capture *cap, | 797 | static int load_events(struct trace_capture *cap, |
| @@ -1290,6 +1252,8 @@ static void tracing_dialog(struct shark_info *info, const char *tracing) | |||
| 1290 | GTK_RESPONSE_ACCEPT); | 1252 | GTK_RESPONSE_ACCEPT); |
| 1291 | gtk_widget_show(button); | 1253 | gtk_widget_show(button); |
| 1292 | 1254 | ||
| 1255 | cap.run_button = button; | ||
| 1256 | |||
| 1293 | gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, | 1257 | gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, |
| 1294 | GTK_RESPONSE_REJECT); | 1258 | GTK_RESPONSE_REJECT); |
| 1295 | 1259 | ||
| @@ -1500,6 +1464,9 @@ static void tracing_dialog(struct shark_info *info, const char *tracing) | |||
| 1500 | goto cont; | 1464 | goto cont; |
| 1501 | } | 1465 | } |
| 1502 | 1466 | ||
| 1467 | /* Make sure no capture is running */ | ||
| 1468 | end_capture(&cap); | ||
| 1469 | |||
| 1503 | /* save the plugin and file to reuse if we come back */ | 1470 | /* save the plugin and file to reuse if we come back */ |
| 1504 | update_plugin(&cap); | 1471 | update_plugin(&cap); |
| 1505 | 1472 | ||
| @@ -1517,8 +1484,6 @@ static void tracing_dialog(struct shark_info *info, const char *tracing) | |||
| 1517 | 1484 | ||
| 1518 | gtk_widget_destroy(dialog); | 1485 | gtk_widget_destroy(dialog); |
| 1519 | 1486 | ||
| 1520 | end_capture(&cap); | ||
| 1521 | |||
| 1522 | if (pevent) | 1487 | if (pevent) |
| 1523 | pevent_free(pevent); | 1488 | pevent_free(pevent); |
| 1524 | 1489 | ||
