I want to create a menu with a group of radio menu items with the help of gtk_action_group_add_radio_actions as shown in the GnomeUIInfo migration guide.
It took long to find out that the callback function takes three arguments instead of two. Up to now I only saw that a gcallback function uses two arguments. But here the user data is received as the third argument:
I realized this in the testmerge.c example in the gtk sources. There was no other hint, also not in the documentation.
To this I have two questions:
How could I have find out that the callback function has three instead of two arguments when I want to use the user data? Is there a way to find this out?
I actually expected the user data to be passed on the second argument position. In this case it should have been of type “GVIEWER_WINDOW”. I realized that this was not the case by checking the type with IS_GVIEWER_WINDOW (user_data). But how could I have find out that the seconde argument is of type GTK_RADIO_ACTION? Is there a method to get the name of a pointer type? If yes, how is that done?
The first and last parameter are always the instance that emits the signal and the user_data pointer that was specified when connecting the handler(*), but as you learned signals can have additional parameters.
(*) usually in that order unless the G_CONNECT_SWAPPED flag was used, in which case they switch places
There is no method for getting the name of an arbitrary pointer type, but you can find out the types of the additional signal parameters:
GSignalQuery query;
guint i;
g_type_class_ref (GTK_TYPE_RADIO_ACTION);
g_signal_query (g_signal_lookup ("changed", GTK_TYPE_RADIO_ACTION), &query);
g_print ("[0]: %s\n", g_type_name (query.itype));
for (i = 0; i < query.n_params; i++)
g_print ("[%d]: %s\n", i + 1, g_type_name (query.param_types[i]));
g_print ("[%d]: gpointer\n", i + 1);
But then consulting the documentation is generally faster, and hopefully also tell you what those parameters mean
That is really interesting. It may be useful for language bindings creation, its a way to find out signal parameter types without direct gobject-introspection use.