Passing Data to Callbacks



Hi,

When I pass some data to a callback and try and access it in the callback 
function it is corrupted.  Should the data that is being passed to the 
callback be cast using gpointer??  I've tried this and it still doesn't work.
In the function where the menu items are added the data 'struct scoreinfo *si'
is correct. 

Here is the connect object function that I'm using and the callback function.

gtk_signal_connect(GTK_OBJECT(menu_item3), "activate",
                            GTK_SIGNAL_FUNC(unhighlight),
                            (struct scoreinfo *)si);
/* callback */
void
unhighlight (gpointer callback_data,GtkWidget * widget)
{
  staffnode *curstaff;
  staff *curstaffstruct;
  measurenode *curmeasure;
  objnode *curobj;
  mudelaobject *mudelaitem;
  /*struct callbackdata *cbdata = (struct callbackdata *)callback_data;*/
  struct scoreinfo *si = (struct scoreinfo *)callback_data;

  for (curstaff = si->thescore; curstaff; curstaff = curstaff->next)
    {
       for (curmeasure = (measurenode *) curstaffstruct->measures;
            curmeasure; curmeasure = curmeasure->next)
       {

          for (curobj = (objnode *)curmeasure->data; curobj; 
                curobj = curobj->next)
            {
            mudelaitem = (mudelaobject *)curobj->data;
                ((chord *)mudelaitem->object)->is_highlighted = FALSE;
            }
       }
    }
}




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