Re: Question about sorting a CLIST
- From: Owen Taylor <otaylor redhat com>
- To: Raul Dias <chaos swi com br>
- Cc: gtk-list redhat com
- Subject: Re: Question about sorting a CLIST
- Date: 15 Nov 1999 12:57:29 -0500
Raul Dias <chaos@swi.com.br> writes:
> Hi again,
>
> I have two questions about sorting a clist.
> The first one.
>
> Is there any other sorting type, other than ascending and descending?
> Like numeric. Or I have to implement that in my app?
>
> The second one:
>
> How do I get the new row number from a selected row after sorting it?
> Is there somerhing like gtk_get_current_selected_row()?
> The closest I got is a function to map x and y to row and column.
typedef gint (*GtkCListCompareFunc) (GtkCList *clist,
gconstpointer ptr1,
gconstpointer ptr2);
/* sets a compare function different to the default */
void gtk_clist_set_compare_func (GtkCList *clist,
GtkCListCompareFunc cmp_func);
For example, I use this in memprof:
====================
static gint
profile_compare_name (GtkCList *clist,
gconstpointer ptr1,
gconstpointer ptr2)
{
ProfileFunc *func1 = ((const GtkCListRow *)ptr1)->data;
ProfileFunc *func2 = ((const GtkCListRow *)ptr2)->data;
return strcmp (func1->symbol->name, func2->symbol->name);
}
[...]
static void
profile_func_click_column (GtkWidget *clist, gint column)
{
static const GtkCListCompareFunc compare_funcs[] = {
profile_compare_name,
profile_compare_self,
profile_compare_total
};
g_return_if_fail (column >= 0 && column < 3);
gtk_clist_set_compare_func (GTK_CLIST (clist), compare_funcs[column]);
gtk_clist_sort (GTK_CLIST (clist));
}
===================
The 'ProfileFunc *' structure is set as row data on each row
in the CList.
Hope this helps,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]