summaryrefslogtreecommitdiffstats
path: root/macosx/HBAudioDefaultsController.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2014-08-04 07:12:12 +0000
committerritsuka <[email protected]>2014-08-04 07:12:12 +0000
commit3fdfc2d020d300bee991b4aa5c931bb9e33c3c10 (patch)
tree88c6296081a2076d71fe59a67fd272995889e199 /macosx/HBAudioDefaultsController.m
parent49a49b9d4664b33dc3d7a723fe421a7b695e2052 (diff)
MacGui: Adds a new sheet for audio defaults (presets), uses the same preset keys as the LinGui.
The built-in presets still use the languages from the Audio preferences. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6264 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBAudioDefaultsController.m')
-rw-r--r--macosx/HBAudioDefaultsController.m109
1 files changed, 109 insertions, 0 deletions
diff --git a/macosx/HBAudioDefaultsController.m b/macosx/HBAudioDefaultsController.m
new file mode 100644
index 000000000..2dfefc292
--- /dev/null
+++ b/macosx/HBAudioDefaultsController.m
@@ -0,0 +1,109 @@
+/* HBAudioDefaultsController.m $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#import "HBAudioDefaultsController.h"
+#import "HBAudioSettings.h"
+#import "HBLanguagesSelection.h"
+
+static void *HBAudioDefaultsContex = &HBAudioDefaultsContex;
+
+@interface HBAudioDefaultsController ()
+
+@property (nonatomic, readonly) HBAudioSettings *settings;
+
+@property (nonatomic, readonly) HBLanguagesSelection *languagesList;
+@property (assign) IBOutlet HBLanguageArrayController *tableController;
+@property (assign) IBOutlet NSButton *showAllButton;
+
+@property (assign) IBOutlet NSArrayController *tracksController;
+
+@end
+
+@implementation HBAudioDefaultsController
+
+- (instancetype)initWithSettings:(HBAudioSettings *)settings
+{
+ self = [super initWithWindowNibName:@"AudioDefaults"];
+ if (self)
+ {
+ _settings = [settings retain];
+ _languagesList = [[HBLanguagesSelection alloc] initWithLanguages:_settings.trackSelectionLanguages];
+ }
+ return self;
+}
+
+- (void)windowDidLoad
+{
+ [self addObserver:self forKeyPath:@"tableController.showSelectedOnly" options:0 context:HBAudioDefaultsContex];
+
+ if (self.settings.trackSelectionLanguages.count)
+ {
+ self.tableController.showSelectedOnly = YES;
+ }
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+ if (context == HBAudioDefaultsContex)
+ {
+ if ([keyPath isEqualToString:@"tableController.showSelectedOnly"])
+ {
+ [self.showAllButton setState:!self.tableController.showSelectedOnly];
+ }
+ }
+ else
+ {
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+ }
+}
+
+- (IBAction)edit:(id)sender
+{
+ self.tableController.showSelectedOnly = !self.tableController.showSelectedOnly;
+}
+
+- (IBAction)addTrack:(id)sender
+{
+ if ([sender selectedSegment])
+ {
+ if ([[self.tracksController arrangedObjects] count] && self.tracksController.selectionIndex != NSNotFound)
+ {
+ [self.tracksController removeObjectAtArrangedObjectIndex:self.tracksController.selectionIndex];
+ }
+ }
+ else
+ {
+ [self.tracksController add:sender];
+ }
+}
+
+- (IBAction)done:(id)sender
+{
+ [[self window] orderOut:nil];
+ [NSApp endSheet:[self window]];
+
+ [self.settings.trackSelectionLanguages removeAllObjects];
+ [self.settings.trackSelectionLanguages addObjectsFromArray:self.languagesList.selectedLanguages];
+
+ if ([self.delegate respondsToSelector:@selector(sheetDidEnd)])
+ {
+ [self.delegate performSelector:@selector(sheetDidEnd)];
+ }
+}
+
+- (void)dealloc
+{
+ [_settings release];
+ [_languagesList release];
+
+ @try {
+ [self removeObserver:self forKeyPath:@"tableController.showSelectedOnly"];
+ } @catch (NSException * __unused exception) {}
+
+ [super dealloc];
+}
+
+@end