Skip to content

Commit

Permalink
Migrated HBBPreferencesController class to Objective-C 2.0 properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
regexident committed Feb 5, 2013
1 parent a530a0b commit 981640b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
15 changes: 1 addition & 14 deletions HandBrakeBatch/HBBPreferencesController.h
Expand Up @@ -11,20 +11,7 @@
#import <Cocoa/Cocoa.h>
#import "HBBLangData.h"

@interface HBBPreferencesController : NSWindowController <NSComboBoxDataSource> {

IBOutlet NSButton * maintainTimestamps;
IBOutlet NSPopUpButton *mpeg4Extension;

IBOutlet NSComboBox *audioBox;
IBOutlet NSComboBox *subtitleBox;
IBOutlet NSMatrix *audioMatrix;
IBOutlet NSMatrix *subtitleMatrix;

HBBLangData *langData;
NSArray *languages;

}
@interface HBBPreferencesController : NSWindowController <NSComboBoxDataSource>

- (IBAction)languageSelected:(id)sender;
- (IBAction)toggleLanguageScan:(id)sender;
Expand Down
44 changes: 29 additions & 15 deletions HandBrakeBatch/HBBPreferencesController.m
Expand Up @@ -10,19 +10,34 @@

#import "HBBPreferencesController.h"

@interface HBBPreferencesController ()

@property (readwrite, assign, nonatomic) IBOutlet NSButton * maintainTimestamps;
@property (readwrite, assign, nonatomic) IBOutlet NSPopUpButton *mpeg4Extension;

@property (readwrite, assign, nonatomic) IBOutlet NSComboBox *audioBox;
@property (readwrite, assign, nonatomic) IBOutlet NSComboBox *subtitleBox;
@property (readwrite, assign, nonatomic) IBOutlet NSMatrix *audioMatrix;
@property (readwrite, assign, nonatomic) IBOutlet NSMatrix *subtitleMatrix;

@property (readwrite, strong, nonatomic) HBBLangData *langData;
@property (readwrite, strong, nonatomic) NSArray *languages;

@end

@implementation HBBPreferencesController

- (void)toggleLanguage:(bool)enable {
if (enable) {
[subtitleBox setEnabled:YES];
[audioBox setEnabled:YES];
[subtitleMatrix setEnabled:YES];
[audioMatrix setEnabled:YES];
[self.subtitleBox setEnabled:YES];
[self.audioBox setEnabled:YES];
[self.subtitleMatrix setEnabled:YES];
[self.audioMatrix setEnabled:YES];
} else {
[subtitleBox setEnabled:NO];
[audioBox setEnabled:NO];
[subtitleMatrix setEnabled:NO];
[audioMatrix setEnabled:NO];
[self.subtitleBox setEnabled:NO];
[self.audioBox setEnabled:NO];
[self.subtitleMatrix setEnabled:NO];
[self.audioMatrix setEnabled:NO];
}
}

Expand All @@ -42,8 +57,8 @@ - (id)init {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HBBScanEnabled"];
}

langData = [HBBLangData defaultHBBLangData];
languages = [langData languageList];
self.langData = [HBBLangData defaultHBBLangData];
self.languages = [self.langData languageList];

return self;
}
Expand All @@ -66,23 +81,22 @@ - (void)windowDidLoad {
}

- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox {
return [languages count];
return [self.languages count];
}

- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index {
return [languages objectAtIndex:index];
return [self.languages objectAtIndex:index];
}

- (IBAction)languageSelected:(id)sender {
NSComboBox *box = sender;

if ([languages containsObject:[box stringValue]]) {
if ([self.languages containsObject:[box stringValue]]) {
return;
}
NSBeginAlertSheet(@"Unknown Language!", @"Ok", nil, nil, [self window], nil, NULL, NULL, NULL, @"Please select a language from the dropdown list.");
[box setStringValue:@"English"];

if (sender == audioBox) {
if (sender == self.audioBox) {
[[NSUserDefaults standardUserDefaults] setValue:@"English" forKey:@"HBBAudioPreferredLanguage"];
} else {
[[NSUserDefaults standardUserDefaults] setValue:@"English" forKey:@"HBBSubtitlePreferredLanguage"];
Expand Down

0 comments on commit 981640b

Please sign in to comment.