summaryrefslogtreecommitdiffstats
path: root/Lib/plat-mac
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/plat-mac')
-rw-r--r--Lib/plat-mac/Carbon/WASTEconst.py207
-rw-r--r--Lib/plat-mac/EasyDialogs.py4
-rw-r--r--Lib/plat-mac/WASTEconst.py207
-rw-r--r--Lib/plat-mac/argvemulator.py90
4 files changed, 35 insertions, 473 deletions
diff --git a/Lib/plat-mac/Carbon/WASTEconst.py b/Lib/plat-mac/Carbon/WASTEconst.py
deleted file mode 100644
index dc73905..0000000
--- a/Lib/plat-mac/Carbon/WASTEconst.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# Generated from 'WASTE.h'
-
-kPascalStackBased = None # workaround for header parsing
-def FOUR_CHAR_CODE(x): return x
-weCantUndoErr = -10015
-weEmptySelectionErr = -10013
-weUnknownObjectTypeErr = -9478
-weObjectNotFoundErr = -9477
-weReadOnlyErr = -9476
-weTextNotFoundErr = -9474
-weInvalidTextEncodingErr = -9473
-weDuplicateAttributeErr = -9472
-weInvalidAttributeSizeErr = -9471
-weReadOnlyAttributeErr = -9470
-weOddByteCountErr = -9469
-weHandlerNotFoundErr = -1717
-weNotHandledErr = -1708
-weNewerVersionErr = -1706
-weCorruptDataErr = -1702
-weProtocolErr = -603
-weUndefinedSelectorErr = -50
-weFlushLeft = -2
-weFlushRight = -1
-weFlushDefault = 0
-weCenter = 1
-weJustify = 2
-weDirDefault = 1
-weDirRightToLeft = -1
-weDirLeftToRight = 0
-weDoFont = 0x0001
-weDoFace = 0x0002
-weDoSize = 0x0004
-weDoColor = 0x0008
-weDoAll = weDoFont | weDoFace | weDoSize | weDoColor
-weDoAddSize = 0x0010
-weDoToggleFace = 0x0020
-weDoReplaceFace = 0x0040
-weDoPreserveScript = 0x0080
-weDoExtractSubscript = 0x0100
-weDoFaceMask = 0x0200
-weDoDirection = 0x00000001
-weDoAlignment = 0x00000002
-weDoLeftIndent = 0x00000004
-weDoRightIndent = 0x00000008
-weDoFirstLineIndent = 0x00000010
-weDoLineSpacing = 0x00000020
-weDoSpaceBefore = 0x00000040
-weDoSpaceAfter = 0x00000080
-weDoBottomBorderStyle = 0x00000400
-kLeadingEdge = -1
-kTrailingEdge = 0
-kObjectEdge = 2
-weFAutoScroll = 0
-weFOutlineHilite = 2
-weFReadOnly = 5
-weFUndo = 6
-weFIntCutAndPaste = 7
-weFDragAndDrop = 8
-weFInhibitRecal = 9
-weFUseTempMem = 10
-weFDrawOffscreen = 11
-weFInhibitRedraw = 12
-weFMonoStyled = 13
-weFMultipleUndo = 14
-weFNoKeyboardSync = 29
-weFInhibitICSupport = 30
-weFInhibitColor = 31
-# weDoAutoScroll = 1UL << weFAutoScroll
-# weDoOutlineHilite = 1UL << weFOutlineHilite
-# weDoReadOnly = 1UL << weFReadOnly
-# weDoUndo = 1UL << weFUndo
-# weDoIntCutAndPaste = 1UL << weFIntCutAndPaste
-# weDoDragAndDrop = 1UL << weFDragAndDrop
-# weDoInhibitRecal = 1UL << weFInhibitRecal
-# weDoUseTempMem = 1UL << weFUseTempMem
-# weDoDrawOffscreen = 1UL << weFDrawOffscreen
-# weDoInhibitRedraw = 1UL << weFInhibitRedraw
-# weDoMonoStyled = 1UL << weFMonoStyled
-# weDoMultipleUndo = 1UL << weFMultipleUndo
-# weDoNoKeyboardSync = 1UL << weFNoKeyboardSync
-# weDoInhibitICSupport = 1UL << weFInhibitICSupport
-# weDoInhibitColor = 1UL << weFInhibitColor
-weBitToggle = -2
-weBitTest = -1
-weBitClear = 0
-weBitSet = 1
-weLowerCase = 0
-weUpperCase = 1
-weFindWholeWords = 0x00000001
-weFindCaseInsensitive = 0x00000002
-weFindDiacriticalInsensitive = 0x00000004
-wePutIntCutAndPaste = 0x00000001
-wePutAddToTypingSequence = 0x00000002
-wePutDetectUnicodeBOM = 0x00000200
-weStreamDestinationKindMask = 0x000000FF
-weStreamIncludeObjects = 0x00000100
-weGetAddUnicodeBOM = 0x00000200
-weGetLittleEndian = 0x00000400
-weTagFontFamily = FOUR_CHAR_CODE('font')
-weTagFontSize = FOUR_CHAR_CODE('ptsz')
-weTagPlain = FOUR_CHAR_CODE('plan')
-weTagBold = FOUR_CHAR_CODE('bold')
-weTagItalic = FOUR_CHAR_CODE('ital')
-weTagUnderline = FOUR_CHAR_CODE('undl')
-weTagOutline = FOUR_CHAR_CODE('outl')
-weTagShadow = FOUR_CHAR_CODE('shad')
-weTagCondensed = FOUR_CHAR_CODE('cond')
-weTagExtended = FOUR_CHAR_CODE('pexp')
-weTagStrikethrough = FOUR_CHAR_CODE('strk')
-weTagTextColor = FOUR_CHAR_CODE('colr')
-weTagBackgroundColor = FOUR_CHAR_CODE('pbcl')
-weTagTransferMode = FOUR_CHAR_CODE('pptm')
-weTagVerticalShift = FOUR_CHAR_CODE('xshf')
-weTagAlignment = FOUR_CHAR_CODE('pjst')
-weTagDirection = FOUR_CHAR_CODE('LDIR')
-weTagLineSpacing = FOUR_CHAR_CODE('ledg')
-weTagLeftIndent = FOUR_CHAR_CODE('lein')
-weTagRightIndent = FOUR_CHAR_CODE('riin')
-weTagFirstLineIndent = FOUR_CHAR_CODE('fidt')
-weTagSpaceBefore = FOUR_CHAR_CODE('spbe')
-weTagSpaceAfter = FOUR_CHAR_CODE('spaf')
-weTagBottomBorderStyle = FOUR_CHAR_CODE('BBRD')
-weTagForceFontFamily = FOUR_CHAR_CODE('ffnt')
-weTagAddFontSize = FOUR_CHAR_CODE('+siz')
-weTagAddVerticalShift = FOUR_CHAR_CODE('+shf')
-weTagTextEncoding = FOUR_CHAR_CODE('ptxe')
-weTagQDStyles = FOUR_CHAR_CODE('qdst')
-weTagTETextStyle = FOUR_CHAR_CODE('tets')
-weTagAlignmentDefault = FOUR_CHAR_CODE('deft')
-weTagAlignmentLeft = FOUR_CHAR_CODE('left')
-weTagAlignmentCenter = FOUR_CHAR_CODE('cent')
-weTagAlignmentRight = FOUR_CHAR_CODE('rght')
-weTagAlignmentFull = FOUR_CHAR_CODE('full')
-weTagDirectionDefault = FOUR_CHAR_CODE('deft')
-weTagDirectionLeftToRight = FOUR_CHAR_CODE('L->R')
-weTagDirectionRightToLeft = FOUR_CHAR_CODE('R->L')
-weTagBorderStyleNone = FOUR_CHAR_CODE('NONE')
-weTagBorderStyleThin = FOUR_CHAR_CODE('SLDL')
-weTagBorderStyleDotted = FOUR_CHAR_CODE('DTDL')
-weTagBorderStyleThick = FOUR_CHAR_CODE('THKL')
-weLineSpacingSingle = 0x00000000
-weLineSpacingOneAndHalf = 0x00008000
-weLineSpacingDouble = 0x00010000
-weCharByteHook = FOUR_CHAR_CODE('cbyt')
-weCharToPixelHook = FOUR_CHAR_CODE('c2p ')
-weCharTypeHook = FOUR_CHAR_CODE('ctyp')
-weClickLoop = FOUR_CHAR_CODE('clik')
-weCurrentDrag = FOUR_CHAR_CODE('drag')
-weDrawTextHook = FOUR_CHAR_CODE('draw')
-weDrawTSMHiliteHook = FOUR_CHAR_CODE('dtsm')
-weEraseHook = FOUR_CHAR_CODE('eras')
-weFontFamilyToNameHook = FOUR_CHAR_CODE('ff2n')
-weFontNameToFamilyHook = FOUR_CHAR_CODE('fn2f')
-weFluxProc = FOUR_CHAR_CODE('flux')
-weHiliteDropAreaHook = FOUR_CHAR_CODE('hidr')
-weLineBreakHook = FOUR_CHAR_CODE('lbrk')
-wePixelToCharHook = FOUR_CHAR_CODE('p2c ')
-wePort = FOUR_CHAR_CODE('port')
-wePreTrackDragHook = FOUR_CHAR_CODE('ptrk')
-weRefCon = FOUR_CHAR_CODE('refc')
-weScrollProc = FOUR_CHAR_CODE('scrl')
-weText = FOUR_CHAR_CODE('text')
-weTranslateDragHook = FOUR_CHAR_CODE('xdrg')
-weTranslucencyThreshold = FOUR_CHAR_CODE('tluc')
-weTSMDocumentID = FOUR_CHAR_CODE('tsmd')
-weTSMPreUpdate = FOUR_CHAR_CODE('pre ')
-weTSMPostUpdate = FOUR_CHAR_CODE('post')
-weURLHint = FOUR_CHAR_CODE('urlh')
-weWordBreakHook = FOUR_CHAR_CODE('wbrk')
-weNewHandler = FOUR_CHAR_CODE('new ')
-weDisposeHandler = FOUR_CHAR_CODE('free')
-weDrawHandler = FOUR_CHAR_CODE('draw')
-weClickHandler = FOUR_CHAR_CODE('clik')
-weStreamHandler = FOUR_CHAR_CODE('strm')
-weHoverHandler = FOUR_CHAR_CODE('hovr')
-kTypeText = FOUR_CHAR_CODE('TEXT')
-kTypeStyles = FOUR_CHAR_CODE('styl')
-kTypeSoup = FOUR_CHAR_CODE('SOUP')
-kTypeFontTable = FOUR_CHAR_CODE('FISH')
-kTypeParaFormat = FOUR_CHAR_CODE('WEpf')
-kTypeRulerScrap = FOUR_CHAR_CODE('WEru')
-kTypeCharFormat = FOUR_CHAR_CODE('WEcf')
-kTypeStyleScrap = FOUR_CHAR_CODE('WEst')
-kTypeUnicodeText = FOUR_CHAR_CODE('utxt')
-kTypeUTF8Text = FOUR_CHAR_CODE('UTF8')
-kTypeStyledText = FOUR_CHAR_CODE('STXT')
-weAKNone = 0
-weAKUnspecified = 1
-weAKTyping = 2
-weAKCut = 3
-weAKPaste = 4
-weAKClear = 5
-weAKDrag = 6
-weAKSetStyle = 7
-weAKSetRuler = 8
-weAKBackspace = 9
-weAKFwdDelete = 10
-weAKCaseChange = 11
-weAKObjectChange = 12
-weToScrap = 0
-weToDrag = 1
-weToSoup = 2
-weMouseEnter = 0
-weMouseWithin = 1
-weMouseLeave = 2
-kCurrentSelection = -1
-kNullStyle = -2
diff --git a/Lib/plat-mac/EasyDialogs.py b/Lib/plat-mac/EasyDialogs.py
index c622d30..b33d1be 100644
--- a/Lib/plat-mac/EasyDialogs.py
+++ b/Lib/plat-mac/EasyDialogs.py
@@ -262,7 +262,7 @@ class ProgressBar:
self.w.ShowWindow()
self.d.DrawDialog()
- def __del__( self ):
+ def __del__(self):
if self.w:
self.w.BringToFront()
self.w.HideWindow()
@@ -274,7 +274,7 @@ class ProgressBar:
self.w.BringToFront()
self.w.SetWTitle(newstr)
- def label( self, *newstr ):
+ def label(self, *newstr):
"""label(text) - Set text in progress box"""
self.w.BringToFront()
if newstr:
diff --git a/Lib/plat-mac/WASTEconst.py b/Lib/plat-mac/WASTEconst.py
deleted file mode 100644
index f453338..0000000
--- a/Lib/plat-mac/WASTEconst.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# Generated from 'WASTE.h'
-
-kPascalStackBased = None # workaround for header parsing
-def FOUR_CHAR_CODE(x): return x
-weCantUndoErr = -10015
-weEmptySelectionErr = -10013
-weUnknownObjectTypeErr = -9478
-weObjectNotFoundErr = -9477
-weReadOnlyErr = -9476
-weTextNotFoundErr = -9474
-weInvalidTextEncodingErr = -9473
-weDuplicateAttributeErr = -9472
-weInvalidAttributeSizeErr = -9471
-weReadOnlyAttributeErr = -9470
-weOddByteCountErr = -9469
-weHandlerNotFoundErr = -1717
-weNotHandledErr = -1708
-weNewerVersionErr = -1706
-weCorruptDataErr = -1702
-weProtocolErr = -603
-weUndefinedSelectorErr = -50
-weFlushLeft = -2
-weFlushRight = -1
-weFlushDefault = 0
-weCenter = 1
-weJustify = 2
-weDirDefault = 1
-weDirRightToLeft = -1
-weDirLeftToRight = 0
-weDoFont = 0x0001
-weDoFace = 0x0002
-weDoSize = 0x0004
-weDoColor = 0x0008
-weDoAll = weDoFont | weDoFace | weDoSize | weDoColor
-weDoAddSize = 0x0010
-weDoToggleFace = 0x0020
-weDoReplaceFace = 0x0040
-weDoPreserveScript = 0x0080
-weDoExtractSubscript = 0x0100
-weDoFaceMask = 0x0200
-weDoDirection = 0x00000001
-weDoAlignment = 0x00000002
-weDoLeftIndent = 0x00000004
-weDoRightIndent = 0x00000008
-weDoFirstLineIndent = 0x00000010
-weDoLineSpacing = 0x00000020
-weDoSpaceBefore = 0x00000040
-weDoSpaceAfter = 0x00000080
-weDoBottomBorderStyle = 0x00000400
-kLeadingEdge = -1
-kTrailingEdge = 0
-kObjectEdge = 2
-weFAutoScroll = 0
-weFOutlineHilite = 2
-weFReadOnly = 5
-weFUndo = 6
-weFIntCutAndPaste = 7
-weFDragAndDrop = 8
-weFInhibitRecal = 9
-weFUseTempMem = 10
-weFDrawOffscreen = 11
-weFInhibitRedraw = 12
-weFMonoStyled = 13
-weFMultipleUndo = 14
-weFNoKeyboardSync = 29
-weFInhibitICSupport = 30
-weFInhibitColor = 31
-weDoAutoScroll = 1 << weFAutoScroll
-weDoOutlineHilite = 1 << weFOutlineHilite
-weDoReadOnly = 1 << weFReadOnly
-weDoUndo = 1 << weFUndo
-weDoIntCutAndPaste = 1 << weFIntCutAndPaste
-weDoDragAndDrop = 1 << weFDragAndDrop
-weDoInhibitRecal = 1 << weFInhibitRecal
-weDoUseTempMem = 1 << weFUseTempMem
-weDoDrawOffscreen = 1 << weFDrawOffscreen
-weDoInhibitRedraw = 1 << weFInhibitRedraw
-weDoMonoStyled = 1 << weFMonoStyled
-weDoMultipleUndo = 1 << weFMultipleUndo
-weDoNoKeyboardSync = 1 << weFNoKeyboardSync
-weDoInhibitICSupport = 1 << weFInhibitICSupport
-# weDoInhibitColor = 1 << weFInhibitColor
-weBitToggle = -2
-weBitTest = -1
-weBitClear = 0
-weBitSet = 1
-weLowerCase = 0
-weUpperCase = 1
-weFindWholeWords = 0x00000001
-weFindCaseInsensitive = 0x00000002
-weFindDiacriticalInsensitive = 0x00000004
-wePutIntCutAndPaste = 0x00000001
-wePutAddToTypingSequence = 0x00000002
-wePutDetectUnicodeBOM = 0x00000200
-weStreamDestinationKindMask = 0x000000FF
-weStreamIncludeObjects = 0x00000100
-weGetAddUnicodeBOM = 0x00000200
-weGetLittleEndian = 0x00000400
-weTagFontFamily = FOUR_CHAR_CODE('font')
-weTagFontSize = FOUR_CHAR_CODE('ptsz')
-weTagPlain = FOUR_CHAR_CODE('plan')
-weTagBold = FOUR_CHAR_CODE('bold')
-weTagItalic = FOUR_CHAR_CODE('ital')
-weTagUnderline = FOUR_CHAR_CODE('undl')
-weTagOutline = FOUR_CHAR_CODE('outl')
-weTagShadow = FOUR_CHAR_CODE('shad')
-weTagCondensed = FOUR_CHAR_CODE('cond')
-weTagExtended = FOUR_CHAR_CODE('pexp')
-weTagStrikethrough = FOUR_CHAR_CODE('strk')
-weTagTextColor = FOUR_CHAR_CODE('colr')
-weTagBackgroundColor = FOUR_CHAR_CODE('pbcl')
-weTagTransferMode = FOUR_CHAR_CODE('pptm')
-weTagVerticalShift = FOUR_CHAR_CODE('xshf')
-weTagAlignment = FOUR_CHAR_CODE('pjst')
-weTagDirection = FOUR_CHAR_CODE('LDIR')
-weTagLineSpacing = FOUR_CHAR_CODE('ledg')
-weTagLeftIndent = FOUR_CHAR_CODE('lein')
-weTagRightIndent = FOUR_CHAR_CODE('riin')
-weTagFirstLineIndent = FOUR_CHAR_CODE('fidt')
-weTagSpaceBefore = FOUR_CHAR_CODE('spbe')
-weTagSpaceAfter = FOUR_CHAR_CODE('spaf')
-weTagBottomBorderStyle = FOUR_CHAR_CODE('BBRD')
-weTagForceFontFamily = FOUR_CHAR_CODE('ffnt')
-weTagAddFontSize = FOUR_CHAR_CODE('+siz')
-weTagAddVerticalShift = FOUR_CHAR_CODE('+shf')
-weTagTextEncoding = FOUR_CHAR_CODE('ptxe')
-weTagQDStyles = FOUR_CHAR_CODE('qdst')
-weTagTETextStyle = FOUR_CHAR_CODE('tets')
-weTagAlignmentDefault = FOUR_CHAR_CODE('deft')
-weTagAlignmentLeft = FOUR_CHAR_CODE('left')
-weTagAlignmentCenter = FOUR_CHAR_CODE('cent')
-weTagAlignmentRight = FOUR_CHAR_CODE('rght')
-weTagAlignmentFull = FOUR_CHAR_CODE('full')
-weTagDirectionDefault = FOUR_CHAR_CODE('deft')
-weTagDirectionLeftToRight = FOUR_CHAR_CODE('L->R')
-weTagDirectionRightToLeft = FOUR_CHAR_CODE('R->L')
-weTagBorderStyleNone = FOUR_CHAR_CODE('NONE')
-weTagBorderStyleThin = FOUR_CHAR_CODE('SLDL')
-weTagBorderStyleDotted = FOUR_CHAR_CODE('DTDL')
-weTagBorderStyleThick = FOUR_CHAR_CODE('THKL')
-weLineSpacingSingle = 0x00000000
-weLineSpacingOneAndHalf = 0x00008000
-weLineSpacingDouble = 0x00010000
-weCharByteHook = FOUR_CHAR_CODE('cbyt')
-weCharToPixelHook = FOUR_CHAR_CODE('c2p ')
-weCharTypeHook = FOUR_CHAR_CODE('ctyp')
-weClickLoop = FOUR_CHAR_CODE('clik')
-weCurrentDrag = FOUR_CHAR_CODE('drag')
-weDrawTextHook = FOUR_CHAR_CODE('draw')
-weDrawTSMHiliteHook = FOUR_CHAR_CODE('dtsm')
-weEraseHook = FOUR_CHAR_CODE('eras')
-weFontFamilyToNameHook = FOUR_CHAR_CODE('ff2n')
-weFontNameToFamilyHook = FOUR_CHAR_CODE('fn2f')
-weFluxProc = FOUR_CHAR_CODE('flux')
-weHiliteDropAreaHook = FOUR_CHAR_CODE('hidr')
-weLineBreakHook = FOUR_CHAR_CODE('lbrk')
-wePixelToCharHook = FOUR_CHAR_CODE('p2c ')
-wePort = FOUR_CHAR_CODE('port')
-wePreTrackDragHook = FOUR_CHAR_CODE('ptrk')
-weRefCon = FOUR_CHAR_CODE('refc')
-weScrollProc = FOUR_CHAR_CODE('scrl')
-weText = FOUR_CHAR_CODE('text')
-weTranslateDragHook = FOUR_CHAR_CODE('xdrg')
-weTranslucencyThreshold = FOUR_CHAR_CODE('tluc')
-weTSMDocumentID = FOUR_CHAR_CODE('tsmd')
-weTSMPreUpdate = FOUR_CHAR_CODE('pre ')
-weTSMPostUpdate = FOUR_CHAR_CODE('post')
-weURLHint = FOUR_CHAR_CODE('urlh')
-weWordBreakHook = FOUR_CHAR_CODE('wbrk')
-weNewHandler = FOUR_CHAR_CODE('new ')
-weDisposeHandler = FOUR_CHAR_CODE('free')
-weDrawHandler = FOUR_CHAR_CODE('draw')
-weClickHandler = FOUR_CHAR_CODE('clik')
-weStreamHandler = FOUR_CHAR_CODE('strm')
-weHoverHandler = FOUR_CHAR_CODE('hovr')
-kTypeText = FOUR_CHAR_CODE('TEXT')
-kTypeStyles = FOUR_CHAR_CODE('styl')
-kTypeSoup = FOUR_CHAR_CODE('SOUP')
-kTypeFontTable = FOUR_CHAR_CODE('FISH')
-kTypeParaFormat = FOUR_CHAR_CODE('WEpf')
-kTypeRulerScrap = FOUR_CHAR_CODE('WEru')
-kTypeCharFormat = FOUR_CHAR_CODE('WEcf')
-kTypeStyleScrap = FOUR_CHAR_CODE('WEst')
-kTypeUnicodeText = FOUR_CHAR_CODE('utxt')
-kTypeUTF8Text = FOUR_CHAR_CODE('UTF8')
-kTypeStyledText = FOUR_CHAR_CODE('STXT')
-weAKNone = 0
-weAKUnspecified = 1
-weAKTyping = 2
-weAKCut = 3
-weAKPaste = 4
-weAKClear = 5
-weAKDrag = 6
-weAKSetStyle = 7
-weAKSetRuler = 8
-weAKBackspace = 9
-weAKFwdDelete = 10
-weAKCaseChange = 11
-weAKObjectChange = 12
-weToScrap = 0
-weToDrag = 1
-weToSoup = 2
-weMouseEnter = 0
-weMouseWithin = 1
-weMouseLeave = 2
-kCurrentSelection = -1
-kNullStyle = -2
diff --git a/Lib/plat-mac/argvemulator.py b/Lib/plat-mac/argvemulator.py
index 6103a8a..2d66f1c 100644
--- a/Lib/plat-mac/argvemulator.py
+++ b/Lib/plat-mac/argvemulator.py
@@ -7,6 +7,7 @@ import traceback
from Carbon import AE
from Carbon.AppleEvents import *
from Carbon import Evt
+from Carbon import File
from Carbon.Events import *
import aetools
@@ -16,36 +17,36 @@ class ArgvCollector:
def __init__(self):
self.quitting = 0
- self.ae_handlers = {}
# Remove the funny -psn_xxx_xxx argument
if len(sys.argv) > 1 and sys.argv[1][:4] == '-psn':
del sys.argv[1]
- self.installaehandler('aevt', 'oapp', self.open_app)
- self.installaehandler('aevt', 'odoc', self.open_file)
- def installaehandler(self, classe, type, callback):
- AE.AEInstallEventHandler(classe, type, self.callback_wrapper)
- self.ae_handlers[(classe, type)] = callback
+ AE.AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, self.__runapp)
+ AE.AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, self.__openfiles)
def close(self):
- for classe, type in self.ae_handlers.keys():
- AE.AERemoveEventHandler(classe, type)
+ AE.AERemoveEventHandler(kCoreEventClass, kAEOpenApplication)
+ AE.AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments)
def mainloop(self, mask = highLevelEventMask, timeout = 1*60):
+ # Note: this is not the right way to run an event loop in OSX or even
+ # "recent" versions of MacOS9. This is however code that has proven
+ # itself.
stoptime = Evt.TickCount() + timeout
while not self.quitting and Evt.TickCount() < stoptime:
- self.dooneevent(mask, timeout)
- self.close()
+ self._dooneevent(mask, timeout)
- def _quit(self):
- self.quitting = 1
+ if not self.quitting:
+ print "argvemulator: timeout waiting for arguments"
- def dooneevent(self, mask = highLevelEventMask, timeout = 1*60):
+ self.close()
+
+ def _dooneevent(self, mask = highLevelEventMask, timeout = 1*60):
got, event = Evt.WaitNextEvent(mask, timeout)
if got:
- self.lowlevelhandler(event)
+ self._lowlevelhandler(event)
- def lowlevelhandler(self, event):
+ def _lowlevelhandler(self, event):
what, message, when, where, modifiers = event
h, v = where
if what == kHighLevelEvent:
@@ -60,53 +61,28 @@ class ArgvCollector:
else:
print "Unhandled event:", event
- def callback_wrapper(self, _request, _reply):
- _parameters, _attributes = aetools.unpackevent(_request)
- _class = _attributes['evcl'].type
- _type = _attributes['evid'].type
-
- if self.ae_handlers.has_key((_class, _type)):
- _function = self.ae_handlers[(_class, _type)]
- elif self.ae_handlers.has_key((_class, '****')):
- _function = self.ae_handlers[(_class, '****')]
- elif self.ae_handlers.has_key(('****', '****')):
- _function = self.ae_handlers[('****', '****')]
- else:
- raise 'Cannot happen: AE callback without handler', (_class, _type)
-
- # XXXX Do key-to-name mapping here
-
- _parameters['_attributes'] = _attributes
- _parameters['_class'] = _class
- _parameters['_type'] = _type
- if _parameters.has_key('----'):
- _object = _parameters['----']
- del _parameters['----']
- # The try/except that used to be here can mask programmer errors.
- # Let the program crash, the programmer can always add a **args
- # to the formal parameter list.
- rv = _function(_object, **_parameters)
- else:
- #Same try/except comment as above
- rv = _function(**_parameters)
- if rv == None:
- aetools.packevent(_reply, {})
- else:
- aetools.packevent(_reply, {'----':rv})
+ def _quit(self):
+ self.quitting = 1
- def open_app(self, **args):
+ def __runapp(self, requestevent, replyevent):
self._quit()
- def open_file(self, _object=None, **args):
- for alias in _object:
- fsr = alias.FSResolveAlias(None)[0]
- pathname = fsr.as_pathname()
- sys.argv.append(pathname)
- self._quit()
+ def __openfiles(self, requestevent, replyevent):
+ try:
+ listdesc = requestevent.AEGetParamDesc(keyDirectObject, typeAEList)
+ for i in range(listdesc.AECountItems()):
+ aliasdesc = listdesc.AEGetNthDesc(i+1, typeAlias)[1]
+ alias = File.Alias(rawdata=aliasdesc.data)
+ fsref = alias.FSResolveAlias(None)[0]
+ pathname = fsref.as_pathname()
+ sys.argv.append(pathname)
+ except Exception, e:
+ print "argvemulator.py warning: can't unpack an open document event"
+ import traceback
+ traceback.print_exc()
- def other(self, _object=None, _class=None, _type=None, **args):
- print 'Ignore AppleEvent', (_class, _type), 'for', _object, 'Other args:', args
+ self._quit()
if __name__ == '__main__':
ArgvCollector().mainloop()