From 2183eeefefb81846c2cc2c6b4bf68b12167f2b24 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sun, 27 Sep 2009 13:26:47 +0000 Subject: =?UTF-8?q?=E2=80=A2=20marked=20'sequel-pro-print-template.html'?= =?UTF-8?q?=20as=20localizable=20=E2=80=A2=20outsourced=20default=20QuickL?= =?UTF-8?q?ook=20types=20into=20a=20localizable=20plist=20-=20prepared=20S?= =?UTF-8?q?P=20preferences=20and=20SP=20code=20to=20allow=20the=20user=20t?= =?UTF-8?q?o=20add=20own=20QL=20types=20=E2=80=A2=20prepared=20a=20localiz?= =?UTF-8?q?able=20'ContentFilter.plist'=20[not=20yet=20implemented=20fully?= =?UTF-8?q?]=20-=20this=20plist=20will=20held=20the=20default=20filter=20o?= =?UTF-8?q?perators=20-=20this=20approach=20will=20give=20the=20user=20the?= =?UTF-8?q?=20chance=20to=20add=20own=20filters=20=E2=80=A2=20removed=20th?= =?UTF-8?q?ree=20tiny=20memory=20leaks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: In MCPResult.m variable 'MCPYear0000' was stored retained. Why? I removed it and couldn't encounter any problems. --- Frameworks/MCPKit/MCPFoundationKit/MCPResult.m | 2 +- Resources/English.lproj/ContentFilters.plist | 7 ++ Resources/English.lproj/EditorQuickLookTypes.plist | 89 ++++++++++++++++++++++ .../English.lproj/sequel-pro-print-template.html | 76 ++++++++++++++++++ Resources/PreferenceDefaults.plist | 85 +-------------------- Resources/sequel-pro-print-template.html | 76 ------------------ Source/CustomQuery.m | 2 + Source/SPFieldEditorController.h | 2 + Source/SPFieldEditorController.m | 37 +++++++-- sequel-pro.xcodeproj/project.pbxproj | 40 +++++++++- 10 files changed, 247 insertions(+), 169 deletions(-) create mode 100644 Resources/English.lproj/ContentFilters.plist create mode 100644 Resources/English.lproj/EditorQuickLookTypes.plist create mode 100644 Resources/English.lproj/sequel-pro-print-template.html delete mode 100644 Resources/sequel-pro-print-template.html diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m index bb7bef5e..9d49bda3 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m @@ -228,7 +228,7 @@ const OUR_CHARSET our_charsets60[] = { if (self = [MCPResult class]) { [self setVersion:030001]; // Ma.Mi.Re -> MaMiRe - MCPYear0000 = [[NSCalendarDate dateWithTimeIntervalSinceReferenceDate:-63146822400.0] retain]; + MCPYear0000 = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate:-63146822400.0]; [MCPYear0000 setCalendarFormat:@"%Y"]; } } diff --git a/Resources/English.lproj/ContentFilters.plist b/Resources/English.lproj/ContentFilters.plist new file mode 100644 index 00000000..4768f16b --- /dev/null +++ b/Resources/English.lproj/ContentFilters.plist @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Resources/English.lproj/EditorQuickLookTypes.plist b/Resources/English.lproj/EditorQuickLookTypes.plist new file mode 100644 index 00000000..011124b8 --- /dev/null +++ b/Resources/English.lproj/EditorQuickLookTypes.plist @@ -0,0 +1,89 @@ + + + + + QuickLookTypes + + + MenuLabel + Image + Extension + icns + treatAsText + + + + MenuLabel + Sound (m4a) + Extension + m4a + treatAsText + + + + MenuLabel + Sound (mp3) + Extension + mp3 + treatAsText + + + + MenuLabel + Sound (linear) + Extension + wav + treatAsText + + + + MenuLabel + Movie (mov) + Extension + mov + treatAsText + + + + MenuLabel + PDF + Extension + pdf + treatAsText + + + + MenuLabel + HTML + Extension + html + treatAsText + + + + MenuLabel + Word Document + Extension + doc + treatAsText + + + + MenuLabel + Word Document (xml) + Extension + docx + treatAsText + + + + MenuLabel + RTF + Extension + rtf + treatAsText + + + + + diff --git a/Resources/English.lproj/sequel-pro-print-template.html b/Resources/English.lproj/sequel-pro-print-template.html new file mode 100644 index 00000000..9dd2f624 --- /dev/null +++ b/Resources/English.lproj/sequel-pro-print-template.html @@ -0,0 +1,76 @@ + + + +Sequel Pro + + + + + +

+ Connection: {{c.username}}{% if c.username %}@{% /if %}{{c.hostname}}{% if c.port %}:{% /if %}{{c.port}}/{{c.database}}
+ Generated on: {% now | date_format: "dd MMM yyyy 'at' HH:mm:ss" %} by {{c.version}}
+ {% if c.query %}SQL query: {{c.query}}{% /if %} +
+

+ + +{% for column in columns %}{% /for %} + + + +{% for row in rows %} + + {% for cell in row %}{% /for %} + +{% /for %} + +
{{ column }}
{{ cell }}
+ + diff --git a/Resources/PreferenceDefaults.plist b/Resources/PreferenceDefaults.plist index 825a093d..33964fbb 100644 --- a/Resources/PreferenceDefaults.plist +++ b/Resources/PreferenceDefaults.plist @@ -107,87 +107,8 @@ PrintImagePreviews QuickLookTypes - - - MenuLabel - Image - Extension - icns - treatAsText - - - - MenuLabel - Sound (m4a) - Extension - m4a - treatAsText - - - - MenuLabel - Sound (mp3) - Extension - mp3 - treatAsText - - - - MenuLabel - Sound (linear) - Extension - wav - treatAsText - - - - MenuLabel - Movie (mov) - Extension - mov - treatAsText - - - - MenuLabel - PDF - Extension - pdf - treatAsText - - - - MenuLabel - HTML - Extension - html - treatAsText - - - - MenuLabel - Word Document - Extension - doc - treatAsText - - - - MenuLabel - Word Document (xml) - Extension - docx - treatAsText - - - - MenuLabel - RTF - Extension - rtf - treatAsText - - - + + ContentFilters + diff --git a/Resources/sequel-pro-print-template.html b/Resources/sequel-pro-print-template.html deleted file mode 100644 index 9dd2f624..00000000 --- a/Resources/sequel-pro-print-template.html +++ /dev/null @@ -1,76 +0,0 @@ - - - -Sequel Pro - - - - - -

- Connection: {{c.username}}{% if c.username %}@{% /if %}{{c.hostname}}{% if c.port %}:{% /if %}{{c.port}}/{{c.database}}
- Generated on: {% now | date_format: "dd MMM yyyy 'at' HH:mm:ss" %} by {{c.version}}
- {% if c.query %}SQL query: {{c.query}}{% /if %} -
-

- - -{% for column in columns %}{% /for %} - - - -{% for row in rows %} - - {% for cell in row %}{% /for %} - -{% /for %} - -
{{ column }}
{{ cell }}
- - diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index f393dc45..3f2afc2f 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -2626,6 +2626,8 @@ [usedQuery release]; [fullResult release]; [favoritesManager release]; + if (helpHTMLTemplate) [helpHTMLTemplate release]; + if (mySQLversion) [mySQLversion release]; if (sortField) [sortField release]; [super dealloc]; diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h index 56b7a2bd..6349f568 100644 --- a/Source/SPFieldEditorController.h +++ b/Source/SPFieldEditorController.h @@ -60,6 +60,8 @@ NSUserDefaults *prefs; + NSDictionary *qlTypes; + int editSheetReturnCode; NSUndoManager *esUndoManager; 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])]; } } diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 54069256..9b886ce9 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -119,7 +119,6 @@ 296DC8BB0F909194002A3258 /* NSDictionary_DeepMutableCopy.m in Sources */ = {isa = PBXBuildFile; fileRef = 296DC8B10F909194002A3258 /* NSDictionary_DeepMutableCopy.m */; }; 296DC8BC0F909194002A3258 /* MGTemplateStandardFilters.m in Sources */ = {isa = PBXBuildFile; fileRef = 296DC8B40F909194002A3258 /* MGTemplateStandardFilters.m */; }; 296DC8BF0F9091DF002A3258 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 296DC8BE0F9091DF002A3258 /* libicucore.dylib */; }; - 296DC8D20F90950C002A3258 /* sequel-pro-print-template.html in Resources */ = {isa = PBXBuildFile; fileRef = 296DC8D10F90950C002A3258 /* sequel-pro-print-template.html */; }; 29A1B7E50FD1293A000B88E8 /* SPPrintAccessory.m in Sources */ = {isa = PBXBuildFile; fileRef = 29A1B7E40FD1293A000B88E8 /* SPPrintAccessory.m */; }; 380F4EF50FC0B68F00B0BFD7 /* stringCategoryAdditionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 380F4EF40FC0B68F00B0BFD7 /* stringCategoryAdditionsTest.m */; }; 380F4F250FC0C3D300B0BFD7 /* mcpKitTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 380F4F240FC0C3D300B0BFD7 /* mcpKitTest.m */; }; @@ -232,6 +231,9 @@ BC9F0881100FCF2C00A80D32 /* SPFieldEditorController.m in Sources */ = {isa = PBXBuildFile; fileRef = BC9F0880100FCF2C00A80D32 /* SPFieldEditorController.m */; }; BCA6271C1031B9D40047E5D5 /* SPTooltip.m in Sources */ = {isa = PBXBuildFile; fileRef = BCA6271B1031B9D40047E5D5 /* SPTooltip.m */; }; BCA6F631100FA7D700E80253 /* FieldEditorSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCA6F62F100FA7D700E80253 /* FieldEditorSheet.xib */; }; + BCB56193106F88EC00167321 /* sequel-pro-print-template.html in Resources */ = {isa = PBXBuildFile; fileRef = BCB56192106F88EC00167321 /* sequel-pro-print-template.html */; }; + BCB56197106F893F00167321 /* ContentFilters.plist in Resources */ = {isa = PBXBuildFile; fileRef = BCB56196106F893F00167321 /* ContentFilters.plist */; }; + BCB5619B106F8A1B00167321 /* EditorQuickLookTypes.plist in Resources */ = {isa = PBXBuildFile; fileRef = BCB5619A106F8A1B00167321 /* EditorQuickLookTypes.plist */; }; BCC5CC3C103EEE49007CE557 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 17B7B593101602D200F057DE /* libz.dylib */; }; BCCBD7FC104408B000D4C50A /* SaveSPFAccessory.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCCBD7FA104408B000D4C50A /* SaveSPFAccessory.xib */; }; BCD0AD490FBBFC340066EA5C /* SPSQLTokenizer.l in Sources */ = {isa = PBXBuildFile; fileRef = BCD0AD480FBBFC340066EA5C /* SPSQLTokenizer.l */; }; @@ -485,7 +487,6 @@ 296DC8B40F909194002A3258 /* MGTemplateStandardFilters.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGTemplateStandardFilters.m; sourceTree = ""; }; 296DC8B50F909194002A3258 /* MGTemplateStandardFilters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGTemplateStandardFilters.h; sourceTree = ""; }; 296DC8BE0F9091DF002A3258 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = usr/lib/libicucore.dylib; sourceTree = SDKROOT; }; - 296DC8D10F90950C002A3258 /* sequel-pro-print-template.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "sequel-pro-print-template.html"; sourceTree = ""; }; 29A1B7E30FD1293A000B88E8 /* SPPrintAccessory.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = SPPrintAccessory.h; sourceTree = ""; }; 29A1B7E40FD1293A000B88E8 /* SPPrintAccessory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPPrintAccessory.m; sourceTree = ""; wrapsLines = 1; }; 29A1B7EA0FD12E55000B88E8 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/PrintAccessory.xib; sourceTree = ""; }; @@ -624,6 +625,9 @@ BCA6271A1031B9D40047E5D5 /* SPTooltip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPTooltip.h; sourceTree = ""; }; BCA6271B1031B9D40047E5D5 /* SPTooltip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPTooltip.m; sourceTree = ""; }; BCA6F630100FA7D700E80253 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/FieldEditorSheet.xib; sourceTree = ""; }; + BCB56190106F88E300167321 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = English; path = "English.lproj/sequel-pro-print-template.html"; sourceTree = ""; }; + BCB56194106F893700167321 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = English; path = English.lproj/ContentFilters.plist; sourceTree = ""; }; + BCB56198106F8A1600167321 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = English; path = English.lproj/EditorQuickLookTypes.plist; sourceTree = ""; }; BCCBD7FB104408B000D4C50A /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/SaveSPFAccessory.xib; sourceTree = ""; }; BCD0AD480FBBFC340066EA5C /* SPSQLTokenizer.l */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.lex; path = SPSQLTokenizer.l; sourceTree = ""; }; BCD0AD4A0FBBFC480066EA5C /* SPSQLTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPSQLTokenizer.h; sourceTree = ""; }; @@ -751,7 +755,7 @@ 1740F8350FC3069700CF3699 /* Templates */ = { isa = PBXGroup; children = ( - 296DC8D10F90950C002A3258 /* sequel-pro-print-template.html */, + BCB56192106F88EC00167321 /* sequel-pro-print-template.html */, BC2C8E210FA8C2DB008468C7 /* sequel-pro-mysql-help-template.html */, ); name = Templates; @@ -774,6 +778,8 @@ 17DA04EA0FC1A7DA00D66140 /* Unit Tests-Info.plist */, B58731270F838C9E00087794 /* PreferenceDefaults.plist */, 17B7B58B1016022C00F057DE /* MCPKit-Info.plist */, + BCB56196106F893F00167321 /* ContentFilters.plist */, + BCB5619A106F8A1B00167321 /* EditorQuickLookTypes.plist */, ); name = Plists; sourceTree = ""; @@ -1520,7 +1526,6 @@ B58730EB0F8381A600087794 /* toolbar-preferences-autoupdate.tiff in Resources */, B58731280F838C9E00087794 /* PreferenceDefaults.plist in Resources */, B52460DB0F8EF93B00171639 /* Console.xib in Resources */, - 296DC8D20F90950C002A3258 /* sequel-pro-print-template.html in Resources */, B508B5DA0F9837A200E03A69 /* button_edit.tiff in Resources */, B53857340F9CC3B600EB2354 /* button_clear.tiff in Resources */, BC2C8E220FA8C2DB008468C7 /* sequel-pro-mysql-help-template.html in Resources */, @@ -1555,6 +1560,9 @@ BC8B0DAF104004F900FC02EC /* EncodingPopupView.xib in Resources */, BCCBD7FC104408B000D4C50A /* SaveSPFAccessory.xib in Resources */, 173C4362104455CA001F3A30 /* QueryFavoriteManager.xib in Resources */, + BCB56193106F88EC00167321 /* sequel-pro-print-template.html in Resources */, + BCB56197106F893F00167321 /* ContentFilters.plist in Resources */, + BCB5619B106F8A1B00167321 /* EditorQuickLookTypes.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1864,6 +1872,30 @@ name = FieldEditorSheet.xib; sourceTree = ""; }; + BCB56192106F88EC00167321 /* sequel-pro-print-template.html */ = { + isa = PBXVariantGroup; + children = ( + BCB56190106F88E300167321 /* English */, + ); + name = "sequel-pro-print-template.html"; + sourceTree = ""; + }; + BCB56196106F893F00167321 /* ContentFilters.plist */ = { + isa = PBXVariantGroup; + children = ( + BCB56194106F893700167321 /* English */, + ); + name = ContentFilters.plist; + sourceTree = ""; + }; + BCB5619A106F8A1B00167321 /* EditorQuickLookTypes.plist */ = { + isa = PBXVariantGroup; + children = ( + BCB56198106F8A1600167321 /* English */, + ); + name = EditorQuickLookTypes.plist; + sourceTree = ""; + }; BCCBD7FA104408B000D4C50A /* SaveSPFAccessory.xib */ = { isa = PBXVariantGroup; children = ( -- cgit v1.2.3