Revision: 7255
http://skim-app.svn.sourceforge.net/skim-app/?rev=7255&view=rev
Author: hofman
Date: 2011-05-26 17:56:42 +0000 (Thu, 26 May 2011)
Log Message:
-----------
update info window when relevant data from the main document changes
Modified Paths:
--------------
trunk/NSDocument_SKExtensions.h
trunk/NSDocument_SKExtensions.m
trunk/SKInfoWindowController.m
trunk/SKMainDocument.m
trunk/SKNotesDocument.m
Modified: trunk/NSDocument_SKExtensions.h
===================================================================
--- trunk/NSDocument_SKExtensions.h 2011-05-25 17:01:10 UTC (rev 7254)
+++ trunk/NSDocument_SKExtensions.h 2011-05-26 17:56:42 UTC (rev 7255)
@@ -39,6 +39,8 @@
#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
+extern NSString *SKDocumentFileURLDidChangeNotification;
+
enum {
SKNormalMode,
SKFullScreenMode,
Modified: trunk/NSDocument_SKExtensions.m
===================================================================
--- trunk/NSDocument_SKExtensions.m 2011-05-25 17:01:10 UTC (rev 7254)
+++ trunk/NSDocument_SKExtensions.m 2011-05-26 17:56:42 UTC (rev 7255)
@@ -55,6 +55,8 @@
#define TEMPLATES_FOLDER_NAME @"Templates"
+NSString *SKDocumentFileURLDidChangeNotification =
@"SKDocumentFileURLDidChangeNotification";
+
@implementation NSDocument (SKExtensions)
+ (BOOL)isPDFDocument { return NO; }
Modified: trunk/SKInfoWindowController.m
===================================================================
--- trunk/SKInfoWindowController.m 2011-05-25 17:01:10 UTC (rev 7254)
+++ trunk/SKInfoWindowController.m 2011-05-26 17:56:42 UTC (rev 7255)
@@ -39,6 +39,7 @@
#import "SKInfoWindowController.h"
#import "SKMainDocument.h"
#import "NSDocument_SKExtensions.h"
+#import "PDFPage_SKExtensions.h"
#import <Quartz/Quartz.h>
#define SKInfoWindowFrameAutosaveName @"SKInfoWindow"
@@ -66,6 +67,8 @@
- (void)handleViewFrameDidChangeNotification:(NSNotification *)notification;
- (void)handleWindowDidBecomeMainNotification:(NSNotification *)notification;
- (void)handleWindowDidResignMainNotification:(NSNotification *)notification;
+- (void)handlePDFDocumentInfoDidChangeNotification:(NSNotification
*)notification;
+- (void)handleDocumentFileURLDidChangeNotification:(NSNotification
*)notification;
@end
@implementation SKInfoWindowController
@@ -127,10 +130,14 @@
[super dealloc];
}
-- (void)windowDidLoad {
- [self setInfo:[self infoForDocument:[[[NSApp mainWindow] windowController]
document]]];
+- (void)updateForDocument:(NSDocument *)doc {
+ [self setInfo:[self infoForDocument:doc]];
[summaryTableView reloadData];
[attributesTableView reloadData];
+}
+
+- (void)windowDidLoad {
+ [self updateForDocument:[self infoForDocument:[[[NSApp mainWindow]
windowController] document]]];
NSArray *tables = [NSArray arrayWithObjects:summaryTableView,
attributesTableView, nil];
NSTableView *tv;
@@ -153,6 +160,12 @@
name:
NSWindowDidBecomeMainNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector:
@selector(handleWindowDidResignMainNotification:)
name:
NSWindowDidResignMainNotification object: nil];
+ [[NSNotificationCenter defaultCenter] addObserver: self selector:
@selector(handlePDFDocumentInfoDidChangeNotification:)
+ name:
PDFDocumentDidUnlockNotification object: nil];
+ [[NSNotificationCenter defaultCenter] addObserver: self selector:
@selector(handlePDFDocumentInfoDidChangeNotification:)
+ name:
SKPDFPageBoundsDidChangeNotification object: nil];
+ [[NSNotificationCenter defaultCenter] addObserver: self selector:
@selector(handleDocumentFileURLDidChangeNotification:)
+ name:
SKDocumentFileURLDidChangeNotification object: nil];
}
static NSString *SKFileSizeStringForFileURL(NSURL *fileURL, unsigned long long
*physicalSizePtr, unsigned long long *logicalSizePtr) {
@@ -292,18 +305,25 @@
}
- (void)handleWindowDidBecomeMainNotification:(NSNotification *)notification {
- NSDocument *doc = [[[notification object] windowController] document];
- [self setInfo:[self infoForDocument:doc]];
- [summaryTableView reloadData];
- [attributesTableView reloadData];
+ [self updateForDocument:[[[notification object] windowController]
document]];
}
- (void)handleWindowDidResignMainNotification:(NSNotification *)notification {
- [self setInfo:nil];
- [summaryTableView reloadData];
- [attributesTableView reloadData];
+ [self updateForDocument:nil];
}
+- (void)handlePDFDocumentInfoDidChangeNotification:(NSNotification
*)notification {
+ NSDocument *doc = [[[NSApp mainWindow] windowController] document];
+ if ([[doc pdfDocument] isEqual:[notification object]])
+ [self updateForDocument:doc];
+}
+
+- (void)handleDocumentFileURLDidChangeNotification:(NSNotification
*)notification {
+ NSDocument *doc = [[[NSApp mainWindow] windowController] document];
+ if ([doc isEqual:[notification object]])
+ [self updateForDocument:doc];
+}
+
- (NSString *)labelForKey:(NSString *)key {
if ([key isEqualToString:SKInfoFileNameKey])
return NSLocalizedString(@"File name:", @"Info label");
Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m 2011-05-25 17:01:10 UTC (rev 7254)
+++ trunk/SKMainDocument.m 2011-05-26 17:56:42 UTC (rev 7255)
@@ -1349,6 +1349,8 @@
[synchronizer setFileName:[absoluteURL path]];
else
[synchronizer setFileName:nil];
+
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKDocumentFileURLDidChangeNotification object:self];
}
- (SKPDFSynchronizer *)synchronizer {
Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m 2011-05-25 17:01:10 UTC (rev 7254)
+++ trunk/SKNotesDocument.m 2011-05-26 17:56:42 UTC (rev 7255)
@@ -387,6 +387,7 @@
if (absoluteURL)
[self setSourceFileURL:nil];
[super setFileURL:absoluteURL];
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKDocumentFileURLDidChangeNotification object:self];
}
- (NSString *)displayName {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit