Passing Data to Callbacks
- From: Adam Tee <eenajt electeng leeds ac uk>
- To: "gtk-app-devel" <gtk-app-devel-list gnome org>
- Subject: Passing Data to Callbacks
- Date: Fri, 1 Feb 2002 08:59:24 +0000
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]