Fix build with GTK < 2.24

Part of #1047.
Fix build with GLib < 2.32

Second part of #1047.