Improve GTK compatibility macros for GTK 2.16

On GTK 2.16 GTK_WIDGET_[UN]SET_FLAGS resolves to a do-while construct which
raises a syntax error when embedded into a ? operator.
Also gtk_widget_get_visible() is only available since GTK 2.18, so add a fallback to
the old variant.

I'm not sure whether the change for compat_widget_set_flag() is the best solution, but it seems to work and fix compilation with GTK 2.16 at least.