Callback function troubles

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";

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),

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?

Brent Briggs

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