Example #1
0
    def initWithMenus(self, menus):
        self = super(self.__class__, self).init()

        statusbar = NSStatusBar.systemStatusBar()

        self.statusitem = statusbar.statusItemWithLength_(NSVariableStatusItemLength)
        # self.statusitem.setHighlightMode_(1)
        self.statusitem.setToolTip_("MyVault")
        self.statusitem.setEnabled_(YES)

        # to signal what is going on
        for i in self.status_images.keys():
            self.images[i] = NSImage.alloc().initByReferencingFile_(self.status_images[i])

        # Set initial image
        self.statusitem.setImage_(self.images["init"])
        # self.statusitem.setAlternateImage_(self.icons['clicked'])

        self.menu = NSMenu.alloc().init()
        self.menu.setDelegate_(self)
        # self.menu.setAutoenablesItems_(NO)

        for m_item, m_sel in menus:
            objc.classAddMethods(Backup, [m_sel])
            menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(*m_item)
            self.menu.addItem_(menuitem)

        self.statusitem.setMenu_(self.menu)
        return self
Example #2
0
    def testPythonSourcedFunctions(self):
        # Same as testPythonSourcedMethods, but using function objects instead
        # of method objects.

        if sys.version_info[0] == 2:
            objc.classAddMethods(MEClass, [
                PurePython.description.im_func,
                PurePython.newMethod.im_func,
                PurePython.purePythonMethod.im_func,
            ])
        else:
            objc.classAddMethods(MEClass, [
                PurePython.description,
                PurePython.newMethod,
                PurePython.purePythonMethod,
            ])

        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(
            MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        self.assertEquals(newInstance.description(), u"<pure>")
        self.assertEquals(newInstance.newMethod(), u"<pure-new>")
        self.assertEquals(newInstance.purePythonMethod(), u"<pure-py>")

        self.assertEquals(preEverythingInstance.description(), u"<pure>")
        self.assertEquals(preEverythingInstance.newMethod(), u"<pure-new>")
        self.assertEquals(preEverythingInstance.purePythonMethod(),
                          u"<pure-py>")
Example #3
0
    def testHiddenAddMethods(self):

        @objc.selector
        def addedmethod(self):
            return "NEW"
        addedmethod.isHidden = True

        def addedclass(self):
            return "NEWCLASS"
        addedclass=objc.selector(addedclass, isClassMethod=True)
        addedclass.isHidden=True

        objc.classAddMethods(OCTestHidden, [addedmethod, addedclass])

        o = OCTestHidden.alloc().init()

        # Instance method
        self.assertRaises(AttributeError, getattr, o, 'addedmethod')

        v = o.performSelector_(b'addedmethod')
        self.assertEquals(v, "NEW")

        v = o.pyobjc_instanceMethods.addedmethod()
        self.assertEquals(v, "NEW")

        # Class method
        self.assertRaises(AttributeError, getattr, OCTestHidden, 'addedclass')

        v = OCTestHidden.performSelector_(b'addedclass')
        self.assertEquals(v, "NEWCLASS")

        v = OCTestHidden.pyobjc_classMethods.addedclass()
        self.assertEquals(v, "NEWCLASS")
    def testHiddenAddMethods(self):
        @objc.selector
        def addedmethod(self):
            return "NEW"

        addedmethod.isHidden = True

        def addedclass(self):
            return "NEWCLASS"

        addedclass = objc.selector(addedclass, isClassMethod=True)
        addedclass.isHidden = True

        objc.classAddMethods(OCTestHidden, [addedmethod, addedclass])

        o = OCTestHidden.alloc().init()

        # Instance method
        self.assertRaises(AttributeError, getattr, o, 'addedmethod')

        v = o.performSelector_(b'addedmethod')
        self.assertEquals(v, "NEW")

        v = o.pyobjc_instanceMethods.addedmethod()
        self.assertEquals(v, "NEW")

        # Class method
        self.assertRaises(AttributeError, getattr, OCTestHidden, 'addedclass')

        v = OCTestHidden.performSelector_(b'addedclass')
        self.assertEquals(v, "NEWCLASS")

        v = OCTestHidden.pyobjc_classMethods.addedclass()
        self.assertEquals(v, "NEWCLASS")
Example #5
0
    def testPythonSourcedMethods(self):
        # 20031227, Ronald: Assigning the methods works alright, but actually
        # using them won't because the new methods are actually still methods
        # of a different class and will therefore complain about the type
        # of 'self'.
        objc.classAddMethods(MEClass, [PurePython.description,
                                                  PurePython.newMethod,
                                                  PurePython.purePythonMethod])


        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        # This is bogus, see above:
        #self.assertEqual(newInstance.description(), "<pure>")
        #self.assertEqual(newInstance.newMethod(), "<pure-new>")
        #self.assertEqual(newInstance.purePythonMethod(), "<pure-py>")

        #self.assertEqual(preEverythingInstance.description(), "<pure>")
        #self.assertEqual(preEverythingInstance.newMethod(), "<pure-new>")
        #self.assertEqual(preEverythingInstance.purePythonMethod(), "<pure-py>")

        self.assertRaises(TypeError, newInstance.description)
        self.assertRaises(TypeError, newInstance.newMethod)
        self.assertRaises(TypeError, newInstance.purePythonMethod)
        self.assertRaises(TypeError, preEverythingInstance.description)
        self.assertRaises(TypeError, preEverythingInstance.newMethod)
        self.assertRaises(TypeError, preEverythingInstance.purePythonMethod)
Example #6
0
    def testPythonSourcedFunctions(self):
        # Same as testPythonSourcedMethods, but using function objects instead
        # of method objects.

        objc.classAddMethods(
            MEClass,
            [
                PurePython.description, PurePython.newMethod,
                PurePython.purePythonMethod
            ],
        )

        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(
            MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        self.assertEqual(newInstance.description(), "<pure>")
        self.assertEqual(newInstance.newMethod(), "<pure-new>")
        self.assertEqual(newInstance.purePythonMethod(), "<pure-py>")

        self.assertEqual(preEverythingInstance.description(), "<pure>")
        self.assertEqual(preEverythingInstance.newMethod(), "<pure-new>")
        self.assertEqual(preEverythingInstance.purePythonMethod(), "<pure-py>")
Example #7
0
    def testPythonSourcedFunctions(self):
        # Same as testPythonSourcedMethods, but using function objects instead
        # of method objects.


        if sys.version_info[0] == 2:
            objc.classAddMethods(MEClass, [
                PurePython.description.im_func,
                PurePython.newMethod.im_func,
                PurePython.purePythonMethod.im_func,
            ])
        else:
            objc.classAddMethods(MEClass, [
                PurePython.description,
                PurePython.newMethod,
                PurePython.purePythonMethod,
            ])

        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        self.assertEqual(newInstance.description(), "<pure>")
        self.assertEqual(newInstance.newMethod(), "<pure-new>")
        self.assertEqual(newInstance.purePythonMethod(), "<pure-py>")

        self.assertEqual(preEverythingInstance.description(), "<pure>")
        self.assertEqual(preEverythingInstance.newMethod(), "<pure-new>")
        self.assertEqual(preEverythingInstance.purePythonMethod(), "<pure-py>")
Example #8
0
    def testAddedMethodType(self):
        def anotherNewClassMethod(cls):
            "CLS DOC STRING"
            return "BAR CLS"

        anotherNewClassMethod = classmethod(anotherNewClassMethod)

        def anotherNewMethod(self):
            "INST DOC STRING"
            return "BAR SELF"

        self.assertTrue(not MEClass.pyobjc_classMethods.respondsToSelector_(
            "anotherNewClassMethod"))
        self.assertTrue(not MEClass.pyobjc_classMethods.
                        instancesRespondToSelector_("anotherNewMethod"))

        objc.classAddMethods(MEClass,
                             [anotherNewClassMethod, anotherNewMethod])
        self.assertTrue(
            MEClass.pyobjc_classMethods.respondsToSelector_(
                "anotherNewClassMethod"))
        self.assertTrue(
            MEClass.pyobjc_classMethods.instancesRespondToSelector_(
                "anotherNewMethod"))

        self.assertEqual(MEClass.anotherNewClassMethod.__doc__,
                         "CLS DOC STRING")
        self.assertEqual(MEClass.anotherNewMethod.__doc__, "INST DOC STRING")
Example #9
0
    def testPythonSourcedMethods(self):
        # 20031227, Ronald: Assigning the methods works alright, but actually
        # using them won't because the new methods are actually still methods
        # of a different class and will therefore complain about the type
        # of 'self'.
        objc.classAddMethods(
            MEClass,
            [
                PurePython.description, PurePython.newMethod,
                PurePython.purePythonMethod
            ],
        )

        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(
            MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        # This is bogus, see above:
        # self.assertEqual(newInstance.description(), "<pure>")
        # self.assertEqual(newInstance.newMethod(), "<pure-new>")
        # self.assertEqual(newInstance.purePythonMethod(), "<pure-py>")

        # self.assertEqual(preEverythingInstance.description(), "<pure>")
        # self.assertEqual(preEverythingInstance.newMethod(), "<pure-new>")
        # self.assertEqual(preEverythingInstance.purePythonMethod(), "<pure-py>")

        self.assertRaises(TypeError, newInstance.description)
        self.assertRaises(TypeError, newInstance.newMethod)
        self.assertRaises(TypeError, newInstance.purePythonMethod)
        self.assertRaises(TypeError, preEverythingInstance.description)
        self.assertRaises(TypeError, preEverythingInstance.newMethod)
        self.assertRaises(TypeError, preEverythingInstance.purePythonMethod)
Example #10
0
    def testNewMethod(self):
        objc.classAddMethods(MEClass, [Methods.pyobjc_instanceMethods.newMethod])

        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))

        newInstance = MEClass.new()

        self.assertEqual(newInstance.newMethod(), "<new-method>")
        self.assertEqual(preEverythingInstance.newMethod(), "<new-method>")
Example #11
0
    def testSubDescriptionOverride(self):
        objc.classAddMethods(MEClass, [MethodsSub.pyobjc_instanceMethods.description])

        self.assert_(MEClass.instancesRespondToSelector_("description"))

        newInstance = MEClass.new()

        self.assertEquals(newInstance.description(), u"<sub-methods>")
        self.assertEquals(preEverythingInstance.description(), u"<sub-methods>")
Example #12
0
    def testDescriptionOverride(self):
        objc.classAddMethods(MEClass, [Methods.pyobjc_instanceMethods.description])

        self.assertTrue(MEClass.instancesRespondToSelector_("description"))

        newInstance = MEClass.new()

        self.assertEqual(newInstance.description(), "<methods>")
        self.assertEqual(preEverythingInstance.description(), "<methods>")
Example #13
0
    def testSubDescriptionOverride(self):
        objc.classAddMethods(MEClass,
                             [MethodsSub.pyobjc_instanceMethods.description])

        self.assertTrue(MEClass.instancesRespondToSelector_("description"))

        newInstance = MEClass.new()

        self.assertEqual(newInstance.description(), "<sub-methods>")
        self.assertEqual(preEverythingInstance.description(), "<sub-methods>")
Example #14
0
    def testNewMethod(self):
        objc.classAddMethods(MEClass,
                             [Methods.pyobjc_instanceMethods.newMethod])

        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))

        newInstance = MEClass.new()

        self.assertEqual(newInstance.newMethod(), "<new-method>")
        self.assertEqual(preEverythingInstance.newMethod(), "<new-method>")
Example #15
0
    def testDescriptionOverride(self):
        objc.classAddMethods(MEClass,
                             [Methods.pyobjc_instanceMethods.description])

        self.assert_(MEClass.instancesRespondToSelector_("description"))

        newInstance = MEClass.new()

        self.assertEquals(newInstance.description(), u"<methods>")
        self.assertEquals(preEverythingInstance.description(), u"<methods>")
Example #16
0
    def testNewClassMethod(self):

        def aNewClassMethod(cls):
            return "Foo cls"
        aNewClassMethod = classmethod(aNewClassMethod)

        self.assertTrue(not MEClass.pyobjc_classMethods.respondsToSelector_("aNewClassMethod"))
        objc.classAddMethods(MEClass, [aNewClassMethod])
        self.assertTrue(MEClass.pyobjc_classMethods.respondsToSelector_("aNewClassMethod"))

        self.assertTrue(MEClass.aNewClassMethod.isClassMethod)
        self.assertEqual(MEClass.aNewClassMethod(), 'Foo cls')
Example #17
0
    def testSubNewMethod(self):
        objc.classAddMethods(MEClass, [MethodsSub.newMethod, MethodsSub.newSubMethod])

        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newSubMethod"))

        newInstance = MEClass.new()

        self.assertEqual(newInstance.newMethod(), "<sub-new-method>")
        self.assertEqual(preEverythingInstance.newMethod(), "<sub-new-method>")
        self.assertEqual(newInstance.newSubMethod(), "<new-method-sub>")
        self.assertEqual(preEverythingInstance.newSubMethod(), "<new-method-sub>")
Example #18
0
    def testSubNewMethod(self):
        objc.classAddMethods(MEClass,
                             [MethodsSub.newMethod, MethodsSub.newSubMethod])

        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newSubMethod"))

        newInstance = MEClass.new()

        self.assertEqual(newInstance.newMethod(), "<sub-new-method>")
        self.assertEqual(preEverythingInstance.newMethod(), "<sub-new-method>")
        self.assertEqual(newInstance.newSubMethod(), "<new-method-sub>")
        self.assertEqual(preEverythingInstance.newSubMethod(),
                         "<new-method-sub>")
Example #19
0
    def testNewClassMethod(self):
        def aNewClassMethod(cls):
            return "Foo cls"

        aNewClassMethod = classmethod(aNewClassMethod)

        self.assertTrue(not MEClass.pyobjc_classMethods.respondsToSelector_(
            "aNewClassMethod"))
        objc.classAddMethods(MEClass, [aNewClassMethod])
        self.assertTrue(
            MEClass.pyobjc_classMethods.respondsToSelector_("aNewClassMethod"))

        self.assertTrue(MEClass.aNewClassMethod.isClassMethod)
        self.assertEqual(MEClass.aNewClassMethod(), "Foo cls")
    def testHiddenInSubClass(self):

        # Instance
        o = OCTestSubHidden.alloc().init()
        self.assertRaises(AttributeError, getattr, o, "body")
        v = o.performSelector_(b'body')
        self.assertEquals(v, "BODY2")

        @objc.selector
        def subclassbody(self):
            return "base"

        subclassbody.isHidden = True

        @objc.selector
        def subclassbody2(self):
            return "base2"

        subclassbody.isHidden = True

        objc.classAddMethods(OCTestHidden, [subclassbody, subclassbody2])

        @objc.selector
        def subclassbody(self):
            return "sub"

        @objc.selector
        def subclassbody2(self):
            return "sub2"

        objc.classAddMethods(OCTestSubHidden, [subclassbody])
        self.assertRaises(AttributeError, getattr, o, "subclassbody")
        v = o.performSelector_(b'subclassbody')
        self.assertEquals(v, "sub")

        OCTestSubHidden.subclassbody2 = subclassbody2
        #self.assertRaises(AttributeError, getattr, o, "subclassbody2")
        v = o.performSelector_(b'subclassbody2')
        self.assertEquals(v, "sub2")

        self.assertRaises(AttributeError, getattr, o, 'boolMethod')
        v = o.pyobjc_instanceMethods.boolMethod()
        self.assertIs(v, False)

        # Class
        self.assertRaises(AttributeError, getattr, OCTestSubHidden,
                          'bodyclass')
        v = OCTestSubHidden.performSelector_(b'bodyclass')
        self.assertEquals(v, "BODYCLASS2")
