RE: Using g_signal_connect in class

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

 



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@xxxxxxxxx [mailto:gtk-list-bounces@xxxxxxxxx] On
Behalf Of Marco Rocco
Sent: Tuesday, July 15, 2008 6:04 AM
To: gtk-list@xxxxxxxxx
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@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux