Re: A Question about GtkTreeSortable



Am Donnerstag, den 20.10.2005, 17:44 +0200 schrieb Iago Rubio:
On Thu, 2005-10-20 at 19:06 +0800, searun wrote:
Hi ,

Now i want to use GtkTreeSortable to sort a list. The first entry in the
gtk_tree_view is an information entry which needn't to be sorted, so i don't
want the GtkTreeIterCompareFunc function use the first entry. In my programe
i check GtkTreeIter, if it is the same as the first iter, the
GtkTreeIterCompareFunc will return 0.

How are you comparing those iters ?

BUT it can't work. After two day's debug, i can't find the reason.

Any help is appreciated, even if you have another good method.

Try to compare the paths with gtk_tree_path_compare() instead of
comparing the iters. I don't know a generic function to compare iters.

gint       
your_tree_iter_compare_func  (GtkTreeModel *model,
                              GtkTreeIter *a,
                              GtkTreeIter *b,
                              gpointer user_data)
{
GtkTreePath* path_first;
GtkTreePath* path_a;
GtkTreePath* path_b;

first_path = gtk_tree_path_new_first();
path_a = gtk_tree_model_get_path (model,a);
path_b = gtk_tree_model_get_path (model,b);

if( gtk_tree_path_compare(path_first, path_a) == 0 ){
      return -1; // "a" is first so "a" always sorts before
}else if ( gtk_tree_path_compare(path_first, path_b) == 0 ){
      return 1;  // "b" is first so "a" always sorts after
}

// none of both are first so compare them 

.....

gtk_tree_path_free(path_first);
gtk_tree_path_free(path_a);
gtk_tree_path_free(path_b);
}

Note that this will IMHO only work if the informal row is inserted into
the model before any other row.

-- 
Christian Neumair <chris gnome-de org>


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