Re: gtk_toolbar_X_item. How can it callback?



Hi,

Douglas Ian Linder <linderdi cs curtin edu au> writes:

> Strange thing I've found: 
> 
> gtk_toolbar_append_item, 
> gtk_toolbar_prepend_item,
> gtk_toolbar_insert_item
> 
> All three are prototyped using the argument set:
> 
> (GtkToolbar *toolbar,
>  const char *text,
>  const char *tooltip_text,
>  const char *tooltip_private_text,
>  GtkWidget *icon,
>  GtkSignalFunc callback,
>  gpointer user_data);
> 
> However, the data type GtkSignalFunc is defined by:
> 
> void        (*GtkSignalFunc)                (void);


All signal callbacks are always passed to g_signal_connect as
GCallback (or GtkSignalFunc as it used to be called). This is just a
convenience. You have to take care of choosing a function with the
correct signature defined in the signal definition (and listed in the
API docs).

> So..........in theory, the user_data part of the argument can't
> get to the call back. However, although compiling it and passing
> a GtkCallback issues warnings through the compiler (like: "warning: 
> passing arg 6 of `gtk_toolbar_append_item' from incompatible pointer 
> type") it seems to work fine (ie. The call back is called with
> the user_data passed to the func_data element of the call back).

You are doing everything correct here despite a missing G_CALLBACK()
around your function pointer in order to avoid the warnings.


Sven



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