Example #21
0
    def testHiddenInSubClass(self):

        # Instance 
        o = OCTestSubHidden.alloc().init()
        self.assertRaises(AttributeError, getattr, o, "body")
        v = o.performSelector_(b'body')
        self.assertEquals(v, "BODY2")

        @objc.selector
        def subclassbody(self):
            return "base"
        subclassbody.isHidden = True

        @objc.selector
        def subclassbody2(self):
            return "base2"
        subclassbody.isHidden = True

        objc.classAddMethods(OCTestHidden, [subclassbody, subclassbody2])


        @objc.selector
        def subclassbody(self):
            return "sub"

        @objc.selector
        def subclassbody2(self):
            return "sub2"

        objc.classAddMethods(OCTestSubHidden, [subclassbody])
        self.assertRaises(AttributeError, getattr, o, "subclassbody")
        v = o.performSelector_(b'subclassbody')
        self.assertEquals(v, "sub")

        OCTestSubHidden.subclassbody2 = subclassbody2
        #self.assertRaises(AttributeError, getattr, o, "subclassbody2")
        v = o.performSelector_(b'subclassbody2')
        self.assertEquals(v, "sub2")

        self.assertRaises(AttributeError, getattr, o, 'boolMethod')
        v = o.pyobjc_instanceMethods.boolMethod()
        self.assertIs(v, False)

        # Class
        self.assertRaises(AttributeError, getattr, OCTestSubHidden, 'bodyclass')
        v = OCTestSubHidden.performSelector_(b'bodyclass')
        self.assertEquals(v, "BODYCLASS2")
