Index: gtk_conf_list.c =================================================================== --- gtk_conf_list.c (revision 1994) +++ gtk_conf_list.c (revision 1995) @@ -40,10 +40,38 @@ rebuild(cl); } +static void fill_misc_cols(gtk_conf_list_t *cl, int row_idx, GtkTreeIter *iter) +{ + int col; + if (cl->get_misc_col_data != NULL) { + for(col = 0; col < cl->num_cols; col++) { + if ((col == cl->col_data) || (col == cl->col_src)) + continue; + char *s = cl->get_misc_col_data(row_idx, col, NULL); + if (s != NULL) { + gtk_list_store_set(cl->l, iter, col, s, -1); + free(s); + } + } + } +} + static void button_ins_cb(GtkButton * button, gtk_conf_list_t *cl) { - GtkTreeIter iter; - printf("ins %d!\n", get_sel(cl, &iter)); + GtkTreeIter *sibl, sibl_, iter; + int idx = get_sel(cl, &sibl_); + if (idx < 0) { + idx = gtk_tree_model_iter_n_children(gtk_tree_view_get_model(GTK_TREE_VIEW(cl->t)), NULL); + sibl = NULL; + } + else + sibl = &sibl_; + + gtk_list_store_insert_before(cl->l, &iter, sibl); + fill_misc_cols(cl, idx, &iter); + +#warning TODO: insert new item at idx + printf("ins %d!\n", idx); } static void button_del_cb(GtkButton * button, gtk_conf_list_t *cl) @@ -103,7 +131,6 @@ #warning TODO: replace list item idx } - GtkWidget *gtk_conf_list_widget(gtk_conf_list_t *cl) { GtkWidget *vbox, *hbox, *bins, *bdel, *bsel, *vfill; @@ -123,7 +150,6 @@ /* fill in the list with initial data */ for(n = 0; n < 8; n++) { - int col; char s[16]; sprintf(s, "foo %d", n); gtk_list_store_append(cl->l, &iter); @@ -130,17 +156,7 @@ gtk_list_store_set(cl->l, &iter, cl->col_data, s, -1); gtk_list_store_set(cl->l, &iter, cl->col_src, "src", -1); - if (cl->get_misc_col_data != NULL) { - for(col = 0; col < cl->num_cols; col++) { - if ((col == cl->col_data) || (col == cl->col_src)) - continue; - char *s = cl->get_misc_col_data(n, col, NULL); - if (s != NULL) { - gtk_list_store_set(cl->l, &iter, col, s, -1); - free(s); - } - } - } + fill_misc_cols(cl, n, &iter); } /* add all columns */