aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPPreferenceController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-19 17:10:55 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-19 17:10:55 +0000
commit692e6e7330d9a6fd0227f74c1665ddc0b19cc4c6 (patch)
tree6eb9bb4b085cbf80b3f038d9cb07edde4220774c /Source/SPPreferenceController.m
parent8915074c6393bdc5cbaa7900299122f0d4e365be (diff)
downloadsequelpro-692e6e7330d9a6fd0227f74c1665ddc0b19cc4c6.tar.gz
sequelpro-692e6e7330d9a6fd0227f74c1665ddc0b19cc4c6.tar.bz2
sequelpro-692e6e7330d9a6fd0227f74c1665ddc0b19cc4c6.zip
• added SPBeginWaitingAlertSheet() routine which offers the chance to display an alert sheet which waits for the change in the didEndSelector method of a passed class NSInteger variable
• applied the SPBeginWaitingAlertSheet routine to Pref > Editor's check for unsaved color themes and in SPCustomQuery's sheet about Stop/Continue/Run All if a query failed after executing "Run All"
Diffstat (limited to 'Source/SPPreferenceController.m')
-rw-r--r--Source/SPPreferenceController.m50
1 files changed, 11 insertions, 39 deletions
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index 2810eeb6..9f09ac2c 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -32,6 +32,7 @@
#import "SPColorAdditions.h"
#import "SPColorWellCell.h"
#import "SPFileManagerAdditions.h"
+#import "SPAlertSheets.h"
@interface SPPreferenceController (PrivateAPI)
@@ -1892,7 +1893,6 @@
- (void)checkForUnsavedThemeDidEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
- [[sheet window] orderOut:self];
checkForUnsavedThemeSheetStatus = returnCode;
}
@@ -1904,45 +1904,17 @@
[[NSColorPanel sharedColorPanel] close];
- checkForUnsavedThemeSheetStatus = -1;
-
- NSAlert *alert = [[[NSAlert alloc] init] autorelease];
- [alert addButtonWithTitle:NSLocalizedString(@"Proceed", @"proceed button")];
- [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"cancel button")];
- [alert addButtonWithTitle:nil];
- [alert setMessageText:NSLocalizedString(@"Warning", @"warning")];
- [alert setInformativeText:NSLocalizedString(@"Current color theme is unsaved. Do you want to proceed without saving it?", @"Current color theme is unsaved. Do you want to proceed without saving it message")];
- [alert setAlertStyle:NSWarningAlertStyle];
- [alert setShowsHelp:NO];
- [alert setShowsSuppressionButton:NO];
-
- [alert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(checkForUnsavedThemeDidEndSheet:returnCode:contextInfo:) contextInfo:nil];
-
- // wait for the sheet
- NSModalSession session = [NSApp beginModalSessionForWindow:[alert window]];
- for (;;) {
-
- if(checkForUnsavedThemeSheetStatus != -1)
- break;
-
- // Execute code on DefaultRunLoop
- [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
- beforeDate:[NSDate distantFuture]];
-
- // Break the run loop if sheet was closed
- if ([NSApp runModalSession:session] != NSRunContinuesResponse
- || ![[alert window] isVisible])
- break;
-
- // Execute code on DefaultRunLoop
- [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
- beforeDate:[NSDate distantFuture]];
-
- }
- [NSApp endModalSession:session];
- [NSApp endSheet:[alert window]];
+ SPBeginWaitingAlertSheet(@"title",
+ NSLocalizedString(@"Proceed", @"proceed button"), NSLocalizedString(@"Cancel", @"cancel button"), nil,
+ NSWarningAlertStyle, [self window], self,
+ @selector(checkForUnsavedThemeDidEndSheet:returnCode:contextInfo:),
+ nil,
+ NSLocalizedString(@"Warning", @"warning"),
+ NSLocalizedString(@"Current color theme is unsaved. Do you want to proceed without saving it?", @"Current color theme is unsaved. Do you want to proceed without saving it message"),
+ checkForUnsavedThemeSheetStatus
+ );
- if(checkForUnsavedThemeSheetStatus == NSAlertFirstButtonReturn) {
+ if(checkForUnsavedThemeSheetStatus == NSAlertDefaultReturn) {
return YES;
}