def initialize(cls): # instantiate updater updater = Updater() # register ourselves objc.runtime.MVMailBundle.registerBundle() # extract plugin version from Info.plist bundle = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix') version = bundle.infoDictionary().get('CFBundleVersion', '??') # initialize app app = App(version, updater) # initialize our posing classes with app instance DocumentEditor.registerQuoteFixApplication(app) ComposeViewController.registerQuoteFixApplication(app) MessageHeaders.registerQuoteFixApplication(app) MailApp.registerQuoteFixApplication(app) QuoteFixPreferencesController.registerQuoteFixApplication(app) CustomizedAttribution.registerQuoteFixApplication(app) # announce that we have loaded NSLog("QuoteFix Plugin (version %s) registered with Mail.app" % version)
def initialize(cls): # Register ourselves as a Mail.app plugin and add an entry for our # 'Fill Text' and Wrap Text' actions to the Edit menu. application = NSApplication.sharedApplication() bundle = NSBundle.bundleWithIdentifier_('uk.me.cdw.MailWrap') cls.registerBundle() editmenu = application.mainMenu().itemAtIndex_(2).submenu() editmenu.addItem_(NSMenuItem.separatorItem()) mask = NSCommandKeyMask | NSAlternateKeyMask editmenu.addItemWithTitle_action_keyEquivalent_('Fill Text', 'fillText', '\\').setKeyEquivalentModifierMask_(mask) mask = NSCommandKeyMask editmenu.addItemWithTitle_action_keyEquivalent_('Wrap Text', 'wrapText', "\\").setKeyEquivalentModifierMask_(mask) # Read our configuration settings if present. Otherwise, set the # correct default values. defaults = NSUserDefaults.standardUserDefaults() defaults = defaults.dictionaryForKey_('MailWrap') or {} ComposeViewController._fixAttribution = defaults.get('FixAttribution', False) EditingMessageWebView._bulletLists = defaults.get('BulletLists', True) EditingMessageWebView._indentWidth = int(defaults.get('IndentWidth', 2)) EditingMessageWebView._wrapWidth = int(defaults.get('WrapWidth', 72)) # Report the plugin name and version to the com.apple.mail log. version = bundle.objectForInfoDictionaryKey_('CFBundleVersion') NSLog('Loaded MailWrap %s' % version)
def initialize(cls): # Register ourselves as a Mail.app plugin and add an entry for our # 'Fill Text' and Wrap Text' actions to the Edit menu. application = NSApplication.sharedApplication() bundle = NSBundle.bundleWithIdentifier_('uk.me.cdw.MailWrap') cls.registerBundle() editmenu = application.mainMenu().itemAtIndex_(2).submenu() editmenu.addItem_(NSMenuItem.separatorItem()) mask = NSCommandKeyMask editmenu.addItemWithTitle_action_keyEquivalent_( 'Fill Text', 'fillText', '\\').setKeyEquivalentModifierMask_(mask) mask = NSCommandKeyMask | NSAlternateKeyMask editmenu.addItemWithTitle_action_keyEquivalent_( 'Wrap Text', 'wrapText', '\\').setKeyEquivalentModifierMask_(mask) # Read our configuration settings if present. Otherwise, set the # correct default values. defaults = NSUserDefaults.standardUserDefaults() defaults = defaults.dictionaryForKey_('MailWrap') or {} ComposeViewController._fixAttribution = defaults.get( 'FixAttribution', True) EditingMessageWebView._bulletLists = defaults.get('BulletLists', True) EditingMessageWebView._indentWidth = int(defaults.get( 'IndentWidth', 2)) EditingMessageWebView._wrapWidth = int(defaults.get('WrapWidth', 76)) # Report the plugin name and version to the com.apple.mail log. version = bundle.objectForInfoDictionaryKey_('CFBundleVersion') NSLog('Loaded MailWrap %s' % version)
def initWithApp_(self, app): self = super(Menu, self).init() if self is None: return None self.app = app self.mainwindow = NSApplication.sharedApplication().mainWindow() self.bundle = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix') return self
def initWithApp_(self, app): self = super(Menu, self).init() if self is None: return None self.app = app self.mainwindow = NSApplication.sharedApplication().mainWindow() self.bundle = NSBundle.bundleWithIdentifier_('pt.barraca.MailTrack') return self
def start(self): newMenuItem = NSMenuItem(self.name, self.showWindow_) Glyphs.menu[WINDOW_MENU].append(newMenuItem) try: bundle = NSBundle.bundleWithIdentifier_( "com.dyb.floatingImageFrame") self.icon = bundle.imageForResource_("icon.png") self.icon.setTemplate_(True) except: pass
def init(self): bundle = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix') nib = bundle.loadNibNamed_owner_topLevelObjects_('QuoteFixPreferencesModule', self, None) if not nib or nib[0] < 1: raise AssertionError('unable to load nib') nib[1].retain() self.view = filter(lambda _: isinstance(_, NSBox), nib[1])[0] self.setMinSize_(self.view.boundsSize()) self.setPreferencesView_(self.view) return self
def init(self): bundle = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix') nib = bundle.loadNibNamed_owner_topLevelObjects_( 'QuoteFixPreferencesModule', self, None) if not nib or nib[0] < 1: raise AssertionError('unable to load nib') nib[1].retain() self.view = filter(lambda _: isinstance(_, NSBox), nib[1])[0] self.setMinSize_(self.view.boundsSize()) self.setPreferencesView_(self.view) return self
def start(self): try: # new API in Glyphs 2.3.1-910 newMenuItem = NSMenuItem(self.name, self.showWindow_) Glyphs.menu[WINDOW_MENU].append(newMenuItem) except: mainMenu = Glyphs.mainMenu() s = objc.selector(self.showWindow_,signature='v@:@') newMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(self.name, s, "") newMenuItem.setTarget_(self) mainMenu.itemWithTag_(5).submenu().addItem_(newMenuItem) try: bundle = NSBundle.bundleWithIdentifier_("com.dyb.floatingImageFrame") self.icon = bundle.imageForResource_("icon.png") self.icon.setTemplate_(True) except: pass
def awakeFromNib(self): self.currentVersionUpdater.setStringValue_(self.app.version) self.updateInterval.setSelectedSegment_(self.app.check_update_interval) self.setLastUpdateCheck() # set donate image bundle = NSBundle.bundleWithIdentifier_('name.klep.mail.MailTrack') path = bundle.pathForResource_ofType_("donate", "gif") image = NSImage.alloc().initByReferencingFile_(path) self.donateButton.setImage_(image) # check custom signature matcher self.check_signature_matcher(self.customSignatureMatcher) self.customSignatureMatcherDefault.setStringValue_(self.app.default_signature_matcher) # set attribution previews self.set_preview(self.customReplyAttribution) self.set_preview(self.customForwardingAttribution) self.set_preview(self.customSendAgainAttribution)
def awakeFromNib(self): self.currentVersionUpdater.setStringValue_(self.app.version) self.updateInterval.setSelectedSegment_(self.app.check_update_interval) self.setLastUpdateCheck() # set donate image bundle = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix') path = bundle.pathForResource_ofType_("donate", "gif") image = NSImage.alloc().initByReferencingFile_(path) self.donateButton.setImage_(image) # check custom signature matcher self.check_signature_matcher(self.customSignatureMatcher) self.customSignatureMatcherDefault.setStringValue_(self.app.default_signature_matcher) # set attribution previews self.set_preview(self.customReplyAttribution) self.set_preview(self.customForwardingAttribution) self.set_preview(self.customSendAgainAttribution)
def initialize(cls): # instantiate updater updater = Updater() # register ourselves objc.runtime.MVMailBundle.registerBundle() # extract plugin version from Info.plist bundle = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix') version = bundle.infoDictionary().get('CFBundleVersion', '??') # initialize app app = App(version, updater) # initialize our posing classes with app instance DocumentEditor.registerQuoteFixApplication(app) MessageHeaders.registerQuoteFixApplication(app) MailApp.registerQuoteFixApplication(app) QuoteFixPreferencesController.registerQuoteFixApplication(app) CustomizedAttribution.registerQuoteFixApplication(app) # announce that we have loaded NSLog("QuoteFix Plugin (version %s) registered with Mail.app" % version)
from AppKit import NSBundle, NSObject from Foundation import NSLog from datetime import datetime from logger import logger import objc, os, os.path # load Sparkle framework BUNDLE = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix') frameworkspath = BUNDLE.privateFrameworksPath() sparklepath = os.path.join(frameworkspath, 'Sparkle.framework') sparkle = dict() # use 'private' storage to keep Sparkle classes in objc.loadBundle('Sparkle', sparkle, bundle_path = sparklepath) class Updater: def __init__(self): # instantiate Sparkle updater try: self.updater = sparkle['SUUpdater'].updaterForBundle_(BUNDLE) except: NSLog("QuoteFix: updater error - cannot initialize the updater for QuoteFix. This usually happens because of compatibility issues between Mail plugins. Updates are disabled, but QuoteFix should function normally.") self.enabled = False return # set delegate self.updater.setDelegate_(UpdaterDelegate.alloc().init().retain()) # reset update cycle self.updater.resetUpdateCycle() # updates are enabled
from AppKit import NSBundle, NSObject from Foundation import NSLog from datetime import datetime from logger import logger import objc, os, os.path # load Sparkle framework BUNDLE = NSBundle.bundleWithIdentifier_('pt.barraca.MailTrack') frameworkspath = BUNDLE.privateFrameworksPath() sparklepath = os.path.join(frameworkspath, 'Sparkle.framework') sparkle = dict() # use 'private' storage to keep Sparkle classes in objc.loadBundle('Sparkle', sparkle, bundle_path=sparklepath) class Updater: def __init__(self): # instantiate Sparkle updater try: self.updater = sparkle['SUUpdater'].updaterForBundle_(BUNDLE) except: NSLog( "MailTrack: updater error - cannot initialize the updater for MailTrack. This usually happens because of compatibility issues between Mail plugins. Updates are disabled, but MailTrack should function normally." ) self.enabled = False return # set delegate self.updater.setDelegate_(UpdaterDelegate.alloc().init().retain()) # reset update cycle self.updater.resetUpdateCycle()
def init(self): context = { NSNibTopLevelObjects : [] } nib = NSNib.alloc().initWithNibNamed_bundle_("MailTrackPreferencesModule.nib", NSBundle.bundleWithIdentifier_('name.klep.mail.MailTrack')) inited = nib.instantiateNibWithExternalNameTable_(context) self.view = filter(lambda _: isinstance(_, NSBox), context[NSNibTopLevelObjects])[0] self.setMinSize_(self.view.boundsSize()) self.setPreferencesView_(self.view) return self
from AppKit import NSBundle, NSObject from Foundation import NSLog from datetime import datetime from logger import logger import objc, os, os.path # load Sparkle framework BUNDLE = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix') frameworkspath = BUNDLE.privateFrameworksPath() sparklepath = os.path.join(frameworkspath, 'Sparkle.framework') sparkle = dict() # use 'private' storage to keep Sparkle classes in objc.loadBundle('Sparkle', sparkle, bundle_path=sparklepath) class Updater: def __init__(self): # instantiate Sparkle updater try: self.updater = sparkle['SUUpdater'].updaterForBundle_(BUNDLE) except: NSLog( "QuoteFix: updater error - cannot initialize the updater for QuoteFix. This usually happens because of compatibility issues between Mail plugins. Updates are disabled, but QuoteFix should function normally." ) self.enabled = False return # set delegate self.updater.setDelegate_(UpdaterDelegate.alloc().init().retain()) # reset update cycle self.updater.resetUpdateCycle()
def init(self): context = { NSNibTopLevelObjects : [] } nib = NSNib.alloc().initWithNibNamed_bundle_("QuoteFixPreferencesModule.nib", NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix')) inited = nib.instantiateNibWithExternalNameTable_(context) self.view = filter(lambda _: isinstance(_, NSBox), context[NSNibTopLevelObjects])[0] self.setMinSize_(self.view.boundsSize()) self.setPreferencesView_(self.view) return self