Revision: 3442
http://skim-app.svn.sourceforge.net/skim-app/?rev=3442&view=rev
Author: hofman
Date: 2008-02-25 03:17:12 -0800 (Mon, 25 Feb 2008)
Log Message:
-----------
Simplify print accessory controllers. Don't use private API to change the
custom print info, rather set the key in the printInfo dictionary. Use more KVC
for these values. Localize summary items in Leopard print panel.
Modified Paths:
--------------
trunk/PDFDocument_SKExtensions.h
trunk/PDFDocument_SKExtensions.m
trunk/SKMainWindowController.m
trunk/SKPrintAccessoryController.h
trunk/SKPrintAccessoryController.m
trunk/SKPrintAccessoryViewController.h
trunk/SKPrintAccessoryViewController.m
Modified: trunk/PDFDocument_SKExtensions.h
===================================================================
--- trunk/PDFDocument_SKExtensions.h 2008-02-25 10:15:58 UTC (rev 3441)
+++ trunk/PDFDocument_SKExtensions.h 2008-02-25 11:17:12 UTC (rev 3442)
@@ -40,14 +40,6 @@
#import <Quartz/Quartz.h>
[EMAIL PROTECTED] PDFDocument (SKPrivateDeclarations)
-- (NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo
autoRotate:(BOOL)autoRotate;
-- (void)cleanupAfterPrintOperation:(NSPrintOperation *)printOperation;
-- (void)setAutoRotate:(BOOL)autoRotate forPrintOperation:(NSPrintOperation
*)printOperation;
-- (void)setPrintScalingMode:(int)printScalingMode
forPrintOperation:(NSPrintOperation *)printOperation;
[EMAIL PROTECTED]
-
-
@interface PDFDocument (SKExtensions)
- (PDFSelection *)selectionByExtendingSelection:(PDFSelection *)selection
toPage:(PDFPage *)page atPoint:(NSPoint)point;
@end
Modified: trunk/PDFDocument_SKExtensions.m
===================================================================
--- trunk/PDFDocument_SKExtensions.m 2008-02-25 10:15:58 UTC (rev 3441)
+++ trunk/PDFDocument_SKExtensions.m 2008-02-25 11:17:12 UTC (rev 3442)
@@ -40,6 +40,13 @@
#import "PDFSelection_SKExtensions.h"
#import "OBUtilities.h"
+
[EMAIL PROTECTED] PDFDocument (SKPrivateDeclarations)
+- (NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo
autoRotate:(BOOL)autoRotate;
+- (void)cleanupAfterPrintOperation:(NSPrintOperation *)printOperation;
[EMAIL PROTECTED]
+
+
@interface PDFDocument (SKPrivateExtensions)
- (NSPrintOperation *)replacementGetPrintOperationForPrintInfo:(NSPrintInfo
*)printInfo autoRotate:(BOOL)autoRotate;
- (void)replacementCleanupAfterPrintOperation:(NSPrintOperation
*)printOperation;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-02-25 10:15:58 UTC (rev 3441)
+++ trunk/SKMainWindowController.m 2008-02-25 11:17:12 UTC (rev 3442)
@@ -3026,11 +3026,11 @@
[[NSBundle bundleWithPath:[[NSBundle mainBundle]
pathForResource:@"Leopard" ofType:@"bundle"]] load];
printAccessoryControllerClass =
NSClassFromString(@"SKPrintAccessoryController");
}
- printAccessoryViewController = [[printAccessoryControllerClass alloc]
initWithPrintOperation:printOperation document:document];
+ printAccessoryViewController = [[printAccessoryControllerClass alloc]
init];
if (printAccessoryViewController)
[printPanel addAccessoryController:printAccessoryViewController];
} else {
- printAccessoryViewController = [[SKPrintAccessoryViewController alloc]
initWithPrintOperation:printOperation document:document];
+ printAccessoryViewController = [[SKPrintAccessoryViewController alloc]
initWithPrintInfo:[printOperation printInfo]];
if (printAccessoryViewController)
[printPanel setAccessoryView:[printAccessoryViewController view]];
}
Modified: trunk/SKPrintAccessoryController.h
===================================================================
--- trunk/SKPrintAccessoryController.h 2008-02-25 10:15:58 UTC (rev 3441)
+++ trunk/SKPrintAccessoryController.h 2008-02-25 11:17:12 UTC (rev 3442)
@@ -43,12 +43,8 @@
@interface SKPrintAccessoryController : NSViewController
<NSPrintPanelAccessorizing> {
IBOutlet NSButton *autoRotateButton;
IBOutlet NSMatrix *printScalingModeMatrix;
- NSPrintOperation *printOperation;
- PDFDocument *document;
}
-- (id)initWithPrintOperation:(NSPrintOperation *)aPrintOperation
document:(PDFDocument *)aDocument;
-
- (BOOL)autoRotate;
- (void)setAutoRotate:(BOOL)autoRotate;
Modified: trunk/SKPrintAccessoryController.m
===================================================================
--- trunk/SKPrintAccessoryController.m 2008-02-25 10:15:58 UTC (rev 3441)
+++ trunk/SKPrintAccessoryController.m 2008-02-25 11:17:12 UTC (rev 3442)
@@ -39,69 +39,53 @@
#import "SKPrintAccessoryController.h"
[EMAIL PROTECTED] PDFDocument (SKLeopardPrivateDeclarations)
-- (void)setAutoRotate:(BOOL)autoRotate forPrintOperation:(NSPrintOperation
*)printOperation;
-- (void)setPrintScalingMode:(int)printScalingMode
forPrintOperation:(NSPrintOperation *)printOperation;
[EMAIL PROTECTED]
-
-
@implementation SKPrintAccessoryController
-- (id)initWithPrintOperation:(NSPrintOperation *)aPrintOperation
document:(PDFDocument *)aDocument {
- if (aDocument == nil || aPrintOperation == nil ||
- (NO == [aDocument
respondsToSelector:@selector(setAutoRotate:forPrintOperation:)] &&
- nil == [aPrintOperation
valueForKeyPath:@"printInfo.dictionary.PDFPrintAutoRotate"])) {
- [self release];
- self = nil;
- } else if (self = [super initWithNibName:@"PrintAccessoryView"
bundle:[NSBundle mainBundle]]) {
- printOperation = [aPrintOperation retain];
- document = [aDocument retain];
- }
- return self;
++ (void)initialize {
+ [self setKeys:[NSArray arrayWithObjects:@"autoRotate",
@"printScalingMode", nil]
triggerChangeNotificationsForDependentKey:@"localizedSummaryItems"];
+ [self setKeys:[NSArray arrayWithObjects:@"representedObject", nil]
triggerChangeNotificationsForDependentKey:@"autoRotate"];
+ [self setKeys:[NSArray arrayWithObjects:@"representedObject", nil]
triggerChangeNotificationsForDependentKey:@"printScalingMode"];
}
-- (void)dealloc {
- [printOperation release];
- [document release];
- [super dealloc];
+- (NSString *)nibName {
+ return @"PrintAccessoryView";
}
-- (void)windowDidLoad {
- [autoRotateButton setState:[self autoRotate] ? NSOnState : NSOffState];
- [printScalingModeMatrix selectCellWithTag:[self printScalingMode]];
- [printScalingModeMatrix setEnabled:[document
respondsToSelector:@selector(setPrintScalingMode:forPrintOperation:)]];
+- (NSBundle *)nibBundle {
+ return [NSBundle mainBundle];
}
- (BOOL)autoRotate {
- return [[printOperation
valueForKeyPath:@"printInfo.dictionary.PDFPrintAutoRotate"] boolValue];
+ return [[self
valueForKeyPath:@"representedObject.dictionary.PDFPrintAutoRotate"] boolValue];
}
- (void)setAutoRotate:(BOOL)autoRotate {
- [self willChangeValueForKey:@"localizedSummaryItems"];
- if ([document
respondsToSelector:@selector(setAutoRotate:forPrintOperation:)])
- [document setAutoRotate:autoRotate forPrintOperation:printOperation];
- [self didChangeValueForKey:@"localizedSummaryItems"];
+ [self setValue:[NSNumber numberWithBool:autoRotate]
forKeyPath:@"representedObject.dictionary.PDFPrintAutoRotate"];
}
- (PDFPrintScalingMode)printScalingMode {
- return [[printOperation
valueForKeyPath:@"printInfo.dictionary.PDFPrintScalingMode"] intValue];
+ return [[self
valueForKeyPath:@"representedObject.dictionary.PDFPrintScalingMode"] intValue];
}
- (void)setPrintScalingMode:(PDFPrintScalingMode)printScalingMode {
- [self willChangeValueForKey:@"localizedSummaryItems"];
- if ([document
respondsToSelector:@selector(setAutoRotate:forPrintOperation:)])
- [document setPrintScalingMode:printScalingMode
forPrintOperation:printOperation];
- [self didChangeValueForKey:@"localizedSummaryItems"];
+ [self setValue:[NSNumber numberWithInteger:printScalingMode]
forKeyPath:@"representedObject.dictionary.PDFPrintScalingMode"];
}
- (NSSet *)keyPathsForValuesAffectingPreview {
- return [NSSet setWithObjects:@"printAutoRotate", @"printScalingMode", nil];
+ return [NSSet setWithObjects:@"autoRotate", @"printScalingMode", nil];
}
- (NSArray *)localizedSummaryItems {
+ NSString *autoRotation = [self autoRotate] ? NSLocalizedString(@"On",
@"Print panel setting") : NSLocalizedString(@"Off", @"Print panel setting");
+ NSString *autoScaling = nil;
+ switch ([self printScalingMode]) {
+ case kPDFPrintPageScaleNone: autoScaling = NSLocalizedString(@"None",
@"Print panel setting"); break;
+ case kPDFPrintPageScaleToFit: autoScaling = NSLocalizedString(@"Scale
Each Page", @"Print panel setting"); break;
+ case kPDFPrintPageScaleDownToFit: autoScaling =
NSLocalizedString(@"Only Scale Down Large Pages", @"Print panel setting");
break;
+ }
return [NSArray arrayWithObjects:
- [NSDictionary dictionaryWithObjectsAndKeys:@"autoRotate",
NSPrintPanelAccessorySummaryItemNameKey, [[self valueForKey:@"printAutoRotate"]
description], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
- [NSDictionary dictionaryWithObjectsAndKeys:@"printScalingMode",
NSPrintPanelAccessorySummaryItemNameKey, [[self
valueForKey:@"printScalingMode"] description],
NSPrintPanelAccessorySummaryItemDescriptionKey, nil], nil];
+ [NSDictionary
dictionaryWithObjectsAndKeys:NSLocalizedString(@"Page Auto Rotation", @"Print
panel setting description"), NSPrintPanelAccessorySummaryItemNameKey,
autoRotation, NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
+ [NSDictionary
dictionaryWithObjectsAndKeys:NSLocalizedString(@"Page Auto Scaling", @"Print
panel setting description"), NSPrintPanelAccessorySummaryItemNameKey,
autoScaling, NSPrintPanelAccessorySummaryItemDescriptionKey, nil], nil];
}
@end
Modified: trunk/SKPrintAccessoryViewController.h
===================================================================
--- trunk/SKPrintAccessoryViewController.h 2008-02-25 10:15:58 UTC (rev
3441)
+++ trunk/SKPrintAccessoryViewController.h 2008-02-25 11:17:12 UTC (rev
3442)
@@ -44,11 +44,10 @@
IBOutlet NSView *view;
IBOutlet NSButton *autoRotateButton;
IBOutlet NSMatrix *printScalingModeMatrix;
- NSPrintOperation *printOperation;
- PDFDocument *document;
+ NSPrintInfo *printInfo;
}
-- (id)initWithPrintOperation:(NSPrintOperation *)aPrintOperation
document:(PDFDocument *)aDocument;
+- (id)initWithPrintInfo:(NSPrintInfo *)aPrintInfo;
- (NSView *)view;
Modified: trunk/SKPrintAccessoryViewController.m
===================================================================
--- trunk/SKPrintAccessoryViewController.m 2008-02-25 10:15:58 UTC (rev
3441)
+++ trunk/SKPrintAccessoryViewController.m 2008-02-25 11:17:12 UTC (rev
3442)
@@ -37,27 +37,22 @@
*/
#import "SKPrintAccessoryViewController.h"
-#import "PDFDocument_SKExtensions.h"
@implementation SKPrintAccessoryViewController
-- (id)initWithPrintOperation:(NSPrintOperation *)aPrintOperation
document:(PDFDocument *)aDocument {
- if (aDocument == nil || aPrintOperation == nil ||
- (NO == [aDocument
respondsToSelector:@selector(setAutoRotate:forPrintOperation:)] &&
- nil == [aPrintOperation
valueForKeyPath:@"printInfo.dictionary.PDFPrintAutoRotate"])) {
+- (id)initWithPrintInfo:(NSPrintInfo *)aPrintInfo {
+ if (aPrintInfo == nil || nil == [aPrintInfo
valueForKeyPath:@"printInfo.dictionary.PDFPrintAutoRotate"]) {
[self release];
self = nil;
} else if (self = [super init]) {
- printOperation = [aPrintOperation retain];
- document = [aDocument retain];
+ printInfo = [aPrintInfo retain];
}
return self;
}
- (void)dealloc {
- [printOperation release];
- [document release];
+ [printInfo release];
[view release];
[super dealloc];
}
@@ -71,7 +66,7 @@
[autoRotateButton setState:[self autoRotate] ? NSOnState : NSOffState];
[printScalingModeMatrix selectCellWithTag:[self printScalingMode]];
- [printScalingModeMatrix setEnabled:[document
respondsToSelector:@selector(setPrintScalingMode:forPrintOperation:)]];
+ [printScalingModeMatrix setEnabled:floor(NSAppKitVersionNumber) >
NSAppKitVersionNumber10_4];
}
- (NSView *)view {
@@ -80,25 +75,19 @@
}
- (BOOL)autoRotate {
- return [[printOperation
valueForKeyPath:@"printInfo.dictionary.PDFPrintAutoRotate"] boolValue];
+ return [[printInfo valueForKeyPath:@"dictionary.PDFPrintAutoRotate"]
boolValue];
}
- (void)setAutoRotate:(BOOL)autoRotate {
- // @@ for Tiger we set the printInfo key, should be tested to see whether
it actually works
- if ([document
respondsToSelector:@selector(setAutoRotate:forPrintOperation:)])
- [document setAutoRotate:autoRotate forPrintOperation:printOperation];
- else
- [printOperation setValue:[NSNumber numberWithBool:autoRotate]
forKeyPath:@"printInfo.dictionary.PDFPrintAutoRotate"];
+ [printInfo setValue:[NSNumber numberWithBool:autoRotate]
forKeyPath:@"dictionary.PDFPrintAutoRotate"];
}
- (PDFPrintScalingMode)printScalingMode {
- return [[printOperation
valueForKeyPath:@"printInfo.dictionary.PDFPrintScalingMode"] intValue];
+ return [[printInfo valueForKeyPath:@"dictionary.PDFPrintScalingMode"]
intValue];
}
- (void)setPrintScalingMode:(PDFPrintScalingMode)printScalingMode {
- // Tiger does not support printScalingMode, so we don't bother setting it
there
- if ([document
respondsToSelector:@selector(setAutoRotate:forPrintOperation:)])
- [document setPrintScalingMode:printScalingMode
forPrintOperation:printOperation];
+ [printInfo setValue:[NSNumber numberWithInt:printScalingMode]
forKeyPath:@"dictionary.PDFPrintScalingMode"];
}
@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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit