Revision: 7054
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7054&view=rev
Author:   hofman
Date:     2011-01-07 16:13:52 +0000 (Fri, 07 Jan 2011)

Log Message:
-----------
Disable more menu and toolbar items when the document is locked. Fix rotate 
toolbar items.

Modified Paths:
--------------
    trunk/SKMainToolbarController.m
    trunk/SKMainWindowController_UI.m
    trunk/SKPDFView.m

Modified: trunk/SKMainToolbarController.m
===================================================================
--- trunk/SKMainToolbarController.m     2011-01-07 14:41:26 UTC (rev 7053)
+++ trunk/SKMainToolbarController.m     2011-01-07 16:13:52 UTC (rev 7054)
@@ -362,6 +362,7 @@
             [item setLabels:NSLocalizedString(@"Rotate Right", @"Toolbar item 
label")];
             [item setToolTip:NSLocalizedString(@"Rotate Right", @"Tool tip 
message")];
             [item setViewWithSizes:rotateRightButton];
+            [item setMenuFormRepresentation:menuItem];
             
         } else if ([identifier 
isEqualToString:SKDocumentToolbarRotateLeftItemIdentifier]) {
             
@@ -374,7 +375,10 @@
             
         } else if ([identifier 
isEqualToString:SKDocumentToolbarRotateLeftRightItemIdentifier]) {
             
-            menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] 
initWithTitle:NSLocalizedString(@"Rotate Left", @"Menu item title") 
action:@selector(rotateAllLeft:) target:mainController] autorelease];
+            menu = [NSMenu menu];
+            [menu addItemWithTitle:NSLocalizedString(@"Rotate Right", @"Menu 
item title") action:@selector(rotateAllRight:) target:mainController];
+            [menu addItemWithTitle:NSLocalizedString(@"Rotate Left", @"Menu 
item title") action:@selector(rotateAllLeft:) target:mainController];
+            menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] 
initWithTitle:NSLocalizedString(@"Rotate", @"Toolbar item label") submenu:menu] 
autorelease];
             
             [item setLabels:NSLocalizedString(@"Rotate", @"Toolbar item 
label")];
             [item setToolTip:NSLocalizedString(@"Rotate Left or Right", @"Tool 
tip message")];
@@ -773,18 +777,24 @@
         return [mainController.pdfView.document isLocked] == NO && 
[mainController.pdfView autoScales] == NO;
     } else if ([identifier 
isEqualToString:SKDocumentToolbarZoomToSelectionItemIdentifier]) {
         return [mainController.pdfView.document isLocked] == NO && 
NSIsEmptyRect([mainController.pdfView currentSelectionRect]) == NO;
+    } else if ([identifier 
isEqualToString:SKDocumentToolbarDisplayBoxItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarDisplayModeItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarSingleTwoUpItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarContinuousItemIdentifier]) {
+        return [mainController.pdfView.document isLocked] == NO;
     } else if ([identifier 
isEqualToString:SKDocumentToolbarNewTextNoteItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarNewCircleNoteItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarNewLineItemIdentifier]) {
-        return ([mainController.pdfView toolMode] == SKTextToolMode || 
[mainController.pdfView toolMode] == SKNoteToolMode) && [mainController.pdfView 
hideNotes] == NO;
+        return ([mainController.pdfView toolMode] == SKTextToolMode || 
[mainController.pdfView toolMode] == SKNoteToolMode) && [mainController.pdfView 
hideNotes] == NO && [mainController.pdfView.document isLocked] == NO;
     } else if ([identifier 
isEqualToString:SKDocumentToolbarNewMarkupItemIdentifier]) {
-        return ([mainController.pdfView toolMode] == SKTextToolMode || 
[mainController.pdfView toolMode] == SKNoteToolMode) && [mainController.pdfView 
hideNotes] == NO && [[mainController.pdfView currentSelection] hasCharacters];
+        return ([mainController.pdfView toolMode] == SKTextToolMode || 
[mainController.pdfView toolMode] == SKNoteToolMode) && [mainController.pdfView 
hideNotes] == NO && [mainController.pdfView.document isLocked] == NO && 
[[mainController.pdfView currentSelection] hasCharacters];
+    } else if ([identifier 
isEqualToString:SKDocumentToolbarNewLineItemIdentifier]) {
+        return ([mainController.pdfView toolMode] == SKTextToolMode || 
[mainController.pdfView toolMode] == SKNoteToolMode) && [mainController.pdfView 
hideNotes] == NO && [mainController.pdfView.document isLocked] == NO && 
[[mainController.pdfView currentSelection] hasCharacters];
     } else if ([identifier 
isEqualToString:SKDocumentToolbarNewNoteItemIdentifier]) {
         BOOL enabled = ([mainController.pdfView toolMode] == SKTextToolMode || 
[mainController.pdfView toolMode] == SKNoteToolMode) && [mainController.pdfView 
hideNotes] == NO && [[mainController.pdfView currentSelection] hasCharacters];
         [noteButton setEnabled:enabled forSegment:SKHighlightNote];
         [noteButton setEnabled:enabled forSegment:SKUnderlineNote];
         [noteButton setEnabled:enabled forSegment:SKStrikeOutNote];
-        return ([mainController.pdfView toolMode] == SKTextToolMode || 
[mainController.pdfView toolMode] == SKNoteToolMode) && [mainController.pdfView 
hideNotes] == NO;
+        return ([mainController.pdfView toolMode] == SKTextToolMode || 
[mainController.pdfView toolMode] == SKNoteToolMode) && [mainController.pdfView 
hideNotes] == NO && [mainController.pdfView.document isLocked] == NO;
     } else if ([identifier 
isEqualToString:SKDocumentToolbarFullScreenItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarPresentationItemIdentifier]) {
         return [mainController.pdfView.document isLocked] == NO;
+    } else if ([identifier 
isEqualToString:SKDocumentToolbarRotateRightItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarRotateLeftItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarRotateLeftRightItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarCropItemIdentifier]) {
+        return [mainController.pdfView.document isLocked] == NO;
     }
     return YES;
 }

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2011-01-07 14:41:26 UTC (rev 7053)
+++ trunk/SKMainWindowController_UI.m   2011-01-07 16:13:52 UTC (rev 7054)
@@ -1359,7 +1359,7 @@
     SEL action = [menuItem action];
     if (action == @selector(createNewNote:)) {
         BOOL isMarkup = [menuItem tag] == SKHighlightNote || [menuItem tag] == 
SKUnderlineNote || [menuItem tag] == SKStrikeOutNote;
-        return [self interactionMode] != SKPresentationMode && ([pdfView 
toolMode] == SKTextToolMode || [pdfView toolMode] == SKNoteToolMode) && 
[pdfView hideNotes] == NO && (isMarkup == NO || [[pdfView currentSelection] 
hasCharacters]);
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO && ([pdfView toolMode] == SKTextToolMode || 
[pdfView toolMode] == SKNoteToolMode) && [pdfView hideNotes] == NO && (isMarkup 
== NO || [[pdfView currentSelection] hasCharacters]);
     } else if (action == @selector(editNote:)) {
         PDFAnnotation *annotation = [pdfView activeAnnotation];
         return [self interactionMode] != SKPresentationMode && [annotation 
isSkimNote] && ([annotation isEditable]);
@@ -1375,33 +1375,33 @@
     } else if (action == @selector(displaySinglePages:)) {
         BOOL displaySinglePages = [pdfView displayMode] == 
kPDFDisplaySinglePage || [pdfView displayMode] == 
kPDFDisplaySinglePageContinuous;
         [menuItem setState:displaySinglePages ? NSOnState : NSOffState];
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(displayFacingPages:)) {
         BOOL displayFacingPages = [pdfView displayMode] == kPDFDisplayTwoUp || 
[pdfView displayMode] == kPDFDisplayTwoUpContinuous;
         [menuItem setState:displayFacingPages ? NSOnState : NSOffState];
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(changeDisplaySinglePages:)) {
         BOOL displaySinglePages1 = [pdfView displayMode] == 
kPDFDisplaySinglePage || [pdfView displayMode] == 
kPDFDisplaySinglePageContinuous;
         BOOL displaySinglePages2 = (PDFDisplayMode)[menuItem tag] == 
kPDFDisplaySinglePage;
         [menuItem setState:displaySinglePages1 == displaySinglePages2 ? 
NSOnState : NSOffState];
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(changeDisplayContinuous:)) {
         BOOL displayContinuous1 = [pdfView displayMode] == 
kPDFDisplaySinglePageContinuous || [pdfView displayMode] == 
kPDFDisplayTwoUpContinuous;
         BOOL displayContinuous2 = (PDFDisplayMode)[menuItem tag] == 
kPDFDisplaySinglePageContinuous;
         [menuItem setState:displayContinuous1 == displayContinuous2 ? 
NSOnState : NSOffState];
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(changeDisplayMode:)) {
         [menuItem setState:[pdfView displayMode] == (PDFDisplayMode)[menuItem 
tag] ? NSOnState : NSOffState];
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(toggleDisplayAsBook:)) {
         [menuItem setState:[pdfView displaysAsBook] ? NSOnState : NSOffState];
-        return [self interactionMode] != SKPresentationMode && ([pdfView 
displayMode] == kPDFDisplayTwoUp || [pdfView displayMode] == 
kPDFDisplayTwoUpContinuous);
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO && ([pdfView displayMode] == kPDFDisplayTwoUp || 
[pdfView displayMode] == kPDFDisplayTwoUpContinuous);
     } else if (action == @selector(toggleDisplayPageBreaks:)) {
         [menuItem setState:[pdfView displaysPageBreaks] ? NSOnState : 
NSOffState];
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(changeDisplayBox:)) {
         [menuItem setState:[pdfView displayBox] == (PDFDisplayBox)[menuItem 
tag] ? NSOnState : NSOffState];
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(delete:) || action == @selector(copy:) || 
action == @selector(cut:) || action == @selector(paste:) || action == 
@selector(alternatePaste:) || action == @selector(pasteAsPlainText:) || action 
== @selector(deselectAll:) || action == @selector(changeAnnotationMode:) || 
action == @selector(changeToolMode:) || action == @selector(changeToolMode:)) {
         return [pdfView validateMenuItem:menuItem];
     } else if (action == @selector(doGoToNextPage:)) {
@@ -1412,6 +1412,8 @@
         return [pdfView canGoToFirstPage];
     } else if (action == @selector(doGoToLastPage:)) {
         return [pdfView canGoToLastPage];
+    } else if (action == @selector(doGoToPage:)) {
+        return [[self pdfDocument] isLocked] == NO;
     } else if (action == @selector(allGoToNextPage:)) {
         return [[allMainDocumentPDFViews() 
valueForKeyPath:@"@min.canGoToNextPage"] boolValue];
     } else if (action == @selector(allGoToPreviousPage:)) {
@@ -1432,6 +1434,8 @@
             [menuItem setTitle:NSLocalizedString(@"Go To Marked Page", @"Menu 
item title")];
             return markedPageIndex != NSNotFound && markedPageIndex != 
[[pdfView currentPage] pageIndex];
         }
+    } else if (action == @selector(markPage:)) {
+        return [[self pdfDocument] isLocked] == NO;
     } else if (action == @selector(doZoomIn:)) {
         return [self interactionMode] != SKPresentationMode && [pdfView 
canZoomIn];
     } else if (action == @selector(doZoomOut:)) {
@@ -1439,7 +1443,7 @@
     } else if (action == @selector(doZoomToActualSize:)) {
         return [[self pdfDocument] isLocked] == NO && fabs([pdfView 
scaleFactor] - 1.0 ) > 0.01;
     } else if (action == @selector(doZoomToPhysicalSize:)) {
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(doZoomToSelection:)) {
         return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO && NSIsEmptyRect([pdfView currentSelectionRect]) 
== NO;
     } else if (action == @selector(doZoomToFit:)) {
@@ -1451,12 +1455,14 @@
         } else {
             [menuItem setTitle:NSLocalizedString(@"Zoom To Height", @"Menu 
item title")];
         }
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(doAutoScale:)) {
         return [[self pdfDocument] isLocked] == NO && [pdfView autoScales] == 
NO;
     } else if (action == @selector(toggleAutoScale:)) {
         [menuItem setState:[pdfView autoScales] ? NSOnState : NSOffState];
         return [[self pdfDocument] isLocked] == NO;
+    } else if (action == @selector(rotateRight:) || action == 
@selector(rotateLeft:) || action == @selector(rotateAllRight:) || action == 
@selector(rotateAllLeft:)) {
+        return [[self pdfDocument] isLocked] == NO;
     } else if (action == @selector(cropAll:) || action == @selector(crop:) || 
action == @selector(autoCropAll:) || action == @selector(smartAutoCropAll:)) {
         return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(autoSelectContent:)) {
@@ -1505,10 +1511,12 @@
         else
             [menuItem setTitle:NSLocalizedString(@"Presentation", @"Menu item 
title")];
         return [[self pdfDocument] isLocked] == NO;
+    } else if (action == @selector(enterFullScreen:) || action == 
@selector(enterPresentation:)) {
+        return [[self pdfDocument] isLocked] == NO;
     } else if (action == @selector(getInfo:)) {
         return [self interactionMode] != SKPresentationMode;
     } else if (action == @selector(performFit:)) {
-        return [self interactionMode] == SKNormalMode;
+        return [self interactionMode] == SKNormalMode && [[self pdfDocument] 
isLocked] == NO;
     } else if (action == @selector(password:)) {
         return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked];
     } else if (action == @selector(toggleReadingBar:)) {
@@ -1516,13 +1524,13 @@
             [menuItem setTitle:NSLocalizedString(@"Hide Reading Bar", @"Menu 
item title")];
         else
             [menuItem setTitle:NSLocalizedString(@"Show Reading Bar", @"Menu 
item title")];
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(savePDFSettingToDefaults:)) {
         if ([self interactionMode] == SKFullScreenMode)
             [menuItem setTitle:NSLocalizedString(@"Use Current View Settings 
as Default for Full Screen", @"Menu item title")];
         else
             [menuItem setTitle:NSLocalizedString(@"Use Current View Settings 
as Default", @"Menu item title")];
-        return [self interactionMode] != SKPresentationMode;
+        return [self interactionMode] != SKPresentationMode && [[self 
pdfDocument] isLocked] == NO;
     } else if (action == @selector(chooseTransition:)) {
         return [[self pdfDocument] pageCount] > 1;
     } else if (action == @selector(toggleCaseInsensitiveSearch:)) {

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2011-01-07 14:41:26 UTC (rev 7053)
+++ trunk/SKPDFView.m   2011-01-07 16:13:52 UTC (rev 7054)
@@ -964,6 +964,14 @@
     return [[self document] isLocked] == NO && [super canGoToPreviousPage];
 }
 
+- (BOOL)canGoToFirstPage {
+    return [[self document] isLocked] == NO && [super canGoToFirstPage];
+}
+
+- (BOOL)canGoToLastPage {
+    return [[self document] isLocked] == NO && [super canGoToLastPage];
+}
+
 - (BOOL)canGoBack {
     return [[self document] isLocked] == NO && [super canGoBack];
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to