Passing (gpointer)data to a signal



The new widget signal code I've developed is working very well, however, I need
a bit more help with creating a new signal within a widget.

When a new signal is created, a marshalling function must be used so that the
signal's parameters can be specified dynamically.  However, I would like to
know why the parameters have to be specified twice?  By this, I mean that they
need to be defined once in the name of the marshalling function, and once at
the end of the gtk_signal_new function.  Why is that?

Also, when I define a callback function as having, for example, two pointers
as parameters, is that the total number of parameters that the callback MUST
have?  The reason I ask this, is when I call "gtk_signal_emit" I pass along
some parameters to the callback function... but what about the (gpointer)data
that the user passes?  My widget can't possibly know that value, so how is it
passed?

Here's some example code:

/* In my main program, I connect a signal to a custom-made "GtkTrack" widget */
    gtk_signal_connect( GTK_OBJECT( trk_pulse[i] ),
			"selected",
			GTK_SIGNAL_FUNC( wnd_led_trk_pulse_selected ),
			(gpointer)i );

/* In my GtkTrack widget, I emit the "selected" signal: */
  gtk_signal_emit( GTK_OBJECT( track ), gtk_track_signals[ GTK_TRACK_SELECTED ],
track );

/* And here's the declaration of the callback function itself: */
void wnd_led_trk_pulse_selected( GtkWidget *widget, gpointer data );


So, to wrap the question up into a (hopefully) comprehensible summary:
How can I get the "(gpointer)i" data to get to my callback function in one
piece, knowing that my "gtk_signal_emit" call does not pass a second parameter
to the callback function?

Thanks for your help,
Duane Johnson



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