Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
 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
Example #5
0
 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
Example #6
0
 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
Example #7
0
 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
Example #8
0
 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
Example #9
0
 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
Example #10
0
	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
Example #11
0
    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)
Example #12
0
    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)
Example #13
0
    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)
Example #14
0
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
Example #15
0
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()
Example #16
0
 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
Example #17
0
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()
Example #18
0
 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