Passing a class method (not function) using gtk_signal_connect()
- From: Chun Teck Soon <cwcsct yahoo co uk>
- To: gtk-list redhat com
- Subject: Passing a class method (not function) using gtk_signal_connect()
- Date: Sun, 25 Jul 1999 14:55:21 +0100 (BST)
Hi,
I'm writing in C++ with Gtk lib. My current problem now is that I'm
trying to send a class method as a callback function using
gtk_signal_connect. This is done inside a self created class
'Application' where the signal connecting action is performed in one of
the method and connecting to another method of the same class.
class Application
{
private:
int *tmp;
public:
connectSignal(...);
callback(...);
};
Application::connectSignal(...)
{
gtk_signal_connect(..., "event",
GTK_SIGNAL_FUNC(callback),NULL);
}
Application::callback(...)
{
*tmp = 10; ==>> problem occur here
}
The problem occurs when the callback function is called (when the event
take place), it has problem accessing the private attributes of
Application. It seems like the method is being called as a function
that do not belong to the class.
I'm able to find ways around this but not in a very OOP manner. Eg.
sending the object's pointer (of Application) over so that the callback
function can access whatever methods or variable of the class.
Eg:
Application::connectSignal(...)
{
gtk_signal_connect(..., "event",
GTK_SIGNAL_FUNC(callback), this);
}
Application::callback(...,Application * app)
{ app->tmp = 10;}
If anybody knows how can I connect a signal with a class or a class
'connected' method with any gtk function, pls let me know. Thanks!
_____________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]