Attachment 'firefox.py'
Download 1 #!/usr/bin/env python
2
3 from simple_at import *
4 from pyatspi import StateSet
5
6 # Ariel Rios
7 # ariel@gnu.org
8 # September 29, 2007
9
10 def run(acc):
11 print "[start]"
12
13 col = acc.queryInterface('IDL:Accessibility/Collection:1.0')
14
15 if col is None:
16 raise NotImplementedError('%s does not implement collection' % acc.name)
17
18 print "[Firefox test]"
19
20 states = StateSet()
21
22 rule = col.createMatchRule(states.raw(), col.MATCH_ANY,
23 "", col.MATCH_ALL,
24 [Accessibility.ROLE_FRAME], col.MATCH_ANY,
25 "IDL:Accessibility/Document:1.0", col.MATCH_ALL,
26 False)
27 ls = col.getMatches (rule, col.SORT_ORDER_CANONICAL, 0)
28
29 frame = ls[0]
30 fcol = frame.queryInterface ('IDL:Accessibility/Collection:1.0')
31
32 frule = fcol.createMatchRule(states.raw(), col.MATCH_ANY,
33 "", col.MATCH_ALL,
34 "", col.MATCH_ALL,
35 "IDL:Accessibility/Collection:1.0", col.MATCH_ALL,
36 False)
37 fls = fcol.getMatches (frule, fcol.SORT_ORDER_CANONICAL, 0)
38
39 print "[Opened documents]"
40
41 for n in fls:
42 print "\t", n.name
43 if n.getState().contains (Accessibility.STATE_VISIBLE):
44 frame = n
45
46 print "[Visible document]"
47
48 print "\t", frame.name
49
50
51 doc = frame
52 hcol = doc.queryInterface ('IDL:Accessibility/Collection:1.0')
53
54 hrule = hcol.createMatchRule (states.raw(), col.MATCH_ALL,
55 ["tag:H2"], col.MATCH_ANY,
56 "", col.MATCH_ALL,
57 "IDL:Accessibility/Hyperlink:1.0", col.MATCH_ALL,
58 False)
59
60 hls = hcol.getMatches (hrule, hcol.SORT_ORDER_CANONICAL, 0)
61
62 print "[Headers]"
63
64 for header in hls:
65 print "\t", header.queryInterface("IDL:Accessibility/EditableText:1.0").getText(0, -1)
66
67 dcol = doc.queryInterface ('IDL:Accessibility/Collection:1.0')
68
69 drule = dcol.createMatchRule (states.raw(), col.MATCH_ANY,
70 "", col.MATCH_ALL,
71 "", col.MATCH_ALL,
72 "IDL:Accessibility/Hyperlink:1.0;IDL:Accessibility/Action:1.0", col.MATCH_ALL,
73 False)
74
75 dls = dcol.getMatches (drule,dcol.SORT_ORDER_CANONICAL, 0)
76
77 print "[Hyperlinks]"
78
79 for n in dls:
80 print "\t", n.name#, n.accessible.getAttributes()
81
82 #col.freeMatchRule(rule)
83 #dcol.freeMatchRule(hrule)
84 #dcol.freeMatchRule(drule)
85 return 1
86
87 if __name__ == '__main__':
88 d = registry.getDesktop(0)
89 for i in xrange(d.childCount):
90 try:
91 c = d.getChildAtIndex(i)
92 except:
93 continue
94 if c is not None and c.name == 'Gran Paradiso':
95 run(c)
96
97 print "[fin]"
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.