aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPProcessListController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-09-26 19:16:35 +0000
committerstuconnolly <stuart02@gmail.com>2010-09-26 19:16:35 +0000
commit9205ee00ec0d9be788db6c54ed0ca9eba3735b9a (patch)
tree7bc1a3e55e8555fb1d3d305e1fe37911030024b2 /Source/SPProcessListController.m
parentd12ddff12e2729bb70c5dacb30927559d9c6615e (diff)
downloadsequelpro-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/SPProcessListController.m')
-rw-r--r--Source/SPProcessListController.m28
1 files changed, 28 insertions, 0 deletions
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