Re: Fixed: GSignal connect with struct *pointer

On Sun, Aug 10, 2003 at 10:12:27PM +0200, Matthias Mann wrote:
On Saturday August 09 2003 13:57 CEST, Leandro A. F. Pereira
    Sure it's possible :)
Thanx to God ore something else. I got an idea and found two
important mistakes in my code. And also a bad discription
about g_signal_connect() in libglib API:
The G_CONNECT_SWAPPED flag is explained with "wether the
instance and data should be swapped when calling the handler".
This is very idiocy. I mean, nobody will get the idea to swap
the instance with the user datas.
I find out: without G_CONNECT_SWAPPED no data will be send to
the callback function. So the API of g_signal_connect() should
start with:
#define g_signal_connect(instance, detailed-signal,
                      c-handler, NULL);
_NO_ user data. To send user data to a callback function the
only way is to use g_signal_connect_swapped(). That's it! Or
did i oversee any thing?

  Yes you did!

The documentation of g_signal_connect is of course right.  But you've
forgotten to read the documentation of the "row-expanded" signal.

You can read that the prototype for all the callback connected to this
signal should be:
void user_function(GtkTreeView *treeview,
                   GtkTreeIter *arg1,
                   GtkTreePath *arg2,
                   gpointer     user_data);

or, if you use g_signal_connect_swapped (notice that user_data and
treeview are "swapped"):
void user_function(gpointer     user_data,
                   GtkTreeIter *arg1,
                   GtkTreePath *arg2,
                   GtkTreeView *treeview);

It isn't at all idiotic to swap the instance with the user data.  This
will let one to destroy a dialog when a button is pressed with this
g_signal_connect_swapped(G_OBJECT(button), "clicked",
                         G_CALLBACK(gtk_widget_destroy), dialog);



david dindinx org
main() {printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}

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