Revision: 15860
          http://sourceforge.net/p/skim-app/code/15860
Author:   hofman
Date:     2025-12-11 16:01:40 +0000 (Thu, 11 Dec 2025)
Log Message:
-----------
no setters for pageLabel and string of snapshots, manual KVO in update methods

Modified Paths:
--------------
    trunk/SKSnapshotWindowController.h
    trunk/SKSnapshotWindowController.m

Modified: trunk/SKSnapshotWindowController.h
===================================================================
--- trunk/SKSnapshotWindowController.h  2025-12-11 15:14:46 UTC (rev 15859)
+++ trunk/SKSnapshotWindowController.h  2025-12-11 16:01:40 UTC (rev 15860)
@@ -70,8 +70,8 @@
 @property (nonatomic, nullable, strong) NSDate *updateDate;
 @property (nonatomic, readonly) NSRect bounds;
 @property (nonatomic, readonly) NSUInteger pageIndex;
-@property (nonatomic, nullable, readonly, copy) NSString *pageLabel;
-@property (nonatomic, nullable, copy) NSString *string;
+@property (nonatomic, nullable, readonly) NSString *pageLabel;
+@property (nonatomic, nullable, readonly) NSString *string;
 @property (nonatomic, readonly) BOOL hasWindow;
 @property (nonatomic, readonly) NSDictionary<NSString *, id> *currentSetup;
 @property (nonatomic) BOOL forceOnTop;

Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m  2025-12-11 15:14:46 UTC (rev 15859)
+++ trunk/SKSnapshotWindowController.m  2025-12-11 16:01:40 UTC (rev 15860)
@@ -78,6 +78,7 @@
 #define WINDOWFRAME_KEY     @"windowFrame"
 #define HASWINDOW_KEY       @"hasWindow"
 #define PAGELABEL_KEY       @"pageLabel"
+#define STRING_KEY          @"string"
 
 #define SKSnapshotWindowFrameAutosaveName @"SKSnapshotWindow"
 #define SKSnapshotViewChangedNotification @"SKSnapshotViewChangedNotification"
@@ -85,7 +86,6 @@
 static char SKSnaphotWindowDefaultsObservationContext;
 
 @interface SKSnapshotWindowController ()
-@property (nonatomic, copy) NSString *pageLabel;
 @property (nonatomic) BOOL hasWindow;
 @end
 
@@ -133,13 +133,6 @@
         return [displayName stringByAppendingEmDashAndString:[NSString 
stringWithFormat:NSLocalizedString(@"Page %@", @""), [self pageLabel]]];
 }
 
-- (void)updateSubtitle {
-    if (@available(macOS 11.0, *))
-        [[self window] setSubtitle:[NSString 
stringWithFormat:NSLocalizedString(@"Page %@", @""), [self pageLabel]]];
-    else
-        [self synchronizeWindowTitleWithDocumentName];
-}
-
 - (void)updateString {
     NSMutableString *mutableString = [NSMutableString string];
     NSRect rect = [pdfView visibleContentRect];
@@ -152,11 +145,19 @@
             [mutableString appendString:[sel string]];
         }
     }
-    [self setString:mutableString];
+    [self willChangeValueForKey:STRING_KEY];
+    string = [mutableString copy];
+    [self didChangeValueForKey:STRING_KEY];
 }
 
 - (void)updatePageLabel {
-    [self setPageLabel:[[pdfView currentPage] displayLabel]];
+    [self willChangeValueForKey:PAGELABEL_KEY];
+    pageLabel = [[[pdfView currentPage] displayLabel] copy];
+    [self didChangeValueForKey:PAGELABEL_KEY];
+    if (@available(macOS 11.0, *))
+        [[self window] setSubtitle:[NSString 
stringWithFormat:NSLocalizedString(@"Page %@", @""), [self pageLabel]]];
+    else
+        [self synchronizeWindowTitleWithDocumentName];
 }
 
 - (void)handlePDFViewChanged {
@@ -167,12 +168,12 @@
 }
 
 - (void)handlePageChangedNotification:(NSNotification *)notification {
-    [self setPageLabel:[[pdfView currentPage] displayLabel]];
+    [self updatePageLabel];
     [self handlePDFViewChanged];
 }
 
 - (void)handleDocumentDidUnlockNotification:(NSNotification *)notification {
-    [self setPageLabel:[[pdfView currentPage] displayLabel]];
+    [self updatePageLabel];
     [self handlePDFViewChanged];
 }
 
@@ -247,7 +248,7 @@
     
     [[self window] makeFirstResponder:pdfView];
        
-    [self setPageLabel:[[pdfView currentPage] displayLabel]];
+    [self updatePageLabel];
     [self handlePDFViewChanged];
     
     [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handlePageChangedNotification:) 
@@ -389,13 +390,6 @@
     return [[pdfView currentPage] pageIndex];
 }
 
-- (void)setPageLabel:(NSString *)newPageLabel {
-    if (pageLabel != newPageLabel) {
-        pageLabel = newPageLabel;
-        [self updateSubtitle];
-    }
-}
-
 - (void)setThumbnail:(NSImage *)newThumbnail {
     if (newThumbnail != thumbnail) {
         thumbnail = newThumbnail;

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