Remember Filter Through Command output choice in user defaults

This commit is contained in:
Allan Odgaard
2014-09-15 17:08:22 +02:00
parent 8224994f5d
commit ee3f90366d

View File

@@ -4,6 +4,8 @@
#import <OakAppKit/OakUIConstructionFunctions.h>
#import <OakTextView/OakTextView.h>
static NSString* const kUserDefaultsFilterOutputType = @"filterOutputType";
@interface OakRunCommandWindowController () <NSWindowDelegate>
@property (nonatomic) NSTextField* commandLabel;
@property (nonatomic) NSComboBox* commandComboBox;
@@ -98,6 +100,8 @@
for(size_t i = 0; i < sizeofA(keyViewLoop); ++i)
keyViewLoop[i].nextKeyView = keyViewLoop[(i + 1) % sizeofA(keyViewLoop)];
self.outputType = (output::type)[[NSUserDefaults standardUserDefaults] integerForKey:kUserDefaultsFilterOutputType];
self.window.initialFirstResponder = self.commandComboBox;
self.window.defaultButtonCell = self.executeButton.cell;
}
@@ -109,6 +113,19 @@
self.outputType = (output::type)[sender tag];
}
- (void)setOutputType:(output::type)newOutputType
{
if(_outputType == newOutputType)
return;
_outputType = newOutputType;
[self.resultPopUpButton selectItemWithTag:_outputType];
if(_outputType)
[[NSUserDefaults standardUserDefaults] setInteger:_outputType forKey:kUserDefaultsFilterOutputType];
else [[NSUserDefaults standardUserDefaults] removeObjectForKey:kUserDefaultsFilterOutputType];
}
- (void)commandChanged:(NSNotification*)notification
{
self.executeButton.enabled = OakNotEmptyString([self.commandComboBox.stringValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]);