diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-06-10 10:35:20 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-06-10 10:35:20 -0400 |
commit | eea14e07e1ff9d3fb7c0215f4589f8a061bf7107 (patch) | |
tree | 4d85ce620ab37be5c255a36a7ed5035ca856fcc0 | |
parent | 200cb94dd4a1f1f47c86a82c1dc665a67f426214 (diff) |
kernelshark: Add hide tasks filter to menu bar
Now the menu bar has hide tasks that popups a task dialog to
let the user choose what tasks to hide. Selecting tasks via
the menu bar will enable the filter automatically.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | kernel-shark.c | 181 | ||||
-rw-r--r-- | kernel-shark.h | 2 |
2 files changed, 156 insertions, 27 deletions
diff --git a/kernel-shark.c b/kernel-shark.c index 7b13bdc..d16448c 100644 --- a/kernel-shark.c +++ b/kernel-shark.c | |||
@@ -350,8 +350,11 @@ sync_task_filter_clicked (GtkWidget *subitem, gpointer data) | |||
350 | "Sync Graph and List Task Filters"); | 350 | "Sync Graph and List Task Filters"); |
351 | 351 | ||
352 | gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_task_menu), | 352 | gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_task_menu), |
353 | "graph task filter"); | 353 | "graph tasks"); |
354 | gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_hide_task_menu), | ||
355 | "graph hide tasks"); | ||
354 | gtk_widget_show(info->list_task_menu); | 356 | gtk_widget_show(info->list_task_menu); |
357 | gtk_widget_show(info->list_hide_task_menu); | ||
355 | 358 | ||
356 | /* The list now uses its own hash */ | 359 | /* The list now uses its own hash */ |
357 | info->list_task_filter = filter_task_hash_copy(info->ginfo->task_filter); | 360 | info->list_task_filter = filter_task_hash_copy(info->ginfo->task_filter); |
@@ -412,20 +415,22 @@ sync_task_filter_clicked (GtkWidget *subitem, gpointer data) | |||
412 | gtk_menu_item_set_label(GTK_MENU_ITEM(info->task_sync_menu), | 415 | gtk_menu_item_set_label(GTK_MENU_ITEM(info->task_sync_menu), |
413 | "Unsync Graph and List Task Filters"); | 416 | "Unsync Graph and List Task Filters"); |
414 | gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_task_menu), | 417 | gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_task_menu), |
415 | "task filter"); | 418 | "tasks"); |
419 | gtk_menu_item_set_label(GTK_MENU_ITEM(info->graph_hide_task_menu), | ||
420 | "hide tasks"); | ||
416 | gtk_widget_hide(info->list_task_menu); | 421 | gtk_widget_hide(info->list_task_menu); |
422 | gtk_widget_hide(info->list_hide_task_menu); | ||
417 | } | 423 | } |
418 | } | 424 | } |
419 | 425 | ||
420 | static void filter_list_enable_clicked (gpointer data); | 426 | static void filter_list_enable_clicked (gpointer data); |
421 | 427 | ||
422 | static void | 428 | static void |
423 | update_list_task_filter_callback(gboolean accept, | 429 | __update_list_task_filter_callback(struct shark_info *info, |
424 | gint *selected, | 430 | gboolean accept, |
425 | gint *non_select, | 431 | gint *selected, |
426 | gpointer data) | 432 | struct filter_task *task_filter) |
427 | { | 433 | { |
428 | struct shark_info *info = data; | ||
429 | GtkTreeView *trace_tree = GTK_TREE_VIEW(info->treeview); | 434 | GtkTreeView *trace_tree = GTK_TREE_VIEW(info->treeview); |
430 | GtkTreeModel *model; | 435 | GtkTreeModel *model; |
431 | TraceViewStore *store; | 436 | TraceViewStore *store; |
@@ -440,11 +445,11 @@ update_list_task_filter_callback(gboolean accept, | |||
440 | 445 | ||
441 | store = TRACE_VIEW_STORE(model); | 446 | store = TRACE_VIEW_STORE(model); |
442 | 447 | ||
443 | filter_task_clear(info->list_task_filter); | 448 | filter_task_clear(task_filter); |
444 | 449 | ||
445 | if (selected) { | 450 | if (selected) { |
446 | for (i = 0; selected[i] >= 0; i++) | 451 | for (i = 0; selected[i] >= 0; i++) |
447 | filter_task_add_pid(info->list_task_filter, selected[i]); | 452 | filter_task_add_pid(task_filter, selected[i]); |
448 | } | 453 | } |
449 | 454 | ||
450 | update_tree_view_filters(info, info->list_task_filter, info->list_hide_tasks); | 455 | update_tree_view_filters(info, info->list_task_filter, info->list_hide_tasks); |
@@ -456,11 +461,36 @@ update_list_task_filter_callback(gboolean accept, | |||
456 | filter_list_enable_clicked(info); | 461 | filter_list_enable_clicked(info); |
457 | } | 462 | } |
458 | 463 | ||
459 | /* Callback for the clicked signal of the List Tasks filter button */ | ||
460 | static void | 464 | static void |
461 | list_tasks_clicked (gpointer data) | 465 | update_list_task_filter_callback(gboolean accept, |
466 | gint *selected, | ||
467 | gint *non_select, | ||
468 | gpointer data) | ||
469 | { | ||
470 | struct shark_info *info = data; | ||
471 | |||
472 | __update_list_task_filter_callback(info, accept, selected, | ||
473 | info->list_task_filter); | ||
474 | } | ||
475 | |||
476 | static void | ||
477 | update_list_hide_task_filter_callback(gboolean accept, | ||
478 | gint *selected, | ||
479 | gint *non_select, | ||
480 | gpointer data) | ||
462 | { | 481 | { |
463 | struct shark_info *info = data; | 482 | struct shark_info *info = data; |
483 | |||
484 | __update_list_task_filter_callback(info, accept, selected, | ||
485 | info->list_hide_tasks); | ||
486 | } | ||
487 | |||
488 | /* Callback for the clicked signal of the List Tasks filter button */ | ||
489 | static void | ||
490 | __list_tasks_clicked (struct shark_info *info, | ||
491 | struct filter_task *task_filter, | ||
492 | trace_task_cb_func func) | ||
493 | { | ||
464 | GtkTreeView *trace_tree = GTK_TREE_VIEW(info->treeview); | 494 | GtkTreeView *trace_tree = GTK_TREE_VIEW(info->treeview); |
465 | struct graph_info *ginfo = info->ginfo; | 495 | struct graph_info *ginfo = info->ginfo; |
466 | GtkTreeModel *model; | 496 | GtkTreeModel *model; |
@@ -478,33 +508,49 @@ list_tasks_clicked (gpointer data) | |||
478 | store = TRACE_VIEW_STORE(model); | 508 | store = TRACE_VIEW_STORE(model); |
479 | 509 | ||
480 | tasks = trace_graph_task_list(ginfo); | 510 | tasks = trace_graph_task_list(ginfo); |
481 | selected = filter_task_pids(info->list_task_filter); | 511 | selected = filter_task_pids(task_filter); |
482 | 512 | ||
483 | trace_task_dialog(info->handle, tasks, selected, | 513 | trace_task_dialog(info->handle, tasks, selected, func, info); |
484 | update_list_task_filter_callback, info); | ||
485 | 514 | ||
486 | free(tasks); | 515 | free(tasks); |
487 | free(selected); | 516 | free(selected); |
488 | } | 517 | } |
489 | 518 | ||
490 | static void | 519 | static void |
491 | update_graph_task_filter_callback(gboolean accept, | 520 | list_tasks_clicked (gpointer data) |
492 | gint *selected, | 521 | { |
493 | gint *non_select, | 522 | struct shark_info *info = data; |
494 | gpointer data) | 523 | |
524 | __list_tasks_clicked(info, info->list_task_filter, | ||
525 | update_list_task_filter_callback); | ||
526 | } | ||
527 | |||
528 | static void | ||
529 | list_hide_tasks_clicked (gpointer data) | ||
495 | { | 530 | { |
496 | struct shark_info *info = data; | 531 | struct shark_info *info = data; |
532 | |||
533 | __list_tasks_clicked(info, info->list_hide_tasks, | ||
534 | update_list_hide_task_filter_callback); | ||
535 | } | ||
536 | |||
537 | static void | ||
538 | __update_graph_task_filter_callback(struct shark_info *info, | ||
539 | gboolean accept, | ||
540 | gint *selected, | ||
541 | struct filter_task *task_filter) | ||
542 | { | ||
497 | struct graph_info *ginfo = info->ginfo; | 543 | struct graph_info *ginfo = info->ginfo; |
498 | int i; | 544 | int i; |
499 | 545 | ||
500 | if (!accept) | 546 | if (!accept) |
501 | return; | 547 | return; |
502 | 548 | ||
503 | filter_task_clear(ginfo->task_filter); | 549 | filter_task_clear(task_filter); |
504 | 550 | ||
505 | if (selected) { | 551 | if (selected) { |
506 | for (i = 0; selected[i] >= 0; i++) | 552 | for (i = 0; selected[i] >= 0; i++) |
507 | filter_task_add_pid(ginfo->task_filter, selected[i]); | 553 | filter_task_add_pid(task_filter, selected[i]); |
508 | } | 554 | } |
509 | 555 | ||
510 | trace_graph_refresh_filters(ginfo); | 556 | trace_graph_refresh_filters(ginfo); |
@@ -521,12 +567,39 @@ update_graph_task_filter_callback(gboolean accept, | |||
521 | } | 567 | } |
522 | } | 568 | } |
523 | 569 | ||
524 | /* Callback for the clicked signal of the Tasks filter button */ | ||
525 | static void | 570 | static void |
526 | graph_tasks_clicked (gpointer data) | 571 | update_graph_task_filter_callback(gboolean accept, |
572 | gint *selected, | ||
573 | gint *non_select, | ||
574 | gpointer data) | ||
575 | { | ||
576 | struct shark_info *info = data; | ||
577 | struct graph_info *ginfo = info->ginfo; | ||
578 | |||
579 | __update_graph_task_filter_callback(info, accept, selected, | ||
580 | ginfo->task_filter); | ||
581 | } | ||
582 | |||
583 | static void | ||
584 | update_graph_hide_task_filter_callback(gboolean accept, | ||
585 | gint *selected, | ||
586 | gint *non_select, | ||
587 | gpointer data) | ||
527 | { | 588 | { |
528 | struct shark_info *info = data; | 589 | struct shark_info *info = data; |
529 | struct graph_info *ginfo = info->ginfo; | 590 | struct graph_info *ginfo = info->ginfo; |
591 | |||
592 | __update_graph_task_filter_callback(info, accept, selected, | ||
593 | ginfo->hide_tasks); | ||
594 | } | ||
595 | |||
596 | /* Callback for the clicked signal of the Tasks filter button */ | ||
597 | static void | ||
598 | __graph_tasks_clicked (struct shark_info *info, | ||
599 | struct filter_task *task_filter, | ||
600 | trace_task_cb_func func) | ||
601 | { | ||
602 | struct graph_info *ginfo = info->ginfo; | ||
530 | gint *selected; | 603 | gint *selected; |
531 | gint *tasks; | 604 | gint *tasks; |
532 | 605 | ||
@@ -534,15 +607,34 @@ graph_tasks_clicked (gpointer data) | |||
534 | return; | 607 | return; |
535 | 608 | ||
536 | tasks = trace_graph_task_list(ginfo); | 609 | tasks = trace_graph_task_list(ginfo); |
537 | selected = filter_task_pids(ginfo->task_filter); | 610 | selected = filter_task_pids(task_filter); |
538 | 611 | ||
539 | trace_task_dialog(ginfo->handle, tasks, selected, | 612 | trace_task_dialog(ginfo->handle, tasks, selected, func, info); |
540 | update_graph_task_filter_callback, info); | ||
541 | 613 | ||
542 | free(tasks); | 614 | free(tasks); |
543 | free(selected); | 615 | free(selected); |
544 | } | 616 | } |
545 | 617 | ||
618 | static void | ||
619 | graph_tasks_clicked (gpointer data) | ||
620 | { | ||
621 | struct shark_info *info = data; | ||
622 | struct graph_info *ginfo = info->ginfo; | ||
623 | |||
624 | __graph_tasks_clicked(info, ginfo->task_filter, | ||
625 | update_graph_task_filter_callback); | ||
626 | } | ||
627 | |||
628 | static void | ||
629 | graph_hide_tasks_clicked (gpointer data) | ||
630 | { | ||
631 | struct shark_info *info = data; | ||
632 | struct graph_info *ginfo = info->ginfo; | ||
633 | |||
634 | __graph_tasks_clicked(info, ginfo->hide_tasks, | ||
635 | update_graph_hide_task_filter_callback); | ||
636 | } | ||
637 | |||
546 | /* Callback for the clicked signal of the Events filter button */ | 638 | /* Callback for the clicked signal of the Events filter button */ |
547 | static void | 639 | static void |
548 | list_events_clicked (gpointer data) | 640 | list_events_clicked (gpointer data) |
@@ -1380,7 +1472,7 @@ void kernel_shark(int argc, char **argv) | |||
1380 | 1472 | ||
1381 | /* --- Filter - List Tasks Option --- */ | 1473 | /* --- Filter - List Tasks Option --- */ |
1382 | 1474 | ||
1383 | sub_item = gtk_menu_item_new_with_label("list task filter"); | 1475 | sub_item = gtk_menu_item_new_with_label("list tasks"); |
1384 | 1476 | ||
1385 | /* Add them to the menu */ | 1477 | /* Add them to the menu */ |
1386 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); | 1478 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); |
@@ -1397,7 +1489,7 @@ void kernel_shark(int argc, char **argv) | |||
1397 | 1489 | ||
1398 | /* --- Filter - Graph Tasks Option --- */ | 1490 | /* --- Filter - Graph Tasks Option --- */ |
1399 | 1491 | ||
1400 | sub_item = gtk_menu_item_new_with_label("task filter"); | 1492 | sub_item = gtk_menu_item_new_with_label("tasks"); |
1401 | 1493 | ||
1402 | /* Add them to the menu */ | 1494 | /* Add them to the menu */ |
1403 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); | 1495 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); |
@@ -1413,6 +1505,41 @@ void kernel_shark(int argc, char **argv) | |||
1413 | gtk_widget_show(sub_item); | 1505 | gtk_widget_show(sub_item); |
1414 | 1506 | ||
1415 | 1507 | ||
1508 | /* --- Filter - List Hide Tasks Option --- */ | ||
1509 | |||
1510 | sub_item = gtk_menu_item_new_with_label("list hide tasks"); | ||
1511 | |||
1512 | /* Add them to the menu */ | ||
1513 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); | ||
1514 | |||
1515 | /* We can attach the Quit menu item to our exit function */ | ||
1516 | g_signal_connect_swapped (G_OBJECT (sub_item), "activate", | ||
1517 | G_CALLBACK (list_hide_tasks_clicked), | ||
1518 | (gpointer) info); | ||
1519 | |||
1520 | info->list_hide_task_menu = sub_item; | ||
1521 | |||
1522 | /* Only show this item when list and graph tasks are not synced */ | ||
1523 | |||
1524 | |||
1525 | /* --- Filter - Graph Hide Tasks Option --- */ | ||
1526 | |||
1527 | sub_item = gtk_menu_item_new_with_label("hide tasks"); | ||
1528 | |||
1529 | /* Add them to the menu */ | ||
1530 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); | ||
1531 | |||
1532 | /* We can attach the Quit menu item to our exit function */ | ||
1533 | g_signal_connect_swapped (G_OBJECT (sub_item), "activate", | ||
1534 | G_CALLBACK (graph_hide_tasks_clicked), | ||
1535 | (gpointer) info); | ||
1536 | |||
1537 | info->graph_hide_task_menu = sub_item; | ||
1538 | |||
1539 | /* We do need to show menu items */ | ||
1540 | gtk_widget_show(sub_item); | ||
1541 | |||
1542 | |||
1416 | /* --- Filter - List Events Option --- */ | 1543 | /* --- Filter - List Events Option --- */ |
1417 | 1544 | ||
1418 | sub_item = gtk_menu_item_new_with_label("list events"); | 1545 | sub_item = gtk_menu_item_new_with_label("list events"); |
diff --git a/kernel-shark.h b/kernel-shark.h index d537332..34d2cfd 100644 --- a/kernel-shark.h +++ b/kernel-shark.h | |||
@@ -33,6 +33,8 @@ struct shark_info { | |||
33 | GtkWidget *task_sync_menu; | 33 | GtkWidget *task_sync_menu; |
34 | GtkWidget *list_task_menu; | 34 | GtkWidget *list_task_menu; |
35 | GtkWidget *graph_task_menu; | 35 | GtkWidget *graph_task_menu; |
36 | GtkWidget *list_hide_task_menu; | ||
37 | GtkWidget *graph_hide_task_menu; | ||
36 | struct graph_callbacks graph_cbs; | 38 | struct graph_callbacks graph_cbs; |
37 | gint selected_task; | 39 | gint selected_task; |
38 | gboolean list_filter_enabled; | 40 | gboolean list_filter_enabled; |