From b9f38cbec0fcdbc1f45fe391445aa594f4d9c0aa Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Sat, 9 Jan 2016 13:37:54 +0100 Subject: [PATCH] Fix things on 10.10 and earlier. --- .../PropertyView/SBChapterViewController.m | 13 ++++++++--- Classes/SBChapterSearchController.m | 23 +++++++++++++++---- Classes/SBDocument.m | 19 +++++++++------ 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Classes/PropertyView/SBChapterViewController.m b/Classes/PropertyView/SBChapterViewController.m index 2c91fa2..8dde434 100755 --- a/Classes/PropertyView/SBChapterViewController.m +++ b/Classes/PropertyView/SBChapterViewController.m @@ -21,9 +21,16 @@ [ps setHeadIndent: -10.0]; [ps setAlignment:NSRightTextAlignment]; - detailBoldAttr = [@{ NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightBold], - NSParagraphStyleAttributeName: ps, - NSForegroundColorAttributeName: [NSColor grayColor] } retain]; + if ([[NSFont class] respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]) { + detailBoldAttr = [@{ NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightBold], + NSParagraphStyleAttributeName: ps, + NSForegroundColorAttributeName: [NSColor grayColor] } retain]; + } + else { + detailBoldAttr = [@{ NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]], + NSParagraphStyleAttributeName: ps, + NSForegroundColorAttributeName: [NSColor grayColor] } retain]; + } chapterTableView.defaultEditingColumn = 1; } diff --git a/Classes/SBChapterSearchController.m b/Classes/SBChapterSearchController.m index 15b9c6e..0986beb 100644 --- a/Classes/SBChapterSearchController.m +++ b/Classes/SBChapterSearchController.m @@ -56,9 +56,16 @@ ps.headIndent = -10.0; ps.alignment = NSTextAlignmentRight; - _detailBoldMonospacedAttr = [@{NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightBold], - NSParagraphStyleAttributeName: ps, - NSForegroundColorAttributeName: [NSColor grayColor]} retain]; + if ([[NSFont class] respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]) { + _detailBoldMonospacedAttr = [@{NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightBold], + NSParagraphStyleAttributeName: ps, + NSForegroundColorAttributeName: [NSColor grayColor]} retain]; + } + else { + _detailBoldMonospacedAttr = [@{NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]], + NSParagraphStyleAttributeName: ps, + NSForegroundColorAttributeName: [NSColor grayColor]} retain]; + } NSMutableParagraphStyle *psL = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]; psL.headIndent = -10.0; @@ -68,8 +75,14 @@ NSForegroundColorAttributeName: [NSColor grayColor]} retain]; - _detailMonospacedAttr = [@{NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightRegular], - NSParagraphStyleAttributeName: ps} retain]; + if ([[NSFont class] respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]) { + _detailMonospacedAttr = [@{NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightRegular], + NSParagraphStyleAttributeName: ps} retain]; + } + else { + _detailMonospacedAttr = [@{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]], + NSParagraphStyleAttributeName: ps} retain]; + } } - (void)windowDidLoad { diff --git a/Classes/SBDocument.m b/Classes/SBDocument.m index c55068a..889fd20 100755 --- a/Classes/SBDocument.m +++ b/Classes/SBDocument.m @@ -463,16 +463,21 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn if ([tableColumn.identifier isEqualToString:@"trackDuration"]) { - NSFont *font = [NSFont monospacedDigitSystemFontOfSize:[NSFont systemFontSize] weight:NSFontWeightRegular]; - NSMutableParagraphStyle *ps = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; - ps.alignment = NSTextAlignmentRight; + if ([[NSFont class] respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]) { + NSFont *font = [NSFont monospacedDigitSystemFontOfSize:[NSFont systemFontSize] weight:NSFontWeightRegular]; + NSMutableParagraphStyle *ps = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; + ps.alignment = NSTextAlignmentRight; - NSDictionary *monospacedAttr = @{NSFontAttributeName: font, - NSParagraphStyleAttributeName: ps}; + NSDictionary *monospacedAttr = @{NSFontAttributeName: font, + NSParagraphStyleAttributeName: ps}; - [ps release]; + [ps release]; - return [[[NSAttributedString alloc] initWithString:track.timeString attributes:monospacedAttr] autorelease]; + return [[[NSAttributedString alloc] initWithString:track.timeString attributes:monospacedAttr] autorelease]; + } + else { + return track.timeString; + } } if ([tableColumn.identifier isEqualToString:@"trackLanguage"]) {