summaryrefslogtreecommitdiffstats
path: root/macosx/HBAddCategoryController.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-11-10 13:59:14 +0100
committerDamiano Galassi <[email protected]>2017-11-10 13:59:14 +0100
commit69e4867fd92921d911b1b288bc3c00de9772c356 (patch)
tree24fbc18f3d7320fec745416d8986b93e9c2caeff /macosx/HBAddCategoryController.m
parent1f7aeb62b9ac51132fddc260e4193e07f056ed2f (diff)
MacGui: add a popup menu to select the category in the add preset sheet.
Diffstat (limited to 'macosx/HBAddCategoryController.m')
-rw-r--r--macosx/HBAddCategoryController.m69
1 files changed, 69 insertions, 0 deletions
diff --git a/macosx/HBAddCategoryController.m b/macosx/HBAddCategoryController.m
new file mode 100644
index 000000000..41de50330
--- /dev/null
+++ b/macosx/HBAddCategoryController.m
@@ -0,0 +1,69 @@
+/* HBAddCategoryController.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 "HBAddCategoryController.h"
+
+#import "HBPresetsManager.h"
+#import "HBPreset.h"
+
+@interface HBAddCategoryController () <NSTextFieldDelegate>
+
+@property (nonatomic, strong) IBOutlet NSTextField *name;
+@property (nonatomic, strong) IBOutlet NSButton *createButton;
+
+@property (nonatomic, strong) HBPresetsManager *manager;
+@property (nonatomic, readwrite) HBPreset *category;
+
+@end
+
+@implementation HBAddCategoryController
+
+- (instancetype)initWithPresetManager:(HBPresetsManager *)manager
+{
+ self = [super initWithWindowNibName:@"HBAddCategoryController"];
+ if (self)
+ {
+ NSParameterAssert(manager);
+ _manager = manager;
+ }
+ return self;
+}
+
+- (void)windowDidLoad
+{
+ [super windowDidLoad];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(controlTextDidChange:)
+ name:NSControlTextDidChangeNotification object:nil];
+}
+
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSControlTextDidChangeNotification object:nil];
+}
+
+- (void)controlTextDidChange:(NSNotification *)obj {
+ self.createButton.enabled = self.name.stringValue.length > 0 ? YES : NO;
+}
+
+- (IBAction)dismiss:(id)sender
+{
+ [self.window orderOut:nil];
+ [NSApp endSheet:self.window returnCode:NSModalResponseCancel];
+}
+
+- (IBAction)create:(id)sender
+{
+ self.category = [[HBPreset alloc] initWithCategoryName:self.name.stringValue builtIn:NO];
+ [self.manager addPreset:self.category];
+
+ [self.window orderOut:nil];
+ [NSApp endSheet:self.window returnCode:NSModalResponseOK];
+}
+
+
+@end