Revision: 15830
          http://sourceforge.net/p/skim-app/code/15830
Author:   hofman
Date:     2025-11-25 17:01:30 +0000 (Tue, 25 Nov 2025)
Log Message:
-----------
us NSBindingName type

Modified Paths:
--------------
    trunk/NSObject_SKExtensions.h
    trunk/NSObject_SKExtensions.m
    trunk/SKColorSwatch.h
    trunk/SKColorSwatch.m
    trunk/SKDisplayPreferences.m
    trunk/SKFontWell.m
    trunk/SKLineWell.m
    trunk/SKMainToolbarController.m
    trunk/SKNoteWindowController.m
    trunk/SKNotesPreferences.m

Modified: trunk/NSObject_SKExtensions.h
===================================================================
--- trunk/NSObject_SKExtensions.h       2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/NSObject_SKExtensions.h       2025-11-25 17:01:30 UTC (rev 15830)
@@ -51,7 +51,7 @@
 
 - (nullable id)handleFormatScriptCommand:(NSScriptCommand *)command;
 
-- (void)propagateValue:(nullable id)value forBinding:(NSString *)binding;
+- (void)propagateValue:(nullable id)value forBinding:(NSBindingName)binding;
 
 @end
 

Modified: trunk/NSObject_SKExtensions.m
===================================================================
--- trunk/NSObject_SKExtensions.m       2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/NSObject_SKExtensions.m       2025-11-25 17:01:30 UTC (rev 15830)
@@ -121,7 +121,7 @@
     return text;
 }
 
-- (void)propagateValue:(id)value forBinding:(NSString *)binding {
+- (void)propagateValue:(id)value forBinding:(NSBindingName)binding {
     NSDictionary *info = [self infoForBinding:binding];
     id observedObject = [info objectForKey:NSObservedObjectKey];
     NSString *observedKeyPath = [info objectForKey:NSObservedKeyPathKey];

Modified: trunk/SKColorSwatch.h
===================================================================
--- trunk/SKColorSwatch.h       2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/SKColorSwatch.h       2025-11-25 17:01:30 UTC (rev 15830)
@@ -40,6 +40,8 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
+extern NSBindingName const SKColorsBinding;
+
 @class SKColorSwatchItemView;
 
 @interface SKColorSwatch : NSControl <NSDraggingSource, NSAccessibilityGroup> {

Modified: trunk/SKColorSwatch.m
===================================================================
--- trunk/SKColorSwatch.m       2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/SKColorSwatch.m       2025-11-25 17:01:30 UTC (rev 15830)
@@ -46,10 +46,10 @@
 #import "NSShadow_SKExtensions.h"
 #import "NSObject_SKExtensions.h"
 
+NSBindingName const SKColorsBinding = @"colors";
+
 NSString *SKColorSwatchOrWellWillActivateNotification = 
@"SKColorSwatchOrWellWillActivateNotification";
 
-#define COLORS_KEY      @"colors"
-
 #define AUTORESIZES_KEY @"autoResizes"
 #define SELECTS_KEY     @"selects"
 #define BEZELHEIGHT_KEY @"bezelHeight"
@@ -128,8 +128,8 @@
         return [super defaultAnimationForKey:key];
 }
 
-- (Class)valueClassForBinding:(NSString *)binding {
-    if ([binding isEqualToString:COLORS_KEY])
+- (Class)valueClassForBinding:(NSBindingName)binding {
+    if ([binding isEqualToString:SKColorsBinding])
         return [NSArray class];
     else
         return [super valueClassForBinding:binding];
@@ -206,8 +206,8 @@
 }
 
 - (void)dealloc {
-    if ([self infoForBinding:COLORS_KEY])
-        SKENSURE_MAIN_THREAD( [self unbind:COLORS_KEY]; );
+    if ([self infoForBinding:SKColorsBinding])
+        SKENSURE_MAIN_THREAD( [self unbind:SKColorsBinding]; );
 }
 
 - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { return YES; }
@@ -567,12 +567,12 @@
 }
 
 - (void)willChangeColors {
-    [self willChangeValueForKey:COLORS_KEY];
+    [self willChangeValueForKey:SKColorsBinding];
 }
 
 - (void)didChangeColors {
-    [self didChangeValueForKey:COLORS_KEY];
-    [self propagateValue:[self colors] forBinding:COLORS_KEY];
+    [self didChangeValueForKey:SKColorsBinding];
+    [self propagateValue:[self colors] forBinding:SKColorsBinding];
 }
 
 - (void)_setColor:(NSColor *)color atIndex:(NSInteger)i {

Modified: trunk/SKDisplayPreferences.m
===================================================================
--- trunk/SKDisplayPreferences.m        2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/SKDisplayPreferences.m        2025-11-25 17:01:30 UTC (rev 15830)
@@ -70,9 +70,9 @@
         }
     }
     @try {
-        [colorSwatch unbind:@"colors"];
+        [colorSwatch unbind:SKColorsBinding];
         [colorSwatch removeObserver:self forKeyPath:@"selectedColorIndex" 
context:&SKDisplayPreferencesColorSwatchObservationContext];
-        [colorSwatch removeObserver:self forKeyPath:@"colors" 
context:&SKDisplayPreferencesColorSwatchObservationContext];
+        [colorSwatch removeObserver:self forKeyPath:SKColorsBinding 
context:&SKDisplayPreferencesColorSwatchObservationContext];
     }
     @catch(id e) {}
 }
@@ -85,10 +85,10 @@
     [super viewDidLoad];
     
     NSValueTransformer *transformer = [NSValueTransformer 
valueTransformerForName:SKUnarchiveColorArrayTransformerName];
-    [colorSwatch bind:@"colors" toObject:[NSUserDefaultsController 
sharedUserDefaultsController] withKeyPath:[@"values." 
stringByAppendingString:SKSwatchColorsKey] 
options:@{NSValueTransformerBindingOption:transformer}];
+    [colorSwatch bind:SKColorsBinding toObject:[NSUserDefaultsController 
sharedUserDefaultsController] withKeyPath:[@"values." 
stringByAppendingString:SKSwatchColorsKey] 
options:@{NSValueTransformerBindingOption:transformer}];
     [colorSwatch setSelects:YES];
     [colorSwatch addObserver:self forKeyPath:@"selectedColorIndex" options:0 
context:&SKDisplayPreferencesColorSwatchObservationContext];
-    [colorSwatch addObserver:self forKeyPath:@"colors" options:0 
context:&SKDisplayPreferencesColorSwatchObservationContext];
+    [colorSwatch addObserver:self forKeyPath:SKColorsBinding options:0 
context:&SKDisplayPreferencesColorSwatchObservationContext];
     
     if (@available(macOS 10.14, *)) {
         [normalColorWell unbind:NSValueBinding];

Modified: trunk/SKFontWell.m
===================================================================
--- trunk/SKFontWell.m  2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/SKFontWell.m  2025-11-25 17:01:30 UTC (rev 15830)
@@ -71,7 +71,7 @@
     return [SKFontWellCell class];
 }
 
-- (Class)valueClassForBinding:(NSString *)binding {
+- (Class)valueClassForBinding:(NSBindingName)binding {
     if ([binding isEqualToString:NSTextColorBinding])
         return [NSColor class];
     else
@@ -211,7 +211,7 @@
     [self setNeedsDisplay:YES];
 }
 
-- (void)propagateValue:(id)value forBinding:(NSString *)binding {
+- (void)propagateValue:(id)value forBinding:(NSBindingName)binding {
     updatedBinding = binding;
     [super propagateValue:value forBinding:binding];
     updatedBinding = nil;

Modified: trunk/SKLineWell.m
===================================================================
--- trunk/SKLineWell.m  2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/SKLineWell.m  2025-11-25 17:01:30 UTC (rev 15830)
@@ -62,7 +62,7 @@
 @synthesize lineWidth, style, dashPattern, startLineStyle, endLineStyle;
 @dynamic active, canActivate, usePixelUnit, displayStyle;
 
-- (Class)valueClassForBinding:(NSString *)binding {
+- (Class)valueClassForBinding:(NSBindingName)binding {
     if ([binding isEqualToString:SKLineWellDashPatternKey])
         return [NSArray class];
     else

Modified: trunk/SKMainToolbarController.m
===================================================================
--- trunk/SKMainToolbarController.m     2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/SKMainToolbarController.m     2025-11-25 17:01:30 UTC (rev 15830)
@@ -160,7 +160,7 @@
 
 - (void)setMainController:(SKMainWindowController *)newMainController {
     if (newMainController == nil) {
-        [colorSwatch unbind:@"colors"];
+        [colorSwatch unbind:SKColorsBinding];
         [[NSNotificationCenter defaultCenter] removeObserver: self];
     }
     mainController = newMainController;
@@ -733,7 +733,7 @@
             
             NSValueTransformer *transformer = [NSValueTransformer 
valueTransformerForName:SKUnarchiveColorArrayTransformerName];
             NSDictionary *options = 
@{NSValueTransformerBindingOption:transformer};
-            [colorSwatch bind:@"colors" toObject:[NSUserDefaultsController 
sharedUserDefaultsController] withKeyPath:[@"values." 
stringByAppendingString:SKSwatchColorsKey] options:options];
+            [colorSwatch bind:SKColorsBinding 
toObject:[NSUserDefaultsController sharedUserDefaultsController] 
withKeyPath:[@"values." stringByAppendingString:SKSwatchColorsKey] 
options:options];
             [colorSwatch sizeToFit];
             [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleColorSwatchFrameChangedNotification:)
                                                          
name:NSViewFrameDidChangeNotification object:colorSwatch];

Modified: trunk/SKNoteWindowController.m
===================================================================
--- trunk/SKNoteWindowController.m      2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/SKNoteWindowController.m      2025-11-25 17:01:30 UTC (rev 15830)
@@ -214,7 +214,7 @@
         NSDictionary *options = nil;
         if (@available(macOS 10.14, *))
             options = 
@{NSValueTransformerBindingOption:[[SKAddTextColorTransformer alloc] init]};
-        [textView bind:@"attributedString" toObject:noteController 
withKeyPath:@"selection.text" options:options];
+        [textView bind:NSAttributedStringBinding toObject:noteController 
withKeyPath:@"selection.text" options:options];
         
         for (NSMenuItem *item in [iconTypePopUpButton itemArray])
             [item setImage:noteIcons[[item tag]]];
@@ -230,7 +230,7 @@
         [textView setImportsGraphics:NO];
         [textView setAllowsImageEditing:NO];
         [textView setUsesDefaultFontSize:YES];
-        [textView bind:@"value" toObject:noteController 
withKeyPath:@"selection.string" options:nil];
+        [textView bind:NSValueBinding toObject:noteController 
withKeyPath:@"selection.string" options:nil];
         
         NSSize minimumSize = [[self window] minSize];
         NSRect frame = [[[self window] contentView] frame];
@@ -265,7 +265,7 @@
         [[[[self document] primaryWindowController] window] makeMainWindow];
     if (previewURL)
         [self endPreviewPanelControl:nil];
-    @try { [textView unbind:[self isNoteType] ? @"attributedString" : 
@"value"]; }
+    @try { [textView unbind:[self isNoteType] ? NSAttributedStringBinding : 
NSValueBinding]; }
     @catch (id e) {}
     [note removeObserver:self forKeyPath:SKNPDFAnnotationPageKey 
context:&SKNoteWindowNoteObservationContext];
     [note removeObserver:self forKeyPath:SKNPDFAnnotationBoundsKey 
context:&SKNoteWindowNoteObservationContext];

Modified: trunk/SKNotesPreferences.m
===================================================================
--- trunk/SKNotesPreferences.m  2025-11-25 15:12:24 UTC (rev 15829)
+++ trunk/SKNotesPreferences.m  2025-11-25 17:01:30 UTC (rev 15830)
@@ -78,7 +78,7 @@
     
     NSDictionary *options = 
@{NSValueTransformerNameBindingOption:SKUnarchiveColorTransformerName};
     [textFontWell setHasTextColor:YES];
-    [textFontWell bind:@"textColor" toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKFreeTextNoteFontColorKey) options:options];
+    [textFontWell bind:NSTextColorBinding toObject:sudc 
withKeyPath:VALUES_KEY_PATH(SKFreeTextNoteFontColorKey) options:options];
 }
 
 #pragma mark Accessors

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to