Revision: 2729
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2729&view=rev
Author:   hofman
Date:     2007-08-27 08:39:41 -0700 (Mon, 27 Aug 2007)

Log Message:
-----------
Do saving of current documents in application delegate rather than the 
application. Somehow the application does not know when it opens the saved 
files.

Modified Paths:
--------------
    trunk/SKApplication.h
    trunk/SKApplication.m
    trunk/SKApplicationController.h
    trunk/SKApplicationController.m

Modified: trunk/SKApplication.h
===================================================================
--- trunk/SKApplication.h       2007-08-27 15:09:12 UTC (rev 2728)
+++ trunk/SKApplication.h       2007-08-27 15:39:41 UTC (rev 2729)
@@ -38,15 +38,18 @@
 
 #import <Cocoa/Cocoa.h>
 
-extern NSString *SKApplicationWillTerminateNotification;
+extern NSString *SKApplicationStartsTerminatingNotification;
 
[EMAIL PROTECTED] SKApplication : NSApplication {
-    NSTimer *currentDocumentsTimer;
-}
[EMAIL PROTECTED] SKApplication : NSApplication
 - (IBAction)orderFrontLineInspector:(id)sender;
 @end
 
 
[EMAIL PROTECTED] NSObject (SKApplicationDelegate)
+- (void)applicationStartsTerminating:(NSNotification *)aNotification;
[EMAIL PROTECTED]
+
+
 @interface NSResponder (SKMagnifyWheel)
 - (void)magnifyWheel:(NSEvent *)theEvent;
 @end

Modified: trunk/SKApplication.m
===================================================================
--- trunk/SKApplication.m       2007-08-27 15:09:12 UTC (rev 2728)
+++ trunk/SKApplication.m       2007-08-27 15:39:41 UTC (rev 2729)
@@ -37,14 +37,13 @@
  */
 
 #import "SKApplication.h"
-#import "SKStringConstants.h"
 #import "SKDocument.h"
 #import "SKPDFSynchronizer.h"
 #import "SKPDFView.h"
 #import "SKLineInspector.h"
 #import "NSString_SKExtensions.h"
 
-NSString *SKApplicationWillTerminateNotification = 
@"SKApplicationWillTerminateNotification";
+NSString *SKApplicationStartsTerminatingNotification = 
@"SKApplicationStartsTerminatingNotification";
 
 @interface NSApplication (NSApplicationPrivateDeclarations)
 - (id)handleOpenScriptCommand:(NSScriptCommand *)command;
@@ -90,21 +89,11 @@
     [super sendEvent:anEvent];
 }
 
-- (void)saveCurrentOpenDocuments:(NSTimer *)timer {
-    [[NSUserDefaults standardUserDefaults] setObject:[[[NSDocumentController 
sharedDocumentController] documents] valueForKey:@"currentDocumentSetup"] 
forKey:SKLastOpenFileNamesKey];
-}
-
-- (void)finishLaunching {
-    [super finishLaunching];
-    currentDocumentsTimer = [[NSTimer scheduledTimerWithTimeInterval:10.0 
target:self selector:@selector(saveCurrentOpenDocuments:) userInfo:nil 
repeats:YES] retain];
-}
-
 - (IBAction)terminate:(id)sender {
-    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKApplicationWillTerminateNotification object:self];
-    [currentDocumentsTimer invalidate];
-    [currentDocumentsTimer release];
-    currentDocumentsTimer = nil;
-    [self saveCurrentOpenDocuments:nil];
+    NSNotification *notification = [NSNotification 
notificationWithName:SKApplicationStartsTerminatingNotification object:self];
+    [[NSNotificationCenter defaultCenter] postNotification:notification];
+    if ([[self delegate] 
respondsToSelector:@selector(applicationStartsTerminating:)])
+        [[self delegate] applicationStartsTerminating:notification];
     [super terminate:sender];
 }
 

Modified: trunk/SKApplicationController.h
===================================================================
--- trunk/SKApplicationController.h     2007-08-27 15:09:12 UTC (rev 2728)
+++ trunk/SKApplicationController.h     2007-08-27 15:39:41 UTC (rev 2729)
@@ -41,8 +41,8 @@
 @class SUUpdater, SKLine, SKDownloadController;
 
 @interface SKApplicationController : NSObject {
+    NSTimer *currentDocumentsTimer;
     BOOL remoteScrolling;
-    
 }
 
 + (void)setupDefaults;
@@ -58,6 +58,8 @@
 
 - (void)doSpotlightImportIfNeeded;
 
+- (void)saveCurrentOpenDocuments:(id)sender;
+
 - (NSString *)applicationSupportPathForDomain:(int)domain create:(BOOL)create;
 - (NSString *)pathForApplicationSupportFile:(NSString *)file ofType:(NSString 
*)extension;
 

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2007-08-27 15:09:12 UTC (rev 2728)
+++ trunk/SKApplicationController.m     2007-08-27 15:39:41 UTC (rev 2729)
@@ -141,6 +141,7 @@
 
 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification{
     [NSApp setServicesProvider:self];
+    
     NSString *versionString = [[[NSBundle mainBundle] infoDictionary] 
objectForKey:@"CFBundleShortVersionString"];
     SKVersionNumber *versionNumber = versionString ? [[[SKVersionNumber alloc] 
initWithVersionString:versionString] autorelease] : nil;
     NSString *lastVersionString = [[NSUserDefaults standardUserDefaults] 
stringForKey:SKLastVersionLaunchedKey];
@@ -149,9 +150,13 @@
         [self showReleaseNotes:nil];
         [[NSUserDefaults standardUserDefaults] setObject:versionString 
forKey:SKLastVersionLaunchedKey];
     }
-       if ([[NSUserDefaults standardUserDefaults] 
boolForKey:SKEnableAppleRemoteKey])
+       
+    if ([[NSUserDefaults standardUserDefaults] 
boolForKey:SKEnableAppleRemoteKey])
         [[AppleRemote sharedRemote] setDelegate:self];
+    
     [self doSpotlightImportIfNeeded];
+    
+    currentDocumentsTimer = [[NSTimer scheduledTimerWithTimeInterval:10.0 
target:self selector:@selector(saveCurrentOpenDocuments:) userInfo:nil 
repeats:YES] retain];
 }
 
 - (void)applicationDidBecomeActive:(NSNotification *)aNotification {
@@ -164,6 +169,13 @@
         [[AppleRemote sharedRemote] setListeningToRemote:NO];
 }
 
+- (void)applicationStartsTerminating:(NSNotification *)aNotification {
+    [currentDocumentsTimer invalidate];
+    [currentDocumentsTimer release];
+    currentDocumentsTimer = nil;
+    [self saveCurrentOpenDocuments:nil];
+}
+
 - (void)applicationWillTerminate:(NSNotification *)aNotification {
        if ([[NSUserDefaults standardUserDefaults] 
boolForKey:SKEnableAppleRemoteKey]) {
         [[AppleRemote sharedRemote] setListeningToRemote:NO];
@@ -341,6 +353,10 @@
     }
 }
 
+- (void)saveCurrentOpenDocuments:(id)sender {
+    [[NSUserDefaults standardUserDefaults] setObject:[[[NSDocumentController 
sharedDocumentController] documents] valueForKey:@"currentDocumentSetup"] 
forKey:SKLastOpenFileNamesKey];
+}
+
 - (NSString *)applicationSupportPathForDomain:(int)domain create:(BOOL)create {
     static CFMutableDictionaryRef pathDict = nil;
     if (pathDict == nil)


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
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to