Re: Newbie prob with functions...



Nicolas Raitman wrote:

[snip]

void showname (GtkWidget * nombre)

This function isn't prototyped correctly.  For a button "clicked" signal,
the prototype looks like this:

void showname (GtkButton *button, gpointer data)

When GTK+ calls this function, the button which received the click will be
assigned to *button and you can supply whatever data you want with the data
pointer.  Check http://developer.gnome.org/doc/API/gtk/index.html for the
correct signal function prototypes.

    gtk_signal_connect (GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC
(showname), nombre);

When you connect the signal here, "nombre" will get passed to the callback as
the "data" parameter.  You would then do something like

        gtk_label_set_text(GTK_LABEL(nombre), "Nicolas");

gpointer is basically a (void *), so the GTK_LABEL() macro will cast it to a
(GtkLabel *).  It also checks to make sure "nombre" really is a GtkLabel and
will print out warning messages if it isn't.


-Josh




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