Revision: 15370
http://sourceforge.net/p/skim-app/code/15370
Author: hofman
Date: 2025-06-05 14:20:02 +0000 (Thu, 05 Jun 2025)
Log Message:
-----------
Add non-duplicate snapshot setups when opening with both setup bookmark and
last open snapshots, compare using only relevant properties.
Modified Paths:
--------------
trunk/SKMainWindowController.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2025-06-05 09:20:15 UTC (rev 15369)
+++ trunk/SKMainWindowController.m 2025-06-05 14:20:02 UTC (rev 15370)
@@ -286,6 +286,24 @@
[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 = @[@"pageIndex", @"rect", @"scaleFactor", @"autoFits"];
+ 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
bnookmarks
BOOL hasWindowSetup = [savedNormalSetup count] > 2;
@@ -468,8 +486,8 @@
// Open snapshots?
NSArray *snapshotSetups = [savedNormalSetup objectForKey:SNAPSHOTS_KEY];
- if (snapshotSetups == nil && [sud boolForKey:SKRememberSnapshotsKey])
- snapshotSetups = [[SKBookmarkController sharedBookmarkController]
snapshotsForRecentDocumentAtURL:[doc fileURL]];
+ if ([sud boolForKey:SKRememberSnapshotsKey])
+ snapshotSetups = mergedSnapshotSetups(snapshotSetups,
[[SKBookmarkController sharedBookmarkController]
snapshotsForRecentDocumentAtURL:[doc fileURL]]);
if ([snapshotSetups count]) {
if ([[pdfView document] isLocked])
[savedNormalSetup setObject:snapshotSetups forKey:SNAPSHOTS_KEY];
@@ -571,8 +589,8 @@
if ([[pdfView document] isLocked]) {
NSArray *snapshotSetups = [savedNormalSetup
objectForKey:SNAPSHOTS_KEY];
[savedNormalSetup addEntriesFromDictionary:setup];
- if ([snapshotSetups count] && [snapshotSetups
isEqualToArray:[setup objectForKey:SNAPSHOTS_KEY]] == NO)
- [savedNormalSetup setObject:[snapshotSetups
arrayByAddingObjectsFromArray:[setup objectForKey:SNAPSHOTS_KEY]]
forKey:SNAPSHOTS_KEY];
+ if ([snapshotSetups count])
+ [savedNormalSetup
setObject:mergedSnapshotSetups(snapshotSetups, [setup
objectForKey:SNAPSHOTS_KEY]) forKey:SNAPSHOTS_KEY];
} else {
if ([self interactionMode] != SKNormalMode) {
[savedNormalSetup addEntriesFromDictionary:setup];
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