Many fixes from gnome-common that are useful for MATE

This has been tested on mate-file-manager and I have not run into any issues building and make distcheck is also happy. 

I put in bug urls and commit urls so it is easy to trace the changes back to gnome-common.