Re: [gtk-list] GtkCList question said:
> Okay, this seems like a really dumb question, but I'm not seeing it. 
> How do you find out what row a selection is on in a GtkCList?

> Here's what I have, in part:

>     if (data->selection == NULL) { gtk_widget_show 
> (no_selection_dialog); 	return (0); } row_num = gtk_clist_find_row_fro
> m_data (GTK_CLIST (clist),  		GTK_CLIST(clist)->selection->data);

> row_num always comes out as -1.  I have 15 rows in the list.  Is this 
> totally wrong?

> -Blaise 

This came (basically) from the gtktest.c program in the distribution, so I 
can't claim any real credit.

Your callback for selection should look like this:

void rpmCListCallback (GtkCList *clist, gint row, gint col,
                       GdkEvent *event, gpointer data) {

and when you set up the clist inthe first place, use a signal connect like:

gtk_signal_connect (GTK_OBJECT (rpmCList), "select_row",
                    (GtkSignalFunc) rpmCListCallback, NULL);

In your callback, row & col will be set to the users selection.  Works for 

Rick Forrister                 <>

Opera: Greek word meaning "death by music".

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