void load_graph_start (LoadGraph *g) { if(!g->timer_index) { load_graph_update(g); g->timer_index = g_timeout_add (g->speed / g->frames_per_unit, load_graph_update, g); } g->draw = TRUE; }
static gboolean update_field(gpointer data) { ShellFieldUpdate *fu = (ShellFieldUpdate *) data; /* if the entry is still selected, update it */ if (fu->entry->selected && fu->entry->fieldfunc) { gchar *value = fu->entry->fieldfunc(fu->field_name); GtkTreeIter *iter = g_hash_table_lookup(update_tbl, fu->field_name); /* this function is also used to feed the load graph when ViewType = SHELL_VIEW_LOAD_GRAPH */ if (fu->loadgraph && shell->view_type == SHELL_VIEW_LOAD_GRAPH) { GtkTreeSelection *ts; ts = gtk_tree_view_get_selection(GTK_TREE_VIEW (shell->info->view)); if (iter && gtk_tree_selection_iter_is_selected(ts, iter)) { load_graph_update(shell->loadgraph, atoi(value)); } g_free(value); return TRUE; } if (iter) { GtkTreeStore *store = GTK_TREE_STORE(shell->info->model); gtk_tree_store_set(store, iter, INFO_TREE_COL_VALUE, value, -1); g_free(value); return TRUE; } } /* otherwise, cleanup and destroy the timeout */ g_free(fu->field_name); g_free(fu); return FALSE; }
gboolean lg_update(gpointer d) { LoadGraph *lg = (LoadGraph *) d; static int i = 0; static int j = 1; if (i > 150) { j = -1; } else if (i < 0) { j = 1; } i += j; if (rand() % 10 > 8) i *= 2; if (rand() % 10 < 2) i /= 2; load_graph_update(lg, i + rand() % 50); return TRUE; }