gtkui: workaround for bug #1183, use gdk_threads_init/enter/leave in correct way