#include <gtk/gtk.h>

gboolean before_realize(GSignalInvocationHint* ihint, guint numParams, const GValue* params, gpointer* data)
{
    GtkWidget* widget = GTK_WIDGET( g_value_get_object(params) );
    if(!GTK_IS_WIDGET(widget)) return FALSE; // destroy hook since it seems to work wrongly
    return TRUE;
}

void hook_gtkwindow_realization()
{
    g_signal_add_emission_hook(g_signal_lookup("parent-set",GTK_TYPE_WINDOW),(GQuark)NULL,(GSignalEmissionHook)before_realize,NULL,NULL);
}

int main(int argc,char** argv)
{
    gtk_init(&argc,&argv);

    GtkWidget* toplevel=GTK_WIDGET(gtk_window_new(GTK_WINDOW_TOPLEVEL));
    g_signal_connect(G_OBJECT(toplevel),"destroy",G_CALLBACK(gtk_main_quit),NULL);

    GtkWidget* combo=gtk_combo_box_new();
    gtk_container_add(GTK_CONTAINER(toplevel),combo);

    // core functionality :)
    hook_gtkwindow_realization();

    gtk_widget_show_all(toplevel);
    gtk_main();

    return 0;
}
