aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SharedSupport/Default Bundles/CopySingleLineQuoted.spBundle/command.plist2
-rw-r--r--SharedSupport/Default Bundles/DB Report.spBundle/command.plist2
-rw-r--r--SharedSupport/Default Bundles/WrapInDelimiter.spBundle/command.plist2
-rw-r--r--Source/SPAppController.m142
4 files changed, 73 insertions, 75 deletions
diff --git a/SharedSupport/Default Bundles/CopySingleLineQuoted.spBundle/command.plist b/SharedSupport/Default Bundles/CopySingleLineQuoted.spBundle/command.plist
index 45d4bf86..56cdd9c4 100644
--- a/SharedSupport/Default Bundles/CopySingleLineQuoted.spBundle/command.plist
+++ b/SharedSupport/Default Bundles/CopySingleLineQuoted.spBundle/command.plist
@@ -43,5 +43,7 @@ Version 1.0
<string>Takes the current query or the selection and copies it as a single line quoted multi-line string by appending a ; into the pasteboard</string>
<key>uuid</key>
<string>CDAC825A-AE80-4544-9DBB-8E68A5C540D0</string>
+ <key>isDefaultBundle</key>
+ <true/>
</dict>
</plist>
diff --git a/SharedSupport/Default Bundles/DB Report.spBundle/command.plist b/SharedSupport/Default Bundles/DB Report.spBundle/command.plist
index 03e50adf..e6c808ae 100644
--- a/SharedSupport/Default Bundles/DB Report.spBundle/command.plist
+++ b/SharedSupport/Default Bundles/DB Report.spBundle/command.plist
@@ -168,5 +168,7 @@ Version 1.0</string>
<string>Display report about all databases of the current connection</string>
<key>uuid</key>
<string>AC45C093-9157-4E18-9683-C94415995935</string>
+ <key>isDefaultBundle</key>
+ <true/>
</dict>
</plist>
diff --git a/SharedSupport/Default Bundles/WrapInDelimiter.spBundle/command.plist b/SharedSupport/Default Bundles/WrapInDelimiter.spBundle/command.plist
index 93816f00..3588396e 100644
--- a/SharedSupport/Default Bundles/WrapInDelimiter.spBundle/command.plist
+++ b/SharedSupport/Default Bundles/WrapInDelimiter.spBundle/command.plist
@@ -41,5 +41,7 @@ Version 1.0</string>
<string>Wrap the current query or selection in DELIMITER ;;</string>
<key>uuid</key>
<string>A67BDE10-0A76-45C2-98DB-B35AC731E8DA</string>
+ <key>isDefaultBundle</key>
+ <true/>
</dict>
</plist>
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 273758ba..c03a9394 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -1346,7 +1346,8 @@
// Clean menu
[menu compatibleRemoveAllItems];
- // Set up the bundle search paths - always the default bundles directory, and the application support directory if it exists
+ // Set up the bundle search paths
+ // First process all in Application Support folder installed ones then Default ones
NSFileManager *fm = [NSFileManager defaultManager];
NSError *appPathError = nil;
NSArray *bundlePaths = [NSArray arrayWithObjects:
@@ -1354,6 +1355,7 @@
[NSString stringWithFormat:@"%@/Contents/SharedSupport/Default Bundles", [[NSBundle mainBundle] bundlePath]],
nil];
+ // If ~/Library/Application Path/Sequel Pro/Bundles couldn't be created bail
if(appPathError != nil) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Bundles Installation Error", @"bundles installation error")
defaultButton:NSLocalizedString(@"OK", @"OK button")
@@ -1427,7 +1429,7 @@
}
if(bundleWasDeleted) continue;
- // If default Bundle is already install check for possible update,
+ // If default Bundle is already installed check for possible update,
// if so duplicate the modified one by appending (user) and updated it
if(doBundleUpdate || [installedBundleUUIDs objectForKey:[cmdData objectForKey:SPBundleFileUUIDKey]] == nil) {
@@ -1522,97 +1524,87 @@
infoPath = [NSString stringWithString:newInfoPath];
}
- [installedBundleUUIDs setObject:[NSDictionary dictionaryWithObjectsAndKeys:
- [NSString stringWithFormat:@"%@ (%@)", bundle, [cmdData objectForKey:SPBundleFileNameKey]], @"name",
- infoPath, @"path", nil] forKey:[cmdData objectForKey:SPBundleFileUUIDKey]];
-
- // Remove updated Bundle from already set bundleItems
- NSString *anUuid = [cmdData objectForKey:SPBundleFileUUIDKey];
- for(NSDictionary* item in [bundleItems objectForKey:[cmdData objectForKey:SPBundleFileScopeKey]]) {
- if([[item objectForKey:SPBundleFileUUIDKey] isEqualToString:anUuid]) {
- [[bundleItems objectForKey:[cmdData objectForKey:SPBundleFileScopeKey]] removeObject:item];
- break;
- }
- }
-
- } else {
- [installedBundleUUIDs setObject:[NSDictionary dictionaryWithObjectsAndKeys:
- [NSString stringWithFormat:@"%@ (%@)", bundle, [cmdData objectForKey:SPBundleFileNameKey]], @"name",
- infoPath, @"path", nil] forKey:[cmdData objectForKey:SPBundleFileUUIDKey]];
}
+ [installedBundleUUIDs setObject:[NSDictionary dictionaryWithObjectsAndKeys:
+ [NSString stringWithFormat:@"%@ (%@)", bundle, [cmdData objectForKey:SPBundleFileNameKey]], @"name",
+ infoPath, @"path", nil] forKey:[cmdData objectForKey:SPBundleFileUUIDKey]];
+
} else {
NSLog(@"No UUID for %@", bundle);
NSBeep();
continue;
}
- NSString *scope = [cmdData objectForKey:SPBundleFileScopeKey];
-
- if(![bundleUsedScopes containsObject:scope]) {
- [bundleUsedScopes addObject:scope];
- [bundleItems setObject:[NSMutableArray array] forKey:scope];
- [bundleCategories setObject:[NSMutableArray array] forKey:scope];
- [bundleKeyEquivalents setObject:[NSMutableDictionary dictionary] forKey:scope];
- }
+ // Register Bundle - do it for default Bundles only while processDefaultBundles
+ if(![cmdData objectForKey:SPBundleFileIsDefaultBundleKey] || processDefaultBundles) {
+ NSString *scope = [cmdData objectForKey:SPBundleFileScopeKey];
- if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length] && ![[bundleCategories objectForKey:scope] containsObject:[cmdData objectForKey:SPBundleFileCategoryKey]])
- [[bundleCategories objectForKey:scope] addObject:[cmdData objectForKey:SPBundleFileCategoryKey]];
-
- NSMutableDictionary *aDict = [NSMutableDictionary dictionary];
- [aDict setObject:[cmdData objectForKey:SPBundleFileNameKey] forKey:SPBundleInternLabelKey];
- [aDict setObject:infoPath forKey:SPBundleInternPathToFileKey];
- [aDict setObject:[cmdData objectForKey:SPBundleFileUUIDKey] forKey:SPBundleFileUUIDKey];
-
- // Register trigger
- if([cmdData objectForKey:SPBundleFileTriggerKey]) {
- if(![bundleTriggers objectForKey:[cmdData objectForKey:SPBundleFileTriggerKey]])
- [bundleTriggers setObject:[NSMutableArray array] forKey:[cmdData objectForKey:SPBundleFileTriggerKey]];
- [[bundleTriggers objectForKey:[cmdData objectForKey:SPBundleFileTriggerKey]] addObject:
- [NSString stringWithFormat:@"%@|%@|%@",
- infoPath,
- [cmdData objectForKey:SPBundleFileScopeKey],
- ([[cmdData objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionShowAsHTML])?[cmdData objectForKey:SPBundleFileUUIDKey]:@""]];
- }
+ // Register scope/category menu structure
+ if(![bundleUsedScopes containsObject:scope]) {
+ [bundleUsedScopes addObject:scope];
+ [bundleItems setObject:[NSMutableArray array] forKey:scope];
+ [bundleCategories setObject:[NSMutableArray array] forKey:scope];
+ [bundleKeyEquivalents setObject:[NSMutableDictionary dictionary] forKey:scope];
+ }
+ if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length] && ![[bundleCategories objectForKey:scope] containsObject:[cmdData objectForKey:SPBundleFileCategoryKey]])
+ [[bundleCategories objectForKey:scope] addObject:[cmdData objectForKey:SPBundleFileCategoryKey]];
+
+ NSMutableDictionary *aDict = [NSMutableDictionary dictionary];
+ [aDict setObject:[cmdData objectForKey:SPBundleFileNameKey] forKey:SPBundleInternLabelKey];
+ [aDict setObject:infoPath forKey:SPBundleInternPathToFileKey];
+
+ // Register trigger
+ if([cmdData objectForKey:SPBundleFileTriggerKey]) {
+ if(![bundleTriggers objectForKey:[cmdData objectForKey:SPBundleFileTriggerKey]])
+ [bundleTriggers setObject:[NSMutableArray array] forKey:[cmdData objectForKey:SPBundleFileTriggerKey]];
+ [[bundleTriggers objectForKey:[cmdData objectForKey:SPBundleFileTriggerKey]] addObject:
+ [NSString stringWithFormat:@"%@|%@|%@",
+ infoPath,
+ [cmdData objectForKey:SPBundleFileScopeKey],
+ ([[cmdData objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionShowAsHTML])?[cmdData objectForKey:SPBundleFileUUIDKey]:@""]];
+ }
- if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length]) {
+ // Register key equivalent
+ if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length]) {
+
+ NSString *theKey = [cmdData objectForKey:SPBundleFileKeyEquivalentKey];
+ NSString *theChar = [theKey substringFromIndex:[theKey length]-1];
+ NSString *theMods = [theKey substringToIndex:[theKey length]-1];
+ NSUInteger mask = 0;
+ if([theMods rangeOfString:@"^"].length) mask = mask | NSControlKeyMask;
+ if([theMods rangeOfString:@"@"].length) mask = mask | NSCommandKeyMask;
+ if([theMods rangeOfString:@"~"].length) mask = mask | NSAlternateKeyMask;
+ if([theMods rangeOfString:@"$"].length) mask = mask | NSShiftKeyMask;
+
+ if(![[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]])
+ [[bundleKeyEquivalents objectForKey:scope] setObject:[NSMutableArray array] forKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]];
+
+ [[[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]] addObject:
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ infoPath, @"path",
+ [cmdData objectForKey:SPBundleFileNameKey], @"title",
+ ([cmdData objectForKey:SPBundleFileTooltipKey]) ?: @"", @"tooltip",
+ nil]];
+
+ [aDict setObject:[NSArray arrayWithObjects:theChar, [NSNumber numberWithInteger:mask], nil] forKey:SPBundleInternKeyEquivalentKey];
+ }
- NSString *theKey = [cmdData objectForKey:SPBundleFileKeyEquivalentKey];
- NSString *theChar = [theKey substringFromIndex:[theKey length]-1];
- NSString *theMods = [theKey substringToIndex:[theKey length]-1];
- NSUInteger mask = 0;
- if([theMods rangeOfString:@"^"].length) mask = mask | NSControlKeyMask;
- if([theMods rangeOfString:@"@"].length) mask = mask | NSCommandKeyMask;
- if([theMods rangeOfString:@"~"].length) mask = mask | NSAlternateKeyMask;
- if([theMods rangeOfString:@"$"].length) mask = mask | NSShiftKeyMask;
+ if([cmdData objectForKey:SPBundleFileTooltipKey] && [[cmdData objectForKey:SPBundleFileTooltipKey] length])
+ [aDict setObject:[cmdData objectForKey:SPBundleFileTooltipKey] forKey:SPBundleFileTooltipKey];
- if(![[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]])
- [[bundleKeyEquivalents objectForKey:scope] setObject:[NSMutableArray array] forKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]];
+ if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length])
+ [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:SPBundleFileCategoryKey];
- [[[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]] addObject:
- [NSDictionary dictionaryWithObjectsAndKeys:
- infoPath, @"path",
- [cmdData objectForKey:SPBundleFileNameKey], @"title",
- ([cmdData objectForKey:SPBundleFileTooltipKey]) ?: @"", @"tooltip",
- nil]];
+ if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length])
+ [aDict setObject:[cmdData objectForKey:SPBundleFileKeyEquivalentKey] forKey:@"key"];
- [aDict setObject:[NSArray arrayWithObjects:theChar, [NSNumber numberWithInteger:mask], nil] forKey:SPBundleInternKeyEquivalentKey];
+ [[bundleItems objectForKey:scope] addObject:aDict];
}
-
- if([cmdData objectForKey:SPBundleFileTooltipKey] && [[cmdData objectForKey:SPBundleFileTooltipKey] length])
- [aDict setObject:[cmdData objectForKey:SPBundleFileTooltipKey] forKey:SPBundleFileTooltipKey];
-
- if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length])
- [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:SPBundleFileCategoryKey];
-
- if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length])
- [aDict setObject:[cmdData objectForKey:SPBundleFileKeyEquivalentKey] forKey:@"key"];
-
- [[bundleItems objectForKey:scope] addObject:aDict];
-
}
}
+ // Sort items for menus
NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:SPBundleInternLabelKey ascending:YES] autorelease];
for(NSString* scope in [bundleItems allKeys]) {
[[bundleItems objectForKey:scope] sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];