diff options
-rw-r--r-- | Source/SPAppController.m | 52 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m | 6 |
2 files changed, 54 insertions, 4 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 0d60437b..9b658dc4 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -139,6 +139,21 @@ */ - (void)applicationDidFinishLaunching:(NSNotification *)notification { + NSDictionary *spfDict = nil; + NSArray *args = [[NSProcessInfo processInfo] arguments]; + if (args.count == 5) { + if (([[args objectAtIndex:1] isEqualToString:@"--spfData"] && [[args objectAtIndex:3] isEqualToString:@"--dataVersion"] && [[args objectAtIndex:4] isEqualToString:@"1"]) || ([[args objectAtIndex:3] isEqualToString:@"--spfData"] && [[args objectAtIndex:1] isEqualToString:@"--dataVersion"] && [[args objectAtIndex:2] isEqualToString:@"1"])) { + NSData* data = [[args objectAtIndex:2] dataUsingEncoding:NSUTF8StringEncoding]; + NSError *error = nil; + spfDict = [NSPropertyListSerialization propertyListWithData:data options:0 format:NULL error:&error]; + if (error) { + spfDict = nil; + } + } + } + + [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(externalApplicationWantsToOpenADatabaseConnection:) name:@"ExternalApplicationWantsToOpenADatabaseConnection" object:nil]; + // Set ourselves as the crash reporter delegate [[FRFeedbackReporter sharedReporter] setDelegate:self]; @@ -151,7 +166,11 @@ // If no documents are open, open one if (![self frontDocument]) { [self newWindow:self]; - + + if (spfDict) { + [[self frontDocument] setState:spfDict]; + } + // Set autoconnection if appropriate if ([[NSUserDefaults standardUserDefaults] boolForKey:SPAutoConnectToDefault]) { [[self frontDocument] connect]; @@ -159,6 +178,37 @@ } } + +- (void)externalApplicationWantsToOpenADatabaseConnection:(NSNotification *)notification +{ + SPWindowController *frontController = nil; + + for (NSWindow *aWindow in [NSApp orderedWindows]) { + if ([[aWindow windowController] isMemberOfClass:[SPWindowController class]]) { + frontController = [aWindow windowController]; + break; + } + } + + // If no window was found or the front most window has no tabs, create a new one + if (!frontController || [[frontController valueForKeyPath:@"tabView"] numberOfTabViewItems] == 1) { + [self newWindow:self]; + // Open the spf file in a new tab if the tab bar is visible + } else if ([[frontController valueForKeyPath:@"tabView"] numberOfTabViewItems] != 1) { + if ([[frontController window] isMiniaturized]) [[frontController window] deminiaturize:self]; + [frontController addNewConnection:self]; + } + + NSDictionary *userInfo = [notification userInfo]; + NSString *MAMP_SPFVersion = [userInfo objectForKey:@"dataVersion"]; + if ([MAMP_SPFVersion isEqualToString:@"1"]) { + NSDictionary *spfStructure = [userInfo objectForKey:@"spfData"]; + if (spfStructure) { + [[self frontDocument] setState:spfStructure]; + } + } +} + /** * Menu item validation. */ diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index c791dfc5..fbba1a4b 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -1073,7 +1073,7 @@ typedef enum { } [bitSheetIntegerTextField setStringValue:[[NSNumber numberWithUnsignedLongLong:intValue] stringValue]]; [bitSheetHexTextField setStringValue:[NSString stringWithFormat:@"%lX", (unsigned long)intValue]]; - [bitSheetOctalTextField setStringValue:[NSString stringWithFormat:@"%llO", (unsigned long long)intValue]]; + [bitSheetOctalTextField setStringValue:[NSString stringWithFormat:@"%llo", (unsigned long long)intValue]]; // free old data if ( sheetEditData != nil ) { [sheetEditData release]; @@ -1199,7 +1199,7 @@ typedef enum { [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%lu", i]] setState:NSOffState]; [bitSheetHexTextField setStringValue:[NSString stringWithFormat:@"%lX", (unsigned long)intValue]]; - [bitSheetOctalTextField setStringValue:[NSString stringWithFormat:@"%llO", (long long)intValue]]; + [bitSheetOctalTextField setStringValue:[NSString stringWithFormat:@"%llo", (long long)intValue]]; i = 0; while( intValue && i < maxBit ) @@ -1223,7 +1223,7 @@ typedef enum { [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", (long)i]] setState:NSOffState]; [bitSheetHexTextField setStringValue:[NSString stringWithFormat:@"%qX", intValue]]; - [bitSheetOctalTextField setStringValue:[NSString stringWithFormat:@"%llO", intValue]]; + [bitSheetOctalTextField setStringValue:[NSString stringWithFormat:@"%llo", intValue]]; i = 0; while( intValue && i < maxBit ) |