Re: Callbacks and Signals works with Classes?



"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]