Revision: 28915 http://sourceforge.net/p/bibdesk/svn/28915 Author: hofman Date: 2024-05-16 17:13:14 +0000 (Thu, 16 May 2024) Log Message: ----------- convenience class method for default preview template name
Modified Paths: -------------- trunk/bibdesk/BDSKPreferenceRecord.m trunk/bibdesk/BDSKTemplate.h trunk/bibdesk/BDSKTemplate.m trunk/bibdesk/BibDocument_UI.m Modified: trunk/bibdesk/BDSKPreferenceRecord.m =================================================================== --- trunk/bibdesk/BDSKPreferenceRecord.m 2024-05-16 17:00:14 UTC (rev 28914) +++ trunk/bibdesk/BDSKPreferenceRecord.m 2024-05-16 17:13:14 UTC (rev 28915) @@ -38,6 +38,7 @@ #import "BDSKPreferenceRecord.h" #import "BDSKStringConstants.h" +#import "BDSKTemplate.h" #define IDENTIFIER_KEY @"identifier" #define CLASS_KEY @"class" @@ -59,7 +60,7 @@ static NSDictionary *localizedDictionary(NSDictionary *aDictionary) { if ([[aDictionary objectForKey:IDENTIFIER_KEY] isEqualToString:@"edu.ucsd.cs.mmccrack.bibdesk.prefpane.display"] == NO) return aDictionary; - NSString *templateName = NSLocalizedString(@"Default preview template", @""); + NSString *templateName = [BDSKTemplate defaultPreviewTemplateName]; if ([[[aDictionary objectForKey:INITIAL_VALUES_KEY] objectForKey:BDSKBottomPreviewDisplayTemplateKey] isEqualToString:templateName]) return aDictionary; NSMutableDictionary *dict = [aDictionary mutableCopy]; Modified: trunk/bibdesk/BDSKTemplate.h =================================================================== --- trunk/bibdesk/BDSKTemplate.h 2024-05-16 17:00:14 UTC (rev 28914) +++ trunk/bibdesk/BDSKTemplate.h 2024-05-16 17:13:14 UTC (rev 28915) @@ -64,8 +64,6 @@ // concrete subclass with specific accessors for the template tree @interface BDSKTemplate : BDSKTreeNode -{ -} @property (class, nonatomic, readonly) NSString *localizedAccessoryString; @property (class, nonatomic, readonly) NSString *localizedMainPageString; @@ -81,6 +79,7 @@ // known export style names @property (class, nonatomic, readonly) NSArray *allStyleNames; +@property (class, nonatomic, readonly) NSString *defaultPreviewTemplateName; + (NSArray *)allStyleNamesForFormat:(BDSKTemplateFormat)format; + (NSString *)defaultStyleNameForFileType:(NSString *)fileType; Modified: trunk/bibdesk/BDSKTemplate.m =================================================================== --- trunk/bibdesk/BDSKTemplate.m 2024-05-16 17:00:14 UTC (rev 28914) +++ trunk/bibdesk/BDSKTemplate.m 2024-05-16 17:13:14 UTC (rev 28915) @@ -331,7 +331,7 @@ return; NSArray *templates = [NSKeyedUnarchiver unarchiveObjectWithData:prefData]; - NSString *defaultName = NSLocalizedString(@"Default preview template", @"template name"); + NSString *defaultName = [self defaultPreviewTemplateName]; NSSet *defaultNames = [NSSet setWithObjects:NSLocalizedString(@"Default RTF template", @"template name"), NSLocalizedString(@"Default RTFD template", @"template name"), NSLocalizedString(@"Default HTML template", @"template name"), NSLocalizedString(@"Default RSS template", @"template name"), NSLocalizedString(@"Default Doc template", @"template name"), nil]; __block NSUInteger idx = 0; @@ -353,6 +353,11 @@ [self setExportTemplates:mutableTemplates]; } ++ (NSString *)defaultPreviewTemplateName +{ + return NSLocalizedString(@"Default preview template", @"template name"); +} + + (NSArray *)allStyleNames; { NSMutableArray *names = [NSMutableArray array]; Modified: trunk/bibdesk/BibDocument_UI.m =================================================================== --- trunk/bibdesk/BibDocument_UI.m 2024-05-16 17:00:14 UTC (rev 28914) +++ trunk/bibdesk/BibDocument_UI.m 2024-05-16 17:13:14 UTC (rev 28915) @@ -162,7 +162,7 @@ if (maxItems > 0 && [items count] > maxItems) items = [items subarrayWithRange:NSMakeRange(0, maxItems)]; - BDSKTemplate *template = [BDSKTemplate templateForStyle:templateStyle] ?: [BDSKTemplate templateForStyle:NSLocalizedString(@"Default preview template", @"template name")] ?: [BDSKTemplate templateForStyle:[BDSKTemplate defaultStyleNameForFileType:@"rtf"]]; + BDSKTemplate *template = [BDSKTemplate templateForStyle:templateStyle] ?: [BDSKTemplate templateForStyle:[BDSKTemplate defaultPreviewTemplateName]] ?: [BDSKTemplate templateForStyle:[BDSKTemplate defaultStyleNameForFileType:@"rtf"]]; NSAttributedString *templateString = nil; NSDictionary *docAttributes = nil; NSURL *tmpDirURL = nil; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit