Callback function troubles
- From: Brent Briggs <briggsjb cs unca edu>
- To: "gtk-app-devel-list redhat com" <gtk-app-devel-list redhat com>, "gtk-list redhat com" <gtk-list redhat com>
- Subject: Callback function troubles
- Date: Fri, 25 Sep 1998 16:33:22 -0400
I have been working on a robotics program and have never been able to
get my widgets to call my functions the way that I want them to.
I have a callback function that looks like this:
void init_arm_callback(GtkWidget *widget, GdkEvent *event,
command_struct *data)
{
cout << "data in init_arm_callback :\n";
cout << "data->fdesrcipter " << data->fdescripter << "\n";
arm_initialize(data);
}
The structure command_struct look like this:
typedef struct {
int fdescripter;
int servo;
int increment;
char command;
int pos[5];
int init[5];
int min[5];
int max[5];
} command_struct;
I am calling this callback with a button like so:
/*setup the initialize button */
button = gtk_button_new_with_label ("Re-Initialize");
gtk_container_add (GTK_CONTAINER (control_vbox), button);
gtk_widget_show (button);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (init_arm_callback),
&command_data);
The values in the structure seem to get changed when the data is passed
fron gtk_signal_connect (......) to init_arm_callback(........). For
instance, command_data.fdescripter has a value of 3 when checked from
main but when the same value is checked from
init_arm_callback(........) I get a value of something like 607312 . Why
is this happening? This doesn't make sense to me but then again I am a
newbie to GTK developement. Can someone Please help me out?
Thanks,
Brent Briggs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]