Re: Passing values to functions



Hi,

Shiraz Baig <shiraz_baig yahoo com> writes:

> I am a newbie. Can anyone tell me, in the following
> elementary program, why doesn't the function "hello"
> that it has not been passed any data. Because in
> gtk-signal-connect, we are passing NULL data.
> Wherefrom is this data coming. In another case, I have
> seen drawing_area being passed like this. How does it
> get to the function "hello".

what was the question again? The code you posted looks
OK and I can't see what your question is. data as passed
to the function hello should indeed be NULL.

If you have seen a drawing_area pointer in a signal 
callback where you expected your user_data you most
probably connected a callback with a wrong signature.
Not all signals are declared as the clicked signal
of a GtkButton:

  void (* clicked)  (GtkButton *button);

which expects a callback of the form

  void callback (GtkButton *button, 
                 gpointer   data);

The signal "expose_event" of a GtkWidget for 
example is defined as 

  gint (* expose_event) (GtkWidget       *widget,
                         GdkEventExpose  *event);

so you need to use a callback of the form

  gint callback (GtkWidget       *widget,
                 GdkEventExpose  *event,
                 gpointer         data);

Or you'd get the event pointer instead of the expected
user_data.


Salut, Sven



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