Revision: 14738
http://sourceforge.net/p/skim-app/code/14738
Author: hofman
Date: 2024-11-22 16:34:37 +0000 (Fri, 22 Nov 2024)
Log Message:
-----------
Show an error when printing fails
Modified Paths:
--------------
trunk/SKApplicationController.m
trunk/SKDocumentController.h
trunk/SKDocumentController.m
trunk/de.lproj/Localizable.strings
trunk/en.lproj/Localizable.strings
trunk/es.lproj/Localizable.strings
trunk/fr.lproj/Localizable.strings
trunk/it.lproj/Localizable.strings
trunk/ja.lproj/Localizable.strings
trunk/nl.lproj/Localizable.strings
trunk/pl.lproj/Localizable.strings
trunk/ru.lproj/Localizable.strings
trunk/zh_CN.lproj/Localizable.strings
trunk/zh_TW.lproj/Localizable.strings
Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m 2024-11-22 15:36:50 UTC (rev 14737)
+++ trunk/SKApplicationController.m 2024-11-22 16:34:37 UTC (rev 14738)
@@ -308,7 +308,9 @@
for (NSString *fileName in fileNames)
[fileURLs addObject:[NSURL fileURLWithPath:fileName]];
- [[NSDocumentController sharedDocumentController]
printDocumentsWithContentsOfURLs:fileURLs withSettings:printSettings
showPrintPanels:showPrintPanels completionHandler:^(BOOL didPrintSuccessfully){
+ [[NSDocumentController sharedDocumentController]
printDocumentsWithContentsOfURLs:fileURLs withSettings:printSettings
showPrintPanels:showPrintPanels completionHandler:^(BOOL didPrintSuccessfully,
NSError *error){
+ if (didPrintSuccessfully == NO && error)
+ [NSApp presentError:error];
if (reply == NSPrintingReplyLater)
[NSApp replyToOpenOrPrint:didPrintSuccessfully ?
NSApplicationDelegateReplySuccess : NSApplicationDelegateReplyFailure];
reply = didPrintSuccessfully ? NSPrintingSuccess : NSPrintingFailure;
Modified: trunk/SKDocumentController.h
===================================================================
--- trunk/SKDocumentController.h 2024-11-22 15:36:50 UTC (rev 14737)
+++ trunk/SKDocumentController.h 2024-11-22 16:34:37 UTC (rev 14738)
@@ -81,7 +81,7 @@
- (void)openDocumentWithBookmark:(SKBookmark *)bookmark
completionHandler:(void (^)(NSDocument * _Nullable document, BOOL
documentWasAlreadyOpen, NSError * _Nullable error))completionHandler;
- (void)openDocumentWithBookmarks:(NSArray<SKBookmark *> *)bookmarks
completionHandler:(void (^)(NSDocument * _Nullable document, BOOL
documentWasAlreadyOpen, NSError * _Nullable error))completionHandler;
-- (void)printDocumentsWithContentsOfURLs:(NSArray<NSURL *> *)urls
withSettings:(NSDictionary<NSString *, id> *)printSettings
showPrintPanels:(BOOL)showPrintPanels completionHandler:(void (^)(BOOL
didPrintSuccessfully))completionHandler;
+- (void)printDocumentsWithContentsOfURLs:(NSArray<NSURL *> *)urls
withSettings:(NSDictionary<NSString *, id> *)printSettings
showPrintPanels:(BOOL)showPrintPanels completionHandler:(void (^)(BOOL
didPrintSuccessfully, NSError *error))completionHandler;
- (nullable Class)documentClassForContentsOfURL:(NSURL *)inAbsoluteURL;
Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m 2024-11-22 15:36:50 UTC (rev 14737)
+++ trunk/SKDocumentController.m 2024-11-22 16:34:37 UTC (rev 14738)
@@ -658,10 +658,10 @@
}
}
-- (void)printDocumentsWithContentsOfURLs:(NSArray *)urls
withSettings:(NSDictionary *)printSettings
showPrintPanels:(BOOL)showPrintPanels completionHandler:(void (^)(BOOL
didPrintSuccessfully))completionHandler {
+- (void)printDocumentsWithContentsOfURLs:(NSArray *)urls
withSettings:(NSDictionary *)printSettings
showPrintPanels:(BOOL)showPrintPanels completionHandler:(void (^)(BOOL
didPrintSuccessfully, NSError *error))completionHandler {
NSUInteger count = [urls count];
if ([urls count] == 0) {
- completionHandler(YES);
+ completionHandler(YES, nil);
return;
}
@@ -672,14 +672,18 @@
void (^block)(BOOL) = ^(BOOL success){
if (documentWasAlreadyOpen == NO)
[document close];
- if (success && nextURLs)
+ if (success && nextURLs) {
[self printDocumentsWithContentsOfURLs:nextURLs
withSettings:printSettings showPrintPanels:showPrintPanels
completionHandler:completionHandler];
- else
- completionHandler(success);
+ } else {
+ NSError *err = nil;
+ if (success == NO)
+ err = [NSError
printDocumentErrorWithLocalizedDescription:[NSString
stringWithFormat:NSLocalizedString(@"The file \"%@\" could not be printed",
@"Error description"), [document displayName]]];
+ completionHandler(success, err);
+ }
};
[document printDocumentWithSettings:printSettings
showPrintPanel:showPrintPanels delegate:self
didPrintSelector:@selector(document:didPrint:contextInfo:) contextInfo:(void
*)CFBridgingRetain(block)];
} else {
- completionHandler(NO);
+ completionHandler(NO, error);
}
}];
}
@@ -726,7 +730,7 @@
- (void)printDocumentFromURLOnPboard:(NSPasteboard *)pboard userData:(NSString
*)userData error:(out NSString * __autoreleasing *)errorString {
NSURL *theURL = [[NSURL readURLsFromPasteboard:pboard] firstObject];
if (theURL)
- [self printDocumentsWithContentsOfURLs:@[theURL] withSettings:@{}
showPrintPanels:[userData boolValue] completionHandler:^(BOOL
didPrintSuccessfully){}];
+ [self printDocumentsWithContentsOfURLs:@[theURL] withSettings:@{}
showPrintPanels:[userData boolValue] completionHandler:^(BOOL
didPrintSuccessfully, NSError *error){}];
}
@end
Modified: trunk/de.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/en.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/es.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/fr.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/it.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/ja.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/nl.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/pl.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/ru.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/zh_CN.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/zh_TW.lproj/Localizable.strings
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit