From ed3d93c5d420dffa1a9ee64851648396b81bcac9 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 17 Jun 2010 10:52:50 +0000 Subject: =?UTF-8?q?=E2=80=A2=20open=20a=20SPF=20file=20in=20a=20new=20tab?= =?UTF-8?q?=20if=20the=20tab=20bar=20of=20the=20front=20most=20document=20?= =?UTF-8?q?is=20visible=20otherwise=20open=20it=20in=20a=20new=20window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPAppController.m | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Source/SPAppController.m b/Source/SPAppController.m index a6b965c7..7a3ec334 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -275,14 +275,25 @@ } else if([[[filename pathExtension] lowercaseString] isEqualToString:@"spf"]) { - SPDatabaseDocument *newTableDocument; + SPWindowController *frontController = nil; - // If the frontmost document isn't connected and hasn't been, open the connection file with it. - // Otherwise, manually open a new document, setting SPAppController as sender to trigger autoconnection - if (![self frontDocument] || [[self frontDocument] mySQLVersion]) { + for (NSWindow *aWindow in [self 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]; } - [[self frontDocument] initWithConnectionFile:filename]; + + [[self frontDocument] initWithConnectionFile:filename]; } else { NSLog(@"Only files with the extensions ‘spf’ or ‘sql’ are allowed."); -- cgit v1.2.3