void search_stats_gui_set_type(int type) { if (type == selected_type) return; search_stats_gui_reset(); search_stats_gui_disable(); selected_type = type; switch (type) { case NO_SEARCH_STATS: /* already disabled */ break; case WORD_SEARCH_STATS: search_stats_gui_enable(search_stats_notify_word); break; case WHOLE_SEARCH_STATS: search_stats_gui_enable(search_stats_notify_whole); break; case ROUTED_SEARCH_STATS: search_stats_gui_enable(search_stats_notify_routed); break; default: g_assert_not_reached(); } }
void on_button_search_stats_reset_clicked(GtkButton *unused_button, gpointer unused_data) { (void) unused_button; (void) unused_data; search_stats_gui_reset(); }
/** * Display the data gathered during the last time period. * Perhaps it would be better to have this done on a button click(?) */ static void search_stats_gui_update_display(void) { gboolean sorting_disabled; tm_t start_time, end_time; time_delta_t elapsed; stat_count = 0; g_object_freeze_notify(G_OBJECT(treeview_search_stats)); gtk_list_store_clear(store_search_stats); /* * Temporarily disable sorting while inserting the updated table. * Otherwise, CPU is overloaded with sorting every addition * to the hash table. */ sorting_disabled = FALSE; tm_now_exact(&start_time); if (store_search_stats->sort_column_id >= 0) { sorting_disabled = TRUE; search_stats_gui_sort_save(); } /* insert the hash table contents into the sorted treeview */ htable_foreach_remove(stat_hash, stats_hash_to_treeview, NULL); tm_now_exact(&end_time); elapsed = tm_elapsed_ms(&end_time, &start_time); /* * Re-enable sorting if previously disabled. * If too much time has elapsed, leave sorting disabled. */ if (sorting_disabled && elapsed < 100) { search_stats_gui_sort_restore(); } else if (!sorting_disabled && elapsed > 200) { /* * If sorting is disabled, and too much time is still elapsing, * then the search stats collection will need to be * discontinued */ search_stats_gui_reset(); search_stats_gui_disable(); search_stats_gui_overload = TRUE; } if (search_stats_gui_overload) { /* update status bar message */ gtk_label_set_text(GTK_LABEL(label_search_stats_count), "Disabling Search Stats due to system load" ); } else { /* update the status bar counter */ gtk_label_printf(GTK_LABEL(label_search_stats_count), NG_("%u term counted", "%u terms counted", stat_count), stat_count); } g_object_thaw_notify(G_OBJECT(treeview_search_stats)); }