You also get moving density waves in galaxies as well, something I forgot to mention.
These also do the same thing as material passing in and out of standing waves....gets compressed and forms spiral arms.
The spiral arms are actually all those OB associations and HII regions, along with the other dust and gas. They are just areas of over density...roughly 10-20% higher than the surrounding space. They travel a lot slower than the general rotation of the galaxy's contents and that's why the arms appear as they do.
Gravity does play a roll....it does all the jostling about of the stars and gas, starts the formation of the stars by collapsing the gas and dust clouds etc.
http://burro.cwru.edu/Academics/Astr...al/spiral.html
http://nedwww.ipac.caltech.edu/level.../carlberg.html