diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-02-17 21:09:03 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-02-21 20:42:07 -0500 |
commit | 254d95492c0a322594d9f50e5d3774d4ece5a4d7 (patch) | |
tree | c38175c6e8912cdc2d813f17d36e5c10c97298a9 | |
parent | 169e56b468c38d073cf0076d7acfb199885ae874 (diff) |
trace-view: Search next pages if current page fails search
If the list search fails to find the search text on the first page,
ask to search on the other pages and continue the search if
yes is selected.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-view-store.c | 7 | ||||
-rw-r--r-- | trace-view.c | 126 |
2 files changed, 96 insertions, 37 deletions
diff --git a/trace-view-store.c b/trace-view-store.c index 4afc192..3abea32 100644 --- a/trace-view-store.c +++ b/trace-view-store.c | |||
@@ -426,7 +426,7 @@ trace_view_store_get_value (GtkTreeModel *tree_model, | |||
426 | const gchar *comm; | 426 | const gchar *comm; |
427 | gchar *str; | 427 | gchar *str; |
428 | guint64 secs, usecs; | 428 | guint64 secs, usecs; |
429 | gint val, pos; | 429 | gint val; |
430 | int cpu; | 430 | int cpu; |
431 | 431 | ||
432 | g_return_if_fail (TRACE_VIEW_IS_LIST (tree_model)); | 432 | g_return_if_fail (TRACE_VIEW_IS_LIST (tree_model)); |
@@ -443,11 +443,6 @@ trace_view_store_get_value (GtkTreeModel *tree_model, | |||
443 | 443 | ||
444 | g_return_if_fail ( record != NULL ); | 444 | g_return_if_fail ( record != NULL ); |
445 | 445 | ||
446 | pos = record->pos - trace_view_store->start_row; | ||
447 | |||
448 | if(pos >= trace_view_store->num_rows) | ||
449 | g_return_if_reached(); | ||
450 | |||
451 | column = get_visible_column(TRACE_VIEW_STORE(tree_model), column); | 446 | column = get_visible_column(TRACE_VIEW_STORE(tree_model), column); |
452 | 447 | ||
453 | switch(column) | 448 | switch(column) |
diff --git a/trace-view.c b/trace-view.c index 0f00098..0ce730c 100644 --- a/trace-view.c +++ b/trace-view.c | |||
@@ -683,6 +683,87 @@ static gboolean test_text(const gchar *text, const gchar *search_text, enum sele | |||
683 | return FALSE; | 683 | return FALSE; |
684 | } | 684 | } |
685 | 685 | ||
686 | static gboolean test_row(GtkTreeModel *model, GtkTreeIter *iter, gint sel, | ||
687 | gint col_num, gint search_val, const gchar *search_text) | ||
688 | { | ||
689 | gchar *text = NULL; | ||
690 | gboolean found = FALSE; | ||
691 | gint val; | ||
692 | |||
693 | switch (col_num) { | ||
694 | case TRACE_VIEW_STORE_COL_INDEX: | ||
695 | case TRACE_VIEW_STORE_COL_CPU: | ||
696 | case TRACE_VIEW_STORE_COL_PID: | ||
697 | /* integers */ | ||
698 | |||
699 | gtk_tree_model_get(model, iter, | ||
700 | col_num, &val, | ||
701 | -1); | ||
702 | if (test_int(val, search_val, sel)) | ||
703 | found = TRUE; | ||
704 | break; | ||
705 | |||
706 | case TRACE_VIEW_STORE_COL_TS: | ||
707 | case TRACE_VIEW_STORE_COL_COMM: | ||
708 | case TRACE_VIEW_STORE_COL_LAT: | ||
709 | case TRACE_VIEW_STORE_COL_EVENT: | ||
710 | case TRACE_VIEW_STORE_COL_INFO: | ||
711 | /* strings */ | ||
712 | |||
713 | gtk_tree_model_get(model, iter, | ||
714 | col_num, &text, | ||
715 | -1); | ||
716 | |||
717 | if (test_text(text, search_text, sel)) | ||
718 | found = TRUE; | ||
719 | break; | ||
720 | } | ||
721 | |||
722 | return found; | ||
723 | } | ||
724 | |||
725 | static void search_next_pages(GtkTreeView *tree, | ||
726 | TraceViewStore *store, gint sel, gint col_num, | ||
727 | gint search_val, const char *search_text) | ||
728 | { | ||
729 | GtkTreeModel *model; | ||
730 | TraceViewRecord *rec; | ||
731 | GtkTreeIter iter; | ||
732 | gint row; | ||
733 | gint total_rows; | ||
734 | gboolean found = FALSE; | ||
735 | |||
736 | model = (GtkTreeModel *)store; | ||
737 | |||
738 | row = store->start_row + store->num_rows; | ||
739 | total_rows = trace_view_store_get_num_actual_rows(store); | ||
740 | |||
741 | trace_set_cursor(GDK_WATCH); | ||
742 | trace_freeze_all(); | ||
743 | |||
744 | for (; row < total_rows; row++) { | ||
745 | |||
746 | /* Needed to process the cursor change */ | ||
747 | if (row & (1 << 5)) | ||
748 | gtk_main_iteration_do(FALSE); | ||
749 | |||
750 | rec = trace_view_store_get_actual_row(store, row); | ||
751 | iter.user_data = rec; | ||
752 | found = test_row(model, &iter, sel, col_num, search_val, search_text); | ||
753 | if (found) | ||
754 | break; | ||
755 | } | ||
756 | trace_unfreeze_all(); | ||
757 | trace_put_cursor(); | ||
758 | |||
759 | if (!found) { | ||
760 | trace_dialog(NULL, TRACE_GUI_INFO, "Not found"); | ||
761 | return; | ||
762 | } | ||
763 | |||
764 | trace_view_select(GTK_WIDGET(tree), rec->timestamp); | ||
765 | } | ||
766 | |||
686 | static void search_tree(gpointer data) | 767 | static void search_tree(gpointer data) |
687 | { | 768 | { |
688 | struct search_info *info = data; | 769 | struct search_info *info = data; |
@@ -695,8 +776,6 @@ static void search_tree(gpointer data) | |||
695 | GtkComboBox *col_combo = GTK_COMBO_BOX(info->column); | 776 | GtkComboBox *col_combo = GTK_COMBO_BOX(info->column); |
696 | GtkComboBox *sel_combo = GTK_COMBO_BOX(info->selection); | 777 | GtkComboBox *sel_combo = GTK_COMBO_BOX(info->selection); |
697 | const gchar *title; | 778 | const gchar *title; |
698 | gint val; | ||
699 | gchar *text = NULL; | ||
700 | const gchar *search_text; | 779 | const gchar *search_text; |
701 | gint col_num; | 780 | gint col_num; |
702 | gint sel; | 781 | gint sel; |
@@ -747,35 +826,7 @@ static void search_tree(gpointer data) | |||
747 | /* Needed to process the cursor change */ | 826 | /* Needed to process the cursor change */ |
748 | gtk_main_iteration_do(FALSE); | 827 | gtk_main_iteration_do(FALSE); |
749 | 828 | ||
750 | switch (col_num) { | 829 | found = test_row(model, &iter, sel, col_num, search_val, search_text); |
751 | case TRACE_VIEW_STORE_COL_INDEX: | ||
752 | case TRACE_VIEW_STORE_COL_CPU: | ||
753 | case TRACE_VIEW_STORE_COL_PID: | ||
754 | /* integers */ | ||
755 | |||
756 | gtk_tree_model_get(model, &iter, | ||
757 | col_num, &val, | ||
758 | -1); | ||
759 | if (test_int(val, search_val, sel)) | ||
760 | found = TRUE; | ||
761 | break; | ||
762 | |||
763 | case TRACE_VIEW_STORE_COL_TS: | ||
764 | case TRACE_VIEW_STORE_COL_COMM: | ||
765 | case TRACE_VIEW_STORE_COL_LAT: | ||
766 | case TRACE_VIEW_STORE_COL_EVENT: | ||
767 | case TRACE_VIEW_STORE_COL_INFO: | ||
768 | /* strings */ | ||
769 | |||
770 | gtk_tree_model_get(model, &iter, | ||
771 | col_num, &text, | ||
772 | -1); | ||
773 | |||
774 | if (test_text(text, search_text, sel)) | ||
775 | found = TRUE; | ||
776 | break; | ||
777 | } | ||
778 | |||
779 | if (found) | 830 | if (found) |
780 | break; | 831 | break; |
781 | } | 832 | } |
@@ -783,6 +834,19 @@ static void search_tree(gpointer data) | |||
783 | trace_put_cursor(); | 834 | trace_put_cursor(); |
784 | 835 | ||
785 | if (!found) { | 836 | if (!found) { |
837 | GtkResponseType ret; | ||
838 | gint pages = trace_view_store_get_pages(store); | ||
839 | gint page = trace_view_store_get_page(store); | ||
840 | |||
841 | if (page < pages) { | ||
842 | ret = trace_dialog(NULL, TRACE_GUI_ASK, | ||
843 | "Not found on this page\n" | ||
844 | "Search next pages?"); | ||
845 | if (ret == GTK_RESPONSE_YES) | ||
846 | search_next_pages(info->treeview, store, sel, | ||
847 | col_num, search_val, search_text); | ||
848 | return; | ||
849 | } | ||
786 | trace_dialog(NULL, TRACE_GUI_INFO, "Not found"); | 850 | trace_dialog(NULL, TRACE_GUI_INFO, "Not found"); |
787 | return; | 851 | return; |
788 | } | 852 | } |