Re: Signal Handlers embedded in C++ classes?




> I am trying to embed a Signal handler (void CloseTheApp(GtkWidget* w, gpointe
> r
> data) specifically) inside a class (a view class that is handling all output
> for my application) but it doesn't seem to work.  

This is the wrong list, gtk-list would be better.

> I'm doing the development
> in MSVC++ 6.0 using the port of GTK+ to windows, so I won't bother you with
> the exact error message, though it seems to have something to do with the fun
> ction
> name not being in scope.  The error comes at the gtk_signal_connect line.  If
> I define CloseTheApp outside of the class it works just fine.  Anyway of maki
> ng
> it a member function?  Thanks.

No because a function pointer in not equal to a member pointer.
You have 3 choices.

  - make the CloseTheApp a static member function.  most C++ handle
    a static member as a C function.  Disadvantage, you can't access
    "this" so it is as good as being out.

  - make proxies of all your functions.  That is a function which
    takes the callback, interprets the data as a C++ type and called
    the C++ function.

  - use the tool designed for the job, gtk--.  They have gone to great 
    lengths to make something usable from C++ transparently.  Thus
    passing a C++ method works just fine.  Several users report sucess
    running 1.2.0 under Win environment, ask on the gtkmm mailing list
    if you are interested in finding more info.  
    (see gtkmm.sourceforge.net)

Hope it helps.  (Isn't this a FAQ?)

--Karl





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