blob: 7663af703e58173543a5f70a2be07166389e5187 [file] [log] [blame]
Jack Jansen1de2a921999-06-21 16:19:43 +00001import Drag
2import time
3xxxx=1
4def decode_hfs(data):
5 import struct, macfs
6 tp = data[0:4]
7 cr = data[4:8]
8 flags = struct.unpack("h", data[8:10])
9 fss = macfs.RawFSSpec(data[10:])
10 return tp, cr, flags, fss
11
12def tracker(msg, dragref, window):
13 pass
14
15def dropper(dragref, window):
16 global xxxx
17 n = dragref.CountDragItems()
18 print 'Drop %d items:'%n
19 for i in range(1, n+1):
20 refnum = dragref.GetDragItemReferenceNumber(i)
21 print '%d (ItemReference 0x%x)'%(i, refnum)
22 nf = dragref.CountDragItemFlavors(refnum)
23 print ' %d flavors:'%nf
24 for j in range(1, nf+1):
25 ftype = dragref.GetFlavorType(refnum, j)
26 fflags = dragref.GetFlavorFlags(refnum, ftype)
27 print ' "%4.4s" 0x%x'%(ftype, fflags)
28 if ftype == 'hfs ':
29 datasize = dragref.GetFlavorDataSize(refnum, ftype)
30 data = dragref.GetFlavorData(refnum, ftype, datasize, 0)
31 print ' datasize', `data`
32 xxxx = data
33 print ' ->', decode_hfs(data)
34
35
36def main():
37 print "Drag things onto output window. Press command-. to quit."
38 Drag.InstallTrackingHandler(tracker)
39 Drag.InstallReceiveHandler(dropper)
40 while 1:
41 time.sleep(100)
42
43main()