#!/usr/bin/python

import pyatspi

def listener(e):
    try:
        appName = e.host_application.name
        stateSet = e.source.getState()
    except:
        return

    if appName != 'nautilus':
        return

    stateList = map(str, stateSet.getStates())
    print '%s\n     %s' % (e.source, '\n     '.join(stateList))

pyatspi.Registry.registerEventListener(listener, 'object:state-changed:selected')
pyatspi.Registry.start()

