[Mac] Dock tile plug-in now follows screen shots directory around.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4255 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
26cc800c6e
commit
b346c2d28a
@ -307,7 +307,7 @@ if (global.timeAccelerationFactor === undefined)
|
||||
|
||||
/**** Backwards-compatibility functions. These will be removed before next stable. ****/
|
||||
|
||||
var failWarning = " This warning will be removed and the script will fail in Oolite 1.75.1.";
|
||||
const failWarning = " This warning will be removed and the script will fail in Oolite 1.75.1.";
|
||||
|
||||
// Define a read-only property that is an alias for another property.
|
||||
function defineCompatibilityGetter(constructorName, oldName, newName)
|
||||
|
@ -164,6 +164,9 @@ NSURL *JAURLFromPersistentFileReference(NSDictionary *fileRef, JAPersistentFileR
|
||||
{
|
||||
stale = carbonStale;
|
||||
result = (NSURL *)CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef);
|
||||
#if 1050 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
CFMakeCollectable((CFURLRef)result);
|
||||
#endif
|
||||
[result autorelease];
|
||||
}
|
||||
DisposeHandle((Handle)alias);
|
||||
|
@ -807,13 +807,37 @@ static NSComparisonResult CompareDisplayModes(id arg1, id arg2, void *context)
|
||||
}
|
||||
|
||||
|
||||
// Helpers to allow -snapshotsURLCreatingIfNeeded: code to be identical here and in dock tile plug-in.
|
||||
static id GetPreference(NSString *key, Class expectedClass)
|
||||
{
|
||||
id result = [[NSUserDefaults standardUserDefaults] objectForKey:key];
|
||||
if (expectedClass != Nil && ![result isKindOfClass:expectedClass]) result = nil;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void SetPreference(NSString *key, id value)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
|
||||
}
|
||||
|
||||
|
||||
static void RemovePreference(NSString *key)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:key];
|
||||
}
|
||||
|
||||
|
||||
#define kSnapshotsDirRefKey @"snapshots-directory-reference"
|
||||
#define kSnapshotsDirNameKey @"snapshots-directory-name"
|
||||
|
||||
- (NSURL *) snapshotsURLCreatingIfNeeded:(BOOL)create
|
||||
{
|
||||
BOOL stale = NO;
|
||||
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
||||
NSDictionary *snapshotDirDict = [prefs dictionaryForKey:@"snapshots-directory-reference"];
|
||||
NSURL *url = nil;
|
||||
NSString *name = DESC(@"snapshots-directory-name-mac");
|
||||
BOOL stale = NO;
|
||||
NSDictionary *snapshotDirDict = GetPreference(kSnapshotsDirRefKey, [NSDictionary class]);
|
||||
NSURL *url = nil;
|
||||
NSString *name = DESC(@"snapshots-directory-name-mac");
|
||||
|
||||
if (snapshotDirDict != nil)
|
||||
{
|
||||
@ -824,7 +848,7 @@ static NSComparisonResult CompareDisplayModes(id arg1, id arg2, void *context)
|
||||
if ([existingName compare:name options:NSCaseInsensitiveSearch] != 0)
|
||||
{
|
||||
// Check name from previous access, because we might have changed localizations.
|
||||
NSString *originalOldName = [prefs stringForKey:@"snapshots-directory-name"];
|
||||
NSString *originalOldName = GetPreference(kSnapshotsDirNameKey, [NSString class]);
|
||||
if ([existingName compare:originalOldName options:NSCaseInsensitiveSearch] != 0)
|
||||
{
|
||||
url = nil;
|
||||
@ -874,12 +898,12 @@ static NSComparisonResult CompareDisplayModes(id arg1, id arg2, void *context)
|
||||
snapshotDirDict = JAPersistentFileReferenceFromURL(url);
|
||||
if (snapshotDirDict != nil)
|
||||
{
|
||||
[prefs setObject:snapshotDirDict forKey:@"snapshots-directory-reference"];
|
||||
[prefs setObject:[[url path] lastPathComponent] forKey:@"snapshots-directory-name"];
|
||||
SetPreference(kSnapshotsDirRefKey, snapshotDirDict);
|
||||
SetPreference(kSnapshotsDirNameKey, [[url path] lastPathComponent]);
|
||||
}
|
||||
else
|
||||
{
|
||||
[prefs removeObjectForKey:@"snapshots-directory-reference"];
|
||||
RemovePreference(kSnapshotsDirRefKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user