1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 11:23:40 +00:00

Merge pull request #1441 from federicobond/replace-deprecated-api

macosx: Replace deprecated NSRunAlertPanel call in Controller.m
This commit is contained in:
Mitch Livingston 2020-11-22 08:57:29 -05:00 committed by GitHub
commit e1a7f5384d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -853,11 +853,15 @@ static void removeKeRangerRansomware()
fPendingTorrentDownloads = nil; fPendingTorrentDownloads = nil;
} }
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title"), NSString * message = [NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.",
[NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.",
"Download not a torrent -> message"), suggestedName, "Download not a torrent -> message"), suggestedName,
[[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]], [[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
NSLocalizedString(@"OK", "Download not a torrent -> button"), nil, nil);
NSAlert * alert = [[NSAlert alloc] init];
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Download not a torrent -> button")];
[alert setMessageText: NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title")];
[alert setInformativeText: message];
[alert runModal];
} }
else else
[download setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]] [download setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]]
@ -872,11 +876,16 @@ static void removeKeRangerRansomware()
- (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error - (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error
{ {
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Torrent download error -> title"), NSString * message = [NSString stringWithFormat: NSLocalizedString(@"The torrent could not be downloaded from %@: %@.",
[NSString stringWithFormat: NSLocalizedString(@"The torrent could not be downloaded from %@: %@.",
"Torrent download failed -> message"), "Torrent download failed -> message"),
[[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding], [[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding],
[error localizedDescription]], NSLocalizedString(@"OK", "Torrent download failed -> button"), nil, nil); [error localizedDescription]];
NSAlert * alert = [[NSAlert alloc] init];
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent download failed -> button")];
[alert setMessageText: NSLocalizedString(@"Torrent download failed", "Torrent download error -> title")];
[alert setInformativeText: message];
[alert runModal];
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]]; [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
if ([fPendingTorrentDownloads count] == 0) if ([fPendingTorrentDownloads count] == 0)