From 876432a34ce9e99c45b16a2d42df5a0af8baec2c Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Wed, 11 Nov 2009 22:51:40 +0000 Subject: Change the main window's non-connected/connecting state title to 'Sequel Pro' and only change it to 'Connecting...' when we are actually trying to establish a connection. Fixes issue #456. --- Source/TableDocument.m | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'Source/TableDocument.m') diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 71ac951f..b8071060 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -163,6 +163,9 @@ // Set up the connection controller connectionController = [[SPConnectionController alloc] initWithDocument:self]; + + // Set the connection controller's delegate + [connectionController setDelegate:self]; // Register observers for when the DisplayTableViewVerticalGridlines preference changes [prefs addObserver:tableSourceInstance forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL]; @@ -3480,10 +3483,12 @@ */ - (NSString *)displaySPName { - if (!_isConnected) return [NSString stringWithFormat:@"%@%@", - ([[[self fileURL] absoluteString] length]) ? [NSString stringWithFormat:@"%@ — ",[[[[self fileURL] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] : @"", - NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting")]; + if (!_isConnected) { + return [NSString stringWithFormat:@"%@%@", + ([[[self fileURL] absoluteString] length]) ? [NSString stringWithFormat:@"%@ — ",[[[[self fileURL] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] : @"", @"Sequel Pro"]; + } + return [NSString stringWithFormat:@"%@(MySQL %@) %@%@%@", ([[[self fileURL] absoluteString] length]) ? [NSString stringWithFormat:@"%@ — ",[self displayName]] : @"", mySQLVersion, @@ -3593,6 +3598,27 @@ return connectionErrorCode; } +#pragma mark - +#pragma mark + +/** + * Invoked by the connection controller when it starts the process of initiating a connection. + */ +- (void)connectionControllerInitiatingConnection:(id)controller +{ + // Update the window title to indicate that we are try to establish a connection + [tableWindow setTitle:NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting")]; +} + +/** + * Invoked by the connection controller when the attempt to initiate a connection failed. + */ +- (void)connectionControllerConnectAttemptFailed:(id)controller +{ + // Reset the window title + [tableWindow setTitle:[self displaySPName]]; +} + #pragma mark - #pragma mark Database name field delegate methods -- cgit v1.2.3