/** * Updates the horizon statistics in the statusbar. * * This is an event-driven callback called from the HSEP code * using the event listener framework. In addition to taking into account * the HSEP information, the number of established non-HSEP nodes and * their library size (if provided) are added to the values displayed. */ void gnet_stats_gui_horizon_update(hsep_triple *table, guint32 triples) { const guint32 hops = 4U; /* must be <= HSEP_N_MAX */ guint64 val; hsep_triple other; if (triples <= hops) /* should not happen */ return; g_assert((gint32) triples > 0); guc_hsep_get_non_hsep_triple(&other); /* * Update the 3 labels in the statusbar with the horizon values for a * distance of 'hops' hops. */ val = table[hops][HSEP_IDX_NODES] + other[HSEP_IDX_NODES]; gtk_label_printf(GTK_LABEL( gui_main_window_lookup("label_statusbar_horizon_node_count")), "%s %s", uint64_to_string(val), NG_("node", "nodes", val)); val = table[hops][HSEP_IDX_FILES] + other[HSEP_IDX_FILES]; gtk_label_printf(GTK_LABEL( gui_main_window_lookup("label_statusbar_horizon_file_count")), "%s %s", uint64_to_string(val), NG_("file", "files", val)); val = table[hops][HSEP_IDX_KIB] + other[HSEP_IDX_KIB]; gtk_label_printf(GTK_LABEL( gui_main_window_lookup("label_statusbar_horizon_kb_count")), "%s", short_kb_size(val, show_metric_units())); }
/** * 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) { GtkWidget *clist_search_stats; GtkWidget *label_search_stats_count; clist_search_stats = gui_main_window_lookup("clist_search_stats"); label_search_stats_count = gui_main_window_lookup("label_search_stats_count"); stat_count = 0; gtk_clist_freeze(GTK_CLIST(clist_search_stats)); gtk_clist_clear(GTK_CLIST(clist_search_stats)); /* insert the hash table contents into the sorted clist */ g_hash_table_foreach_remove(stat_hash, stats_hash_to_clist, NULL); gtk_clist_sort(GTK_CLIST(clist_search_stats)); gtk_clist_thaw(GTK_CLIST(clist_search_stats)); /* update the counter */ gtk_label_printf(GTK_LABEL(label_search_stats_count), NG_("%u term counted", "%u terms counted", stat_count), stat_count); }
/** * 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)); }