aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPPreferenceController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-18 15:50:45 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-18 15:50:45 +0000
commite3887342fb81afaa2222a143fdc4384289eb65e5 (patch)
tree8041465afcb4a5a86c3fbe0a8c88ad9a6bca0e37 /Source/SPPreferenceController.m
parent8c1128f6710c6738cc969a11f05bef89c8722c63 (diff)
downloadsequelpro-e3887342fb81afaa2222a143fdc4384289eb65e5.tar.gz
sequelpro-e3887342fb81afaa2222a143fdc4384289eb65e5.tar.bz2
sequelpro-e3887342fb81afaa2222a143fdc4384289eb65e5.zip
• convert alert about unsaved color theme to a waiting sheet
Diffstat (limited to 'Source/SPPreferenceController.m')
-rw-r--r--Source/SPPreferenceController.m49
1 files changed, 44 insertions, 5 deletions
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index 19cfbfd0..8c2311ee 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -1750,20 +1750,59 @@
if (error) [[NSAlert alertWithError:error] runModal];
}
+- (void)checkForUnsavedThemeDidEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
+{
+ [[sheet window] orderOut:self];
+ checkForUnsavedThemeSheetStatus = returnCode;
+}
+
+
- (BOOL)checkForUnsavedTheme
{
if(![prefs objectForKey:SPCustomQueryEditorThemeName] || [[[prefs objectForKey:SPCustomQueryEditorThemeName] lowercaseString] isEqualToString:@"user-defined"]) {
+ [[NSColorPanel sharedColorPanel] close];
+
+ checkForUnsavedThemeSheetStatus = -1;
+
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle:NSLocalizedString(@"Proceed", @"proceed button")];
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"cancel button")];
- [alert setMessageText: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 setInformativeText:@""];
+ [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];
- NSInteger choice = [[alert onMainThread] runModal];
- if(choice == NSAlertFirstButtonReturn) {
- [[NSColorPanel sharedColorPanel] close];
+ [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]];
+
+ if(checkForUnsavedThemeSheetStatus == NSAlertFirstButtonReturn) {
return YES;
}