Add an API to map a GType name to a get_type function
@jdahlin
Submitted by Johan Dahlin Link to original bug (#445510)
Description
It would be good to have an API in glib which would try to guess the name of the get_type function using the naming rules convention used in GTK+ and other libraries.
I'll attach an implementation which given a type name resolves it to a _get_type function and calls it. It handles the following cases:
- GtkWindow -> gtk_window_get_type
- GtkFileChooserButton -> gtk_file_chooser_button_get_type
- GtkHBox -> gtk_hbox_get_type
- GtkUIManager -> gtk_ui_manager_get_type
Owen mentioned the following grammar on gtk-devel:
FUNCNAME := INITIAL_WORD "_" WORD+ "_get_type" INITIAL_WORD := [A-Z][a-z0-9]* WORD := [A-Z]{1,2}[a-z0-9]+ | [A_Z]{2,}
Which I think my implementation covers, apart from also allowing all characters allowed in a GTypeName.
There's no obvious place for this in glib, since gmodule doesn't link to gobject and gobject doesn't link to gmodule. Perhaps that could change?
Version: 2.12.x