Exemple #1
0
        def testProtocols(self):
            objc.protocolNamed('GKMatchDelegate')

            self.assertArgHasType(GKMatchDelegateHelper.match_player_didChangeConnectionState_, 2, objc._C_NSUInteger)
            self.assertArgHasType(GKMatchDelegateHelper.match_player_didChangeState_, 2, objc._C_NSUInteger)
            self.assertResultIsBOOL(GKMatchDelegateHelper.match_shouldReinviteDisconnectedPlayer_)
            self.assertResultIsBOOL(GKMatchDelegateHelper.match_shouldReinvitePlayer_)
        def testProtocols(self):
            objc.protocolNamed('GKSessionDelegate')

            self.assertArgHasType(GameCenter.TestGKPublicProtocolsHelper.session_peer_didChangeState_, 2, objc._C_NSUInteger)

            objc.protocolNamed('GKVoiceChatClient')
            self.assertArgHasType(GameCenter.TestGKPublicProtocolsHelper.voiceChatService_didReceiveInvitationFromParticipantID_callID_, 2, objc._C_NSUInteger)
        def testClasses10_10(self):
            objc.protocolNamed('NCWidgetProviding')

            self.assertArgIsBlock(TestNCWidgetProvidingHelper.widgetPerformUpdateWithCompletionHandler_, 0, b'v' + objc._C_NSUInteger)
            self.assertResultHasType(TestNCWidgetProvidingHelper.widgetMarginInsetsForProposedMarginInsets_, NotificationCenter.NSEdgeInsets.__typestr__)
            self.assertArgHasType(TestNCWidgetProvidingHelper.widgetMarginInsetsForProposedMarginInsets_, 0, NotificationCenter.NSEdgeInsets.__typestr__)
            self.assertResultIsBOOL(TestNCWidgetProvidingHelper.widgetAllowsEditing)
        def testProtocols(self):
            objc.protocolNamed('GKTurnBasedEventListener')

            self.assertArgIsBOOL(TestGKTurnBasedMatchHelper.player_receivedTurnEventForMatch_didBecomeActive_, 2)

            objc.protocolNamed('GKTurnBasedEventHandlerDelegate')
            self.assertArgIsBOOL(TestGKTurnBasedMatchHelper.handleTurnEventForMatch_didBecomeActive_, 1)
 def testIncorrectlyDefiningFormalProtocols(self):
     # Some bad calls to objc.formal_protocol
     self.assertRaises(TypeError, objc.formal_protocol, [], None, ())
     self.assertRaises(TypeError, objc.formal_protocol, 'supers', (NSObject,) , ())
     self.assertRaises(TypeError, objc.formal_protocol, 'supers', objc.protocolNamed('NSLocking') , ())
     self.assertRaises(TypeError, objc.formal_protocol, 'supers', [
             objc.protocolNamed('NSLocking'),
             "hello",
         ], ())
     self.assertRaises(TypeError, objc.formal_protocol, 'supers', None, [
             objc.selector(None, selector=b'fooMethod:', signature=b'v@:i'),
             "hello",
         ])
 def testIncorrectlyDefiningFormalProtocols(self):
     # Some bad calls to objc.formal_protocol
     self.assertRaises(TypeError, objc.formal_protocol, [], None, ())
     self.assertRaises(TypeError, objc.formal_protocol, "supers", (NSObject,), ())
     self.assertRaises(TypeError, objc.formal_protocol, "supers", objc.protocolNamed("NSLocking"), ())
     self.assertRaises(TypeError, objc.formal_protocol, "supers", [objc.protocolNamed("NSLocking"), "hello"], ())
     self.assertRaises(
         TypeError,
         objc.formal_protocol,
         "supers",
         None,
         [objc.selector(None, selector=b"fooMethod:", signature=b"v@:i"), "hello"],
     )
    def test_protocols(self):
        import sysconfig
        target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
        if target in ('10.6', '10.7', '10.9'):
           # The protocol is not available for older binaries...
           return

        self.assertIsInstance(objc.protocolNamed('JSExport'), objc.formal_protocol)
        def testInheritedProtocol(self):
            class MyClassImplementingNSObject(NSObject, protocols=[objc.protocolNamed("OC_TestProtocol2")]):
                def method(self): return 1

                @classmethod
                def classMethod(self):
                    return 2
            self.assertTrue(MyClassImplementingNSObject.conformsToProtocol_(objc.protocolNamed("OC_TestProtocol2")))
    def testBasic2(self):
        orig_protocolsForProcess = objc._objc.protocolsForProcess
        try:
            objc._objc.protocolsForProcess = lambda: []
            PROTOCOL_CACHE.clear()

            p = objc.protocolNamed("NSObject")
            self.assertIsInstance(p, objc.formal_protocol)

        finally:
            objc._objc.protocolsForProcess = orig_protocolsForProcess
def search(path, searchValue):
    '''
    List records that match the given query.
    '''
    node = _get_node(path)

    if not node:
        log.error('Query not possible, cannot get reference to node at path: {}'.format(path))
        return None

    # @objc.callbackFor("CFOpenDirectory.ODQuerySetCallback")
    # def query_callback(query, value, context, error, info):
    #     log.warning('got callback')
    #     pass

    query, err = ODQuery.queryWithNode_forRecordTypes_attribute_matchType_queryValues_returnAttributes_maximumResults_error_(
        node,
        kODRecordTypeUsers,
        kODAttributeTypeRecordName,
        kODMatchContains,
        searchValue,
        kODAttributeTypeStandardOnly,
        0,
        None
    )

    if err:
        log.error('Failed to construct query: {}'.format(err))
        return None

    ODQueryDelegate = objc.protocolNamed('ODQueryDelegate')

    class QueryDelegate(NSObject, ODQueryDelegate):
        def query_foundResults_error_(self, inQuery, inResults, inError):
            log.error('FOUND RESULTS')

    qd = QueryDelegate()
    query.setDelegate_(qd)
    query.scheduleInRunLoop_forMode_(NSRunLoop.currentRunLoop(), NSDefaultRunLoopMode)
#!/usr/bin/env python
# encoding: utf-8

import objc
from Foundation import *
from AppKit import *
import sys, os, re

MainBundle = NSBundle.mainBundle()
path = MainBundle.bundlePath() + "/Contents/Scripts"
if not path in sys.path:
	sys.path.append( path )

import GlyphsApp

GlyphsFilterProtocol = objc.protocolNamed( "GlyphsFilter" )

class GlyphsFilterInsertInflections ( NSObject, GlyphsFilterProtocol ):
	
	def init( self ):
		"""
		Do all initializing here.
		"""
		return self
	
	def interfaceVersion( self ):
		"""
		Distinguishes the API version the plugin was built for. 
		Return 1.
		"""
		try:
Exemple #12
0
 def testLockIsLock(self):
     # Test for bug #1735937
     lock = Foundation.NSLock.alloc().init()
     self.assertTrue(lock.conformsToProtocol_(objc.protocolNamed("NSLocking")))
Exemple #13
0
import objc
from Foundation import *
from AppKit import *
import sys, os, re

from DrawBotWindow import GlyphsDrawBotController

MainBundle = NSBundle.mainBundle()
path = MainBundle.bundlePath() + "/Contents/Scripts"
if not path in sys.path:
    sys.path.append(path)

import GlyphsApp

GlyphsPluginProtocol = objc.protocolNamed("GlyphsPlugin")


class DrawBotDocument(NSDocument, GlyphsPluginProtocol):
    def init(self):
        """
		You can add an observer like in the example.
		Do all initializing here.
		"""
        self.text = ""
        self = super(DrawBotDocument, self).init()
        return self

    def loadPlugin(self):
        mainMenu = NSApplication.sharedApplication().mainMenu()
        s = objc.selector(self.newDocument, signature='v@:')
Exemple #14
0
 def testProtocolObjects10_12(self):
     objc.protocolNamed("NSCloudSharingServiceDelegate")
 def testProtocols(self):
     objc.protocolNamed("AVAudioMixing")
     objc.protocolNamed("AVAudioStereoMixing")
     objc.protocolNamed("AVAudio3DMixing")
#!/usr/bin/env python
# encoding: utf-8

import objc
import sys

from GlyphsApp import *
from GlyphsApp.plugins import *

GlyphsReporter = objc.protocolNamed('GlyphsReporter')

class GlyphsExpandPathsPreviewTool (NSObject, GlyphsReporter):
	def init(self):
		self.controller = None
		self.offsetCurvePluginClass = None
		return self
	
	def title(self):
		return "Expand Paths Preview"
	
	def interfaceVersion(self):
		return 1
	
 	def trigger(self):
		'''The key to select the tool with keyboard'''
		return "x"
		
	def drawBackgroundForLayer_(self, Layer):
		if self.offsetCurvePluginClass is None:
			try:
				self.offsetCurvePluginClass = objc.lookUpClass("GlyphsFilterOffsetCurve")
Exemple #17
0
 def testProtocols(self):
     objc.protocolNamed("AVCaptureFileOutputRecordingDelegate")
     objc.protocolNamed("AVCaptureFileOutputDelegate")
 def testProtocols(self):
     objc.protocolNamed("IMServicePlugInPresenceSupport")
Exemple #19
0
 def test_protocols(self):
     objc.protocolNamed("MPSCNNBatchNormalizationDataSource")
Exemple #20
0
 def testProtocolObjects(self):
     objc.protocolNamed("NSProgressReporting")
Exemple #21
0
 def testProtocols10_8(self):
     objc.protocolNamed("GKAchievementViewControllerDelegate")
Exemple #22
0
"""Bridge.py. The main Python-(Swift) plugin bundle entry module"""
import logging
import sys
import objc
from Foundation import NSObject
from Cocoa import NSView
from AppKit import NSGraphicsContext, NSRectToCGRect
import Quartz
from behavior_detector.behavior_detector import BehaviorDetector
from behavior_detector.aggregator import Aggregator
from calendar_integration import quickstart

BridgeInterface = objc.protocolNamed("StackFlow.BridgeInterface")


class Bridge(NSObject, protocols=[BridgeInterface]):
    @classmethod
    def createInstance(self):
        return Bridge.alloc().init()

    def getPythonInformation(self):
        return sys.version

    def addWithA_b_(self, a, b):
        return a + b

    def shouldBreathe(self):
        return BD.should_breathe()

    def findFlowTime(self):
        return quickstart.find_flowtime()
    NSObject,
    CBCentralManager,
    CBPeripheral,
    CBUUID,
    NSArray,
    NSDictionary,
    NSNumber,
    NSError,
)

from bleak.backends.corebluetooth.PeripheralDelegate import PeripheralDelegate
from bleak.backends.corebluetooth.device import BLEDeviceCoreBluetooth

logger = logging.getLogger(__name__)

CBCentralManagerDelegate = objc.protocolNamed("CBCentralManagerDelegate")


class CMDConnectionState(Enum):
    DISCONNECTED = 0
    PENDING = 1
    CONNECTED = 2


class CentralManagerDelegate(NSObject):
    """macOS conforming python class for managing the CentralManger for BLE"""

    ___pyobjc_protocols__ = [CBCentralManagerDelegate]

    def init(self):
        """macOS init function for NSObject"""
 def testProtocols(self):
     self.assertIsInstance(
         objc.protocolNamed("AVCaptureViewDelegate"), objc.formal_protocol
     )
					self.outputWords.append(w)
		# output
		
		if len(self.outputWords) < 1:
			print "word-o-mat: No matching words found <sad trombone>"
		else:
			outputString = " ".join(self.outputWords)
			try:
				Glyphs.currentDocument.windowController().activeEditViewController().graphicView().setDisplayString_(outputString)
			except:
				Message("No open document found; word-o-mat will output to the Output Window.")
				warned = True
				print "word-o-mat:", outputString
				pass

GlyphsPlugin = objc.protocolNamed('GlyphsPlugin')
class WordOMat(NSObject, GlyphsPlugin):
	
	def init(self):
		self.wordomat = None
		return self
	
	def loadPlugin(self):
		mainMenu = NSApplication.sharedApplication().mainMenu()
		s = objc.selector(self.showWindow,signature='v@:')
		newMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(self.title(), s, "" )
		newMenuItem.setTarget_(self)
		
		mainMenu.itemAtIndex_(2).submenu().addItem_(newMenuItem)
	
	def title(self):
 def test_protocols(self):
     objc.protocolNamed("MIDICIProfileResponderDelegate")
Exemple #27
0
 def test_protocols(self):
     objc.protocolNamed("MTLResource")
#
#########################################################

import objc
from Foundation import *
from AppKit import *
import sys, os, re

MainBundle = NSBundle.mainBundle()
path = MainBundle.bundlePath() + "/Contents/Scripts"
if not path in sys.path:
	sys.path.append( path )

import GlyphsApp

GlyphsReporterProtocol = objc.protocolNamed( "GlyphsReporter" )

class ShowKerningGroupReference ( NSObject, GlyphsReporterProtocol ):
	
	def init( self ):
		"""
		Put any initializations you want to make here.
		"""
		try:
			#Bundle = NSBundle.bundleForClass_( NSClassFromString( self.className() ));
			return self
		except Exception as e:
			self.logToConsole( "init: %s" % str(e) )
	
	def interfaceVersion( self ):
		"""
 def testProtocols(self):
     objc.protocolNamed('GKFriendRequestComposeViewControllerDelegate')
 def testProtocols(self):
     objc.protocolNamed("NSStreamDelegate")
Exemple #31
0
 def testProtocolObjects(self):
     objc.protocolNamed("NSSharingServiceDelegate")
     objc.protocolNamed("NSSharingServicePickerDelegate")
 def testProtocols(self):
     objc.protocolNamed('CNKeyDescriptor')
 def test_protocols(self):
     objc.protocolNamed("CXProviderDelegate")
Exemple #34
0
 def test_formal_protocols(self):
     self.assertIsInstance(objc.protocolNamed('SKPaymentTransactionObserver'), objc.formal_protocol)
     self.assertIsInstance(objc.protocolNamed('SKProductsRequestDelegate'), objc.formal_protocol)
     self.assertIsInstance(objc.protocolNamed('SKRequestDelegate'), objc.formal_protocol)
Exemple #35
0
 def testProtocolObjects(self):
     objc.protocolNamed("NSPasteboardWriting")
     objc.protocolNamed("NSPasteboardReading")
Exemple #36
0
 def test_protocols(self):
     objc.protocolNamed("MTLIndirectRenderCommand")
Exemple #37
0
 def testProtocols(self):
     objc.protocolNamed("AVPictureInPictureControllerDelegate")
Exemple #38
0
 def testProtocolObjects10_14(self):
     objc.protocolNamed("NSPasteboardTypeOwner")
        def testClasses10_10(self):
            objc.protocolNamed('NCWidgetSearchViewDelegate')

            self.assertArgHasType(TestNCWidgetSearchViewDelegateHelper.widgetSearch_searchForTerm_maxResults_,
                    2, objc._C_NSUInteger)
Exemple #40
0
 def testProtocols(self):
     objc.protocolNamed("IMServicePlugInGroupListSupport")
     objc.protocolNamed("IMServicePlugInGroupListEditingSupport")
     objc.protocolNamed("IMServicePlugInGroupListOrderingSupport")
     objc.protocolNamed("IMServicePlugInGroupListAuthorizationSupport")
     objc.protocolNamed("IMServicePlugInGroupListHandlePictureSupport")
     objc.protocolNamed("IMServiceApplicationGroupListSupport")
     objc.protocolNamed("IMServiceApplicationGroupListAuthorizationSupport")
 def testProtocols(self):
     objc.protocolNamed('SBApplicationDelegate')
     self.assertArgHasType(TestSBApplicationHelper.eventDidFail_withError_, 0, b'r^{AEDesc=I^^{OpaqueAEDataStorageType}}')
Exemple #42
0
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

import sys
import os.path

from Foundation import *
from AppKit import *
import objc

NSObject = objc.lookUpClass('NSObject')
CodaPlugIn = objc.protocolNamed('CodaPlugIn')

class CodaPluginSkeleton(NSObject, CodaPlugIn):
    '''
    Initializes the menu items and is responsible for directing
    actions to the appropriate class
    '''

	# AT A MINIMUM you must change this line:
    plugin_name = 'Coda Plugin Skeleton'

    # Change this to disable automatic sorting of menu items:
    sort_menu_items = True

    def initWithPlugInController_plugInBundle_(self, controller, bundle):
        self.initWithPlugInController_bundle_(controller, bundle)
      def GetRightText(self):
            return ""

      def GetMetadata(self, controller):
            self.log("In GetMetadata for menu  %s" % self.page_title.encode("ascii","replace"))
            if self.metadata_func is not None:
                  return self.metadata_func(controller, self.page_title)
            else:
                  return None


# used to duck-type Menus (to indicate an item is a submenu)
def IsMenu(a):
      return hasattr(a,'page_title')

BRMenuListItemProvider = objc.protocolNamed('BRMenuListItemProvider')
class MenuDataSource(NSObject, BRMenuListItemProvider,ControllerUtilities):
      def initWithController_Menu_(self, ctrlr, menu):
            self.ctrlr = ctrlr
            self.menu = menu
            return self
      
      def itemCount(self):
            return len(self.menu.items)

      def titleForRow_(self,row):
            if row >= len(self.menu.items):
                  return None
            if IsMenu(self.menu.items[row]):
                  return self.menu.items[row].page_title
            else:
Exemple #44
0
 def testProtocols(self):
     objc.protocolNamed('ISyncFiltering')
	   and choose which outlet shall be linked to the UI element
	7. IBActions: Ctrl-drag from a UI element (e.g. button) to the File’s Owner in the left sidebar,
	   and choose the class method the UI element is supposed to trigger.
	   If you want a stepping field (change the value with up/downarrow),
	   then select the Entry Field, and set Identity Inspector > Custom Class to:
		GSSteppingTextField
	   ... and Attributes Inspector (top right, 4th icon) > Control > State to:
		Continuous
	8. Compile the .xib file to a .nib file with this Terminal command:
		ibtool xxx.xib --compile xxx.nib
	   (Replace xxx by the name of your xib/nib)
	   Please note: Every time the .xib is changed, it has to be recompiled to a .nib.
	   Check Console.app for error messages to see if everything went right.
"""

GlyphsFileFormatProtocol = objc.protocolNamed( "GlyphsFileFormat" )

class ____PluginClassName____ ( NSObject, GlyphsFileFormatProtocol ):
	settings_view = objc.IBOutlet()
	
	def init( self ):
		"""
		Do all initializing here.
		"""
		try:
			NSBundle.loadNibNamed_owner_( "____PluginFileName____Dialog", self )
			thisBundle = NSBundle.bundleForClass_( NSClassFromString( self.className() ) )
			self.toolbarIcon = NSImage.alloc().initWithContentsOfFile_( thisBundle.pathForImageResource_( "ExportIcon" ) )
			self.toolbarIcon.setName_( "ExportIcon" )
		except Exception as e:
			self.logToConsole( "init: %s" % str(e) )
 def test_protocols(self):
     self.assertIsInstance(objc.protocolNamed("SKProductsRequestDelegate"), objc.formal_protocol)
 def testProtocols10_8(self):
     objc.protocolNamed('GKViewController')
Exemple #48
0
 def testClasses(self):
     v = objc.protocolNamed("QLPreviewItem")
     self.assertIsInstance(v, objc.formal_protocol)
Exemple #49
0
#
#  Created by Julian Eberius on 28.01.14.
#  Copyright (c) 2014 Julian Eberius. All rights reserved.
#

import objc
import pyobjc_metadata
from Foundation import NSClassFromString, NSLog, NSUserDefaults

