Revision: 3415
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3415&view=rev
Author:   hofman
Date:     2008-02-18 04:44:32 -0800 (Mon, 18 Feb 2008)

Log Message:
-----------
Ignore auto-rotate pref on Leopard as it cannot be changed anymore. Always 
auto-rotate when printing from AppleScript. It shows the print panel anyway as 
we cannot suppress that.

Modified Paths:
--------------
    trunk/SKDocument.h
    trunk/SKDocument.m

Modified: trunk/SKDocument.h
===================================================================
--- trunk/SKDocument.h  2008-02-18 12:00:31 UTC (rev 3414)
+++ trunk/SKDocument.h  2008-02-18 12:44:32 UTC (rev 3415)
@@ -63,8 +63,7 @@
     IBOutlet NSView *readNotesAccessoryView;
     IBOutlet NSButton *replaceNotesCheckButton;
     
-    IBOutlet NSButton *autoRotateButton;
-    BOOL autoRotate;
+    NSButton *autoRotateButton;
     
     // variables to be saved:
     NSData *pdfData;

Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m  2008-02-18 12:00:31 UTC (rev 3414)
+++ trunk/SKDocument.m  2008-02-18 12:44:32 UTC (rev 3415)
@@ -112,13 +112,6 @@
 
 @implementation SKDocument
 
-- (id)init {
-    if (self = [super init]) {
-        autoRotate = [[NSUserDefaults standardUserDefaults] 
boolForKey:SKAutoRotatePrintedPagesKey];
-    }
-    return self;
-}
-
 - (void)dealloc {
     [[NSUserDefaultsController sharedUserDefaultsController] 
removeObserver:self forKey:SKAutoCheckFileUpdateKey];
     [[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -149,17 +142,19 @@
         [self tryToUnlockDocument:pdfDocument];
     
     if ([pdfDocument pageCount]) {
+        BOOL autoRotate = (floor(NSAppKitVersionNumber) <= 
NSAppKitVersionNumber10_4) ? [[NSUserDefaults standardUserDefaults] 
boolForKey:SKAutoRotatePrintedPagesKey] : YES;
         PDFPage *page = [pdfDocument pageAtIndex:0];
         NSPrintInfo *printInfo = [self printInfo];
         NSSize pageSize = [page boundsForBox:kPDFDisplayBoxMediaBox].size;
+        
+        printInfo = [printInfo copy];
+        [printInfo setValue:[NSNumber numberWithBool:autoRotate] 
forKeyPath:@"dictionary.PDFPrintAutoRotate"];
         if ([page rotation] % 180 == 90)
             pageSize = NSMakeSize(pageSize.height, pageSize.width);
-        if (NO == NSEqualSizes(pageSize, [printInfo paperSize])) {
-            printInfo = [printInfo copy];
+        if (NO == NSEqualSizes(pageSize, [printInfo paperSize]))
             [printInfo setPaperSize:pageSize];
-            [self setPrintInfo:printInfo];
-            [printInfo release];
-        }
+        [self setPrintInfo:printInfo];
+        [printInfo release];
     }
     
     [mainController setPdfDocument:pdfDocument];
@@ -767,6 +762,7 @@
 #pragma mark Actions
 
 - (IBAction)printDocument:(id)sender{
+    BOOL autoRotate = [[[self printInfo] 
valueForKeyPath:@"dictionary.PDFPrintAutoRotate"] boolValue];
     [[self pdfView] printWithInfo:[self printInfo] autoRotate:autoRotate];
 }
 
@@ -1535,16 +1531,16 @@
 }
 
 - (void)setPrintInfo:(NSPrintInfo *)printInfo {
-    [[self undoManager] disableUndoRegistration];
-    [super setPrintInfo:printInfo];
-    [[self undoManager] enableUndoRegistration];
     if (autoRotateButton) {
-        BOOL newAutoRotate = [autoRotateButton state] == NSOnState;
-        if (newAutoRotate != autoRotate) {
-            autoRotate = newAutoRotate;
+        BOOL autoRotate = [autoRotateButton state] == NSOnState;
+        if (autoRotate != [[printInfo 
valueForKeyPath:@"dictionary.PDFPrintAutoRotate"] boolValue]) {
+            [printInfo setValue:[NSNumber numberWithBool:autoRotate] 
forKeyPath:@"dictionary.PDFPrintAutoRotate"];
             [[NSUserDefaults standardUserDefaults] setBool:autoRotate 
forKey:SKAutoRotatePrintedPagesKey];
         }
     }
+    [[self undoManager] disableUndoRegistration];
+    [super setPrintInfo:printInfo];
+    [[self undoManager] enableUndoRegistration];
 }
 
 - (BOOL)preparePageLayout:(NSPageLayout *)pageLayout {
@@ -1555,6 +1551,7 @@
         [autoRotateButton setTitle:NSLocalizedString(@"Auto Rotate Pages", 
@"Print layout sheet button title")];
         [autoRotateButton sizeToFit];
     }
+    BOOL autoRotate = [[[self printInfo] 
valueForKeyPath:@"dictionary.PDFPrintAutoRotate"] boolValue];
     [autoRotateButton setState:autoRotate ? NSOnState : NSOffState];
     [pageLayout setAccessoryView:autoRotateButton];
     return YES;
@@ -1812,7 +1809,7 @@
         [[printInfo dictionary] addEntriesFromDictionary:settings];
     }
     
-    [[self pdfView] printWithInfo:printInfo autoRotate:NO];
+    [[self pdfView] printWithInfo:printInfo autoRotate:YES];
     
     return nil;
 }


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

Reply via email to