diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-06-17 10:52:50 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-06-17 10:52:50 +0000 |
commit | ed3d93c5d420dffa1a9ee64851648396b81bcac9 (patch) | |
tree | 9b94d39f0da3cc5fe641b9b11a08ac05c935874b /Source/SPAppController.m | |
parent | 6bde8e73c88f59fc3a41e6aab1db8aa233fb1b08 (diff) | |
download | sequelpro-ed3d93c5d420dffa1a9ee64851648396b81bcac9.tar.gz sequelpro-ed3d93c5d420dffa1a9ee64851648396b81bcac9.tar.bz2 sequelpro-ed3d93c5d420dffa1a9ee64851648396b81bcac9.zip |
• open a SPF file in a new tab if the tab bar of the front most document is visible otherwise open it in a new window
Diffstat (limited to 'Source/SPAppController.m')
-rw-r--r-- | Source/SPAppController.m | 21 |
1 files 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."); |