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

Re: CLIST



Hello Phillip,

I'm new at this too.  I eventually figured this out.

sel is a GList linked list of the selections made in the Clist. I haven't used a clist as of yet, but I've done it with a standard GtkList.  The data in the linked list is the actual references to the GtkListItem widgets that are stored in the clist.  I prefered to write it this way.

GList *selList = NULL; /* its not just a selection but a list of selections */
GtkWidget *list = NULL;
GtkListItem *sel = NULL;

list = lookup_widget( GTK_WIDGET(ref), "name_of_clist" );
selList = GTK_LIST(list)->selection;

if (selList == NULL) return; /*no selection made*/

/*
now if you've enabled multiple selection mode in the clist, the selList will have multiple list items attached to it.  For the sake of an example, this list is single selection only.  Since a selection has been made there is only one list item.  GList delcaration and structure is in the glib api documentation.
*/

sel = selList->data;

/*
sel is now the selected GtkListItem widget

do what you want with the item
.
.
.


*/

/* delete the list item from the clist */
gtk_container_remove( GTK_CONTAINER(list), GTK_WIDGET(sel) );
gtk_widget_show_all( GTK_WIDGET(list) );


/* done */


I'm not sure if that's the correct way to remove the list item but it worked for me, everything else I tried resulted in a segfault.  The GList selection list is an internal list to the Gtk[C]List widget.  When I would free it I had problems so I don't think your supposed to :P

Hope that helps,


Keith



On Sun, Jul 08, 2001 at 05:02:40PM -0400, Phillip wrote:
> 
> Hello
> 
> im tryin to learn how to program GUI in general and i throught myself 
> into the gtk pool.
> i got a clist
> 
> list = lookup_widget (GTK_WIDGET (button), "lista_input");
> 
> im trying to make able when u select a row, then u could press the 
> delete button  to remove that row.
> 
> the FAQ says something about
> 
> sel = GTK_LIST(list)->selection;
> 
>  what is sel?
> im using
> printf("%d \n", list);
> but it doesnt seem to output a right thing...
> 
> 
> any advices about this?
> 
> thank you.
> 
> -- 
> 
> 
> ----------------
> Phillip Neumann
> filzin@bigfoot.com
> ----------------
> 
> 
> 
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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