Revision: 14767 http://sourceforge.net/p/skim-app/code/14767 Author: hofman Date: 2024-11-30 15:35:52 +0000 (Sat, 30 Nov 2024) Log Message: ----------- show password sheet when attempting to print a document that does not allow printing
Modified Paths: -------------- trunk/SKMainDocument.m Modified: trunk/SKMainDocument.m =================================================================== --- trunk/SKMainDocument.m 2024-11-30 15:26:59 UTC (rev 14766) +++ trunk/SKMainDocument.m 2024-11-30 15:35:52 UTC (rev 14767) @@ -1350,8 +1350,6 @@ NSOrderedAscending == [[self fileModificationDate] compare:fileModificationDate([self fileURL])]) return YES; return [super validateUserInterfaceItem:anItem]; - } else if ([anItem action] == @selector(printDocument:)) { - return [[self pdfDocument] allowsPrinting]; } else if ([anItem action] == @selector(convertNotes:)) { return [[NSWorkspace sharedWorkspace] type:[self fileType] conformsToType:SKDocumentTypePDF] && [[self pdfDocument] allowsNotes]; } else if ([anItem action] == @selector(readNotes:)) { @@ -1380,6 +1378,22 @@ [[self mainWindowController] remoteButtonPressed:theEvent]; } +- (void)printDocument:(id)sender { + PDFDocument *pdfDoc = [self pdfDocument]; + if ([pdfDoc allowsPrinting]) { + [super printDocument:sender]; + } else { + SKTextFieldSheetController *passwordSheetController = [[SKTextFieldSheetController alloc] initWithWindowNibName:@"PasswordSheet"]; + [passwordSheetController beginSheetModalForWindow:[[self mainWindowController] window] completionHandler:^(NSModalResponse result) { + if (result == NSModalResponseOK) { + [[passwordSheetController window] orderOut:nil]; + [pdfDoc unlockWithPassword:[passwordSheetController stringValue]]; + [self printDocument:nil]; + } + }]; + } +} + #pragma mark Notification handlers - (void)handleWindowWillCloseNotification:(NSNotification *)notification { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit