Permalink
Browse files

Merge pull request #2116 from abhibeckert/master

Changes by Andreas Beier from MAMP
  • Loading branch information...
abhibeckert committed May 15, 2015
2 parents 0f0c43e + 7654a9f commit 57d0d4400d25265dee4e70376e8c9ab6b96e8f79
Showing with 54 additions and 4 deletions.
  1. +51 −1 Source/SPAppController.m
  2. +3 −3 Source/SPFieldEditorController.m
View
@@ -139,6 +139,21 @@ - (void)awakeFromNib
*/
- (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,14 +166,49 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
// 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];
}
}
}
- (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.
*/
@@ -1073,7 +1073,7 @@ - (void)updateBitSheet
}
[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 @@ - (void)controlTextDidChange:(NSNotification *)notification
[[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 @@ - (void)controlTextDidChange:(NSNotification *)notification
[[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 )

0 comments on commit 57d0d44

Please sign in to comment.