From bfa3a5e74f002379827aee31e7124093663433f3 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Mon, 5 Sep 2011 16:40:26 +0200 Subject: [PATCH] =?utf8?q?Aggiunta=20la=20possibilit=C3=A0=20di=20copiare?= =?utf8?q?=20dei=20GtkTreeModelFilter.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/utils.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/utils.c b/src/utils.c index eaf3d34..6be1e4c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -517,10 +517,14 @@ GtkTreeModel GtkTreeModel *ret; GType *gtypes; + guint cols; guint col; + GtkTreeModel *model_child; + GtkTreeIter iter; + GtkTreeIter iter_child; GtkTreeIter iter_new; ret = NULL; @@ -528,7 +532,13 @@ GtkTreeModel gtypes = solipa_gtktreemodel_get_gtypes (model, &cols); if (gtypes != NULL) { - if (GTK_IS_LIST_STORE (model)) + if (GTK_IS_TREE_MODEL_FILTER (model)) + { + model_child = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model)); + } + + if (GTK_IS_LIST_STORE (model) + || (model_child != NULL && GTK_IS_LIST_STORE (model_child))) { ret = GTK_TREE_MODEL (gtk_list_store_newv (cols, gtypes)); @@ -542,7 +552,16 @@ GtkTreeModel for (col = 0; col < cols; col++) { GValue gval = {0}; - gtk_tree_model_get_value (model, &iter, col, &gval); + + if (model_child != NULL) + { + gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &iter_child, &iter); + gtk_tree_model_get_value (model_child, &iter_child, col, &gval); + } + else + { + gtk_tree_model_get_value (model, &iter, col, &gval); + } gtk_list_store_set_value (GTK_LIST_STORE (ret), &iter_new, col, &gval); g_value_unset (&gval); } @@ -550,7 +569,8 @@ GtkTreeModel } } } - else if (GTK_IS_TREE_MODEL (model)) + else if (GTK_IS_TREE_STORE (model) + || (model_child != NULL && GTK_IS_TREE_STORE (model_child))) { ret = GTK_TREE_MODEL (gtk_tree_store_newv (cols, gtypes)); -- 2.49.0