aboutsummaryrefslogtreecommitdiffstats
path: root/Source
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
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')
-rw-r--r--Source/SPPreferenceController.h3
-rw-r--r--Source/SPPreferenceController.m49
2 files changed, 47 insertions, 5 deletions
diff --git a/Source/SPPreferenceController.h b/Source/SPPreferenceController.h
index 8dae6077..cba77f5e 100644
--- a/Source/SPPreferenceController.h
+++ b/Source/SPPreferenceController.h
@@ -102,6 +102,7 @@
SPFavoritesSortItem previousSortItem, currentSortItem;
NSString *themePath;
+ NSInteger checkForUnsavedThemeSheetStatus;
}
- (void)applyRevisionChanges;
@@ -145,5 +146,7 @@
- (BOOL)checkForUnsavedTheme;
- (void)updateDisplayColorThemeName;
- (NSArray *)getAvailableThemes;
+- (void)checkForUnsavedThemeDidEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
+
@end
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;
}