aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFieldEditorController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-09-27 13:26:47 +0000
committerBibiko <bibiko@eva.mpg.de>2009-09-27 13:26:47 +0000
commit2183eeefefb81846c2cc2c6b4bf68b12167f2b24 (patch)
treededc18dc550106e3d889c26fe263b3319f896c06 /Source/SPFieldEditorController.m
parent572b761e971c732585ef5f0fcf852e1842d44e31 (diff)
downloadsequelpro-2183eeefefb81846c2cc2c6b4bf68b12167f2b24.tar.gz
sequelpro-2183eeefefb81846c2cc2c6b4bf68b12167f2b24.tar.bz2
sequelpro-2183eeefefb81846c2cc2c6b4bf68b12167f2b24.zip
• marked 'sequel-pro-print-template.html' as localizable
• outsourced default QuickLook types into a localizable plist - prepared SP preferences and SP code to allow the user to add own QL types • prepared a localizable 'ContentFilter.plist' [not yet implemented fully] - this plist will held the default filter operators - this approach will give the user the chance to add own filters • removed three tiny memory leaks Note: In MCPResult.m variable 'MCPYear0000' was stored retained. Why? I removed it and couldn't encounter any problems.
Diffstat (limited to 'Source/SPFieldEditorController.m')
-rw-r--r--Source/SPFieldEditorController.m37
1 files changed, 31 insertions, 6 deletions
diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m
index 2234681f..bdb78726 100644
--- a/Source/SPFieldEditorController.m
+++ b/Source/SPFieldEditorController.m
@@ -65,6 +65,32 @@
[menu addItem:item];
[item release];
NSUInteger tag = 2;
+
+ // Load default QL types
+ NSMutableArray *qlTypesItems = [[NSMutableArray alloc] init];
+ NSError *readError = nil;
+ NSString *convError = nil;
+ NSPropertyListFormat format;
+
+ NSData *defaultTypeData = [NSData dataWithContentsOfFile:[NSBundle pathForResource:@"EditorQuickLookTypes.plist" ofType:nil inDirectory:[[NSBundle mainBundle] bundlePath]]
+ options:NSMappedRead error:&readError];
+
+ NSDictionary *defaultQLTypes = [NSPropertyListSerialization propertyListFromData:defaultTypeData
+ mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError];
+ if(defaultQLTypes == nil || readError != nil || convError != nil)
+ NSLog(@"Error while reading 'EditorQuickLookTypes.plist':\n%@\n%@", [readError localizedDescription], convError);
+ if(defaultQLTypes != nil && [defaultQLTypes objectForKey:@"QuickLookTypes"]) {
+ for(id type in [defaultQLTypes objectForKey:@"QuickLookTypes"]) {
+ NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithString:[type objectForKey:@"MenuLabel"]] action:NULL keyEquivalent:@""];
+ [item setTag:tag];
+ [item setAction:@selector(quickLookFormatButton:)];
+ [menu addItem:item];
+ [item release];
+ tag++;
+ [qlTypesItems addObject:type];
+ }
+ }
+ // Load user-defined QL types
if([prefs objectForKey:@"QuickLookTypes"]) {
for(id type in [prefs objectForKey:@"QuickLookTypes"]) {
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithString:[type objectForKey:@"MenuLabel"]] action:NULL keyEquivalent:@""];
@@ -73,9 +99,11 @@
[menu addItem:item];
[item release];
tag++;
+ [qlTypesItems addObject:type];
}
}
-
+ qlTypes = [NSDictionary dictionaryWithObject:[qlTypesItems retain] forKey:@"QuickLookTypes"];
+ [qlTypesItems release];
}
return self;
@@ -510,11 +538,8 @@
- (IBAction)quickLookFormatButton:(id)sender
{
-
- id types = [prefs objectForKey:@"QuickLookTypes"];
-
- if(types != nil && [types isKindOfClass:[NSArray class]] && [types count] > [sender tag] - 2) {
- NSDictionary *type = [types objectAtIndex:[sender tag] - 2];
+ if(qlTypes != nil && [[qlTypes objectForKey:@"QuickLookTypes"] count] > [sender tag] - 2) {
+ NSDictionary *type = [[qlTypes objectForKey:@"QuickLookTypes"] objectAtIndex:[sender tag] - 2];
[self invokeQuickLookOfType:[type objectForKey:@"Extension"] treatAsText:([[type objectForKey:@"treatAsText"] intValue])];
}
}