Re: Signals & Callbacks - Help!!



Le mercredi 06 juillet 2005 �0:47 +0000, jalkadir gosonic ca a �it :
> I am trying to hook the 'clicked' signal of a button to a callaback
> function that receives a std::string value that will be displayed in a
> Dialogbox. I have tried this:
> 
> callback function
> ~~~~~~~~~~~~~~~~~
> gboolean MessageInfo(std::string& msg){...}
> 
> 
> g_signal_connect(GTK_OBJECT(btnCreateAccount), "clicked",
>                       GTK_SIGNAL_FUNC(MessageInfo), NULL);
> 
> But this does not work, can anyone help?

In the gtk docs, you can find:
"clicked"   void        user_function      (GtkButton *button,
                                            gpointer user_data);
That is, the first parameter of your callback is the button which was clicked, unless you use g_signal_connect_swapped.
SQo you have two solutions, either, you change the signayure of MessageInfo:
gboolean MessageInfo(GtkButoon* btn, std::string& msg){...}
or you use g_signal_connect_swapped:
g_signal_connect_swapped(GTK_OBJECT(btnCreateAccount), "clicked",
                      GTK_SIGNAL_FUNC(MessageInfo), NULL);




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