Re: Signals & Callbacks - Help!!

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

 



Le mercredi 06 juillet 2005 à 23:32 +0200, David Necas (Yeti) a écrit :
> On Wed, Jul 06, 2005 at 10:58:59PM +0200, Jean Bréfort 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

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux