コード例 #1
0
    def filter(self, layer, inEditView, customParameters):

        # Called on font export, get value from customParameters
        if "coordinates" in customParameters:
            coordinates = customParameters['coordinates']

        # Called through UI, use stored value
        else:
            coordinates = Glyphs.defaults['com.mekkablue.Fade.coordinates']

        pathOperator = NSClassFromString("GSPathOperator")

        for coordinateCode in coordinates.split(","):
            # remove all whitespace:
            coordinateCode = self.cleanSyntax(coordinateCode)

            # check if syntax valid:
            if coordinateCode and coordinateCode[0] in "xy" and coordinateCode[
                    1] in "<>":
                # bounding rect coordinates:
                minX, minY = layer.bounds.origin
                maxX, maxY = minX + layer.bounds.size.width, minY + layer.bounds.size.height

                # pad rectangle coordinates:
                minX -= 1
                minY -= 1
                maxX += 1
                maxY += 1

                # cut value
                cut = float(coordinateCode[2:])

                # cut rectangle value:
                if coordinateCode[0] == "x":
                    if coordinateCode[1] == ">":
                        minX = cut
                    elif coordinateCode[1] == "<":
                        maxX = cut
                elif coordinateCode[0] == "y":
                    if coordinateCode[1] == ">":
                        minY = cut
                    elif coordinateCode[1] == "<":
                        maxY = cut

                # calculate GSPath subtracting:
                subtractRect = self.rectPath(minX, minY, maxX, maxY)
                subtractPaths = NSMutableArray.alloc().initWithObject_(
                    subtractRect)
                layerPaths = NSMutableArray.alloc().init(
                )  # should work with simply ...layer.shapes
                for p in layer.copyDecomposedLayer().shapes:
                    layerPaths.addObject_(p)
                if pathOperator.subtractPaths_from_error_(
                        subtractPaths, layerPaths, None):
                    layer.shapes = layerPaths
コード例 #2
0
ファイル: DockEditor.py プロジェクト: robperc/DockEditor
	def __init__(self):
		self.app_dirs = [os.path.join("/Applications", app_dir) for app_dir in os.listdir('/Applications') if not app_dir.startswith(".") and not app_dir.endswith(".app")]
		self.app_dirs += (
			'/Applications',
			'/System/Library/CoreServices/', 
			'/System/Library/CoreServices/Applications/'
		)
		self.sections    = ('persistent-apps', 'persistent-others')
		self.tiles       = ('file-tile', 'directory-tile', 'url-tile')
		self.id          = "com.apple.dock"
		self.apps        = NSMutableArray.alloc().initWithArray_(CoreFoundation.CFPreferencesCopyAppValue("persistent-apps", self.id))
		self.others      = NSMutableArray.alloc().initWithArray_(CoreFoundation.CFPreferencesCopyAppValue("persistent-others", self.id))
		self.labels      = self.getLabels()
コード例 #3
0
ファイル: DockEditor.py プロジェクト: robperc/DockEditor
 def __init__(self):
     self.app_dirs = [
         os.path.join("/Applications", app_dir)
         for app_dir in os.listdir('/Applications')
         if not app_dir.startswith(".") and not app_dir.endswith(".app")
     ]
     self.app_dirs += ('/Applications', '/System/Library/CoreServices/',
                       '/System/Library/CoreServices/Applications/')
     self.sections = ('persistent-apps', 'persistent-others')
     self.tiles = ('file-tile', 'directory-tile', 'url-tile')
     self.id = "com.apple.dock"
     self.apps = NSMutableArray.alloc().initWithArray_(
         CoreFoundation.CFPreferencesCopyAppValue("persistent-apps",
                                                  self.id))
     self.others = NSMutableArray.alloc().initWithArray_(
         CoreFoundation.CFPreferencesCopyAppValue("persistent-others",
                                                  self.id))
     self.labels = self.getLabels()
コード例 #4
0
def volume_list(folders, delegate):
    volumes = NSMutableArray.alloc().init()
    volumes.addObject_(NSString.alloc().initWithString_(os.path.expanduser('~/Ubuntu One')))
    volumes.addObject_(NSString.alloc().initWithString_(os.path.expanduser('/Users/jose/Library/Application Support/ubuntuone')))
    
    for folder in folders:
        if (bool(folder['subscribed'])):
            volumes.addObject_(NSString.alloc().initWithString_(folder['path']))

    delegate.returnedVolumeList_(volumes)
コード例 #5
0
ファイル: ncprefs.py プロジェクト: drewdiver/ncprefs.py
def modify_ncprefs_plist(key, value, item_index):
    # make an immutuble copy of the 'apps' array in ncprefs
    new_apps_array = NSMutableArray.alloc().initWithArray_(pl)
    # make a mutable copy of the target dict within the array
    new_dict = NSMutableDictionary.alloc().initWithDictionary_copyItems_(
        new_apps_array[item_index], True)
    # set the value
    new_dict[key] = value
    # replace the mutible dict within the mutable array
    new_apps_array.replaceObjectAtIndex_withObject_(item_index, new_dict)
    # replace the array in the ncprefs plist
    CFPreferencesSetAppValue("apps", new_apps_array, NCPREFS_PLIST)
コード例 #6
0
def writePlist(timestamp, writePlistPath):
    sippysip = []
    if os.path.isfile(writePlistPath):
        sippysip = CFPreferencesCopyAppValue('Events', writePlistPath)
        if sippysip:
            sippysip = NSMutableArray.alloc().initWithArray_(sippysip)
        else:
            sippysip = []
        sippysip.append(timestamp)
        CFPreferencesSetAppValue('Events', sippysip, writePlistPath)
    else:
        sippysip.append(timestamp)
        CFPreferencesSetAppValue('Events', sippysip, writePlistPath)
コード例 #7
0
def volume_list(folders, delegate):
    volumes = NSMutableArray.alloc().init()
    volumes.addObject_(NSString.alloc().initWithString_(
        os.path.expanduser('~/Ubuntu One')))
    volumes.addObject_(NSString.alloc().initWithString_(
        os.path.expanduser(
            '/Users/jose/Library/Application Support/ubuntuone')))

    for folder in folders:
        if (bool(folder['subscribed'])):
            volumes.addObject_(NSString.alloc().initWithString_(
                folder['path']))

    delegate.returnedVolumeList_(volumes)
コード例 #8
0
	def process_(self, sender):
		"""
		This method gets called when the user invokes the Dialog.
		"""
		try:
			# Create Preview in Edit View, and save & show original in ShadowLayers:
			ShadowLayers = self.valueForKey_("shadowLayers")
			Layers = self.valueForKey_("layers")
			checkSelection = True
			for k in range(len(ShadowLayers)):
				ShadowLayer = ShadowLayers[k]
				Layer = Layers[k]
				Layer.setPaths_(NSMutableArray.alloc().initWithArray_copyItems_(ShadowLayer.pyobjc_instanceMethods.paths(), True))
				Layer.setSelection_(None)
				try:
					# Glyphs 2.1 and earlier:
					if len(ShadowLayer.selection()) > 0 and checkSelection:
						for i in range(len(ShadowLayer.paths)):
							currShadowPath = ShadowLayer.paths[i]
							currLayerPath = Layer.paths[i]
							for j in range(len(currShadowPath.nodes)):
								currShadowNode = currShadowPath.nodes[j]
								if ShadowLayer.selection().containsObject_(currShadowNode):
									Layer.addSelection_(currLayerPath.nodes[j])
				except:
					# Glyphs 2.2 and later:
					if len(ShadowLayer.selection) > 0 and checkSelection:
						for i in range(len(ShadowLayer.paths)):
							currShadowPath = ShadowLayer.paths[i]
							currLayerPath = Layer.paths[i]
							for j in range(len(currShadowPath.nodes)):
								currShadowNode = currShadowPath.nodes[j]
								if currShadowNode in ShadowLayer.selection:
									Layer.addSelection_(currLayerPath.nodes[j])
				
				self.filter(Layer, Glyphs.font.currentTab != None, {}) # add your class variables here
				Layer.clearSelection()
			
			# Safe the values in the FontMaster. But could be saved in UserDefaults, too.
			# FontMaster = self.valueForKey_("fontMaster")
			# FontMaster.userData[ "____myValue____" ] = NSNumber.numberWithInteger_(self.____myValue____)
			
			# call the superclass to trigger the immediate redraw:
			objc.super(FilterWithDialog, self).process_(sender)
		except:
			self.logError(traceback.format_exc())
