Hello,
I’m migrate my aplication from GTK 1.2 to 2.10. So I try to use GtkTreeStore and GtkTreeView. The fist task is to show the file system hierarchy (and I want to filter this list, but it will be a second question). When the user choose to expand one directory, I must add a lot of rows. To preserve times, i try to detach the model from the tree, and to disable the sort. The result is that it goes faster but i got this error message
Gtk_CRITICAL ** : gtk_tree_store_sort : assertion tree_store->default_sort_func != NULL failed
Gtk_CRITICAL ** : gtk_tree_store_sort_iter_changed : assertion tree_store->default_sort_func != NULL failed
Is there an other way to disable the sort ?
Thank you -----------------------------------------------------------------------------------------------------------------------------------------------------------------
// creating the interface GtkTreeStore *p_TreeStore = gtk_tree_store_new(1, G_TYPE_STRING); GtkTreeSortable *p_Sortable = GTK_TREE_SORTABLE(p_TreeStore), GtkTreeView *p_TreeView = gtk_tree_new_with_model (GTK_TREE_MODEL(p_TreeStore));
gtk_tree_sortable_set_default_sort_func(p_Sortable, my_sort_function, GINT_TO_POINTER(0), NULL); ... GtkCellRenderer *p_Renderer = gtk_cell_text_new (); GtkTreeViewColumn *p_Column = gtk_tree_view_column_new_with_attributes (NULL, p_Renderer, “text”, 0, NULL); Gtk_tree_view_append_column(p_TreeView, p_Column);
gtk_tree_view_column_set_title ( p_Column, “File List”); gtk_tree_view_column_set_clickable ( p_Column, TRUE); gtk_tree_view_column_set_sort_column(p_Column, 0); gtk_tree_sortable_set_sort_column_id(p_Sortable, GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_ASCENDING);
gtk_tree_view_set_headers_visible (p_TreeView, TRUE); gtk_tree_view_set_expander_column (p_TreeView, 0); gtk_tree_view_enable_tree_lines(p_TreeView, TRUE);
g_signal_connect(G_OBJECT(p_TreeView), “row_expanded”, G_CALLBACK(cb_expand), my_filter); g_signal_connect(G_OBJECT(p_TreeView), “row_collapsed”, G_CALLBACK(cb_collapse), my_filter);
// the callback void cb_expand(GtkTreeView * p_TreeView, GtkTreeIter * p_Iter, GtkTrePath * path, gpointer user_data) { GtkTreeStore * p_TreeStore = GTK_TREE_STORE(gtk_tree_view_get_model(p_TreeView);
GtkTreeSortable * p_Sortable = GTK_TREE_SORTABLE(p_TreeStore);
gtk_tree_storable_set_default_sort_func(p_Sortable, NULL, NULL, NULL);
g_object_ref(p_TreeStore); gtk_tree_set_model(p_TreeView, NULL); .... // expand the tree by adding rows .... gtk_tree_set_model(p_TreeView, NULL); g_object_unref(p_TreeStroe);.
gtk_tree_sortable_set_default_sort_func(p_Sortable, my_sort_function, GINT_TO_POINTER(0), NULL); }
|