Re: Using g_signal_connect in class



On Tue, Jul 15, 2008 at 12:09 PM, Marco Rocco <mr85mr gmail com> wrote:

Hello, this is my first post on this mailing list, now i do my request:
can i use g_signal_connect  in a method of my class, using as c_handler a
private function of class? ...and if i can, how i can do ?


If you use C++ and plain GTK, supposing you are initializing your callback
in the  you should do something like this:

class MyClass
{
  GtkWidget *mywidget_;
  static void handle_click_cbk(GtkWidget *mywidget_, MyClass *data) {
data->handle_click(); }

  void handle_click(); // your real callback
public:
  MyClass() {
     mywidget_ = gtk_button_new();
     g_signal_connect(mywidget_, "clicked", GCallback(handle_click_cbk),
this);
  }
};

-- 
Bye,
 Gabry



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