aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPWindowController.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-05-24 09:24:38 +0000
committerrowanbeentje <rowan@beent.je>2010-05-24 09:24:38 +0000
commitd48005bd9b34f2fb1afd31f7487b7bbf8b9b978f (patch)
treec27ac371a986bdf2e8f9dd4441ed37c44b04ec64 /Source/SPWindowController.m
parent98238ec8fb393295fc01804a3104092e3ea24c92 (diff)
downloadsequelpro-d48005bd9b34f2fb1afd31f7487b7bbf8b9b978f.tar.gz
sequelpro-d48005bd9b34f2fb1afd31f7487b7bbf8b9b978f.tar.bz2
sequelpro-d48005bd9b34f2fb1afd31f7487b7bbf8b9b978f.zip
- Add support for progress indicator in tabs
- Hide Navigator menu option again - Remove accidentally committed debug
Diffstat (limited to 'Source/SPWindowController.m')
-rw-r--r--Source/SPWindowController.m47
1 files changed, 46 insertions, 1 deletions
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 <PSMTabBar/PSMTabBarControl.h>
#import <PSMTabBar/PSMTabStyle.h>
+@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