RE: Using g_signal_connect in class



Only if the member function is static.  Calling a non-static member
function requires two addresses: the instance address and the function
address.  Whether its public or private doesn't matter because access to
function pointers is not checked by compilers.  I frequently do
something like this:

class SomeClass
{
  ...
private:
  ...
  static void staticCb(..., gpointer inInstance) {
    SomeClass* instance = (SomeClass*)inInstance;
    instance->callback(...);
  }
  void callback(...) {
    ...
  }
  ...
  void someFunc() {
    ...
    g_signal_connect(..., G_CALLBACK(&staticCb), this);
    ...
  }
  ...
};


-Anthony Vallone


-----Original Message-----
From: gtk-list-bounces gnome org [mailto:gtk-list-bounces gnome org] On
Behalf Of Marco Rocco
Sent: Tuesday, July 15, 2008 6:04 AM
To: gtk-list gnome org
Subject: Using g_signal_connect in class

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 ?

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list


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