]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Aggiunta la possibilità di copiare dei GtkTreeModelFilter.
authorAndrea Zagli <azagli@libero.it>
Mon, 5 Sep 2011 14:40:26 +0000 (16:40 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 5 Sep 2011 14:40:26 +0000 (16:40 +0200)
src/utils.c

index eaf3d3448d5fcb198440bc6346499ed5addeaba2..6be1e4c814f89517181447975fcc4fe815fcd94f 100644 (file)
@@ -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));