[gtk+] tests: Dump the operation that is performed to stderr
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] tests: Dump the operation that is performed to stderr
- Date: Sat, 10 Dec 2011 07:01:15 +0000 (UTC)
commit 4d3986e709f46cf829e91f1382185a69f6e185c4
Author: Benjamin Otte <otte redhat com>
Date: Sat Dec 10 04:52:48 2011 +0100
tests: Dump the operation that is performed to stderr
tests/testtreechanging.c | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/tests/testtreechanging.c b/tests/testtreechanging.c
index 825caeb..943b641 100644
--- a/tests/testtreechanging.c
+++ b/tests/testtreechanging.c
@@ -57,6 +57,33 @@ get_rows (GtkTreeView *treeview)
return GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (treeview), "rows"));
}
+static void
+log_operation_for_path (GtkTreePath *path,
+ const char *operation_name)
+{
+ char *path_string;
+
+ path_string = gtk_tree_path_to_string (path);
+
+ g_printerr ("%10s %s\n", operation_name, path_string);
+
+ g_free (path_string);
+}
+
+static void
+log_operation (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ const char *operation_name)
+{
+ GtkTreePath *path;
+
+ path = gtk_tree_model_get_path (model, iter);
+
+ log_operation_for_path (path, operation_name);
+
+ gtk_tree_path_free (path);
+}
+
/* moves iter to the next iter in the model in the display order
* inside a treeview. Returns FALSE if no more rows exist.
*/
@@ -106,6 +133,7 @@ delete (GtkTreeView *treeview)
}
n_rows -= count_children (model, &iter) + 1;
+ log_operation (model, &iter, "remove");
gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
set_rows (treeview, n_rows);
}
@@ -115,6 +143,7 @@ add_one (GtkTreeModel *model,
GtkTreeIter *iter)
{
guint n = gtk_tree_model_iter_n_children (model, iter);
+ GtkTreeIter new_iter;
static guint counter = 0;
if (n > 0 && g_random_boolean ())
@@ -126,11 +155,12 @@ add_one (GtkTreeModel *model,
}
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
- NULL,
+ &new_iter,
iter,
g_random_int_range (-1, n),
0, ++counter,
-1);
+ log_operation (model, &new_iter, "add");
}
static void
@@ -175,6 +205,7 @@ expand (GtkTreeView *treeview)
path = gtk_tree_model_get_path (model, &iter);
if (!gtk_tree_view_row_expanded (treeview, path))
{
+ log_operation (model, &iter, "expand");
gtk_tree_view_expand_row (treeview, path, FALSE);
gtk_tree_path_free (path);
return;
@@ -212,6 +243,7 @@ collapse (GtkTreeView *treeview)
if (last)
{
+ log_operation_for_path (last, "collapse");
gtk_tree_view_collapse_row (treeview, last);
gtk_tree_path_free (last);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]