aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPAppController.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-11-23 01:47:52 +0000
committerrowanbeentje <rowan@beent.je>2010-11-23 01:47:52 +0000
commitfe9a592ca3be829570f5bd88efd5b427120556e5 (patch)
tree7ccaa095207ae6f2d85b54f6954589f6c3650801 /Source/SPAppController.m
parent6b023e9b57269c4cbdd53f8fc6ca58a6ac563c7f (diff)
downloadsequelpro-fe9a592ca3be829570f5bd88efd5b427120556e5.tar.gz
sequelpro-fe9a592ca3be829570f5bd88efd5b427120556e5.tar.bz2
sequelpro-fe9a592ca3be829570f5bd88efd5b427120556e5.zip
- Abstract SPDatabaseDocument's Connection/.spf saving/loading functionality into state setting and getting functions, and refactor old commands to use them
- Fix restoring of content sort column order and selected indexes - Add menu items for duplicating current tab (as an alternate), opening selected table in a new tab, or opening selected database in a new tab - Clean up file menu by making Connection/Session "Save as..." menu items alternates - Update localisable strings
Diffstat (limited to 'Source/SPAppController.m')
-rw-r--r--Source/SPAppController.m39
1 files changed, 36 insertions, 3 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 534b3741..c5704f80 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -124,10 +124,14 @@
return NO;
}
- if([menuItem action] == @selector(newTab:))
+ if ([menuItem action] == @selector(newTab:))
{
return ([[self frontDocumentWindow] attachedSheet] == nil);
}
+ if ([menuItem action] == @selector(duplicateTab:))
+ {
+ return ([[self frontDocument] getConnection] != nil);
+ }
return YES;
}
@@ -319,7 +323,7 @@
[frontController addNewConnection:self];
}
- [[self frontDocument] initWithConnectionFile:filename];
+ [[self frontDocument] setStateFromConnectionFile:filename];
}
else if([[[filename pathExtension] lowercaseString] isEqualToString:[SPBundleFileExtension lowercaseString]]) {
@@ -418,7 +422,7 @@
[newWindowController addNewConnection:self];
[[self frontDocument] setIsSavedInBundle:isBundleFile];
- [[self frontDocument] initWithConnectionFile:fileName];
+ [[self frontDocument] setStateFromConnectionFile:fileName];
}
} else {
@@ -657,6 +661,35 @@
}
/**
+ * Duplicate the current connection tab
+ */
+- (IBAction)duplicateTab:(id)sender
+{
+ SPDatabaseDocument *theFrontDocument = [self frontDocument];
+ if (!theFrontDocument) return [self newTab:sender];
+
+ // Add a new tab to the window
+ if ([[self frontDocumentWindow] isMiniaturized]) [[self frontDocumentWindow] deminiaturize:self];
+ [[[self frontDocumentWindow] windowController] addNewConnection:self];
+
+ // Get the state of the previously-frontmost document
+ NSDictionary *allStateDetails = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithBool:YES], @"connection",
+ [NSNumber numberWithBool:YES], @"history",
+ [NSNumber numberWithBool:YES], @"session",
+ [NSNumber numberWithBool:YES], @"query",
+ [NSNumber numberWithBool:YES], @"password",
+ nil];
+ NSMutableDictionary *theFrontState = [NSMutableDictionary dictionaryWithDictionary:[theFrontDocument stateIncludingDetails:allStateDetails]];
+
+ // Ensure it's set to autoconnect
+ [theFrontState setObject:[NSNumber numberWithBool:YES] forKey:@"auto_connect"];
+
+ // Set the connection on the new tab
+ [[self frontDocument] setState:theFrontState];
+}
+
+/**
* Retrieve the frontmost document window; returns nil if not found.
*/
- (NSWindow *) frontDocumentWindow