Parameter passing and gpointers...
- From: Chris Elston <celston corky sapien net>
- To: <gtk-app-devel-list gnome org>
- Subject: Parameter passing and gpointers...
- Date: Tue, 13 Nov 2001 13:25:56 -0500 (EST)
Ok, some of you may recall that a few months ago I sent a question talking
about sending multiple params to a signal handler. One suggestion was
thru using a struct and passing a reference to that struct. This is
giving me some problems and I'm not sure why. I only have so much
experience in C so that may be what's wrong. Here's an example of what
I'm trying to do:
struct MyStruct {
GtkWidget *entry1;
GtkWidget *entry2;
}
void create_dialog( void ) {
struct MyStruct *my_struct;
.....
my_struct->entry1 = gtk_entry_new();
my_struct->entry2 = gtk_entry_new();
.....
gtk_signal_connect(
GTK_OBJECT(some_button), "clicked",
GTK_SIGNAL_FUNC(my_callback),
(gpointer) my_struct
);
.....
}
void my_callback( GtkWidget *w, gpointer data ) {
struct MyStruct *local_struct = (struct MyStruct *) data;
char* some_text = gtk_entry_get_text(
GTK_ENTRY(local_struct->entry1)
);
.....
}
I'm getting all sorts of compile errors trying the above. I've also tried
to use different pointer syntax but to no avail. What am I doing wrong?
What do you usually do in this situation? Are malloc and free necessary
for what I'm doing?
--
Chris Elston
celston corky sapien net
---------------------------------
Nucleus Communications
Web Script Programmer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]