[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: widget array
- From: adlaib <adlaib lucent com>
- To: gtk-app-devel-list redhat com
- Subject: Re: widget array
- Date: Tue, 19 Oct 1999 11:37:03 -0500
oh yeah.
just cast the array
ie:
---------------------------------------------------------------------------------------
int i;
gpointer widgetPtr;
gpointer tempWidgetPtr;
widgetPtr = (gpointer)malloc(sizeof(widgetPtr)*NUM_WIDGETS);
//use tempWidgetPtr to traverse the array,
tempWidgetPtr = widgetPtr;
// i guess u can write a macro for the typecast
for (i=0; i<NUM_WIDGETS; i++) {
*((GtkWidget **)tempWidgetPtr) = gtk_CREATE_SOME_KIND_OF_WIDGET();
DO_SOME_WIDGET_PROCESSING(*((GtkWidget **)tempWidgetPtr));
tempWidgetPtr=+ sizeof(tempWidgetPtr);
}
//u don't need a cast here cause widgetPtr is already a gpointer.
gtk_signal_connect(GTK_OBJECT(THE_WIDGET_THAT_GENERATES_THE_SINGAL),
"THE_SIGNAL",
GTK_SIGNAL_FUNC(THE_SIGNAL_HANDLER), widgetPtr);
---------------------------------------------------------------------------------------
THE_SIGNAL_HANDLER() - should destroy all NUM_WIDGETS (depending on what u r
doing) and
free widgetPtr - if nobody else needs it or else youre gonna have some nasty
memory leaks.
what i do is define a stucture of several ptrs, malloc the stuct - and pass the
structPtr to the signal handler - that way i can do many arrays of widgets at
the
same time.
widgetArray[NUM_WIDGETS] willl NOT work... (unless u declare it static - yuck)
hope that helps...
ksteen@earthlink.net wrote:
>
> Is it possible to set up an array of gtk widgets and pass the array
> to a function with gtk_signal_connect()? I have a window that
> collects information from the user. I would like to pass all the
> widgets in an array to another function that reads and manipulates the
> information. Currently, I am using gtk_object_set_data () and then
> looking up each widget in the called function. That works fine but
> seems like sloppy code. I think that my problem is that a gpointer is a
> void pointer and I am not casting the pointer correctly to acces the
> array. Any help will be greatly appreciated.
>
> Thanks,
> Ken
>
> --
> To unsubscribe: mail gtk-app-devel-list-request@redhat.com with
> "unsubscribe" as the Subject.
>
> Mailing list concerns should be mailed to <listmaster@redhat.com>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]