One side of change is related on making code easier to follow, due it started being quite messy because of all in-lined mode/view checks. Now there's a bit of code duplication, but it's much easier to see what's going on there. Another side of patch is related on re-arranging elements in header in a way that follows rule "depending elements are placed after elements they depends on". This might be a bit against mostly-used-based elements placement, but now it's much easier to figure out where to add new option. Also it fits better other blender's areas such as image editor header, i.e.