WIP: how to walk the tree ? Another (small) step...
This commit is contained in:
parent
7b364f0674
commit
e9a67bcf4a
|
@ -92,18 +92,31 @@ static void iterating_a_model_in_a_depth_first_fashion (GtkTreeModel *model)
|
|||
// gboolean (*GtkTreeModelForeachFunc) (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
|
||||
GtkTreeIter iter, iter_parent;
|
||||
gboolean valid = 0;
|
||||
GtkTreePath *chemin;
|
||||
char *str_data;
|
||||
int row_count = 0;
|
||||
|
||||
valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||
if (valid) gtk_tree_model_get (model, &iter, STRING_COLUMN, &str_data, -1);
|
||||
gtk_tree_model_get_iter_first (model, &iter);
|
||||
gtk_tree_model_get (model, &iter, STRING_COLUMN, &str_data, -1);
|
||||
g_print ("first row %d: (%s)\n", row_count, str_data);
|
||||
|
||||
valid = gtk_tree_model_iter_children (model, &iter_parent, &iter);
|
||||
valid = gtk_tree_model_iter_children (model, &iter, &iter_parent);
|
||||
gtk_tree_model_iter_children (model, &iter_parent, &iter);
|
||||
gtk_tree_model_iter_children (model, &iter, &iter_parent); // Sets iter to point to the first child of parent.
|
||||
//gtk_tree_model_iter_next (model, &iter);
|
||||
if (valid) gtk_tree_model_get (model, &iter, STRING_COLUMN, &str_data, -1);
|
||||
g_print ("next row %d: (%s)\n", row_count, str_data);
|
||||
gtk_tree_model_get (model, &iter, STRING_COLUMN, &str_data, -1);
|
||||
g_print ("next row %d: (%s) < False (should be 'A' - line 104)\n", row_count, str_data);
|
||||
|
||||
chemin = gtk_tree_path_new_from_string ("0:0:0:1:0:1");
|
||||
gtk_tree_model_get_iter (model, &iter, chemin);
|
||||
gtk_tree_model_get (model, &iter, STRING_COLUMN, &str_data, -1);
|
||||
g_print ("row from path 0:0:0:1:0:1 %d = (%s)\n", row_count, str_data);
|
||||
gtk_tree_path_free (chemin);
|
||||
|
||||
|
||||
/* GtkTreeIter parent_iter; gtk_tree_model_iter_nth_child (my_tree_model, &iter, NULL, 3); // walk the tree to find the iterator */
|
||||
/* parent_iter = iter; gtk_tree_model_iter_nth_child (my_tree_model, &iter, &parent_iter, 2); */
|
||||
/* parent_iter = iter; gtk_tree_model_iter_nth_child (my_tree_model, &iter, &parent_iter, 5); */
|
||||
|
||||
|
||||
/* while (valid) first row 0: (ROOT) next row 0: (D)*/
|
||||
/* { */
|
||||
|
@ -121,20 +134,14 @@ static void iterating_a_model_in_a_depth_first_fashion (GtkTreeModel *model)
|
|||
}
|
||||
|
||||
// Three ways of getting the iter pointing to the location https://developer-old.gnome.org/gtk4/stable/GtkTreeModel.html#gtk-tree-row-reference-new
|
||||
static void acquiring_a_GtkTreeIter (GtkTreeModel *my_tree_model, GtkTreePath *my_tree_path)
|
||||
{
|
||||
GtkTreeIter iter; // get the iterator from a string
|
||||
gtk_tree_model_get_iter_from_string (my_tree_model, &iter, gtk_tree_path_to_string (my_tree_path));
|
||||
g_print ("acquiring_a_GtkTreeIter from path : [ %s ] (lines 225 & 108)\n", gtk_tree_path_to_string (my_tree_path));
|
||||
|
||||
my_tree_path = gtk_tree_path_new_from_string (gtk_tree_path_to_string (my_tree_path)); // get the iterator from a path
|
||||
gtk_tree_model_get_iter (my_tree_model, &iter, my_tree_path);
|
||||
gtk_tree_path_free (my_tree_path);
|
||||
|
||||
/* GtkTreeIter parent_iter; gtk_tree_model_iter_nth_child (my_tree_model, &iter, NULL, 3); // walk the tree to find the iterator */
|
||||
/* parent_iter = iter; gtk_tree_model_iter_nth_child (my_tree_model, &iter, &parent_iter, 2); */
|
||||
/* parent_iter = iter; gtk_tree_model_iter_nth_child (my_tree_model, &iter, &parent_iter, 5); */
|
||||
}
|
||||
/* static void acquiring_a_GtkTreeIter (GtkTreeModel *my_tree_model, GtkTreePath *my_tree_path) */
|
||||
/* { */
|
||||
/* GtkTreeIter iter; // get the iterator from a string */
|
||||
/* gtk_tree_model_get_iter (model, &iter, my_tree_path); */
|
||||
/* gtk_tree_model_get (model, &iter, STRING_COLUMN, &str_data, -1); */
|
||||
/* g_print ("row from path %s %d = (%s)\n", gtk_tree_path_to_string (my_tree_path), row_count, str_data); */
|
||||
/* gtk_tree_path_free (my_tree_path); */
|
||||
/* } */
|
||||
|
||||
static void /* https://developer-old.gnome.org/gtk4/stable/GtkTreeModel.html#GtkTreePath-struct and #gtk-tree-row-reference-new */
|
||||
edit_a_cell (GtkTreeModel *my_tree_model,
|
||||
|
@ -251,7 +258,7 @@ do_tree_store (GtkWidget *do_widget)
|
|||
my_tree_model = create_node_recursive (my_tree_store, O, NULL, 0);
|
||||
iterating_a_model_in_a_depth_first_fashion (my_tree_model);
|
||||
GtkTreePath *my_path = gtk_tree_path_new_from_string ("0:0:1:0:1");
|
||||
acquiring_a_GtkTreeIter (my_tree_model, my_path);
|
||||
// acquiring_a_GtkTreeIter (my_tree_model, my_path);
|
||||
// GtkTreeIter *my_iter; edit_a_cell (my_tree_model, NULL, my_iter, NULL, my_path);
|
||||
|
||||
/* create tree view */
|
||||
|
|
Loading…
Reference in New Issue