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. Before I go ahead and test this on more packages I like to get some feedback.

I put in bug urls and commit urls so it is easy to trace the changes back to gnome-common.

There are also changes in compiler-flags which I intentionally left out. If wanted I will send a new PULL with these changes included.

Opinions, objects or ...?

PS: Do notice that this is for branch 1.6, I will send it for MASTER as soon as we had some discussion/testing.