#include <gtk/gtk.h>
#include <string.h>

static void
inspect(GType type)
{
    GParamSpec **props;
    gpointer klass;
    guint i, nprops;

    if (G_TYPE_IS_INTERFACE(type)) {
        klass = g_type_default_interface_ref(type);
        props = g_object_interface_list_properties(klass, &nprops);
    }
    else if (G_TYPE_IS_INSTANTIATABLE(type)) {
        klass = g_type_class_ref(type);
        props = g_object_class_list_properties(klass, &nprops);
    }
    else
        g_assert_not_reached();

    g_printerr("Inspecting %s\n", g_type_name(type));
    g_printerr("%d properties:", nprops);
    for (i = 0; i < nprops; i++)
        g_printerr(" %s", props[i]->name);
    g_printerr("\n");
    g_free(props);
}

int
main(int argc, char *argv[])
{
    if (glib_major_version == 2 && glib_minor_version < 3) {
        g_printerr("Too old GLib.\n");
        return 1;
    }

    g_type_init();
    if (argc == 2 && !strcmp(argv[1], "invert")) {
        inspect(GTK_TYPE_IM_CONTEXT);
        inspect(GTK_TYPE_TREE_MODEL);
    }
    else {
        inspect(GTK_TYPE_TREE_MODEL);
        inspect(GTK_TYPE_IM_CONTEXT);
    }

    return 0;
}
