RE: gtk-list Digest, Vol 12, Issue 34

"Ansell, Larry" <Larry_Ansell maxtor com> wrote:
> When I connect to a signal
> gtk_signal_connect( GTK_OBJECT( button ), "focus-in-event",
>                               GTK_SIGNAL_FUNC( buttonHandler 
> ), argToPass );
> In my handler,
> void buttonHandler( GtkWidget *widget, gpointer *data ) { }

Other folks have already commented on:
-- use g_signal_connect instead of gtk_signal_connect
-- "clicked" may be a more appropriate event for a button
   than "focus-in-event"

My comment is on the handler itself.  The prototype for a
focus-in-event handler is:
   gboolean handler(GtkWidget *widget, GdkEventFocus *event,
                    gpointer user_data)
That is, the focus-in-event handler takes 3 arguments (not 2),
the "data" parameter is a gpointer not gpointer *, and returns
a boolean (not void).  You can't depend on the C compiler to
catch this signature mismatch.  GTK uses a generic callback
signature (void (*GCallback)(void)) and the G_CALLBACK macro
(or in your case GTK_SIGNAL_FUNC) casts the callback to match
GCallback.  You must verify that your handler matches the
required signature.

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