mirror of
https://github.com/transmission/transmission
synced 2024-12-22 07:42:37 +00:00
Update some selector-based alerts to block-based
This commit is contained in:
parent
7b815b766c
commit
4a4233feae
1 changed files with 24 additions and 25 deletions
|
@ -735,16 +735,21 @@ static void removeKeRangerRansomware()
|
|||
|
||||
if ([fDefaults boolForKey: @"CheckQuitDownloading"] ? downloading > 0 : active > 0)
|
||||
{
|
||||
NSString * message = active == 1
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.alertStyle = NSAlertStyleInformational;
|
||||
alert.messageText = NSLocalizedString(@"Are you sure you want to quit?", "Confirm Quit panel -> title");
|
||||
alert.informativeText = active == 1
|
||||
? NSLocalizedString(@"There is an active transfer that will be paused on quit."
|
||||
" The transfer will automatically resume on the next launch.", "Confirm Quit panel -> message")
|
||||
: [NSString stringWithFormat: NSLocalizedString(@"There are %d active transfers that will be paused on quit."
|
||||
" The transfers will automatically resume on the next launch.", "Confirm Quit panel -> message"), active];
|
||||
|
||||
NSBeginAlertSheet(NSLocalizedString(@"Are you sure you want to quit?", "Confirm Quit panel -> title"),
|
||||
NSLocalizedString(@"Quit", "Confirm Quit panel -> button"),
|
||||
NSLocalizedString(@"Cancel", "Confirm Quit panel -> button"), nil, fWindow, self,
|
||||
@selector(quitSheetDidEnd:returnCode:contextInfo:), nil, nil, @"%@", message);
|
||||
[alert addButtonWithTitle:NSLocalizedString(@"Quit", "Confirm Quit panel -> button")];
|
||||
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Confirm Quit panel -> button")];
|
||||
|
||||
[alert beginSheetModalForWindow:fWindow
|
||||
completionHandler:^(NSModalResponse returnCode) {
|
||||
[NSApp replyToApplicationShouldTerminate: returnCode == NSAlertFirstButtonReturn];
|
||||
}];
|
||||
return NSTerminateLater;
|
||||
}
|
||||
}
|
||||
|
@ -752,11 +757,6 @@ static void removeKeRangerRansomware()
|
|||
return NSTerminateNow;
|
||||
}
|
||||
|
||||
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
|
||||
{
|
||||
[NSApp replyToApplicationShouldTerminate: returnCode == NSAlertDefaultReturn];
|
||||
}
|
||||
|
||||
- (void) applicationWillTerminate: (NSNotification *) notification
|
||||
{
|
||||
fQuitting = YES;
|
||||
|
@ -1401,9 +1401,6 @@ static void removeKeRangerRansomware()
|
|||
|
||||
if ([fDefaults boolForKey: @"CheckRemoveDownloading"] ? downloading > 0 : active > 0)
|
||||
{
|
||||
NSDictionary * dict = @{ @"Torrents" : torrents,
|
||||
@"DeleteData" : @(deleteData) };
|
||||
|
||||
NSString * title, * message;
|
||||
|
||||
const NSUInteger selected = [torrents count];
|
||||
|
@ -1446,9 +1443,19 @@ static void removeKeRangerRansomware()
|
|||
"Removal confirm panel -> message part 2")];
|
||||
}
|
||||
|
||||
NSBeginAlertSheet(title, NSLocalizedString(@"Remove", "Removal confirm panel -> button"),
|
||||
NSLocalizedString(@"Cancel", "Removal confirm panel -> button"), nil, fWindow, self,
|
||||
nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), (__bridge_retained void *)(dict), @"%@", message);
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.alertStyle = NSAlertStyleInformational;
|
||||
alert.messageText = title;
|
||||
alert.informativeText = message;
|
||||
[alert addButtonWithTitle:NSLocalizedString(@"Remove", "Removal confirm panel -> button")];
|
||||
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Removal confirm panel -> button")];
|
||||
|
||||
[alert beginSheetModalForWindow:fWindow
|
||||
completionHandler:^(NSModalResponse returnCode) {
|
||||
if (returnCode == NSAlertFirstButtonReturn) {
|
||||
[self confirmRemoveTorrents: torrents deleteData: deleteData];
|
||||
}
|
||||
}];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1456,14 +1463,6 @@ static void removeKeRangerRansomware()
|
|||
[self confirmRemoveTorrents: torrents deleteData: deleteData];
|
||||
}
|
||||
|
||||
- (void) removeSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
|
||||
{
|
||||
NSDictionary * dict = (__bridge_transfer NSDictionary *)contextInfo;
|
||||
NSArray * torrents = dict[@"Torrents"];
|
||||
if (returnCode == NSAlertDefaultReturn)
|
||||
[self confirmRemoveTorrents: torrents deleteData: [dict[@"DeleteData"] boolValue]];
|
||||
}
|
||||
|
||||
- (void) confirmRemoveTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData
|
||||
{
|
||||
//miscellaneous
|
||||
|
|
Loading…
Reference in a new issue