PySpotify = NSClassFromString("PySpotify")
SPSession = NSClassFromString("SPSession")
SPSearch = NSClassFromString("SPSearch")
SPAsyncLoading = NSClassFromString("SPAsyncLoading")
SPArtistBrowse = NSClassFromString("SPArtistBrowse")
SPAlbumBrowse = NSClassFromString("SPAlbumBrowse")
SPSessionPlaybackDelegate = objc.protocolNamed("SPSessionPlaybackDelegate")


def async_load(items, callback):
    SPAsyncLoading.waitUntilLoaded_timeout_then_(items, 20.0, callback)


class Spotify(PySpotify, SPSessionPlaybackDelegate):

    playlist = []  # list of SPTrack
    login_state = "logged_out"
    login_error = None
    current_track = None

    _current_track_idx = -1
 def testProtocolsObjects(self):
     objc.protocolNamed("NSUserNotificationCenterDelegate")
Exemple #51
0

import objc
from Foundation import *
from AppKit import *
import sys, os, re, traceback

MainBundle = NSBundle.mainBundle()
path = MainBundle.bundlePath() + "/Contents/Scripts"
if not path in sys.path:
	sys.path.append( path )

#import GlyphsApp
from GlyphsApp import *

GlyphsReporterProtocol = objc.protocolNamed( "GlyphsReporter" )

class ReporterPluginItalic ( NSObject, GlyphsReporterProtocol ):
	
	def init( self ):
		"""
		Put any initializations you want to make here.
		"""
		try:
			#Bundle = NSBundle.bundleForClass_( NSClassFromString( self.className() ));

			self.lastErrorMessage = ''

			# Default values
			self.menuName = 'New ReporterPlugin'
			self.keyboardShortcut = None
Exemple #52
0
 def testProtocols(self):
     objc.protocolNamed("SCNBoundingVolume")
Exemple #53
0
 def testProtocols10_5(self):
     # Document for 10.5, but not actually present there
     objc.protocolNamed('ISyncSessionDriverDataSource')
     objc.protocolNamed('NSPersistentStoreCoordinatorSyncing')
 def testProtocols(self):
     objc.protocolNamed("CNChangeHistoryEventVisitor")
	   and choose which outlet shall be linked to the UI element
	7. IBActions: Ctrl-drag from a UI element (e.g. button) to the File’s Owner in the left sidebar,
	   and choose the class method the UI element is supposed to trigger.
	   If you want a stepping field (change the value with up/downarrow),
	   then select the Entry Field, and set Identity Inspector > Custom Class to:
		GSSteppingTextField
	   ... and Attributes Inspector (top right, 4th icon) > Control > State to:
		Continuous
	8. Compile the .xib file to a .nib file with this Terminal command:
		ibtool xxx.xib --compile xxx.nib
	   (Replace xxx by the name of your xib/nib)
	   Please note: Every time the .xib is changed, it has to be recompiled to a .nib.
	   Check Console.app for error messages to see if everything went right.
"""

GlyphsPaletteProtocol = objc.protocolNamed( "GlyphsPalette" )

class ____PluginClassName____ ( NSObject, GlyphsPaletteProtocol ):
	# Define all your IB outlets for your .xib after _theView:
	_windowController = None
	_theView = objc.IBOutlet() # Palette view on which you can place UI elements.
	
	def init( self ):
		"""
		Do all initializing here, and customize the quadruple underscore items.
		____CFBundleIdentifier____ should be the reverse domain name you specified in Info.plist.
		"""
		try:
			if not NSBundle.loadNibNamed_owner_( "____PaletteView____", self ):
				self.logToConsole( "Error loading .nib into Palette." )
		
 def testProtocolObjects(self):
     objc.protocolNamed("ICDeviceBrowserDelegate")
 def testProtocols(self):
     objc.protocolNamed('GKMatchmakerViewControllerDelegate')
Exemple #58
0
 def testProtocols(self):
     objc.protocolNamed("NSXMLParserDelegate")
 def testProtocols(self):
     objc.protocolNamed('IMServicePlugInFileTransferSessionSupport')
     objc.protocolNamed('IMServiceApplicationFileTransferSessionSupport')
Exemple #60
0
 def testProtocols(self):
     objc.protocolNamed("AVAudioPlayerDelegate")