Re: Signals & Callbacks - Help!! Part 2

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

 



I did as you suggested and this is the result of the modifications:
----snip-----
gboolean MessageInfo(GtkButton* btn, char* msg){...}

g_signal_connect(GTK_OBJECT(btnCreateAccount),"clicked", /*This line
causes the error*/
                    GTK_SIGNAL_FUNC(MessageInfo(btnCreateAccount,
strMsg.c_str()) ), NULL);
----eos----

But for some reason I get an error message that reads:
50: error: cannot convert `GtkWidget*' to `GtkButton*' for argument `1' to
`gboolean
=======

I am really lost here, can anybody give me a hand on this?

TIA


> 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
>
>
> --
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail?
>

_______________________________________________

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