aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/MainMenu.xib71
-rw-r--r--Source/SPWindowController.h2
-rw-r--r--Source/SPWindowController.m95
3 files changed, 138 insertions, 30 deletions
diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib
index 5ae45696..27b5bfc8 100644
--- a/Interfaces/English.lproj/MainMenu.xib
+++ b/Interfaces/English.lproj/MainMenu.xib
@@ -2,18 +2,16 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">10D2094</string>
+ <string key="IBDocument.SystemVersion">10F569</string>
<string key="IBDocument.InterfaceBuilderVersion">762</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
- <string key="IBDocument.HIToolboxVersion">460.00</string>
+ <string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">762</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="956"/>
- <integer value="29"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1746,7 +1744,6 @@
</object>
<object class="NSMenuItem" id="875212976">
<reference key="NSMenu" ref="850647710"/>
- <bool key="NSIsHidden">YES</bool>
<string key="NSTitle">Move Tab to New Window</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
@@ -2942,14 +2939,6 @@
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
- <string key="label">openSelectedTabInNewWindow:</string>
- <reference key="source" ref="63651044"/>
- <reference key="destination" ref="875212976"/>
- </object>
- <int key="connectionID">1110</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
<string key="label">newTab:</string>
<reference key="source" ref="63651044"/>
<reference key="destination" ref="363338347"/>
@@ -2964,6 +2953,14 @@
</object>
<int key="connectionID">1114</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">moveSelectedTabInNewWindow:</string>
+ <reference key="source" ref="63651044"/>
+ <reference key="destination" ref="875212976"/>
+ </object>
+ <int key="connectionID">1115</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -4788,7 +4785,7 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
- <string>{{528, 322}, {269, 143}}</string>
+ <string>{{485, 542}, {269, 143}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{449, 1007}, {197, 53}}</string>
@@ -5035,7 +5032,7 @@
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{719, 367}, {258, 93}}</string>
+ <string>{{671, 367}, {258, 93}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -5069,7 +5066,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">1114</int>
+ <int key="maxID">1115</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -6517,6 +6514,48 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">SPWindowController</string>
+ <string key="superclassName">NSWindowController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>addNewConnection:</string>
+ <string>closeTab:</string>
+ <string>moveSelectedTabInNewWindow:</string>
+ <string>selectNextDocumentTab:</string>
+ <string>selectPreviousDocumentTab:</string>
+ <string>updateAllTabTitles:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>tabBar</string>
+ <string>tabView</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>PSMTabBarControl</string>
+ <string>NSTabView</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBDocumentRelativeSource</string>
+ <string key="minorKey">../../Source/SPWindowController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">SUUpdater</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
diff --git a/Source/SPWindowController.h b/Source/SPWindowController.h
index 28186901..88b3e3a2 100644
--- a/Source/SPWindowController.h
+++ b/Source/SPWindowController.h
@@ -39,7 +39,7 @@
// Database connection management
- (IBAction) addNewConnection:(id)sender;
-- (IBAction) openSelectedTabInNewWindow:(id)sender;
+- (IBAction) moveSelectedTabInNewWindow:(id)sender;
- (SPDatabaseDocument *) selectedTableDocument;
- (void) updateSelectedTableDocument;
- (void) updateAllTabTitles:(id)sender;
diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m
index eaa98997..e5e2ca13 100644
--- a/Source/SPWindowController.m
+++ b/Source/SPWindowController.m
@@ -153,7 +153,7 @@
/**
* Close the current tab, or if it's the last in the window, the window.
*/
-- (IBAction)closeTab:(id)sender
+- (IBAction) closeTab:(id)sender
{
// Return if the selected tab shouldn't be closed
@@ -170,7 +170,7 @@
/**
* Select next tab; if last select first one.
*/
-- (IBAction)selectNextDocumentTab:(id)sender
+- (IBAction) selectNextDocumentTab:(id)sender
{
if([tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == [tabView numberOfTabViewItems] - 1)
[tabView selectFirstTabViewItem:nil];
@@ -181,7 +181,7 @@
/**
* Select previous tab; if first select last one.
*/
-- (IBAction)selectPreviousDocumentTab:(id)sender
+- (IBAction) selectPreviousDocumentTab:(id)sender
{
if([tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == 0)
[tabView selectLastTabViewItem:nil];
@@ -190,18 +190,92 @@
}
/**
- * Menu validation
+ * Move the currently selected tab to a new window.
*/
-- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
+- (IBAction) moveSelectedTabInNewWindow:(id)sender
{
- // Select Next/Previous Tab
- if ([menuItem action] == @selector(selectPreviousDocumentTab:) || [menuItem action] == @selector(selectNextDocumentTab:)) {
- return ([tabView numberOfTabViewItems] != 1);
+
+ static NSPoint cascadeLocation = {.x = 0, .y = 0};
+
+ SPDatabaseDocument *selectedDocument = [[tabView selectedTabViewItem] identifier];
+ NSTabViewItem *selectedTabViewItem = [tabView selectedTabViewItem];
+ PSMTabBarCell *selectedCell = [[tabBar cells] objectAtIndex:[tabView indexOfTabViewItem:selectedTabViewItem]];
+
+ SPWindowController *newWindowController = [[SPWindowController alloc] initWithWindowNibName:@"MainWindow"];
+ NSWindow *newWindow = [newWindowController window];
+
+ CGFloat toolbarHeight = 0;
+ if ([[[self window] toolbar] isVisible]) {
+ NSRect innerFrame = [NSWindow contentRectForFrameRect:[[self window] frame] styleMask:[[self window] styleMask]];
+ toolbarHeight = innerFrame.size.height - [[[self window] contentView] frame].size.height;
}
+ // Set the new window position and size
+ NSRect targetWindowFrame = [[self window] frame];
+ targetWindowFrame.size.height -= toolbarHeight;
+ [newWindow setFrame:targetWindowFrame display:NO];
+
+ // Cascade according to the statically stored cascade location.
+ cascadeLocation = [newWindow cascadeTopLeftFromPoint:cascadeLocation];
+
+ // Set the window controller as the window's delegate
+ [newWindow setDelegate:newWindowController];
+
+ // Set window title
+ [newWindow setTitle:[[[[tabView selectedTabViewItem] identifier] parentWindow] title]];
+
+ // New window's tabBar control
+ PSMTabBarControl *control = [newWindowController valueForKey:@"tabBar"];
+
+ // Add the selected tab to the new window
+ [[control cells] insertObject:selectedCell atIndex:0];
+
+ // Remove 'isProcessing' observer from old windowController
+ [selectedDocument removeObserver:self forKeyPath:@"isProcessing"];
+
+ // Update new 'isProcessing' observer and bind the new tab bar's progress display to the document
+ [self _updateProgressIndicatorForItem:selectedTabViewItem];
+
+ //remove the tracking rects and bindings registered on the old tab
+ [tabBar removeTrackingRect:[selectedCell closeButtonTrackingTag]];
+ [tabBar removeTrackingRect:[selectedCell cellTrackingTag]];
+ [tabBar removeTabForCell:selectedCell];
+
+ //rebind the selected cell to the new control
+ [control bindPropertiesForCell:selectedCell andTabViewItem:selectedTabViewItem];
+
+ [selectedCell setControlView:control];
+
+ [[tabBar tabView] removeTabViewItem:[selectedCell representedObject]];
+
+ [[control tabView] addTabViewItem:selectedTabViewItem];
+
+ [control update:NO]; //make sure the new tab is set in the correct position
+
+ // Update tabBar of the new window
+ [newWindowController tabView:[tabBar tabView] didDropTabViewItem:[selectedCell representedObject] inTabBar:control];
+
+ [newWindow makeKeyAndOrderFront:nil];
+
+}
+
+/**
+ * Menu validation
+ */
+- (BOOL) validateMenuItem:(NSMenuItem *)menuItem
+{
+
// See if the front document blocks validation of this item
if (![selectedTableDocument validateMenuItem:menuItem]) return NO;
+ // Select Next/Previous/Move Tab
+ if ( [menuItem action] == @selector(selectPreviousDocumentTab:)
+ || [menuItem action] == @selector(selectNextDocumentTab:)
+ || [menuItem action] == @selector(moveSelectedTabInNewWindow:))
+ {
+ return ([tabView numberOfTabViewItems] != 1);
+ }
+
return YES;
}
@@ -475,11 +549,6 @@
[tabBar setHideForSingleTab:YES];
}
-- (IBAction) openSelectedTabInNewWindow:(id)sender
-{
- // not yet implemented
-}
-
#pragma mark -
#pragma mark Window delegate methods