Add average, count in tree functions

For now the only option in tree views is "sum" which is cool, but
we need more functions like average and count. This is compatible
backwards with other gtk clients.