From 3bbcf08f70e3b8538d0a89e686051581bb5ecd09 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 6 Oct 2009 20:50:36 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20main=20menu=20item:=20"Open=20?= =?UTF-8?q?=E2=80=9C=E2=80=9D=20in=20New=20Window"=20=E2=8C=A5?= =?UTF-8?q?=E2=8C=98O=20as=20alternated=20menu=20item=20bound=20to=20"Open?= =?UTF-8?q?=E2=80=A6"=20-=20this=20action=20opens=20the=20current=20file-b?= =?UTF-8?q?ased=20connection=20in=20a=20new=20window=20by=20reading=20=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPAppController.m | 5 +++++ Source/TableDocument.h | 1 + Source/TableDocument.m | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+) (limited to 'Source') diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 94a732b9..547d1e9c 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -87,6 +87,11 @@ return NO; } } + if ([menuItem action] == @selector(openCurrentConnectionInNewWindow:)) + { + [menuItem setTitle:NSLocalizedString(@"Open in New Window", @"menu item open in new window")]; + return NO; + } return YES; } diff --git a/Source/TableDocument.h b/Source/TableDocument.h index 3a8adbfb..37f8ca60 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -166,6 +166,7 @@ enum sp_current_query_mode - (IBAction)removeDatabase:(id)sender; - (IBAction)showMySQLHelp:(id)sender; - (IBAction)saveServerVariables:(id)sender; +- (IBAction)openCurrentConnectionInNewWindow:(id)sender; - (NSArray *)allDatabaseNames; // Encoding methods diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 10f74e67..1c9613fa 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -1951,6 +1951,20 @@ contextInfo:nil]; } +- (IBAction)openCurrentConnectionInNewWindow:(id)sender +{ + TableDocument *newTableDocument; + + // Manually open a new document, setting SPAppController as sender to trigger autoconnection + if (newTableDocument = [[NSDocumentController sharedDocumentController] makeUntitledDocumentOfType:@"SequelPro connection" error:nil]) { + [newTableDocument setShouldAutomaticallyConnect:NO]; + [[NSDocumentController sharedDocumentController] addDocument:newTableDocument]; + [newTableDocument makeWindowControllers]; + [newTableDocument showWindows]; + [newTableDocument initWithConnectionFile:[[[self fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + } +} + - (void)closeConnection { [mySQLConnection disconnect]; @@ -2613,6 +2627,17 @@ return ([menuItem action] == @selector(newDocument:) || [menuItem action] == @selector(terminate:)); } + if ([menuItem action] == @selector(openCurrentConnectionInNewWindow:)) + { + if([[[self fileURL] absoluteString] hasPrefix:@"/"]) { + [menuItem setTitle:[NSString stringWithFormat:NSLocalizedString(@"Open “%@” in New Window", @"menu item open “%@” in new window"), [[[[self fileURL] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; + return YES; + } else { + [menuItem setTitle:NSLocalizedString(@"Open in New Window", @"menu item open in new window")]; + return NO; + } + } + if ([menuItem action] == @selector(import:) || [menuItem action] == @selector(export:) || [menuItem action] == @selector(exportMultipleTables:) || -- cgit v1.2.3