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.
Make the compat_widget_set_flag macro more robust
Merge "Improve GTK compatibility macros for GTK 2.16" from eht16/master