diff options
author | stuconnolly <stuart02@gmail.com> | 2010-09-26 19:16:35 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-09-26 19:16:35 +0000 |
commit | 9205ee00ec0d9be788db6c54ed0ca9eba3735b9a (patch) | |
tree | 7bc1a3e55e8555fb1d3d305e1fe37911030024b2 /Source | |
parent | d12ddff12e2729bb70c5dacb30927559d9c6615e (diff) | |
download | sequelpro-9205ee00ec0d9be788db6c54ed0ca9eba3735b9a.tar.gz sequelpro-9205ee00ec0d9be788db6c54ed0ca9eba3735b9a.tar.bz2 sequelpro-9205ee00ec0d9be788db6c54ed0ca9eba3735b9a.zip |
Remember the width of the server process list tableview columns between application launches. Implements issue #814.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConstants.h | 1 | ||||
-rw-r--r-- | Source/SPConstants.m | 1 | ||||
-rw-r--r-- | Source/SPProcessListController.m | 28 |
3 files changed, 30 insertions, 0 deletions
diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 00fc0607..a5efccee 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -309,6 +309,7 @@ extern NSString *SPConsoleShowHelps; extern NSString *SPEditInSheetEnabled; extern NSString *SPTableInformationPanelCollapsed; extern NSString *SPTableColumnWidths; +extern NSString *SPProcessListTableColumnWidths; extern NSString *SPProcessListShowProcessID; extern NSString *SPProcessListEnableAutoRefresh; extern NSString *SPProcessListAutoRrefreshInterval; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index e3de4b06..e7cbb414 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -135,6 +135,7 @@ NSString *SPConsoleShowConnections = @"ConsoleShowConnections"; NSString *SPEditInSheetEnabled = @"EditInSheetEnabled"; NSString *SPTableInformationPanelCollapsed = @"TableInformationPanelCollapsed"; NSString *SPTableColumnWidths = @"tableColumnWidths"; +NSString *SPProcessListTableColumnWidths = @"ProcessListTableColumnWidths"; NSString *SPProcessListShowProcessID = @"ProcessListShowProcessID"; NSString *SPProcessListEnableAutoRefresh = @"ProcessListEnableAutoRefresh"; NSString *SPProcessListAutoRrefreshInterval = @"ProcessListAutoRrefreshInterval"; diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index 886e6f2b..961e983c 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -92,6 +92,11 @@ for (NSTableColumn *column in [processListTableView tableColumns]) { [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + + // Also, if available restore the table's column widths + NSNumber *columnWidth = [[prefs objectForKey:SPProcessListTableColumnWidths] objectForKey:[[column headerCell] stringValue]]; + + if (columnWidth) [column setWidth:[columnWidth doubleValue]]; } // Register as an observer for the when the UseMonospacedFonts preference changes @@ -479,6 +484,29 @@ [tableView reloadData]; } +/** + * Table view delegate method. Called whenever the user changes a column width. + */ +- (void)tableViewColumnDidResize:(NSNotification *)notification +{ + NSTableColumn *column = [[notification userInfo] objectForKey:@"NSTableColumn"]; + + // Get the existing table column widths dictionary if it exists + NSMutableDictionary *tableColumnWidths = ([prefs objectForKey:SPProcessListTableColumnWidths]) ? + [NSMutableDictionary dictionaryWithDictionary:[prefs objectForKey:SPProcessListTableColumnWidths]] : + [NSMutableDictionary dictionary]; + + // Save column size + NSString *columnName = [[column headerCell] stringValue]; + + if (columnName) { + [tableColumnWidths setObject:[NSNumber numberWithDouble:[column width]] forKey:columnName]; + + [prefs setObject:tableColumnWidths forKey:SPProcessListTableColumnWidths]; + } +} + + #pragma mark - #pragma mark Text field delegate methods |