Use G_DEFINE_TYPE and friends to define GTypes

This makes the _get_type() functions threadsafe.