From d48005bd9b34f2fb1afd31f7487b7bbf8b9b978f Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 24 May 2010 09:24:38 +0000 Subject: - Add support for progress indicator in tabs - Hide Navigator menu option again - Remove accidentally committed debug --- Interfaces/English.lproj/MainMenu.xib | 11 ++++---- Source/SPHistoryController.m | 1 - Source/SPWindowController.m | 47 ++++++++++++++++++++++++++++++++++- Source/TableContent.m | 2 +- Source/TableDocument.h | 1 + Source/TableDocument.m | 18 +++----------- 6 files changed, 57 insertions(+), 23 deletions(-) diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib index 9eb99ada..26ba4dc4 100644 --- a/Interfaces/English.lproj/MainMenu.xib +++ b/Interfaces/English.lproj/MainMenu.xib @@ -2,7 +2,7 @@ 1050 - 10D573 + 10D2094 762 1038.29 460.00 @@ -12,7 +12,7 @@ YES - + YES @@ -1236,6 +1236,7 @@ + YES Show Navigator n 1835008 @@ -5066,7 +5067,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{594, 292}, {251, 293}} + {{546, 237}, {251, 293}} com.apple.InterfaceBuilder.CocoaPlugin {{698, 703}, {184, 133}} @@ -5092,7 +5093,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{644, 332}, {255, 253}} + {{596, 277}, {255, 253}} com.apple.InterfaceBuilder.CocoaPlugin {{312, 683}, {231, 153}} @@ -5159,7 +5160,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{725, 352}, {292, 233}} + {{677, 297}, {292, 233}} com.apple.InterfaceBuilder.CocoaPlugin {{829, 663}, {268, 173}} com.apple.InterfaceBuilder.CocoaPlugin diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m index 421569e7..b8128a0f 100644 --- a/Source/SPHistoryController.m +++ b/Source/SPHistoryController.m @@ -65,7 +65,6 @@ - (void) dealloc { -NSLog(@"history is dealloc'd"); [[NSNotificationCenter defaultCenter] removeObserver:self]; [tableContentStates release]; [history release]; diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index 3c8b9be7..d7b4f6ac 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -28,6 +28,12 @@ #import #import +@interface SPWindowController (PrivateAPI) + +- (void) _updateProgressIndicatorForItem:(NSTabViewItem *)theItem; + +@end + @implementation SPWindowController /** @@ -97,7 +103,10 @@ // Tell the new database connection view to set up the window and update titles [newTableDocument didBecomeActiveTabInWindow]; [newTableDocument updateWindowTitle:self]; - + + // Bind the tab bar's progress display to the document + [self _updateProgressIndicatorForItem:newItem]; + [newTableDocument release]; } @@ -193,6 +202,7 @@ - (void)tabView:(NSTabView *)aTabView didCloseTabViewItem:(NSTabViewItem *)tabViewItem { TableDocument *theDocument = [tabViewItem identifier]; + [theDocument removeObserver:self forKeyPath:@"isProcessing"]; [theDocument parentTabDidClose]; } @@ -224,6 +234,10 @@ [draggedDocument willResignActiveTabInWindow]; [draggedDocument setParentWindow:[tabBarControl window]]; [draggedDocument didBecomeActiveTabInWindow]; + + // Update isProcessing observation + [draggedDocument removeObserver:[draggedFromWindow windowController] forKeyPath:@"isProcessing"]; + [[[tabBarControl window] windowController] _updateProgressIndicatorForItem:tabViewItem]; } } @@ -369,4 +383,35 @@ return [frontDocument performSelector:theSelector withObject:theObject]; } +@end + +@implementation SPWindowController (PrivateAPI) + +/** + * Binds a tab bar item's progress indicator to the represented + * tableDocument. + */ +- (void) _updateProgressIndicatorForItem:(NSTabViewItem *)theItem +{ + PSMTabBarCell *theCell = [[tabBar cells] objectAtIndex:[tabView indexOfTabViewItem:theItem]]; + [[theCell indicator] setControlSize:NSSmallControlSize]; + TableDocument *theDocument = [theItem identifier]; + + [[theCell indicator] setHidden:NO]; + NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary]; + [bindingOptions setObject:NSNegateBooleanTransformerName forKey:@"NSValueTransformerName"]; + [[theCell indicator] bind:@"animate" toObject:theDocument withKeyPath:@"isProcessing" options:nil]; + [[theCell indicator] bind:@"hidden" toObject:theDocument withKeyPath:@"isProcessing" options:bindingOptions]; + [theDocument addObserver:self forKeyPath:@"isProcessing" options:nil context:nil]; +} + +/** + * When receiving an update for a bound value - an observed value on the + * document - ask the tab bar control to redraw as appropriate. + */ +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + [tabBar update]; +} + @end \ No newline at end of file diff --git a/Source/TableContent.m b/Source/TableContent.m index cf639b72..723d107a 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -3386,7 +3386,7 @@ // Last but not least - (void)dealloc -{NSLog(@"content is deallocd"); +{ [[NSNotificationCenter defaultCenter] removeObserver:self]; [tableValues release]; diff --git a/Source/TableDocument.h b/Source/TableDocument.h index 539d14b2..b8478f98 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -188,6 +188,7 @@ @property (readwrite, assign) SPWindowController *parentWindowController; @property (readwrite, assign) NSTabViewItem *parentTabViewItem; +@property (readwrite, assign) BOOL isProcessing; - (BOOL)isUntitled; - (BOOL)couldCommitCurrentViewActions; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 5d3209e5..d0637eed 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -75,6 +75,7 @@ @synthesize parentWindowController; @synthesize parentTabViewItem; +@synthesize isProcessing; - (id)init { @@ -2583,7 +2584,7 @@ */ - (void)willPerformQuery:(NSNotification *)notification { - isProcessing = YES; + [self setIsProcessing:YES]; [queryProgressBar startAnimation:self]; } @@ -2592,7 +2593,7 @@ */ - (void)hasPerformedQuery:(NSNotification *)notification { - isProcessing = NO; + [self setIsProcessing:NO]; [queryProgressBar stopAnimation:self]; } @@ -3931,18 +3932,6 @@ if (_isWorkingLevel && [parentWindowController selectedTableDocument] == self) [self centerTaskWindow]; } -/** - * Support the tab's progress spinner - */ -- (BOOL)isProcessing -{ - return (isProcessing || (_isWorkingLevel > 0)); -} -- (void)setIsProcessing:(BOOL)value -{ - isProcessing = value; -} - /** * Set the parent window */ @@ -4228,7 +4217,6 @@ */ - (void)dealloc { -NSLog(@"is dealloc'd"); // Unregister observers [prefs removeObserver:self forKeyPath:SPDisplayTableViewVerticalGridlines]; -- cgit v1.2.3