コード例 #9
0
ファイル: plugins.py プロジェクト: schriftgestalt/GlyphsSDK
	def process_(self, sender):
		"""
		This method gets called when the user invokes the Dialog.
		"""
		try:
			# Create Preview in Edit View, and save & show original in ShadowLayers:
			ShadowLayers = self.valueForKey_("shadowLayers")
			Layers = self.valueForKey_("layers")
			checkSelection = True
			for k in range(len(ShadowLayers)):
				ShadowLayer = ShadowLayers[k]
				Layer = Layers[k]
				Layer.setPaths_(NSMutableArray.alloc().initWithArray_copyItems_(ShadowLayer.pyobjc_instanceMethods.paths(), True))
				Layer.setSelection_(None)
				try:
					# Glyphs 2.1 and earlier:
					if len(ShadowLayer.selection()) > 0 and checkSelection:
						for i in range(len(ShadowLayer.paths)):
							currShadowPath = ShadowLayer.paths[i]
							currLayerPath = Layer.paths[i]
							for j in range(len(currShadowPath.nodes)):
								currShadowNode = currShadowPath.nodes[j]
								if ShadowLayer.selection().containsObject_(currShadowNode):
									Layer.addSelection_(currLayerPath.nodes[j])
				except:
					# Glyphs 2.2 and later:
					if len(ShadowLayer.selection) > 0 and checkSelection:
						for i in range(len(ShadowLayer.paths)):
							currShadowPath = ShadowLayer.paths[i]
							currLayerPath = Layer.paths[i]
							for j in range(len(currShadowPath.nodes)):
								currShadowNode = currShadowPath.nodes[j]
								if currShadowNode in ShadowLayer.selection:
									Layer.addSelection_(currLayerPath.nodes[j])

				self.filter(Layer, Glyphs.font.currentTab is not None, {})  # add your class variables here
				Layer.clearSelection()

			# Safe the values in the FontMaster. But could be saved in UserDefaults, too.
			# FontMaster = self.valueForKey_("fontMaster")
			# FontMaster.userData["____myValue____"] = NSNumber.numberWithInteger_(self.____myValue____)

			# call the superclass to trigger the immediate redraw:
			objc.super(FilterWithDialog, self).process_(sender)
		except:
			self.logError(traceback.format_exc())
コード例 #10
0
ls_prefs = os.path.join(
    NSHomeDirectory(),
    u'Library/Preferences/com.apple.LaunchServices/com.apple.LaunchServices')
ls_prefs_plist = ls_prefs + u'.plist'

if os.path.isfile(ls_prefs_plist):
    # read it in
    current_prefs = CFPreferencesCopyMultiple(None, ls_prefs,
                                              kCFPreferencesAnyUser,
                                              kCFPreferencesCurrentHost)
else:
    # make a new dictionary
    current_prefs = NSMutableDictionary()

# Get any existing key or a new blank dict if not present
magnified = current_prefs.get(u'LSHighResolutionModeIsMagnified',
                              NSMutableDictionary())
magnified_editable = NSMutableDictionary.dictionaryWithDictionary_(magnified)
# Build our values
options = NSMutableArray.alloc().init()
options.append(bookmark)
# A value of 3 = enabled, value of 2 = disabled
options.append(3)
magnified_editable[lowres_app_id] = options

# Update the setting
update_dict = NSMutableDictionary()
update_dict[u'LSHighResolutionModeIsMagnified'] = magnified_editable
result = CFPreferencesSetMultiple(update_dict, None, ls_prefs,
                                  kCFPreferencesAnyUser,
                                  kCFPreferencesCurrentHost)
コード例 #11
0
    def __init__(self, eventTypes, pathMode, pathString, whitelist, blacklist, ignoreSysFiles, ignoreDirEvents, proxy):
        """
            Set-up Monitor thread.
            
            After initialising the superclass and some instance variables
            try to create an FSEventStream. Throw an exeption if this fails.
            
            :Parameters:
                eventTypes : 
                    A list of the event types to be monitored.          
                    
                pathMode : 
                    The mode of directory monitoring: flat, recursive or following.

                pathString : string
                    A string representing a path to be monitored.
                  
                whitelist : list<string>
                    A list of files and extensions of interest.
                    
                blacklist : list<string>
                    A list of subdirectories to be excluded.

                ignoreSysFiles :
                    If true platform dependent sys files should be ignored.
                    
                monitorId :
                    Unique id for the monitor included in callbacks.
                    
                proxy :
                    A proxy to be informed of events
                    
        """
        AbstractPlatformMonitor.__init__(self, eventTypes, pathMode, pathString, whitelist, blacklist, ignoreSysFiles, ignoreDirEvents, proxy)
        self.log = logging.getLogger("fsserver."+__name__)
        
        #: an FSEvents.FSEventStream StreamRef object reference.
        self.streamRef = None
        #: FSEvents.CFRunLoop object reference.
        self.runLoopRef = None
        self.clientInfo = str(uuid.uuid1())
        #
        # Without using the mutable array, ie using the Python list directly, 
        # the code works but throws up a couple of horrible warnings:
        # "Oject of class OC_PythonArray autoreleased with no pool in place 
        #     - just leaking"
        # With the array there are still warnings about the strings whether 
        # Python native strings are used or NSStrings.
        #
        # All of these warnings are eliminated by using a pool for the lifetime 
        # of the NSMutableArray.
        #
        pool = NSAutoreleasePool.alloc().init()
        pathsToMonitor = NSMutableArray.alloc().init()
        ms = NSString.stringWithString_(self.pathsToMonitor)
        pathsToMonitor.insertObject_atIndex_(ms, 0)

        self.directory = fsDirectory.Directory(pathString=self.pathsToMonitor, 
                                            whitelist=self.whitelist,
                                            pathMode=self.pathMode)

        self.streamRef = FSEvents.FSEventStreamCreate(FSEvents.kCFAllocatorDefault,
                                self.callback,
                                self.clientInfo,
                                pathsToMonitor,
                                FSEvents.kFSEventStreamEventIdSinceNow,
                                1,
                                FSEvents.kFSEventStreamCreateFlagWatchRoot)
 
        #
        # Release the pool now that the NSMutableArray has been used.
        #
        del pool
             
        if self.streamRef == None:
            raise Exception('Failed to create FSEvent Stream')
            
        self.log.info('Monitor set-up on %s', str(self.pathsToMonitor))
        self.log.info('Monitoring %s events', str(self.eTypes))
