Revision: 3063
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3063&view=rev
Author:   hofman
Date:     2007-10-23 10:06:07 -0700 (Tue, 23 Oct 2007)

Log Message:
-----------
Make sure recent document info (pahge index and snapshots) is saved. It seems 
something has changed in the framework, because the old way does not work 
anymore.

Extra check before automatically reloading, always show alert when there are 
notes. Add a hidden default to automatically reload.

Modified Paths:
--------------
    trunk/SKApplicationController.m
    trunk/SKDocument.h
    trunk/SKDocument.m
    trunk/SKMainWindowController.m

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2007-10-23 16:36:39 UTC (rev 3062)
+++ trunk/SKApplicationController.m     2007-10-23 17:06:07 UTC (rev 3063)
@@ -385,6 +385,7 @@
 
 - (void)saveCurrentOpenDocuments:(id)sender {
     [[NSUserDefaults standardUserDefaults] setObject:[[[NSDocumentController 
sharedDocumentController] documents] valueForKey:@"currentDocumentSetup"] 
forKey:SKLastOpenFileNamesKey];
+    [[[NSDocumentController sharedDocumentController] documents] 
makeObjectsPerformSelector:@selector(saveRecentDocumentInfo)];
 }
 
 - (NSString *)applicationSupportPathForDomain:(int)domain create:(BOOL)create {

Modified: trunk/SKDocument.h
===================================================================
--- trunk/SKDocument.h  2007-10-23 16:36:39 UTC (rev 3062)
+++ trunk/SKDocument.h  2007-10-23 17:06:07 UTC (rev 3063)
@@ -77,6 +77,7 @@
     SKPDFSynchronizer *synchronizer;
     NSString *watchedFile;
     BOOL autoUpdate;
+    BOOL disableAutoReload;
     BOOL isSaving;
     BOOL fileChangedOnDisk;
     BOOL exportUsingPanel;
@@ -139,6 +140,11 @@
 @end
 
 
[EMAIL PROTECTED] NSDocument (SKExtensions)
+- (void)saveRecentDocumentInfo;
[EMAIL PROTECTED]
+
+
 @interface NSWindow (SKScriptingExtensions)
 - (id)handleRevertScriptCommand:(NSScriptCommand *)command;
 @end

Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m  2007-10-23 16:36:39 UTC (rev 3062)
+++ trunk/SKDocument.m  2007-10-23 17:06:07 UTC (rev 3063)
@@ -66,6 +66,8 @@
 #import "SKProgressController.h"
 #import "NSView_SKExtensions.h"
 #import <Security/Security.h>
+#import "SKBookmarkController.h"
+#import "PDFPage_SKExtensions.h"
 
 #define BUNDLE_DATA_FILENAME @"data"
 
@@ -74,6 +76,7 @@
 NSString *SKDocumentWillSaveNotification = @"SKDocumentWillSaveNotification";
 
 static NSString *SKLastExportedTypeKey = @"SKLastExportedType";
+static NSString *SKAutoReloadFileUpdateKey = @"SKAutoReloadFileUpdate";
 
 @interface NSFileManager (SKDocumentExtensions)
 - (NSString *)subfileWithExtension:(NSString *)extensions 
inPDFBundleAtPath:(NSString *)path;
@@ -177,6 +180,13 @@
     return progressController;
 }
 
+- (void)saveRecentDocumentInfo {
+    unsigned int pageIndex = [[[self pdfView] currentPage] pageIndex];
+    NSString *path = [[self fileURL] path];
+    if (pageIndex != NSNotFound && path)
+        [[SKBookmarkController sharedBookmarkController] 
addRecentDocumentForPath:path pageIndex:pageIndex snapshots:[[[self 
mainWindowController] snapshots] valueForKey:@"currentSetup"]];
+}
+
 #pragma mark Document read/write
 
 - (BOOL)prepareSavePanel:(NSSavePanel *)savePanel {
@@ -989,6 +999,7 @@
     
     if (returnCode == NSAlertOtherReturn) {
         autoUpdate = NO;
+        disableAutoReload = YES;
     } else {
         NSError *error = nil;
         
@@ -999,6 +1010,7 @@
         
         if (returnCode == NSAlertAlternateReturn)
             autoUpdate = YES;
+        disableAutoReload = NO;
     }
 }
 
@@ -1049,12 +1061,13 @@
             unsigned trailerIndex = [trailerData indexOfBytes:pattern 
length:patternLength options:NSBackwardsSearch];
             
             if (trailerIndex != NSNotFound) {
-                if (autoUpdate && [self isDocumentEdited] == NO) {
+                BOOL shouldAutoUpdate = autoUpdate || [[NSUserDefaults 
standardUserDefaults] boolForKey:SKAutoReloadFileUpdateKey];
+                if (disableAutoReload == NO && shouldAutoUpdate && [self 
isDocumentEdited] == NO && [[self notes] count] == 0) {
                     // tried queuing this with a delayed perform/cancel 
previous, but revert takes long enough that the cancel was never used
                     [self fileUpdateAlertDidEnd:nil 
returnCode:NSAlertDefaultReturn contextInfo:NULL];
                 } else {
                     NSString *message;
-                    if ([self isDocumentEdited])
+                    if ([self isDocumentEdited] || [[self notes] count] > 0)
                         message = NSLocalizedString(@"The PDF file has changed 
on disk. If you reload, your changes will be lost. Do you want to reload this 
document now?", @"Informative text in alert dialog");
                     else 
                         message = NSLocalizedString(@"The PDF file has changed 
on disk. Do you want to reload this document now? Choosing Auto will reload 
this file automatically for future changes.", @"Informative text in alert 
dialog");
@@ -1850,6 +1863,11 @@
 @end
 
 
[EMAIL PROTECTED] NSDocument (SKExtensions)
+- (void)saveRecentDocumentInfo {}
[EMAIL PROTECTED]
+
+
 @implementation NSFileManager (SKDocumentExtensions)
 
 - (NSString *)subfileWithExtension:(NSString *)extension 
inPDFBundleAtPath:(NSString *)path {

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2007-10-23 16:36:39 UTC (rev 3062)
+++ trunk/SKMainWindowController.m      2007-10-23 17:06:07 UTC (rev 3063)
@@ -880,12 +880,6 @@
 #pragma mark Accessors
 
 - (void)setDocument:(NSDocument *)document {
-    if ([self document] && document == nil) {
-        unsigned int pageIndex = [[pdfView currentPage] pageIndex];
-        NSString *path = [[[self document] fileURL] path];
-        if (pageIndex != NSNotFound && path)
-            [[SKBookmarkController sharedBookmarkController] 
addRecentDocumentForPath:path pageIndex:pageIndex snapshots:[snapshots 
valueForKey:@"currentSetup"]];
-    }
     [super setDocument:document];
 }
 


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: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to