Revision: 12336 http://sourceforge.net/p/skim-app/code/12336 Author: hofman Date: 2021-05-19 14:17:46 +0000 (Wed, 19 May 2021) Log Message: ----------- Combine binding update methods
Modified Paths: -------------- trunk/SKFontWell.m Modified: trunk/SKFontWell.m =================================================================== --- trunk/SKFontWell.m 2021-05-19 14:13:02 UTC (rev 12335) +++ trunk/SKFontWell.m 2021-05-19 14:17:46 UTC (rev 12336) @@ -176,17 +176,10 @@ [self setNeedsDisplay:YES]; } -- (void)notifyFontBinding { - NSDictionary *info = [self infoForBinding:FONTNAME_KEY]; - [[info objectForKey:NSObservedObjectKey] setValue:[self fontName] forKeyPath:[info objectForKey:NSObservedKeyPathKey]]; - info = [self infoForBinding:FONTSIZE_KEY]; - [[info objectForKey:NSObservedObjectKey] setValue:[NSNumber numberWithDouble:[self fontSize]] forKeyPath:[info objectForKey:NSObservedKeyPathKey]]; -} - -- (void)notifyTextColorBinding { - NSDictionary *info = [self infoForBinding:TEXTCOLOR_KEY]; +- (void)notifyBinding:(NSString *)binding { + NSDictionary *info = [self infoForBinding:binding]; if (info) { - id value = [self textColor]; + id value = [self valueForKey:binding]; NSValueTransformer *valueTransformer = [[info objectForKey:NSOptionsKey] objectForKey:NSValueTransformerBindingOption]; if (valueTransformer == nil || [valueTransformer isEqual:[NSNull null]]) { NSString *transformerName = [[info objectForKey:NSOptionsKey] objectForKey:NSValueTransformerNameBindingOption]; @@ -203,7 +196,7 @@ - (void)changeFontFromFontManager:(id)sender { if ([self isActive]) { [self setFont:[sender convertFont:[self font]]]; - [self notifyFontBinding]; + [self notifyBinding:FONTNAME_KEY]; [self sendAction:[self action] to:[self target]]; } } @@ -211,7 +204,7 @@ - (void)changeAttributesFromFontManager:(id)sender { if ([self isActive] && [self hasTextColor]) { [self setTextColor:[[sender convertAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[self textColor], NSForegroundColorAttributeName, nil]] valueForKey:NSForegroundColorAttributeName]]; - [self notifyTextColorBinding]; + [self notifyBinding:TEXTCOLOR_KEY]; [self sendAction:[self action] to:[self target]]; } } @@ -436,12 +429,12 @@ if (droppedFont) { [self setFont:droppedFont]; - [self notifyFontBinding]; + [self notifyBinding:FONTNAME_KEY]; [self sendAction:[self action] to:[self target]]; } if (droppedColor) { [self setTextColor:droppedColor]; - [self notifyTextColorBinding]; + [self notifyBinding:TEXTCOLOR_KEY]; [self sendAction:[self action] to:[self target]]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit