From 50f47a853adcac4ee1d5394a6f4ef99789314cf3 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 19 Aug 2010 09:54:16 +0000 Subject: =?UTF-8?q?=E2=80=A2=20double-click=20in=20Finder=20on=20a=20'spTh?= =?UTF-8?q?eme'=20file=20installs=20this=20theme=20in=20SP's=20support=20f?= =?UTF-8?q?older=20=E2=80=A2=20fixed=20opening=20of=20other=20file=20types?= =?UTF-8?q?=20by=20checking=20lower=20cased=20strings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPAppController.m | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'Source') diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 4bd8edeb..b03603bd 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -202,7 +202,7 @@ for (NSString *filename in filenames) { // Opens a sql file and insert its content into the Custom Query editor - if([[[filename pathExtension] lowercaseString] isEqualToString:SPFileExtensionSQL]) { + if([[[filename pathExtension] lowercaseString] isEqualToString:[SPFileExtensionSQL lowercaseString]]) { // Check size and NSFileType NSDictionary *attr = [[NSFileManager defaultManager] fileAttributesAtPath:filename traverseLink:YES]; @@ -280,7 +280,7 @@ break; // open only the first SQL file } - else if([[[filename pathExtension] lowercaseString] isEqualToString:SPFileExtensionDefault]) { + else if([[[filename pathExtension] lowercaseString] isEqualToString:[SPFileExtensionDefault lowercaseString]]) { SPWindowController *frontController = nil; @@ -302,7 +302,7 @@ [[self frontDocument] initWithConnectionFile:filename]; } - else if([[[filename pathExtension] lowercaseString] isEqualToString:SPBundleFileExtension]) { + else if([[[filename pathExtension] lowercaseString] isEqualToString:[SPBundleFileExtension lowercaseString]]) { NSError *readError = nil; NSString *convError = nil; @@ -423,8 +423,35 @@ [spfs release]; } + else if([[[filename pathExtension] lowercaseString] isEqualToString:[SPColorThemeFileExtension lowercaseString]]) { + NSFileManager *fm = [NSFileManager defaultManager]; + NSString *themePath = [[NSString stringWithString:@"~/Library/Application Support/Sequel Pro/Themes"] stringByExpandingTildeInPath]; + if(![fm fileExistsAtPath:themePath isDirectory:nil]) { + if(![fm createDirectoryAtPath:themePath withIntermediateDirectories:YES attributes:nil error:nil]) { + NSBeep(); + return; + } + } + NSString *newPath = [NSString stringWithFormat:@"%@/%@", themePath, [filename lastPathComponent]]; + if(![fm fileExistsAtPath:newPath isDirectory:nil]) { + if(![fm copyItemAtPath:filename toPath:newPath error:nil]) { + NSBeep(); + return; + } + } else { + NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while installing color theme file", @"error while installing color theme file")] + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"The color theme ‘%@’ already exists.", @"the color theme ‘%@’ already exists."), [filename lastPathComponent]]]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert runModal]; + return; + } + } else { - NSLog(@"Only files with the extensions ‘spf’ or ‘sql’ are allowed."); + NSLog(@"Only files with the extensions ‘%@’, ‘%@’, ‘%@’ or ‘%@’ are allowed.", SPFileExtensionDefault, SPBundleFileExtension, SPColorThemeFileExtension, SPFileExtensionSQL); } } } -- cgit v1.2.3