#!/usr/bin/python

import pyatspi

def getLineForCell(cell):
    try:
        text = cell.queryText()
    except:
        return

    string = text.getTextAtOffset(0, pyatspi.TEXT_BOUNDARY_LINE_START)[0]
    if cell.name and string == cell.name:
        return

    print("name: %s\ntext: %s\n" % (cell.name, string))

def listener(event):
    isCell = lambda x: x and x.getRole() == pyatspi.ROLE_TABLE_CELL 
    map(getLineForCell, pyatspi.findAllDescendants(event.source, isCell))
    
pyatspi.Registry.registerEventListener(listener, "window:activate")
pyatspi.Registry.start()
