Re: Connecting to a signal given as a string
- From: "Søren Hauberg" <hauberg gmail com>
- To: "Murray Cumming" <murrayc murrayc com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: Connecting to a signal given as a string
- Date: Sun, 26 Oct 2008 11:28:58 +0100
2008/10/26 Murray Cumming <murrayc murrayc com>:
> On Sun, 2008-10-26 at 00:13 +0200, Milosz Derezynski wrote:
>> You can not do it with a nonstatic member function because the this
>> pointer is always implied with a static mem. fun. (which you most
>> likely know, just repeating it for all); there's no way to directly
>> connect C GSignals in a C++ object to a nonstatic member function.
>
> You should do it the same way that gtkmm does it:
> Your static callback function should call the C++ method on the C++
> instance that was passed in the user_data parameter.
I've tried the following:
g_signal_connect (G_OBJECT (html_widget), "load_finished",
G_CALLBACK (on_page_loaded), this);
in the constructor of the class that does the rendering. Then I have
the following function
static void on_page_loaded (WebView *web_view)
{
web_view->on_load_finished ();
}
that calls the member function of my choice. But this gives my a
segfault. Is there anything obviously wrong with this?
> Of course, it's far easier just to use a gtkmm-style wrapper, such as
> webkitmm:
> http://blogs.gnome.org/jjongsma/2008/06/27/webkitmm/
Yeah, I'd love to use this, but it has one downside: it's not packaged
by that many distributions (none?). So, in the future, I'm sure I'll
be using this, but for now I'd prefer just to use the C interface.
Thanks,
Søren
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]