Revision: 15341
          http://sourceforge.net/p/skim-app/code/15341
Author:   hofman
Date:     2025-06-01 17:19:23 +0000 (Sun, 01 Jun 2025)
Log Message:
-----------
implement applyOptions: in the document class

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

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2025-06-01 17:08:56 UTC (rev 15340)
+++ trunk/SKMainDocument.m      2025-06-01 17:19:23 UTC (rev 15341)
@@ -251,7 +251,36 @@
 }
 
 - (void)applyOptions:(NSDictionary *)options {
-    [[self mainWindowController] applyOptions:options];
+    SKPDFView *pdfView = [self pdfView];
+    NSInteger page = [[options objectForKey:@"page"] integerValue];
+    NSString *searchString = [options objectForKey:@"search"];
+    NSMutableDictionary *settings = [options mutableCopy];
+    [settings removeObjectForKey:@"page"];
+    [settings removeObjectForKey:@"point"];
+    [settings removeObjectForKey:@"search"];
+    if ([settings count]) {
+        if (page == 0 && [[pdfView currentPage] pageIndex] > 0)
+            [pdfView setDisplaySettingsAndRewind:settings];
+        else
+            [pdfView setDisplaySettings:settings];
+    }
+    if (page > 0) {
+        page = MIN(page, (NSInteger)[[pdfView document] pageCount]);
+        NSString *pointString = [options objectForKey:@"point"];
+        if ([pointString length] > 0) {
+            SKDestination dest;
+            if ([pointString hasPrefix:@"{"] == NO)
+                pointString = [NSString stringWithFormat:@"{%@}", pointString];
+            dest.pageIndex = page - 1;
+            dest.point = NSPointFromString(pointString);
+            [pdfView goToCurrentDestination:dest];
+        } else if ((NSInteger)[[pdfView currentPage] pageIndex] != page) {
+            [pdfView goToCurrentPage:[[pdfView document] pageAtIndex:page - 
1]];
+        }
+    }
+    if ([searchString length] > 0) {
+        [[self mainWindowController] setSearchString:searchString];
+    }
 }
 
 - (NSInteger)definitiveOption:(NSInteger)option usingMessageText:(NSString 
*)messageText informativeText:(NSString *)informativeText {

Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h      2025-06-01 17:08:56 UTC (rev 15340)
+++ trunk/SKMainWindowController.h      2025-06-01 17:19:23 UTC (rev 15341)
@@ -218,7 +218,7 @@
     
 @property (nonatomic, nullable, strong) IBOutlet NSView *leftSideContentView, 
*rightSideContentView;
 
-@property (nonatomic, nullable, readonly) NSString *searchString;
+@property (nonatomic, nullable, strong) NSString *searchString;
 
 - (SKTransitionController *)transitionControllerCreating:(BOOL)create;
 
@@ -320,7 +320,6 @@
 
 - (void)applySetup:(NSDictionary<NSString *, id> *)setup;
 - (NSDictionary<NSString *, id> *)currentSetup;
-- (void)applyOptions:(NSDictionary<NSString *, id> *)options;
 
 - (void)updateSubtitle;
 - (void)updateLeftStatus;

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2025-06-01 17:08:56 UTC (rev 15340)
+++ trunk/SKMainWindowController.m      2025-06-01 17:19:23 UTC (rev 15341)
@@ -620,41 +620,6 @@
     return setup;
 }
 
-- (void)applyOptions:(NSDictionary *)options {
-    NSInteger page = [[options objectForKey:@"page"] integerValue];
-    NSString *searchString = [options objectForKey:@"search"];
-    NSMutableDictionary *settings = [options mutableCopy];
-    [settings removeObjectForKey:@"page"];
-    [settings removeObjectForKey:@"point"];
-    [settings removeObjectForKey:@"search"];
-    if ([settings count]) {
-        if (page == 0 && [[pdfView currentPage] pageIndex] > 0)
-            [pdfView setDisplaySettingsAndRewind:settings];
-        else
-            [pdfView setDisplaySettings:settings];
-    }
-    if (page > 0) {
-        page = MIN(page, (NSInteger)[[pdfView document] pageCount]);
-        NSString *pointString = [options objectForKey:@"point"];
-        if ([pointString length] > 0) {
-            SKDestination dest;
-            if ([pointString hasPrefix:@"{"] == NO)
-                pointString = [NSString stringWithFormat:@"{%@}", pointString];
-            dest.pageIndex = page - 1;
-            dest.point = NSPointFromString(pointString);
-            [pdfView goToCurrentDestination:dest];
-        } else if ((NSInteger)[[pdfView currentPage] pageIndex] != page) {
-            [pdfView goToCurrentPage:[[pdfView document] pageAtIndex:page - 
1]];
-        }
-    }
-    if ([searchString length] > 0) {
-        if ([self leftSidePaneIsOpen] == NO)
-            [self toggleLeftSidePane:nil];
-        [leftSideController.searchField setStringValue:searchString];
-        [self performSelector:@selector(search:) 
withObject:leftSideController.searchField afterDelay:0.0];
-    }
-}
-
 #pragma mark UI updating
 
 - (void)updateSubtitle {
@@ -1699,6 +1664,18 @@
     return [leftSideController.searchField stringValue];
 }
 
+- (void)setSearchString:(NSString *)searchString {
+    if ([searchString length] > 0) {
+        if ([self leftSidePaneIsOpen] == NO)
+            [self toggleLeftSidePane:nil];
+        [leftSideController.searchField setStringValue:searchString];
+        [self performSelector:@selector(search:) 
withObject:leftSideController.searchField afterDelay:0.0];
+    } else {
+        [leftSideController.searchField setStringValue:searchString];
+        [self search:leftSideController.searchField];
+    }
+}
+
 - (BOOL)findString:(NSString *)string forward:(BOOL)forward {
     PDFDocument *pdfDoc = [pdfView document];
     if ([pdfDoc isFinding]) {

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

Reply via email to