aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPWindowController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2011-05-09 20:08:53 +0000
committerstuconnolly <stuart02@gmail.com>2011-05-09 20:08:53 +0000
commit5914260a1ca2db3da190fde077145756ba169bf4 (patch)
tree88e05c7abf6e3832da2e1ae6b57068700610fd3a /Source/SPWindowController.m
parent4efbaf34545f7a11baf3b426b8a9b1c25f4f93c7 (diff)
downloadsequelpro-5914260a1ca2db3da190fde077145756ba169bf4.tar.gz
sequelpro-5914260a1ca2db3da190fde077145756ba169bf4.tar.bz2
sequelpro-5914260a1ca2db3da190fde077145756ba169bf4.zip
Add the ability to double click a tab to duplicate the connection in a new tab (equivalent to the 'Open Database in New Tab' menu item). Implements issue #1040.
Diffstat (limited to 'Source/SPWindowController.m')
-rw-r--r--Source/SPWindowController.m20
1 files changed, 17 insertions, 3 deletions
diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m
index c097e711..ed18335d 100644
--- a/Source/SPWindowController.m
+++ b/Source/SPWindowController.m
@@ -42,7 +42,7 @@
/**
* awakeFromNib
*/
-- (void) awakeFromNib
+- (void)awakeFromNib
{
selectedTableDocument = nil;
@@ -67,9 +67,13 @@
[tabBar setTearOffStyle:PSMTabBarTearOffAlphaWindow];
[tabBar setUsesSafariStyleDragging:YES];
- // hook up add tab button
+ // Hook up add tab button
[tabBar setCreateNewTabTarget:self];
[tabBar setCreateNewTabAction:@selector(addNewConnection:)];
+
+ // Set the double click target and action
+ [tabBar setDoubleClickTarget:self];
+ [tabBar setDoubleClickAction:@selector(openDatabaseInNewTab)];
// Retrieve references to the 'Close Window' and 'Close Tab' menus. These are updated as window focus changes.
closeWindowMenuItem = [[[[NSApp mainMenu] itemWithTag:SPMainMenuFile] submenu] itemWithTag:1003];
@@ -100,7 +104,6 @@
*/
- (IBAction) addNewConnection:(id)sender
{
-
// Create a new database connection view
SPDatabaseDocument *newTableDocument = [[SPDatabaseDocument alloc] init];
[newTableDocument setParentWindowController:self];
@@ -326,11 +329,22 @@
}
}
+
- (void)setHideForSingleTab:(BOOL)hide
{
[tabBar setHideForSingleTab:hide];
}
+/**
+ * Opens the current connection in a new tab, but only if it's already connected.
+ */
+- (void)openDatabaseInNewTab
+{
+ if ([selectedTableDocument database]) {
+ [selectedTableDocument openDatabaseInNewTab:self];
+ }
+}
+
#pragma mark -
#pragma mark Tab view delegate methods