Re: Listbox, Treeview and attaching pointers to rows
- From: Damien Caliste <damien caliste cea fr>
- To: arto karppinen iki fi
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Listbox, Treeview and attaching pointers to rows
- Date: Wed, 24 Oct 2007 14:37:16 +0200
Hello,
Le 24/10/2007, Arto Karppinen <exeonical mail suomi net> a Ãcrit :
Row one -> Data pointer 1
Row two -> Data pointer 1
Row n+1 -> Data pointer 1
How would one accomplish such amazing task?
Your data pointer should added in your model:
enum
{
COL_LABEL,
COL_DATA,
NB_COLS
};
GtkListStore *list;
list = gtk_list_store_new (NB_COLS, G_TYPE_STRING, G_TYPE_POINTER);
Then, when you populate your model, store your data pointers:
for (i = 0; i < n; i++)
{
/* Compute the values, associating a label and
and data pointer. */
[...]
/* Store them in the liststore. */
gtk_list_store_set(list, &iter,
COL_LABEL , label_i,
COL_DATA , (gpointer)data_row_i,
-1);
}
You don't need to store your data pointers into a custom array, they are
stored for you in the liststore.
Finally, in your selection callback (at the iterator iter), retrieve the
stored data pointers:
gpointer data_row;
gtk_tree_model_get(GTK_TREE_MODEL(list), &iter,
COL_DATA, &data_row, -1);
Damien.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]