コード例 #12
0
ファイル: snippet.py プロジェクト: szabo92/gistable
if 'com.oracle.java.JavaAppletPlugin' in my_policy:
    # make a mutable copy of the dict
    current_dict = my_policy['com.oracle.java.JavaAppletPlugin']
    my_policy['com.oracle.java.JavaAppletPlugin'] = NSMutableDictionary.alloc(
    ).initWithDictionary_copyItems_(current_dict, True)
else:
    # create an empty dict
    my_policy['com.oracle.java.JavaAppletPlugin'] = {}

if 'PlugInHostnamePolicies' in my_policy['com.oracle.java.JavaAppletPlugin']:
    # make a mutable copy of the array
    current_array = my_policy['com.oracle.java.JavaAppletPlugin'][
        'PlugInHostnamePolicies']
    my_policy['com.oracle.java.JavaAppletPlugin'][
        'PlugInHostnamePolicies'] = NSMutableArray.alloc().initWithArray_(
            current_array)
else:
    # create an empty array
    my_policy['com.oracle.java.JavaAppletPlugin'][
        'PlugInHostnamePolicies'] = []

found_foocorp_vpn = False
# iterate through dicts in com.oracle.java.JavaAppletPlugin:PlugInHostnamePolicies
for dict_item in my_policy['com.oracle.java.JavaAppletPlugin'][
        'PlugInHostnamePolicies']:
    if dict_item.get('PlugInHostname') == 'vpn.foocorp.com':
        found_foocorp_vpn = True

if not found_foocorp_vpn:
    foocorp_vpn = {
        'PlugInPageURL': 'https://vpn.foocorp.com/index.cgi',
コード例 #13
0
def get_downloads(downloads, delegate):
    returnDownloads = NSMutableArray.alloc().initWithCapacity_(len(downloads))
    for download in downloads:
        returnDownloads.addObject_(NSString.alloc().initWithString_(download['path']))
    delegate.returnedDownloads_(returnDownloads)
コード例 #14
0
def get_uploads(uploads, delegate):
    returnUploads = NSMutableArray.alloc().initWithCapacity_(len(uploads))
    for upload in uploads:
        returnUploads.addObject_(NSString.alloc().initWithString_(upload['path']))
    delegate.returnedUploads_(returnUploads)
コード例 #15
0
def get_uploads(uploads, delegate):
    returnUploads = NSMutableArray.alloc().initWithCapacity_(len(uploads))
    for upload in uploads:
        returnUploads.addObject_(NSString.alloc().initWithString_(
            upload['path']))
    delegate.returnedUploads_(returnUploads)
コード例 #16
0
def get_downloads(downloads, delegate):
    returnDownloads = NSMutableArray.alloc().initWithCapacity_(len(downloads))
    for download in downloads:
        returnDownloads.addObject_(NSString.alloc().initWithString_(
            download['path']))
    delegate.returnedDownloads_(returnDownloads)
コード例 #17
0
	def __init__(self):
		self.id              = "com.apple.sidebarlists"
		self.favoriteservers = NSMutableDictionary.alloc().initWithDictionary_copyItems_(CoreFoundation.CFPreferencesCopyAppValue("favoriteservers", self.id), True)
		self.items           = NSMutableArray.alloc().initWithArray_(self.favoriteservers["CustomListItems"] if self.favoriteservers.get("CustomListItems") else list())
		self.labels          = [item["Name"] for item in self.items]