aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-06-25 23:47:03 +0000
committerrowanbeentje <rowan@beent.je>2009-06-25 23:47:03 +0000
commitc07a014d36c1ed5cc157abb4725e41d91bdfa304 (patch)
tree39be01b70a6fefa8dcaef3dd17d81909b7d79650
parent11790e1f90b457f440b2d2bd36a7a576dc1e427d (diff)
downloadsequelpro-c07a014d36c1ed5cc157abb4725e41d91bdfa304.tar.gz
sequelpro-c07a014d36c1ed5cc157abb4725e41d91bdfa304.tar.bz2
sequelpro-c07a014d36c1ed5cc157abb4725e41d91bdfa304.zip
- Printing of backgrounds is now correctly separated from the WebKit preferences, and no longer links SP to Safari
-rw-r--r--Source/SPPrintAccessory.h5
-rw-r--r--Source/SPPrintAccessory.m15
-rw-r--r--Source/TableDocument.m1
3 files changed, 18 insertions, 3 deletions
diff --git a/Source/SPPrintAccessory.h b/Source/SPPrintAccessory.h
index 5bdf4343..b1975b7e 100644
--- a/Source/SPPrintAccessory.h
+++ b/Source/SPPrintAccessory.h
@@ -1,10 +1,15 @@
#import <Cocoa/Cocoa.h>
+#import <WebKit/WebKit.h>
@interface SPPrintAccessory : NSViewController <NSPrintPanelAccessorizing>
{
IBOutlet NSView *printAccessoryView;
IBOutlet NSUserDefaultsController *defaultsController;
+
+ WebView *printWebView;
}
+- (void) setPrintView:(WebView *)theWebView;
+
@end
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 <WebKit/WebKit.h>
@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"];
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index acd8d978..d710caa1 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -157,6 +157,7 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
SPPrintAccessory *printAccessory = [[SPPrintAccessory alloc] init];
[printAccessory initWithNibName:@"printAccessory" bundle:nil];
+ [printAccessory setPrintView:printWebView];
[printPanel addAccessoryController:printAccessory];
NSPageLayout *pageLayout = [NSPageLayout pageLayout];