Revision: 16020
          http://sourceforge.net/p/skim-app/code/16020
Author:   hofman
Date:     2026-01-14 16:02:39 +0000 (Wed, 14 Jan 2026)
Log Message:
-----------
move some methods to functions

Modified Paths:
--------------
    trunk/SKMainWindowController.m

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2026-01-13 17:36:47 UTC (rev 16019)
+++ trunk/SKMainWindowController.m      2026-01-14 16:02:39 UTC (rev 16020)
@@ -180,13 +180,14 @@
 
 #pragma mark -    
 
+static SKDestination destinationFromSetup(NSDictionary *setup);
+static void setDestinationInSetup(SKDestination dest, NSMutableDictionary 
*setup);
+static NSArray *mergedSnapshotSetups(NSArray *setups1, NSArray *setups2);
+
 @interface SKMainWindowController ()
 
 - (void)cleanup;
 
-- (SKDestination)destinationFromSetup:(NSDictionary *)setup;
-- (void)setDestination:(SKDestination)dest inSetup:(NSMutableDictionary 
*)setup;
-
 - (void)applyLeftSideWidth:(CGFloat)leftSideWidth 
rightSideWidth:(CGFloat)rightSideWidth;
 
 - (void)updateTableFont;
@@ -210,6 +211,7 @@
 
 @end
 
+#pragma mark -
 
 @implementation SKMainWindowController
 
@@ -303,24 +305,6 @@
     [self setPresentationNotesDocument:nil];
 }
 
-static NSArray *mergedSnapshotSetups(NSArray *setups1, NSArray *setups2) {
-    if ([setups1 count] == 0)
-        return [setups2 count] ? setups2 : nil;
-    else if ([setups2 count] == 0)
-        return setups1;
-    NSArray *keys = @[@"page", @"rect"];
-    NSMutableSet *set = [NSMutableSet set];
-    NSMutableArray *setups = [NSMutableArray arrayWithArray:setups1];
-    for (NSDictionary *setup in setups1)
-        [set addObject:[setup dictionaryWithValuesForKeys:keys]];
-    for (NSDictionary *setup in setups2) {
-        if ([set containsObject:[setup dictionaryWithValuesForKeys:keys]] == 
NO)
-            [setups addObject:setup];
-    }
-    return setups;
-    
-}
-
 - (void)windowDidLoad{
     // savedNormalSetup can contain pageIndex and snapshots from non-setup 
bookmarks
     BOOL hasWindowSetup = [savedNormalSetup count] > 2;
@@ -472,7 +456,7 @@
     }
     
     // Go to page?
-    SKDestination dest = [self destinationFromSetup:savedNormalSetup];
+    SKDestination dest = destinationFromSetup(savedNormalSetup);
     BOOL rememberPage = dest.pageIndex == NSNotFound && [sud 
boolForKey:SKRememberLastPageViewedKey];
     BOOL rememberSnapshots = [sud boolForKey:SKRememberSnapshotsKey];
     SKBookmark *recentDoc = nil;
@@ -483,7 +467,7 @@
         dest.pageIndex = [recentDoc pageIndex];
     if (dest.pageIndex != NSNotFound && [[pdfView document] pageCount] > 
dest.pageIndex) {
         if ([[pdfView document] isLocked]) {
-            [self setDestination:dest inSetup:savedNormalSetup];
+            setDestinationInSetup(dest, savedNormalSetup);
         } else if ([[pdfView currentPage] pageIndex] != dest.pageIndex || 
NSEqualPoints(dest.point, SKUnspecifiedPoint) == NO) {
             [pdfView goToSKDestination:dest];
             [lastViewedPages setCount:0];
@@ -602,7 +586,7 @@
             if ([snapshotSetups count])
                 [self showSnapshotsWithSetups:snapshotSetups];
             
-            SKDestination dest = [self destinationFromSetup:setup];
+            SKDestination dest = destinationFromSetup(setup);
             if (dest.pageIndex != NSNotFound && dest.pageIndex != [[pdfView 
currentPage] pageIndex])
                 [pdfView goToSKDestination:dest];
         }
@@ -620,7 +604,7 @@
         [setup setObject:NSStringFromRect([[self window] frame]) 
forKey:MAINWINDOWFRAME_KEY];
     [setup setObject:[NSNumber numberWithDouble:[self leftSideWidth]] 
forKey:LEFTSIDEPANEWIDTH_KEY];
     [setup setObject:[NSNumber numberWithDouble:[self rightSideWidth]] 
forKey:RIGHTSIDEPANEWIDTH_KEY];
-    [self setDestination:dest inSetup:setup];
+    setDestinationInSetup(dest, setup);
     if (cropBoxes)
         [setup setObject:cropBoxes forKey:CROPBOXES_KEY];
     if ([snapshots count])
@@ -635,28 +619,6 @@
     return setup;
 }
 
-- (SKDestination)destinationFromSetup:(NSDictionary *)setup {
-    SKDestination dest = {NSNotFound, SKUnspecifiedPoint};
-    NSNumber *pageNumber = [setup objectForKey:PAGEINDEX_KEY];
-    if (pageNumber) {
-        dest.pageIndex = [pageNumber unsignedIntegerValue];
-        if (dest.pageIndex != NSNotFound) {
-            NSString *pointString = [setup objectForKey:SCROLLPOINT_KEY];
-            if (pointString)
-                dest.point = NSPointFromString(pointString);
-        }
-    }
-    return dest;
-}
-
-- (void)setDestination:(SKDestination)dest inSetup:(NSMutableDictionary 
*)setup {
-    if (dest.pageIndex != NSNotFound) {
-        [setup setObject:[NSNumber numberWithUnsignedInteger:dest.pageIndex] 
forKey:PAGEINDEX_KEY];
-        if (NSEqualPoints(dest.point, SKUnspecifiedPoint) == NO)
-            [setup setObject:NSStringFromPoint(dest.point) 
forKey:SCROLLPOINT_KEY];
-    }
-}
-
 #pragma mark UI updating
 
 - (NSString *)pageStatus {
@@ -1169,7 +1131,7 @@
                if ([self interactionMode] == SKNormalMode)
                     [savedNormalSetup setDictionary:[pdfView displaySettings]];
                 [savedNormalSetup setObject:@YES forKey:LOCKED_KEY];
-                [self setDestination:dest inSetup:savedNormalSetup];
+                setDestinationInSetup(dest, savedNormalSetup);
                 if ([snapshotDicts count])
                     [savedNormalSetup setObject:snapshotDicts 
forKey:SNAPSHOTS_KEY];
             }
@@ -2107,7 +2069,7 @@
         mwcFlags.hasCropped = 1;
     }
     
-    SKDestination dest = [self destinationFromSetup:savedNormalSetup];
+    SKDestination dest = destinationFromSetup(savedNormalSetup);
     if (dest.pageIndex != NSNotFound) {
         [pdfView goToSKDestination:dest];
         [lastViewedPages setCount:0];
@@ -3256,3 +3218,43 @@
 }
 
 @end
+
+
+static SKDestination destinationFromSetup(NSDictionary *setup) {
+    SKDestination dest = {NSNotFound, SKUnspecifiedPoint};
+    NSNumber *pageNumber = [setup objectForKey:PAGEINDEX_KEY];
+    if (pageNumber) {
+        dest.pageIndex = [pageNumber unsignedIntegerValue];
+        if (dest.pageIndex != NSNotFound) {
+            NSString *pointString = [setup objectForKey:SCROLLPOINT_KEY];
+            if (pointString)
+                dest.point = NSPointFromString(pointString);
+        }
+    }
+    return dest;
+}
+
+static void setDestinationInSetup(SKDestination dest, NSMutableDictionary 
*setup) {
+    if (dest.pageIndex != NSNotFound) {
+        [setup setObject:[NSNumber numberWithUnsignedInteger:dest.pageIndex] 
forKey:PAGEINDEX_KEY];
+        if (NSEqualPoints(dest.point, SKUnspecifiedPoint) == NO)
+            [setup setObject:NSStringFromPoint(dest.point) 
forKey:SCROLLPOINT_KEY];
+    }
+}
+
+static NSArray *mergedSnapshotSetups(NSArray *setups1, NSArray *setups2) {
+    if ([setups1 count] == 0)
+        return [setups2 count] ? setups2 : nil;
+    else if ([setups2 count] == 0)
+        return setups1;
+    NSArray *keys = @[@"page", @"rect"];
+    NSMutableSet *set = [NSMutableSet set];
+    NSMutableArray *setups = [NSMutableArray arrayWithArray:setups1];
+    for (NSDictionary *setup in setups1)
+        [set addObject:[setup dictionaryWithValuesForKeys:keys]];
+    for (NSDictionary *setup in setups2) {
+        if ([set containsObject:[setup dictionaryWithValuesForKeys:keys]] == 
NO)
+            [setups addObject:setup];
+    }
+    return setups;
+}

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