Re: Clist
- From: Brad House <brad mainstreetsoftworks com>
- To: gtk-list gnome org
- Subject: Re: Clist
- Date: Thu, 16 Aug 2001 20:34:21 -0400
Well, I finally figured out how to get a selection from a CLIST...but
VERY undocumented!!! Pulled this info directly out of the source...
It works fantasically...so for anyone else that may need this looking
through the archives, I post this.
int CList_get_selected(GtkCList *clist, int **listings)
{
GList *list;
int cnt=0;
if (clist==NULL) return(0);
list=clist->selection;
listings[0]=NULL;
while(list)
{
listings[0]=(int *)realloc(listings[0], (cnt+1)*sizeof(int));
listings[0][cnt]=GPOINTER_TO_INT(list->data);
list=list->next;
cnt++;
}
return(cnt);
}
anyhow, it returns the number of rows selected. Obviously
for a single CList it will return 1 assuming a row is selected.
you should call it like this:
int cnt, i, *listings=NULL;
GtkWidget *w; /* direct to widget of your clist */
cnt=CList_get_selected(GTK_CLIST(w), &listings);
for (i=0; i<cnt; i++) {
/* do something with listings[i] */
}
free(listings);
I really wish this function which I just defined existed
in GTK...it's a hell of a lot easier than grabbing
clicking events and storing what selection was clicked,
etc....
Oh well, apparently you shouldn't even use CLists in v2.0
hmm...
-Brad
Brad House wrote:
> Is there a way to obtain the selected value of a CList at a given time.
> Or must you use a callback and track when columns are selected yourself?
> If you can pull it directly...what function?
>
> Thanks.
>
> -----------------------------
> Brad House
> Sr. Developer
> Main Street Softworks, Inc.
>
> brad mainstreetsoftworks com
> (352) 378-8228
> -----------------------------
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]