Hi,
I am writing a SIMBL plugin for Mail.app, so far it loads and the
correct method has been swizzled. However, i would like to call the
original method and that is where the problem lies.
If you could see the code(below), in console.app, i get the following
error because of old(x)
"
2007-06-26 03:42:04.053 Mail[2600] *** NSRunLoop ignoring exception
'exceptions.Typ eError: 'int' object is not callable' that raised
during posting of delayed perform with target 5bd1b10 and selector
'_finalSetup'
"
#saved as MailDump.py
import objc
from Foundation import *
from AppKit import *
WebMessageEdito r = objc.lookUpClas s('WebMessageEd itor')
old=1
swizzled = {}
#http://end.com/svn/BionicDOM/tags/1.0/
BionicDOMPalett e.py
def swizzle(cls, SEL, func):
NSLog(cls)
oldIMP = cls.instanceMet hodForSelector_ (SEL)
oldMethod = objc.selector(o ldIMP.__call__,
selector=oldIMP .selector, signature=oldIM P.signature)
newMethod = objc.selector(f unc, selector=oldIMP .selector,
signature=oldIM P.signature)
objc.classAddMe thod(cls, 'OLD'+SEL, oldMethod)
objc.classAddMe thod(cls, SEL, newMethod)
swizzled[(cls, SEL, func)] = (oldMethod, newMethod, oldIMP)
return(oldMetho d)
def updateContentsT oShowSignature_ (self,x):
NSLog("OHMYGOD" )
old(x)
class MWM(NSObject):
plugin = None # We will retain a pointer to the plugin to prevent
it being garbage-collected
@classmethod
def sharedInstance( cls): # not strictly necessary, but we only
need one instance of our object
if not cls.plugin:
cls.plugin = cls.alloc().ini t()
return cls.plugin
@classmethod
def initialize(cls) :
old=swizzle(Web MessageEditor,
'updateContents ToShowSignature :', updateContentsT oShowSignature_ )
#setup.py
# from distutils.core import setup
# import py2app
# plist = dict(
# NSPrincipalClas s='MWM',
# CFBundleName='M WM',
# SIMBLTargetAppl ications=[dict(BundleIden tifier='com.app le.mail',
MinBundleVersio n='000', MaxBundleVersio n='999920')],
# )
# setup(
# plugin=['MailDump.py'],
# options=dict(py 2app=dict(
# extension='.bun dle',
# plist=plist,
# )),
# )
#Run the following
#python2.4 setup.py py2app -A
#and copy the dist/MailDump.bundle to ~/Library/Application Support/
SIMBL/Plugins/