Re: Callbacks and Signals works with Classes?
- From: Tero Pulkkinen <terop fanta modeemi cs tut fi>
- To: "Andrés" Giraldo <andres_giraldo yahoo com>
- Cc: Gtk List <gtk-list gnome org>
- Subject: Re: Callbacks and Signals works with Classes?
- Date: 13 Jun 2001 23:45:30 +0300
"Andrés" Giraldo <andres_giraldo yahoo com> writes:
> Ok, thanks, but how I supposed to make request to the
> class members?
GtkObject has these methods called
gtk_object_set_data()
gtk_object_get_data()
which lets you store additional pointers to the widget. This is how
you can store a pointer of your C++ class to a widget and the connected
callbacks can use the c++ methods. Like this:
// init:
GtkWidget *widget = gtk_button_new("test");
gtk_object_set_data(GTK_OBJECT(widget), "mycppobject", this);
// callback:
static void callback(GtkWidget *w) {
MyCpp *obj = (MyCpp*)gtk_object_get_data(GTK_OBJECT(w), "mycppobject");
obj->DoIt();
}
--
-- Tero Pulkkinen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]