aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-31 19:18:50 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-31 19:18:50 +0000
commit26865c7ea66092de62009cc8f1212863326f4a49 (patch)
treed45f73c6bd07492574c2ab6be19fb2428f684363
parent441ef7b38085eebcd5d05806f70b56ab9a2b0925 (diff)
downloadsequelpro-26865c7ea66092de62009cc8f1212863326f4a49.tar.gz
sequelpro-26865c7ea66092de62009cc8f1212863326f4a49.tar.bz2
sequelpro-26865c7ea66092de62009cc8f1212863326f4a49.zip
• fixed AppleScript crash after calling 'open' without any parameter
- this should fix the issues 108, 1398, 226 , 1157, 1473 • added AppleScript support for command 'print' - it prints the active view • renamed SP classes in sequel-pro.scriptSuite • AppleScript command 'make new document' opens a new window and connects to default automatically if set
-rw-r--r--Resources/Scripting/sequel-pro.scriptSuite6
-rw-r--r--Source/SPAppController.m37
2 files changed, 33 insertions, 10 deletions
diff --git a/Resources/Scripting/sequel-pro.scriptSuite b/Resources/Scripting/sequel-pro.scriptSuite
index 1385660a..0647ee18 100644
--- a/Resources/Scripting/sequel-pro.scriptSuite
+++ b/Resources/Scripting/sequel-pro.scriptSuite
@@ -8,10 +8,12 @@
"Superclass" = "NSCoreSuite.NSApplication";
"SupportedCommands" = {
"NSCoreSuite.Quit" = "handleQuitScriptCommand:";
+ "NSCoreSuite.Open" = "handleOpenScriptCommand:";
+ "NSCoreSuite.Print" = "handlePrintScriptCommand:";
};
"ToManyRelationships" = {
"orderedDocuments" = {
- "Type" = "TableDocument";
+ "Type" = "SPDatabaseDocument";
"AppleEventCode" = "docu";
};
"orderedWindows" = {
@@ -20,7 +22,7 @@
};
};
};
- "TableDocument" = {
+ "SPDatabaseDocument" = {
"Superclass" = "NSCoreSuite.NSDocument";
"AppleEventCode" = "docu";
};
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 88890c46..c6d89c02 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -199,6 +199,7 @@
*/
- (void)application:(NSApplication *)app openFiles:(NSArray *)filenames
{
+
for (NSString *filename in filenames)
{
// Opens a sql file and insert its content into the Custom Query editor
@@ -889,7 +890,7 @@
// }
// - (void)handleOpenEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
// {
-// NSLog(@"OPEN %@", [event description]);
+// NSLog(@"OPEN ");
// }
//
// - (void)applicationWillFinishLaunching:(NSNotification *)aNotification
@@ -898,7 +899,7 @@
// [aeManager setEventHandler:self andSelector:@selector(handleQuitEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
// [aeManager setEventHandler:self andSelector:@selector(handleOpenEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEOpenApplication];
// }
-//
+
/**
* Is needed to interact with AppleScript for set/get internal SP variables
@@ -933,12 +934,12 @@
- (void)insertInOrderedDocuments:(SPDatabaseDocument *)doc
{
[self newWindow:self];
-/* if ([[NSUserDefaults standardUserDefaults] boolForKey:SPAutoConnectToDefault])
- [doc setShouldAutomaticallyConnect:YES];
-
- [[NSDocumentController sharedDocumentController] addDocument:doc];
- [doc makeWindowControllers];
- [doc showWindows];*/
+
+ // Set autoconnection if appropriate
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:SPAutoConnectToDefault]) {
+ [[self frontDocument] connect];
+ }
+
}
/**
@@ -959,6 +960,26 @@
return nil;
}
+/**
+ * AppleScript handler
+ * This handler is needed to catch an 'open' command if no argument was passed which would cause a crash
+ */
+- (id)handleOpenScriptCommand:(NSScriptCommand *)command
+{
+ return nil;
+}
+
+/**
+ * AppleScript handler for print
+ * This handler prints the active view
+ */
+- (id)handlePrintScriptCommand:(NSScriptCommand *)command
+{
+ SPDatabaseDocument *frontDoc = [self frontDocument];
+ if (frontDoc && ![frontDoc isWorking] && ![[frontDoc connectionID] isEqualToString:@"_"])
+ [frontDoc startPrintDocumentOperation];
+}
+
#pragma mark -
/**