aboutsummaryrefslogtreecommitdiffstats
path: root/Source/MainController.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-04-10 15:34:14 +0000
committerrowanbeentje <rowan@beent.je>2009-04-10 15:34:14 +0000
commit06a412a95e9882c71d40272999f65a89e3447564 (patch)
tree9d48b50c6d322ef3787aec3d394940cafa976628 /Source/MainController.m
parenta199e73f7acf177cf197fea3e4dc0abe2ab4789b (diff)
downloadsequelpro-06a412a95e9882c71d40272999f65a89e3447564.tar.gz
sequelpro-06a412a95e9882c71d40272999f65a89e3447564.tar.bz2
sequelpro-06a412a95e9882c71d40272999f65a89e3447564.zip
- Make MainController the application delegate, and override standard automatic creation methods to only trigger automatic connection (if enabled in prefs) for automatically created windows
Diffstat (limited to 'Source/MainController.m')
-rw-r--r--Source/MainController.m22
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/MainController.m b/Source/MainController.m
index 06f5d739..2e80e396 100644
--- a/Source/MainController.m
+++ b/Source/MainController.m
@@ -131,6 +131,28 @@
#pragma mark Other methods
/**
+ * Override the default open-blank-document methods to automatically connect
+ * automatically opened windows.
+ */
+- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
+{
+ TableDocument *firstTableDocument;
+
+ // Manually open a new document, setting MainController as sender to trigger autoconnection
+ if (firstTableDocument = [[NSDocumentController sharedDocumentController] makeUntitledDocumentOfType:@"DocumentType" error:nil]) {
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AutoConnectToDefault"]) {
+ [firstTableDocument setShouldAutomaticallyConnect:YES];
+ }
+ [[NSDocumentController sharedDocumentController] addDocument:firstTableDocument];
+ [firstTableDocument makeWindowControllers];
+ [firstTableDocument showWindows];
+ }
+
+ // Return NO to the automatic opening
+ return NO;
+}
+
+/**
* What exactly is this for?
*/
- (id)handleQuitScriptCommand:(NSScriptCommand *)command