Example #22
0
    def testAddedMethodType(self):
        def anotherNewClassMethod(cls):
            "CLS DOC STRING"
            return "BAR CLS"
        anotherNewClassMethod = classmethod(anotherNewClassMethod)

        def anotherNewMethod(self):
            "INST DOC STRING"
            return "BAR SELF"

        self.assertTrue(not MEClass.pyobjc_classMethods.respondsToSelector_("anotherNewClassMethod"))
        self.assertTrue(not MEClass.pyobjc_classMethods.instancesRespondToSelector_("anotherNewMethod"))

        objc.classAddMethods(MEClass, [anotherNewClassMethod, anotherNewMethod])
        self.assertTrue(MEClass.pyobjc_classMethods.respondsToSelector_("anotherNewClassMethod"))
        self.assertTrue(MEClass.pyobjc_classMethods.instancesRespondToSelector_("anotherNewMethod"))

        self.assertEqual(MEClass.anotherNewClassMethod.__doc__, "CLS DOC STRING")
        self.assertEqual(MEClass.anotherNewMethod.__doc__, "INST DOC STRING")
Example #23
0
    def testPythonSourcedFunctions(self):
        # Same as testPythonSourcedMethods, but using function objects instead
        # of method objects.


        objc.classAddMethods(MEClass, [
            PurePython.description.im_func,
            PurePython.newMethod.im_func,
            PurePython.purePythonMethod.im_func
        ])

        self.assert_(MEClass.instancesRespondToSelector_("description"))
        self.assert_(MEClass.instancesRespondToSelector_("newMethod"))
        self.assert_(MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        self.assertEquals(newInstance.description(), u"<pure>")
        self.assertEquals(newInstance.newMethod(), u"<pure-new>")
        self.assertEquals(newInstance.purePythonMethod(), u"<pure-py>")

        self.assertEquals(preEverythingInstance.description(), u"<pure>")
        self.assertEquals(preEverythingInstance.newMethod(), u"<pure-new>")
        self.assertEquals(preEverythingInstance.purePythonMethod(), u"<pure-py>")
Example #24
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self._okToClose = False
        #systray = QSystemTrayIcon(self)
        #systray.setIcon(QIcon(":/icons/icon.png"))
        #systray.show()
        #def systray_activated(reason):
        #    self.setVisible(self.isVisible() ^ True)
        #systray.activated.connect(systray_activated)

        # results
        self._incr_results = None
        self._fts_results = None
        self._found_items = None

        # status
        self._selection_pending = False
        self._loading_pending = False
        self._auto_fts_phrase = None

        # Lazy-loaded objects
        self._lazy = {}

        # Setup
        self._setup_ui()
        self._restore_from_config()

        # Timers
        def _makeSingleShotTimer(slot):
            timer = QTimer(self)
            timer.setSingleShot(True)
            timer.timeout.connect(slot)
            return timer

        self._timerUpdateIndex = \
                _makeSingleShotTimer(self._updateIndex)
        self._timerAutoFTS = \
                _makeSingleShotTimer(self._onTimerAutoFullSearchTimeout)
        self._timerAutoPron = \
                _makeSingleShotTimer(self._onTimerAutoPronTimeout)
        self._timerSpellCorrection = \
                _makeSingleShotTimer(self._onTimerSpellCorrection)
        self._timerSearchingLabel = \
                _makeSingleShotTimer(self._onTimerSearchingLabel)

        # Clipboard
        clipboard = QApplication.clipboard()
        clipboard.dataChanged.connect(
                partial(self._onClipboardChanged, mode=QClipboard.Clipboard))
        clipboard.selectionChanged.connect(
            partial(self._onClipboardChanged, mode=QClipboard.Selection))

        # Stylesheet for the item list pane
        try:
            self._ui.listWidgetIndex.setStyleSheet(
                    _load_static_data('styles/list.css')\
                            .decode('utf-8', 'ignore'))
        except EnvironmentError:
            pass

        # Check index
        QTimer.singleShot(0, self._check_index)

        # Show
        self.show()

        # Click on the dock icon (OS X)
        if objc:
            def applicationShouldHandleReopen_hasVisibleWindows_(s, a, f):
                self.show()

            objc.classAddMethods(
                Cocoa.NSApplication.sharedApplication().delegate().class__(),
                [applicationShouldHandleReopen_hasVisibleWindows_])
Example #25
0
import sys

from AppKit import *
from Foundation import *
import objc

MessageRuleClass = objc.runtime.MessageRule
oldPerformActionsOnMessages_destinationStores_rejectedMessages_messagesToBeDeleted_ = MessageRuleClass.instanceMethodForSelector_("performActionsOnMessages:destinationStores:rejectedMessages:messagesToBeDeleted:")

def performActionsOnMessages_destinationStores_rejectedMessages_messagesToBeDeleted_(self, messages, stores, rejectedMessages, messagesToBeDeleted):
    NSLog('yes')
    oldPerformActionsOnMessages_destinationStores_rejectedMessages_messagesToBeDeleted_(self, messages, stores, rejectedMessages, messagesToBeDeleted)
    NSLog('done')

objc.classAddMethods(MessageRuleClass,
[performActionsOnMessages_destinationStores_rejectedMessages_messagesToBeDeleted_])


class ToyMailBundle2 (objc.runtime.MVMailBundle):
    def applicationWillTerminate_ (self, notification):
        NSLog('ToyMailBundle2 is shutting down')
        NSNotificationCenter.defaultCenter().removeObserver_name_object_(self,
None, None)

    def init (self):
        self = super(ToyMailBundle2, self).init()
        if self:
            NSLog('ToyMailBundle2 -init called')
            NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self,

            'applicationWillTerminate:',
Example #26
0
MessageRuleClass = objc.runtime.MessageRule
oldPerformActionsOnMessages_destinationStores_rejectedMessages_messagesToBeDeleted_ = MessageRuleClass.instanceMethodForSelector_(
    "performActionsOnMessages:destinationStores:rejectedMessages:messagesToBeDeleted:"
)


def performActionsOnMessages_destinationStores_rejectedMessages_messagesToBeDeleted_(
        self, messages, stores, rejectedMessages, messagesToBeDeleted):
    NSLog('yes')
    oldPerformActionsOnMessages_destinationStores_rejectedMessages_messagesToBeDeleted_(
        self, messages, stores, rejectedMessages, messagesToBeDeleted)
    NSLog('done')


objc.classAddMethods(MessageRuleClass, [
    performActionsOnMessages_destinationStores_rejectedMessages_messagesToBeDeleted_
])


class ToyMailBundle2(objc.runtime.MVMailBundle):
    def applicationWillTerminate_(self, notification):
        NSLog('ToyMailBundle2 is shutting down')
        NSNotificationCenter.defaultCenter().removeObserver_name_object_(
            self, None, None)

    def init(self):
        self = super(ToyMailBundle2, self).init()
        if self:
            NSLog('ToyMailBundle2 -init called')
            NSNotificationCenter.defaultCenter(
            ).addObserver_selector_name_object_(
Example #27
0
def performDragOperation_(self, sender):
    filename = self.checkSource_(sender)
    if filename:
        self._delegate.acceptSource_(filename)
        return True
    else:
        return False


class IEDBoxSourceSelector(NSBox):
    pass
classAddMethods(IEDBoxSourceSelector, [
    awakeFromNib,
    setDelegate_,
    startAcceptingDrag,
    stopAcceptingDrag,
    checkSource_,
    draggingEntered_,
    draggingUpdated_,
    performDragOperation_,
])

class IEDImageViewSourceSelector(NSImageView):
    pass
classAddMethods(IEDImageViewSourceSelector, [
    awakeFromNib,
    setDelegate_,
    startAcceptingDrag,
    stopAcceptingDrag,
    checkSource_,
    draggingEntered_,
    draggingUpdated_,
Example #28
0
def performDragOperation_(self, sender):
    filename = self.checkSource_(sender)
    if filename:
        self._delegate.acceptSource_(filename)
        return True
    else:
        return False


class IEDBoxSourceSelector(NSBox):
    pass
classAddMethods(IEDBoxSourceSelector, [
    awakeFromNib,
    setDelegate_,
    startAcceptingDrag,
    stopAcceptingDrag,
    checkSource_,
    draggingEntered_,
    draggingUpdated_,
    performDragOperation_,
])

class IEDImageViewSourceSelector(NSImageView):
    pass
classAddMethods(IEDImageViewSourceSelector, [
    awakeFromNib,
    setDelegate_,
    startAcceptingDrag,
    stopAcceptingDrag,
    checkSource_,
    draggingEntered_,
    draggingUpdated_,
Example #29
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self._okToClose = False
        # systray = QSystemTrayIcon(self)
        # systray.setIcon(QIcon(":/icons/icon.png"))
        # systray.show()
        # def systray_activated(reason):
        #    self.setVisible(self.isVisible() ^ True)
        # systray.activated.connect(systray_activated)

        # results
        self._incr_results = None
        self._fts_results = None
        self._found_items = None

        # status
        self._selection_pending = False
        self._loading_pending = False
        self._auto_fts_phrase = None

        # Lazy-loaded objects
        self._lazy = {}

        # ebi
        self._internal_req = None

        # Setup
        self._setup_ui()
        self._restore_from_config()

        # Timers
        def _makeSingleShotTimer(slot):
            timer = QTimer(self)
            timer.setSingleShot(True)
            timer.timeout.connect(slot)
            return timer

        self._timerUpdateIndex = \
            _makeSingleShotTimer(self._updateIndex)
        self._timerAutoFTS = \
            _makeSingleShotTimer(self._onTimerAutoFullSearchTimeout)
        self._timerAutoPron = \
            _makeSingleShotTimer(self._onTimerAutoPronTimeout)
        self._timerSpellCorrection = \
            _makeSingleShotTimer(self._onTimerSpellCorrection)
        self._timerSearchingLabel = \
            _makeSingleShotTimer(self._onTimerSearchingLabel)

        # Clipboard
        clipboard = QApplication.clipboard()
        clipboard.dataChanged.connect(
            partial(self._onClipboardChanged, mode=QClipboard.Clipboard))
        clipboard.selectionChanged.connect(
            partial(self._onClipboardChanged, mode=QClipboard.Selection))

        # Stylesheet for the item list pane
        try:
            self._ui.listWidgetIndex.setStyleSheet(
                _load_static_data('styles/list.css') \
                    .decode('utf-8', 'ignore'))
        except EnvironmentError:
            pass

        # Check index
        QTimer.singleShot(0, self._check_index)

        # Show
        self.show()

        # Click on the dock icon (OS X)
        if objc:

            def applicationShouldHandleReopen_hasVisibleWindows_(s, a, f):
                self.show()

            objc.classAddMethods(
                Cocoa.NSApplication.sharedApplication().delegate().class__(),
                [applicationShouldHandleReopen_hasVisibleWindows_])
Example #30
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self._okToClose = False
        # systray = QSystemTrayIcon(self)
        # systray.setIcon(QIcon(":/icons/icon.png"))
        # systray.show()
        # def systray_activated(reason):
        #    self.setVisible(self.isVisible() ^ True)
        # systray.activated.connect(systray_activated)

        # results
        self._incr_results = None
        self._fts_results = None
        self._found_items = None

        # status
        self._selection_pending = False
        self._loading_pending = False
        self._auto_fts_phrase = None

        # Lazy-loaded objects
        self._lazy = {}

        # Local URL scheme
        for name in _LOCAL_SCHEMES:
            scheme = QWebEngineUrlScheme(name.encode("ascii"))
            scheme.setFlags(
                QWebEngineUrlScheme.SecureScheme
                | QWebEngineUrlScheme.LocalScheme
                | QWebEngineUrlScheme.LocalAccessAllowed
                | QWebEngineUrlScheme.CorsEnabled
            )
            QWebEngineUrlScheme.registerScheme(scheme)

        self._scheme_handler = MyUrlSchemeHandler(self)
        profile = QWebEngineProfile.defaultProfile()
        for name in _LOCAL_SCHEMES:
            profile.installUrlSchemeHandler(name.encode("ascii"), self._scheme_handler)

        # Url request interceptor
        profile.setUrlRequestInterceptor(UrlRequestInterceptor(self))

        # Setup
        self._setup_ui()
        self._restore_from_config()

        # Timers
        def _makeSingleShotTimer(slot):
            timer = QTimer(self)
            timer.setSingleShot(True)
            timer.timeout.connect(slot)
            return timer

        self._timerUpdateIndex = _makeSingleShotTimer(self._updateIndex)
        self._timerAutoFTS = _makeSingleShotTimer(self._onTimerAutoFullSearchTimeout)
        self._timerAutoPron = _makeSingleShotTimer(self._onTimerAutoPronTimeout)
        self._timerSpellCorrection = _makeSingleShotTimer(self._onTimerSpellCorrection)
        self._timerSearchingLabel = _makeSingleShotTimer(self._onTimerSearchingLabel)

        # Clipboard
        clipboard = QApplication.clipboard()
        clipboard.dataChanged.connect(
            partial(self._onClipboardChanged, mode=QClipboard.Clipboard)
        )
        clipboard.selectionChanged.connect(
            partial(self._onClipboardChanged, mode=QClipboard.Selection)
        )

        # Stylesheet for the item list pane
        try:
            self._ui.listWidgetIndex.setStyleSheet(
                _load_static_data("styles/list.css").decode("utf-8", "ignore")
            )
        except EnvironmentError:
            pass

        # Check index
        QTimer.singleShot(0, self._check_index)

        # Show
        self.show()

        # Click the dock icon (macOS)
        if objc:

            def applicationShouldHandleReopen_hasVisibleWindows_(s, a, f):
                self.show()

            objc.classAddMethods(
                Cocoa.NSApplication.sharedApplication().delegate().class__(),
                [applicationShouldHandleReopen_hasVisibleWindows_],
            )