aboutsummaryrefslogtreecommitdiffstats
path: root/TableDocument.m
diff options
context:
space:
mode:
authorabhibeckert <abhi@abhibeckert.com>2008-05-02 13:36:51 +0000
committerabhibeckert <abhi@abhibeckert.com>2008-05-02 13:36:51 +0000
commitc37f104dcd8be90ead12cfb92a3425cafe9c4e97 (patch)
tree9da5d585176cbc00f07555d7ff98fc5b2ce18f35 /TableDocument.m
parentd508dc92ea00639c7bb6213bfcce945085913a0a (diff)
downloadsequelpro-c37f104dcd8be90ead12cfb92a3425cafe9c4e97.tar.gz
sequelpro-c37f104dcd8be90ead12cfb92a3425cafe9c4e97.tar.bz2
sequelpro-c37f104dcd8be90ead12cfb92a3425cafe9c4e97.zip
database select toolbar item is now the same width as the left split
fixed some bugs with the database select toolbar item when customizing the toolbar
Diffstat (limited to 'TableDocument.m')
-rw-r--r--TableDocument.m47
1 files changed, 43 insertions, 4 deletions
diff --git a/TableDocument.m b/TableDocument.m
index 259b6171..ea562e3b 100644
--- a/TableDocument.m
+++ b/TableDocument.m
@@ -43,6 +43,7 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
_encoding = [@"utf8" retain];
chooseDatabaseButton = nil;
+ chooseDatabaseToolbarItem = nil;
return self;
}
@@ -1150,22 +1151,32 @@ passes the request to the tableDump object
// select the structure toolbar item
[self viewStructure:self];
+
+ // update the toolbar item size
+ [self updateChooseDatabaseToolbarItemWidth];
}
/**
* toolbar delegate method
*/
-- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
+- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)willBeInsertedIntoToolbar
{
NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease];
if ([itemIdentifier isEqualToString:DatabaseSelectToolbarItemIdentifier]) {
- toolbarItem = [[[DatabaseSelectToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease];
- chooseDatabaseButton = [[(DatabaseSelectToolbarItem *)toolbarItem databaseSelectPopupButton] retain];
-
+ [toolbarItem setLabel:NSLocalizedString(@"Select Database", @"toolbar item for selecting a db")];
+ [toolbarItem setPaletteLabel:[toolbarItem label]];
+ [toolbarItem setView:chooseDatabaseButton];
+ [toolbarItem setMinSize:NSMakeSize(200,26)];
+ [toolbarItem setMaxSize:NSMakeSize(200,32)];
[chooseDatabaseButton setTarget:self];
[chooseDatabaseButton setAction:@selector(chooseDatabase:)];
+
+ if (willBeInsertedIntoToolbar) {
+ chooseDatabaseToolbarItem = toolbarItem;
+ [self updateChooseDatabaseToolbarItemWidth];
+ }
} else if ([itemIdentifier isEqualToString:@"ToggleConsoleIdentifier"]) {
//set the text label to be displayed in the toolbar and customization palette
[toolbarItem setPaletteLabel:NSLocalizedString(@"Show/Hide Console", @"toolbar item for show/hide console")];
@@ -1426,6 +1437,34 @@ invoked when query gave an error
return proposedMin + 160;
}
+- (void)splitViewDidResizeSubviews:(NSNotification *)notification
+{
+ [self updateChooseDatabaseToolbarItemWidth];
+}
+
+- (void)updateChooseDatabaseToolbarItemWidth
+{
+ // make sure the toolbar item is actually in the toolbar
+ if (!chooseDatabaseToolbarItem)
+ return;
+
+ // grab the width of the left pane
+ float leftPaneWidth = [dbTablesTableView frame].size.width;
+
+ // subtract some pixels to allow for misc stuff
+ leftPaneWidth -= 12;
+
+ // make sure it's not too small or to big
+ if (leftPaneWidth < 130)
+ leftPaneWidth = 130;
+ if (leftPaneWidth > 360)
+ leftPaneWidth = 360;
+
+ // apply the size
+ [chooseDatabaseToolbarItem setMinSize:NSMakeSize(leftPaneWidth, 26)];
+ [chooseDatabaseToolbarItem setMaxSize:NSMakeSize(leftPaneWidth, 32)];
+}
+
//tableView datasource methods
- (int)numberOfRowsInTableView:(NSTableView *)aTableView