diff options
author | stuconnolly <stuart02@gmail.com> | 2009-11-14 22:21:13 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-11-14 22:21:13 +0000 |
commit | 694e5a55fe9f2579fdef121e3da9d300ed372f89 (patch) | |
tree | 6a3e033bc5437ef157a225d2cdf7975ea4cfb9af /Source/TableContent.m | |
parent | 1ac04adbfe9ad64a9aaa35780301309718ff85d9 (diff) | |
download | sequelpro-694e5a55fe9f2579fdef121e3da9d300ed372f89.tar.gz sequelpro-694e5a55fe9f2579fdef121e3da9d300ed372f89.tar.bz2 sequelpro-694e5a55fe9f2579fdef121e3da9d300ed372f89.zip |
Updates to the 'use monospaced font' preference, making it a lot more consistent across all table views. Also includes live updating when the preference is changed as well as its implementation in the query console, process list and variables table views.
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r-- | Source/TableContent.m | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m index d479a3a3..552fbd41 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -119,11 +119,14 @@ return self; } +/** + * Initialise various interface controls + */ - (void)awakeFromNib { // Set the table content view's vertical gridlines if required [tableContentView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; - + // Add observers for document task activity [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startDocumentTaskForTab:) @@ -319,11 +322,7 @@ } // Set the data cell font according to the preferences - if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [dataCell setFont:[NSFont fontWithName:@"Monaco" size:10]]; - } else { - [dataCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } + [dataCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; // Assign the data cell [theCol setDataCell:dataCell]; @@ -1257,14 +1256,8 @@ [tableContentView setVerticalMotionCanBeginDrag:NO]; - if ( [prefs boolForKey:SPUseMonospacedFonts] ) { - [argumentField setFont:[NSFont fontWithName:@"Monaco" size:10]]; - [limitRowsField setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]]; - } else { - [limitRowsField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - [argumentField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } [limitRowsStepper setEnabled:NO]; + if ( ![prefs boolForKey:SPLimitResults] ) { [limitRowsField setStringValue:@""]; } @@ -2878,9 +2871,22 @@ */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [tableContentView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } + // Use monospaced fonts preference changed + else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { + + BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + + for (NSTableColumn *column in [tableContentView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + [tableContentView reloadData]; + } } /** |