TreeStore reordering



-

I'm a bit confused about how reordering cells in GtkTreeView using GtkTreeStore is supposed to work in Gtk+ 2.2.1. I have a TreeView with a TreeStore with the following cells (pardon the poor ascii art):

-Folder 1
-Folder 2
    -Folder 3
          -Folder 4

I am able to drag and reorder Folder 4 to a child of Folder 2, or child of the non-existant root (ie, on the level with 1 & 2), but I cannot drag it to be a child of Folder 1. Or, if I drag it out of Folder 3, I cannot drag it back in? Is this how reordering is supposed to work with the TreeStore, or is it a bug in my application (test case provided) somewhere, or what?

--
-charlie
#include <gtk/gtk.h>

GtkTreeModel * create_store(void)
{
        GtkTreeStore *s;
        GtkTreeIter i1;
        GtkTreeIter i2;

        s = gtk_tree_store_new(2,G_TYPE_STRING,G_TYPE_STRING);

        gtk_tree_store_append(s,&i1,NULL);
        gtk_tree_store_set(s,&i1,0,"Folder 1",-1);

        gtk_tree_store_append(s,&i1,NULL);
        gtk_tree_store_set(s,&i1,0,"Folder 2",-1);
        
        gtk_tree_store_append(s,&i2,&i1);
        gtk_tree_store_set(s,&i2,0,"Folder 3",-1);

        gtk_tree_store_append(s,&i1,&i2);
        gtk_tree_store_set(s,&i1,0,"Folder 4",-1);

        return GTK_TREE_MODEL(s);
}


gint main(gint argc,gchar **argv)
{
        GtkWidget *window;
        GtkWidget *view;
        GtkTreeModel *store;
        GtkCellRenderer *renderer;
        GtkTreeViewColumn *column;

        gtk_init(&argc,&argv);

        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

        store = create_store();

        view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
        gtk_tree_view_set_reorderable(GTK_TREE_VIEW(view),TRUE);
        gtk_tree_view_expand_all(GTK_TREE_VIEW(view));
        gtk_container_add(GTK_CONTAINER(window),view);

        renderer = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes("Title",renderer,"text",0,NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(view),column);

        gtk_widget_show_all(window);

        gtk_main();

        return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]