Re: Signals & Callbacks - Help!!
- From: Jean Bréfort <jean brefort normalesup org>
- To: "David Necas (Yeti)" <yeti physics muni cz>
- Cc: gtk-list gnome org
- Subject: Re: Signals & Callbacks - Help!!
- Date: Thu, 07 Jul 2005 07:28:35 +0200
Le mercredi 06 juillet 2005 �3:32 +0200, David Necas (Yeti) a �it :
> On Wed, Jul 06, 2005 at 10:58:59PM +0200, Jean Br�rt wrote:
> > 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);
>
> Note however, GObject callbacks don't mix very logically
> with C++ pass-by-reference argument style.
>
> You can't pass a std::string variable as the last argument of
> g_signal_connect() as you would in direct function call, you
> have to pass a pointer, and once you do that, it doesn't
> make sense to declare
>
> MessageInfo(std::string &msg)
>
> instead of
>
> MessageInfo(std::string *msg)
>
> Yeti
Yes, I missed that yesterday evening :(
You must also pass this pointer to the g_signal_connect or
g_signal_connect_swapped call as the last argument. If you use NULL,
your callback will be called with a NULL argument.
Jean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]