Revision: 3835
http://skim-app.svn.sourceforge.net/skim-app/?rev=3835&view=rev
Author: hofman
Date: 2008-05-02 05:19:52 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Move back document notifications to main object file, as this is not a UI
notification.
Modified Paths:
--------------
trunk/SKMainWindowController.m
trunk/SKMainWindowController_UI.h
trunk/SKMainWindowController_UI.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-05-02 11:46:28 UTC (rev 3834)
+++ trunk/SKMainWindowController.m 2008-05-02 12:19:52 UTC (rev 3835)
@@ -144,7 +144,7 @@
@end
[EMAIL PROTECTED] SKMainWindowController (Private)
[EMAIL PROTECTED] SKMainWindowController (SKPrivate)
- (void)setupToolbar;
@@ -180,13 +180,8 @@
- (void)goToDestination:(PDFDestination *)destination;
- (void)goToPage:(PDFPage *)page;
-- (void)handlePageChangedNotification:(NSNotification *)notification;
-- (void)handleScaleChangedNotification:(NSNotification *)notification;
-- (void)handleToolModeChangedNotification:(NSNotification *)notification;
-- (void)handleDisplayBoxChangedNotification:(NSNotification *)notification;
-- (void)handleDisplayModeChangedNotification:(NSNotification *)notification;
-- (void)handleAnnotationModeChangedNotification:(NSNotification *)notification;
-- (void)handleChangedHistoryNotification:(NSNotification *)notification;
+- (void)registerForDocumentNotifications;
+- (void)unregisterForDocumentNotifications;
- (void)registerAsObserver;
- (void)unregisterAsObserver;
@@ -198,6 +193,7 @@
@end
+
@implementation SKMainWindowController
+ (void)initialize {
@@ -2686,49 +2682,6 @@
#pragma mark Searching
-- (void)documentDidBeginDocumentFind:(NSNotification *)note {
- if (findPanelFind == NO) {
- NSString *message = [NSLocalizedString(@"Searching", @"Message in
search table header") stringByAppendingEllipsis];
- [findArrayController removeObjects:searchResults];
- [[[findTableView
tableColumnWithIdentifier:SKMainWindowResultsColumnIdentifer] headerCell]
setStringValue:message];
- [[findTableView headerView] setNeedsDisplay:YES];
- [[[groupedFindTableView
tableColumnWithIdentifier:SKMainWindowRelevanceColumnIdentifer] headerCell]
setStringValue:message];
- [[groupedFindTableView headerView] setNeedsDisplay:YES];
- [groupedFindArrayController removeObjects:groupedSearchResults];
- [statusBar setProgressIndicatorStyle:SKProgressIndicatorBarStyle];
- [[statusBar progressIndicator] setMaxValue:[[note object] pageCount]];
- [[statusBar progressIndicator] setDoubleValue:0.0];
- [statusBar startAnimation:self];
- }
-}
-
-- (void)documentDidEndDocumentFind:(NSNotification *)note {
- if (findPanelFind == NO) {
- NSString *message = [NSString stringWithFormat:NSLocalizedString(@"%i
Results", @"Message in search table header"), [searchResults count]];
- [self willChangeValueForKey:SKMainWindowSearchResultsKey];
- [self didChangeValueForKey:SKMainWindowSearchResultsKey];
- [self willChangeValueForKey:SKMainWindowGroupedSearchResultsKey];
- [self didChangeValueForKey:SKMainWindowGroupedSearchResultsKey];
- [[[findTableView
tableColumnWithIdentifier:SKMainWindowResultsColumnIdentifer] headerCell]
setStringValue:message];
- [[findTableView headerView] setNeedsDisplay:YES];
- [[[groupedFindTableView
tableColumnWithIdentifier:SKMainWindowRelevanceColumnIdentifer] headerCell]
setStringValue:message];
- [[groupedFindTableView headerView] setNeedsDisplay:YES];
- [statusBar stopAnimation:self];
- [statusBar setProgressIndicatorStyle:SKProgressIndicatorNone];
- }
-}
-
-- (void)documentDidEndPageFind:(NSNotification *)note {
- NSNumber *pageIndex = [[note userInfo]
objectForKey:@"PDFDocumentPageIndex"];
- [[statusBar progressIndicator] setDoubleValue:[pageIndex doubleValue]];
- if ([pageIndex unsignedIntValue] % 50 == 0) {
- [self willChangeValueForKey:SKMainWindowSearchResultsKey];
- [self didChangeValueForKey:SKMainWindowSearchResultsKey];
- [self willChangeValueForKey:SKMainWindowGroupedSearchResultsKey];
- [self didChangeValueForKey:SKMainWindowGroupedSearchResultsKey];
- }
-}
-
- (void)didMatchString:(PDFSelection *)instance {
if (findPanelFind == NO) {
[searchResults addObject:instance];
@@ -2954,6 +2907,124 @@
}
}
+#pragma mark PDFDocument delegate
+
+- (void)documentDidBeginDocumentFind:(NSNotification *)note {
+ if (findPanelFind == NO) {
+ NSString *message = [NSLocalizedString(@"Searching", @"Message in
search table header") stringByAppendingEllipsis];
+ [findArrayController removeObjects:searchResults];
+ [[[findTableView
tableColumnWithIdentifier:SKMainWindowResultsColumnIdentifer] headerCell]
setStringValue:message];
+ [[findTableView headerView] setNeedsDisplay:YES];
+ [[[groupedFindTableView
tableColumnWithIdentifier:SKMainWindowRelevanceColumnIdentifer] headerCell]
setStringValue:message];
+ [[groupedFindTableView headerView] setNeedsDisplay:YES];
+ [groupedFindArrayController removeObjects:groupedSearchResults];
+ [statusBar setProgressIndicatorStyle:SKProgressIndicatorBarStyle];
+ [[statusBar progressIndicator] setMaxValue:[[note object] pageCount]];
+ [[statusBar progressIndicator] setDoubleValue:0.0];
+ [statusBar startAnimation:self];
+ }
+}
+
+- (void)documentDidEndDocumentFind:(NSNotification *)note {
+ if (findPanelFind == NO) {
+ NSString *message = [NSString stringWithFormat:NSLocalizedString(@"%i
Results", @"Message in search table header"), [searchResults count]];
+ [self willChangeValueForKey:SKMainWindowSearchResultsKey];
+ [self didChangeValueForKey:SKMainWindowSearchResultsKey];
+ [self willChangeValueForKey:SKMainWindowGroupedSearchResultsKey];
+ [self didChangeValueForKey:SKMainWindowGroupedSearchResultsKey];
+ [[[findTableView
tableColumnWithIdentifier:SKMainWindowResultsColumnIdentifer] headerCell]
setStringValue:message];
+ [[findTableView headerView] setNeedsDisplay:YES];
+ [[[groupedFindTableView
tableColumnWithIdentifier:SKMainWindowRelevanceColumnIdentifer] headerCell]
setStringValue:message];
+ [[groupedFindTableView headerView] setNeedsDisplay:YES];
+ [statusBar stopAnimation:self];
+ [statusBar setProgressIndicatorStyle:SKProgressIndicatorNone];
+ }
+}
+
+- (void)documentDidEndPageFind:(NSNotification *)note {
+ NSNumber *pageIndex = [[note userInfo]
objectForKey:@"PDFDocumentPageIndex"];
+ [[statusBar progressIndicator] setDoubleValue:[pageIndex doubleValue]];
+ if ([pageIndex unsignedIntValue] % 50 == 0) {
+ [self willChangeValueForKey:SKMainWindowSearchResultsKey];
+ [self didChangeValueForKey:SKMainWindowSearchResultsKey];
+ [self willChangeValueForKey:SKMainWindowGroupedSearchResultsKey];
+ [self didChangeValueForKey:SKMainWindowGroupedSearchResultsKey];
+ }
+}
+
+- (void)documentDidUnlock:(NSNotification *)notification {
+ [self updatePageLabelsAndOutline];
+}
+
+#pragma mark PDFDocument notifications
+
+- (void)handlePageBoundsDidChangeNotification:(NSNotification *)notification {
+ NSDictionary *info = [notification userInfo];
+ PDFPage *page = [info objectForKey:SKPDFPagePageKey];
+ BOOL displayChanged = [[info objectForKey:SKPDFPageActionKey]
isEqualToString:SKPDFPageActionRotate] || [pdfView displayBox] ==
kPDFDisplayBoxCropBox;
+
+ if (displayChanged)
+ [pdfView layoutDocumentView];
+ if (page) {
+ unsigned int idx = [page pageIndex];
+ NSEnumerator *snapshotEnum = [snapshots objectEnumerator];
+ SKSnapshotWindowController *wc;
+ while (wc = [snapshotEnum nextObject]) {
+ if ([wc isPageVisible:page]) {
+ [self snapshotNeedsUpdate:wc];
+ [wc redisplay];
+ }
+ }
+ if (displayChanged)
+ [self updateThumbnailAtPageIndex:idx];
+ } else {
+ [snapshots makeObjectsPerformSelector:@selector(redisplay)];
+ [self allSnapshotsNeedUpdate];
+ if (displayChanged)
+ [self allThumbnailsNeedUpdate];
+ }
+
+ [secondaryPdfView setNeedsDisplay:YES];
+}
+
+- (void)handleDocumentBeginWrite:(NSNotification *)notification {
+ // Establish maximum and current value for progress bar.
+ [[self progressController] setMaxValue:(double)[[pdfView document]
pageCount]];
+ [[self progressController] setDoubleValue:0.0];
+ [[self progressController] setMessage:[NSLocalizedString(@"Exporting
PDF", @"Message for progress sheet") stringByAppendingEllipsis]];
+
+ // Bring up the save panel as a sheet.
+ [[self progressController] beginSheetModalForWindow:[self window]];
+}
+
+- (void)handleDocumentEndWrite:(NSNotification *)notification {
+ [[self progressController] endSheet];
+}
+
+- (void)handleDocumentEndPageWrite:(NSNotification *)notification {
+ [[self progressController] setDoubleValue: [[[notification userInfo]
objectForKey:@"PDFDocumentPageIndex"] floatValue]];
+}
+
+- (void)registerForDocumentNotifications {
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+ [nc addObserver:self selector:@selector(handleDocumentBeginWrite:)
+ name:@"PDFDidBeginDocumentWrite" object:[pdfView
document]];
+ [nc addObserver:self selector:@selector(handleDocumentEndWrite:)
+ name:@"PDFDidEndDocumentWrite" object:[pdfView
document]];
+ [nc addObserver:self selector:@selector(handleDocumentEndPageWrite:)
+ name:@"PDFDidEndPageWrite" object:[pdfView
document]];
+ [nc addObserver:self
selector:@selector(handlePageBoundsDidChangeNotification:)
+ name:SKPDFPageBoundsDidChangeNotification
object:[pdfView document]];
+}
+
+- (void)unregisterForDocumentNotifications {
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+ [nc removeObserver:self name:@"PDFDidBeginDocumentWrite" object:[pdfView
document]];
+ [nc removeObserver:self name:@"PDFDidEndDocumentWrite" object:[pdfView
document]];
+ [nc removeObserver:self name:@"PDFDidEndPageWrite" object:[pdfView
document]];
+ [nc removeObserver:self name:SKPDFPageBoundsDidChangeNotification
object:[pdfView document]];
+}
+
#pragma mark Tiger history fixes
- (void)registerDestinationHistory:(PDFDestination *)destination {
Modified: trunk/SKMainWindowController_UI.h
===================================================================
--- trunk/SKMainWindowController_UI.h 2008-05-02 11:46:28 UTC (rev 3834)
+++ trunk/SKMainWindowController_UI.h 2008-05-02 12:19:52 UTC (rev 3835)
@@ -41,7 +41,15 @@
@interface SKMainWindowController (UI)
+
- (void)registerForNotifications;
-- (void)registerForDocumentNotifications;
-- (void)unregisterForDocumentNotifications;
+
+- (void)handlePageChangedNotification:(NSNotification *)notification;
+- (void)handleScaleChangedNotification:(NSNotification *)notification;
+- (void)handleToolModeChangedNotification:(NSNotification *)notification;
+- (void)handleDisplayBoxChangedNotification:(NSNotification *)notification;
+- (void)handleDisplayModeChangedNotification:(NSNotification *)notification;
+- (void)handleAnnotationModeChangedNotification:(NSNotification *)notification;
+- (void)handleChangedHistoryNotification:(NSNotification *)notification;
+
@end
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2008-05-02 11:46:28 UTC (rev 3834)
+++ trunk/SKMainWindowController_UI.m 2008-05-02 12:19:52 UTC (rev 3835)
@@ -78,7 +78,6 @@
- (void)updateNoteFilterPredicate;
- (void)updateFindResultHighlights:(BOOL)scroll;
-- (void)updatePageLabelsAndOutline;
- (void)hideLeftSideWindow;
- (void)hideRightSideWindow;
@@ -89,8 +88,6 @@
- (void)showHoverWindowForDestination:(PDFDestination *)dest;
-- (SKProgressController *)progressController;
-
@end
#pragma mark -
@@ -1447,57 +1444,6 @@
[self updateThumbnailAtPageIndex:[newPage pageIndex]];
}
-- (void)handlePageBoundsDidChangeNotification:(NSNotification *)notification {
- NSDictionary *info = [notification userInfo];
- PDFPage *page = [info objectForKey:SKPDFPagePageKey];
- BOOL displayChanged = [[info objectForKey:SKPDFPageActionKey]
isEqualToString:SKPDFPageActionRotate] || [pdfView displayBox] ==
kPDFDisplayBoxCropBox;
-
- if (displayChanged)
- [pdfView layoutDocumentView];
- if (page) {
- unsigned int idx = [page pageIndex];
- NSEnumerator *snapshotEnum = [snapshots objectEnumerator];
- SKSnapshotWindowController *wc;
- while (wc = [snapshotEnum nextObject]) {
- if ([wc isPageVisible:page]) {
- [self snapshotNeedsUpdate:wc];
- [wc redisplay];
- }
- }
- if (displayChanged)
- [self updateThumbnailAtPageIndex:idx];
- } else {
- [snapshots makeObjectsPerformSelector:@selector(redisplay)];
- [self allSnapshotsNeedUpdate];
- if (displayChanged)
- [self allThumbnailsNeedUpdate];
- }
-
- [secondaryPdfView setNeedsDisplay:YES];
-}
-
-- (void)handleDocumentBeginWrite:(NSNotification *)notification {
- // Establish maximum and current value for progress bar.
- [[self progressController] setMaxValue:(double)[[pdfView document]
pageCount]];
- [[self progressController] setDoubleValue:0.0];
- [[self progressController] setMessage:[NSLocalizedString(@"Exporting
PDF", @"Message for progress sheet") stringByAppendingEllipsis]];
-
- // Bring up the save panel as a sheet.
- [[self progressController] beginSheetModalForWindow:[self window]];
-}
-
-- (void)handleDocumentEndWrite:(NSNotification *)notification {
- [[self progressController] endSheet];
-}
-
-- (void)handleDocumentEndPageWrite:(NSNotification *)notification {
- [[self progressController] setDoubleValue: [[[notification userInfo]
objectForKey:@"PDFDocumentPageIndex"] floatValue]];
-}
-
-- (void)documentDidUnlock:(NSNotification *)notification {
- [self updatePageLabelsAndOutline];
-}
-
#pragma mark Observer registration
- (void)registerForNotifications {
@@ -1547,24 +1493,4 @@
name:NSUndoManagerCheckpointNotification
object:[[self document] undoManager]];
}
-- (void)registerForDocumentNotifications {
- NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- [nc addObserver:self selector:@selector(handleDocumentBeginWrite:)
- name:@"PDFDidBeginDocumentWrite" object:[pdfView
document]];
- [nc addObserver:self selector:@selector(handleDocumentEndWrite:)
- name:@"PDFDidEndDocumentWrite" object:[pdfView
document]];
- [nc addObserver:self selector:@selector(handleDocumentEndPageWrite:)
- name:@"PDFDidEndPageWrite" object:[pdfView
document]];
- [nc addObserver:self
selector:@selector(handlePageBoundsDidChangeNotification:)
- name:SKPDFPageBoundsDidChangeNotification
object:[pdfView document]];
-}
-
-- (void)unregisterForDocumentNotifications {
- NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- [nc removeObserver:self name:@"PDFDidBeginDocumentWrite" object:[pdfView
document]];
- [nc removeObserver:self name:@"PDFDidEndDocumentWrite" object:[pdfView
document]];
- [nc removeObserver:self name:@"PDFDidEndPageWrite" object:[pdfView
document]];
- [nc removeObserver:self name:SKPDFPageBoundsDidChangeNotification
object:[pdfView document]];
-}
-
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit