static void draw_gtk_node(stat_node* node) { GtkTreeIter *parent = NULL; stat_node *child; int num_columns = node->st->num_columns+N_RESERVED_COL; gint *columns = (gint*) g_malloc(sizeof(gint)*num_columns); GValue *values = (GValue*) g_malloc0(sizeof(GValue)*num_columns); gchar **valstrs = stats_tree_get_values_from_node(node); int count; columns[0]= 0; g_value_init(values, G_TYPE_POINTER); g_value_set_pointer(values, node); for (count = N_RESERVED_COL; count<num_columns; count++) { columns[count]= count; g_value_init(values+count, G_TYPE_STRING); g_value_take_string (values+count,valstrs[count-N_RESERVED_COL]); } if (!node->pr) { node->pr = (st_node_pres *)g_malloc(sizeof(st_node_pres)); if (node->st->pr->store) { node->pr->iter = (GtkTreeIter *)g_malloc0(sizeof(GtkTreeIter)); if ( node->parent && node->parent->pr ) { parent = node->parent->pr->iter; } gtk_tree_store_append (node->st->pr->store, node->pr->iter, parent); gtk_tree_store_set_valuesv(node->st->pr->store, node->pr->iter, columns, values, num_columns); } } if (node->st->pr->store && node->pr->iter) { /* skip reserved columns and first entry in the stats_tree values */ /* list (the node name). These should already be set and static. */ gtk_tree_store_set_valuesv(node->st->pr->store, node->pr->iter, columns+N_RESERVED_COL+1, values+N_RESERVED_COL+1, num_columns-N_RESERVED_COL-1); } for (count = 0; count<num_columns; count++) { g_value_unset(values+count); } g_free(columns); g_free(values); g_free(valstrs); if (node->children) { for (child = node->children; child; child = child->next ) draw_gtk_node(child); } }
/* Helper function for tst_set() */ static gboolean tst_helper(gpointer user_data) { struct tree_store_data* dat = (struct tree_store_data*)user_data; GtkTreeIter* iter = get_iter_for(dat->which); if(!iter) { return FALSE; } gtk_tree_store_set_valuesv(certificates, iter, dat->columns, dat->values, dat->n_values); dat->free(dat); return FALSE; }