aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Frameworks/PSMTabBar/PSMTabBarControl.h67
-rw-r--r--Frameworks/PSMTabBar/PSMTabBarControl.m25
-rw-r--r--Source/SPDatabaseDocument.m7
-rw-r--r--Source/SPWindowController.h10
-rw-r--r--Source/SPWindowController.m20
5 files changed, 83 insertions, 46 deletions
diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.h b/Frameworks/PSMTabBar/PSMTabBarControl.h
index 663bb74e..481bb3b8 100644
--- a/Frameworks/PSMTabBar/PSMTabBarControl.h
+++ b/Frameworks/PSMTabBar/PSMTabBarControl.h
@@ -66,53 +66,55 @@ enum {
// Spring-loading.
NSTimer *_springTimer;
- NSTabViewItem *_tabViewItemWithSpring;
+ NSTabViewItem *_tabViewItemWithSpring;
// drawing style
id<PSMTabStyle> style;
- BOOL _canCloseOnlyTab;
- BOOL _disableTabClose;
- BOOL _hideForSingleTab;
- BOOL _showAddTabButton;
- BOOL _sizeCellsToFit;
- BOOL _useOverflowMenu;
- BOOL _alwaysShowActiveTab;
- BOOL _allowsScrubbing;
- BOOL _useSafariStyleDragging;
- NSInteger _resizeAreaCompensation;
- PSMTabBarOrientation _orientation;
- BOOL _automaticallyAnimates;
+ BOOL _canCloseOnlyTab;
+ BOOL _disableTabClose;
+ BOOL _hideForSingleTab;
+ BOOL _showAddTabButton;
+ BOOL _sizeCellsToFit;
+ BOOL _useOverflowMenu;
+ BOOL _alwaysShowActiveTab;
+ BOOL _allowsScrubbing;
+ BOOL _useSafariStyleDragging;
+ NSInteger _resizeAreaCompensation;
+ PSMTabBarOrientation _orientation;
+ BOOL _automaticallyAnimates;
NSTimer *_animationTimer;
PSMTabBarTearOffStyle _tearOffStyle;
// behavior
- BOOL _allowsBackgroundTabClosing;
- BOOL _selectsTabsOnMouseDown;
- BOOL _createsTabOnDoubleClick;
- id _createNewTabTarget;
- SEL _createNewTabAction;
+ BOOL _allowsBackgroundTabClosing;
+ BOOL _selectsTabsOnMouseDown;
+ BOOL _createsTabOnDoubleClick;
+ id _createNewTabTarget;
+ SEL _createNewTabAction;
+ id _doubleClickTarget;
+ SEL _doubleClickAction;
// vertical tab resizing
- BOOL _allowsResizing;
- BOOL _resizing;
+ BOOL _allowsResizing;
+ BOOL _resizing;
// cell width
- NSInteger _cellMinWidth;
- NSInteger _cellMaxWidth;
- NSInteger _cellOptimumWidth;
+ NSInteger _cellMinWidth;
+ NSInteger _cellMaxWidth;
+ NSInteger _cellOptimumWidth;
// animation for hide/show
- NSInteger _currentStep;
- BOOL _isHidden;
+ NSInteger _currentStep;
+ BOOL _isHidden;
IBOutlet id partnerView; // gets resized when hide/show
- BOOL _awakenedFromNib;
- NSInteger _tabBarWidth;
+ BOOL _awakenedFromNib;
+ NSInteger _tabBarWidth;
NSTimer *_showHideAnimationTimer;
// drag and drop
- NSEvent *_lastMouseDownEvent; // keep this for dragging reference
- BOOL _didDrag;
- BOOL _closeClicked;
+ NSEvent *_lastMouseDownEvent; // keep this for dragging reference
+ BOOL _didDrag;
+ BOOL _closeClicked;
// MVC help
IBOutlet id delegate;
@@ -144,6 +146,11 @@ enum {
- (SEL)createNewTabAction;
- (void)setCreateNewTabAction:(SEL)selector;
+- (id)doubleClickTarget;
+- (void)setDoubleClickTarget:(id)object;
+- (SEL)doubleClickAction;
+- (void)setDoubleClickAction:(SEL)selector;
+
- (NSInteger)cellMinWidth;
- (void)setCellMinWidth:(NSInteger)value;
- (NSInteger)cellMaxWidth;
diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.m b/Frameworks/PSMTabBar/PSMTabBarControl.m
index 028dc84b..a38c50b0 100644
--- a/Frameworks/PSMTabBar/PSMTabBarControl.m
+++ b/Frameworks/PSMTabBar/PSMTabBarControl.m
@@ -471,8 +471,6 @@
[self update];
}
-
-
- (id)createNewTabTarget
{
return _createNewTabTarget;
@@ -495,7 +493,25 @@
[[self addTabButton] setAction:selector];
}
+- (id)doubleClickTarget
+{
+ return _doubleClickTarget;
+}
+
+- (void)setDoubleClickTarget:(id)object
+{
+ _doubleClickTarget = object;
+}
+
+- (SEL)doubleClickAction
+{
+ return _doubleClickAction;
+}
+- (void)setDoubleClickAction:(SEL)selector
+{
+ _doubleClickAction = selector;
+}
- (NSInteger)cellMinWidth
{
@@ -1327,6 +1343,11 @@
[cell setCloseButtonOver:NO];
[cell setCloseButtonPressed:YES];
_closeClicked = YES;
+ }
+ else if ([theEvent clickCount] == 2) {
+ [cell setCloseButtonOver:NO];
+
+ [_doubleClickTarget performSelector:_doubleClickAction withObject:cell];
} else {
[cell setCloseButtonPressed:NO];
if (_selectsTabsOnMouseDown) {
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 44dd929d..c8f926e1 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -80,7 +80,7 @@
// Constants
static NSString *SPCreateSyntx = @"SPCreateSyntax";
-@interface SPDatabaseDocument (PrivateAPI)
+@interface SPDatabaseDocument ()
#ifndef SP_REFACTOR /* method decls */
- (void)_addDatabase;
@@ -3177,7 +3177,6 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax";
*/
- (IBAction)openDatabaseInNewTab:(id)sender
{
-
// Add a new tab to the window
[[parentWindow windowController] addNewConnection:self];
@@ -5607,10 +5606,6 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax";
return tablesListInstance;
}
-@end
-
-@implementation SPDatabaseDocument (PrivateAPI)
-
#ifndef SP_REFACTOR /* whole database operations */
- (void)_copyDatabase
diff --git a/Source/SPWindowController.h b/Source/SPWindowController.h
index 5626c580..ae1e9d27 100644
--- a/Source/SPWindowController.h
+++ b/Source/SPWindowController.h
@@ -37,11 +37,11 @@
}
// Database connection management
-- (IBAction) addNewConnection:(id)sender;
-- (IBAction) moveSelectedTabInNewWindow:(id)sender;
-- (SPDatabaseDocument *) selectedTableDocument;
-- (void) updateSelectedTableDocument;
-- (void) updateAllTabTitles:(id)sender;
+- (IBAction)addNewConnection:(id)sender;
+- (IBAction)moveSelectedTabInNewWindow:(id)sender;
+- (SPDatabaseDocument *)selectedTableDocument;
+- (void)updateSelectedTableDocument;
+- (void)updateAllTabTitles:(id)sender;
- (IBAction)closeTab:(id)sender;
- (IBAction)selectNextDocumentTab:(id)sender;
- (IBAction)selectPreviousDocumentTab:(id)sender;
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