Revision: 4461
http://skim-app.svn.sourceforge.net/skim-app/?rev=4461&view=rev
Author: hofman
Date: 2008-08-27 19:53:53 +0000 (Wed, 27 Aug 2008)
Log Message:
-----------
Register the current document setup any time a document is opened or removed.
Modified Paths:
--------------
trunk/SKApplicationController.m
trunk/SKDocumentController.h
trunk/SKDocumentController.m
trunk/SKNotesDocument.m
trunk/SKPDFDocument.m
Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m 2008-08-27 12:09:30 UTC (rev 4460)
+++ trunk/SKApplicationController.m 2008-08-27 19:53:53 UTC (rev 4461)
@@ -138,6 +138,11 @@
[[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
}
+- (void)registerCurrentDocuments:(NSNotification *)aNotification {
+ [[NSUserDefaults standardUserDefaults] setObject:[[[NSDocumentController
sharedDocumentController] documents] valueForKey:SKCurrentDocumentSetupKey]
forKey:SKLastOpenFileNamesKey];
+ [[[NSDocumentController sharedDocumentController] documents]
makeObjectsPerformSelector:@selector(saveRecentDocumentInfo)];
+}
+
#pragma mark NSApplication delegate
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender{
@@ -192,6 +197,13 @@
[container
instantiateAndAddRemoteControlDeviceWithClass:[GlobalKeyboardDevice class]];
}
remoteControl = container;
+
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+ [nc addObserver:self selector:@selector(registerCurrentDocuments:)
+ name:SKDocumentDidShowNotification object:nil];
+ [nc addObserver:self selector:@selector(registerCurrentDocuments:)
+
name:SKDocumentControllerDidRemoveDocumentNotification object:nil];
+ [self registerCurrentDocuments:nil];
}
// we don't want to reopen last open files when re-activating the app
@@ -208,8 +220,10 @@
}
- (void)applicationStartsTerminating:(NSNotification *)aNotification {
- [[NSUserDefaults standardUserDefaults] setObject:[[[NSDocumentController
sharedDocumentController] documents] valueForKey:SKCurrentDocumentSetupKey]
forKey:SKLastOpenFileNamesKey];
- [[[NSDocumentController sharedDocumentController] documents]
makeObjectsPerformSelector:@selector(saveRecentDocumentInfo)];
+ [self registerCurrentDocuments:aNotification];
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+ [nc removeObserver:self name:SKDocumentDidShowNotification object:nil];
+ [nc removeObserver:self
name:SKDocumentControllerDidRemoveDocumentNotification object:nil];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
Modified: trunk/SKDocumentController.h
===================================================================
--- trunk/SKDocumentController.h 2008-08-27 12:09:30 UTC (rev 4460)
+++ trunk/SKDocumentController.h 2008-08-27 19:53:53 UTC (rev 4461)
@@ -69,6 +69,10 @@
extern NSString *SKDocumentSetupAliasKey;
extern NSString *SKDocumentSetupFileNameKey;
+extern NSString *SKDocumentControllerDidAddDocumentNotification;
+extern NSString *SKDocumentControllerDidRemoveDocumentNotification;
+extern NSString *SKDocumentDidShowNotification;
+
@interface SKDocumentController : NSDocumentController {
NSArray *customExportTemplateFiles;
}
Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m 2008-08-27 12:09:30 UTC (rev 4460)
+++ trunk/SKDocumentController.m 2008-08-27 19:53:53 UTC (rev 4461)
@@ -161,6 +161,10 @@
NSString *SKDocumentSetupAliasKey = @"_BDAlias";
NSString *SKDocumentSetupFileNameKey = @"fileName";
+NSString *SKDocumentControllerDidAddDocumentNotification =
@"SKDocumentControllerDidAddDocumentNotification";
+NSString *SKDocumentControllerDidRemoveDocumentNotification =
@"SKDocumentControllerDidRemoveDocumentNotification";
+NSString *SKDocumentDidShowNotification = @"SKDocumentDidShowNotification";
+
@implementation SKDocumentController
+ (void)initialize {
@@ -216,6 +220,18 @@
return type;
}
+- (void)addDocument:(NSDocument *)document {
+ [super addDocument:document];
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKDocumentControllerDidAddDocumentNotification
+ object:self userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:document, @"document", nil]];
+}
+
+- (void)removeDocument:(NSDocument *)document {
+ [super removeDocument:[[document retain] autorelease]];
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKDocumentControllerDidRemoveDocumentNotification
+ object:self userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:document, @"document", nil]];
+}
+
- (NSString *)typeForContentsOfURL:(NSURL *)inAbsoluteURL error:(NSError
**)outError {
unsigned int headerLength = 5;
Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m 2008-08-27 12:09:30 UTC (rev 4460)
+++ trunk/SKNotesDocument.m 2008-08-27 19:53:53 UTC (rev 4461)
@@ -87,6 +87,11 @@
return @"NotesDocument";
}
+- (void)showWindows{
+ [super showWindows];
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKDocumentDidShowNotification object:self];
+}
+
- (void)windowControllerDidLoadNib:(NSWindowController *)aController {
[aController setShouldCloseDocument:YES];
Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m 2008-08-27 12:09:30 UTC (rev 4460)
+++ trunk/SKPDFDocument.m 2008-08-27 19:53:53 UTC (rev 4461)
@@ -180,6 +180,8 @@
[@"" isEqualToString:searchString] == NO) {
[[self mainWindowController]
displaySearchResultsForString:searchString];
}
+
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKDocumentDidShowNotification object:self];
}
- (SKProgressController *)progressController {
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 Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit