Revision: 12914
http://sourceforge.net/p/skim-app/code/12914
Author: hofman
Date: 2022-05-10 18:18:35 +0000 (Tue, 10 May 2022)
Log Message:
-----------
Implement applyOptions in mainWindowController,obviates need of pageNumber
accessors and method to set the search string
Modified Paths:
--------------
trunk/SKMainDocument.m
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
trunk/SKMainWindowController_UI.m
Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m 2022-05-10 17:45:29 UTC (rev 12913)
+++ trunk/SKMainDocument.m 2022-05-10 18:18:35 UTC (rev 12914)
@@ -272,13 +272,7 @@
}
- (void)applyOptions:(NSDictionary *)options {
- NSInteger page = [[options objectForKey:@"page"] integerValue];
- NSString *searchString = [options objectForKey:@"search"];
- if (page > 0)
- [[self mainWindowController] setPageNumber:page];
- if ([searchString length] > 0)
- [[self mainWindowController]
displaySearchResultsForString:searchString];
- [[self mainWindowController] applyPDFSettings:options rewind:NO];
+ [[self mainWindowController] applyOptions:options];
}
#pragma mark Writing
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2022-05-10 17:45:29 UTC (rev 12913)
+++ trunk/SKMainWindowController.h 2022-05-10 18:18:35 UTC (rev 12914)
@@ -216,8 +216,6 @@
@property (nonatomic, retain) IBOutlet NSView *leftSideContentView,
*rightSideContentView;
-- (void)displaySearchResultsForString:(NSString *)string;
-
@property (nonatomic, readonly) NSString *searchString;
- (void)showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect
scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
@@ -276,7 +274,6 @@
@property (nonatomic, copy) NSArray *selectedNotes;
-@property (nonatomic) NSUInteger pageNumber;
@property (nonatomic, copy) NSString *pageLabel;
@property (nonatomic, readonly) SKInteractionMode interactionMode;
@@ -339,6 +336,7 @@
- (NSDictionary *)currentSetup;
- (void)applyPDFSettings:(NSDictionary *)setup rewind:(BOOL)rewind;
- (NSDictionary *)currentPDFSettings;
+- (void)applyOptions:(NSDictionary *)options;
- (void)updateLeftStatus;
- (void)updateRightStatus;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2022-05-10 17:45:29 UTC (rev 12913)
+++ trunk/SKMainWindowController.m 2022-05-10 18:18:35 UTC (rev 12914)
@@ -229,7 +229,7 @@
@implementation SKMainWindowController
@synthesize mainWindow, splitView, centerContentView, pdfSplitView,
pdfContentView, statusBar, pdfView, secondaryPdfView, leftSideController,
rightSideController, toolbarController, leftSideContentView,
rightSideContentView, presentationNotesDocument, presentationNotesOffset, tags,
rating, pageLabel, interactionMode, placeholderPdfDocument;
-@dynamic pdfDocument, presentationOptions, selectedNotes, pageNumber,
widgetProperties, autoScales, leftSidePaneState, rightSidePaneState,
findPaneState, leftSidePaneIsOpen, rightSidePaneIsOpen, recentInfoNeedsUpdate,
searchString, hasOverview, notesMenu;
+@dynamic pdfDocument, presentationOptions, selectedNotes, widgetProperties,
autoScales, leftSidePaneState, rightSidePaneState, findPaneState,
leftSidePaneIsOpen, rightSidePaneIsOpen, recentInfoNeedsUpdate, searchString,
hasOverview, notesMenu;
+ (void)initialize {
SKINITIALIZE;
@@ -710,10 +710,33 @@
return setup;
}
+- (void)applyOptions:(NSDictionary *)options {
+ NSInteger page = [[options objectForKey:@"page"] integerValue];
+ NSString *searchString = [options objectForKey:@"search"];
+ if (page > 0) {
+ page = MIN(page, (NSInteger)[[pdfView document] pageCount]);
+ NSString *pointString = [options objectForKey:@"point"];
+ if ([pointString length] > 0) {
+ if ([pointString hasPrefix:@"{"] == NO)
+ pointString = [NSString stringWithFormat:@"{%@}", pointString];
+ [pdfView goToPageAtIndex:page - 1
point:NSPointFromString(pointString)];
+ } else if ((NSInteger)[[pdfView currentPage] pageIndex] != page) {
+ [pdfView goToPage:[[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];
+ }
+ [self applyPDFSettings:options rewind:NO];
+}
+
#pragma mark UI updating
- (void)updateLeftStatus {
- NSString *message = [NSString stringWithFormat:NSLocalizedString(@"Page
%ld of %ld", @"Status message"), (long)[self pageNumber], (long)[[pdfView
document] pageCount]];
+ NSString *message = [NSString stringWithFormat:NSLocalizedString(@"Page
%ld of %ld", @"Status message"), (long)([[[self pdfView] currentPage]
pageIndex] + 1), (long)[[pdfView document] pageCount]];
[statusBar setLeftStringValue:message];
}
@@ -1204,19 +1227,6 @@
}
}
-- (NSUInteger)pageNumber {
- return [[pdfView currentPage] pageIndex] + 1;
-}
-
-- (void)setPageNumber:(NSUInteger)number {
- // Check that the page number exists
- NSUInteger pageCount = [[pdfView document] pageCount];
- if (number > pageCount)
- number = pageCount;
- if (number > 0 && [[pdfView currentPage] pageIndex] != number - 1)
- [pdfView goToPage:[[pdfView document] pageAtIndex:number - 1]];
-}
-
- (void)updatePageLabel {
NSString *label = [[pdfView currentPage] displayLabel];
if (label != pageLabel) {
@@ -1757,13 +1767,6 @@
#pragma mark Searching
-- (void)displaySearchResultsForString:(NSString *)string {
- if ([self leftSidePaneIsOpen] == NO)
- [self toggleLeftSidePane:nil];
- [leftSideController.searchField setStringValue:string];
- [self performSelector:@selector(search:)
withObject:leftSideController.searchField afterDelay:0.0];
-}
-
- (NSString *)searchString {
return [leftSideController.searchField stringValue];
}
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2022-05-10 17:45:29 UTC (rev 12913)
+++ trunk/SKMainWindowController_UI.m 2022-05-10 18:18:35 UTC (rev 12914)
@@ -230,7 +230,7 @@
- (NSString *)windowTitleForDocumentDisplayName:(NSString *)displayName {
if ([pdfView document])
- return [NSString stringWithFormat:NSLocalizedString(@"%@ (page %ld of
%ld)", @"Window title format"), displayName, (long)[self pageNumber],
(long)[[pdfView document] pageCount]];
+ return [NSString stringWithFormat:NSLocalizedString(@"%@ (page %ld of
%ld)", @"Window title format"), displayName, (long)([[[self pdfView]
currentPage] pageIndex] + 1), (long)[[pdfView document] pageCount]];
else
return displayName;
}
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