aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-19 09:54:16 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-19 09:54:16 +0000
commit50f47a853adcac4ee1d5394a6f4ef99789314cf3 (patch)
treebf8797e8d077f55dec71ff3b426c310d4169ffee
parent68a5b956417d578b5b5a272bc13072ea13f90245 (diff)
downloadsequelpro-50f47a853adcac4ee1d5394a6f4ef99789314cf3.tar.gz
sequelpro-50f47a853adcac4ee1d5394a6f4ef99789314cf3.tar.bz2
sequelpro-50f47a853adcac4ee1d5394a6f4ef99789314cf3.zip
• double-click in Finder on a 'spTheme' file installs this theme in SP's support folder
• fixed opening of other file types by checking lower cased strings
-rw-r--r--Source/SPAppController.m35
1 files changed, 31 insertions, 4 deletions
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);
}
}
}