From c07a014d36c1ed5cc157abb4725e41d91bdfa304 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 25 Jun 2009 23:47:03 +0000 Subject: - Printing of backgrounds is now correctly separated from the WebKit preferences, and no longer links SP to Safari --- Source/SPPrintAccessory.m | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Source/SPPrintAccessory.m') diff --git a/Source/SPPrintAccessory.m b/Source/SPPrintAccessory.m index 93c7ce4e..d0f3dc14 100644 --- a/Source/SPPrintAccessory.m +++ b/Source/SPPrintAccessory.m @@ -1,18 +1,17 @@ #import "SPPrintAccessory.h" -#import @implementation SPPrintAccessory - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { defaultsController = [NSUserDefaultsController sharedUserDefaultsController]; + printWebView = nil; return [super initWithNibName:@"printAccessory" bundle:nibBundleOrNil]; } - (void)awakeFromNib { [self setView:printAccessoryView]; - [[WebPreferences standardPreferences] setShouldPrintBackgrounds:[[defaultsController valueForKeyPath:@"values.PrintBackground"] boolValue] ]; [defaultsController addObserver:self forKeyPath:@"values.PrintBackground" options:NSKeyValueObservingOptionNew context:@"PrinterSettingsChanged"]; } @@ -32,12 +31,22 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([(NSString *)context isEqualToString:@"PrinterSettingsChanged"]) { - [[WebPreferences standardPreferences] setShouldPrintBackgrounds:[[defaultsController valueForKeyPath:@"values.PrintBackground"] boolValue] ]; + if (printWebView) [[printWebView preferences] setShouldPrintBackgrounds:[[defaultsController valueForKeyPath:@"values.PrintBackground"] boolValue]]; } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } } +/* + * Set the print view that the print accessory controls; set initial + * preferences based on user defaults. + */ +- (void) setPrintView:(WebView *)theWebView +{ + printWebView = theWebView; + [[printWebView preferences] setShouldPrintBackgrounds:[[defaultsController valueForKeyPath:@"values.PrintBackground"] boolValue]]; +} + - (void)dealloc { [defaultsController removeObserver:self forKeyPath:@"values.PrintBackground"]; -- cgit v1.2.3