summaryrefslogtreecommitdiffstats
path: root/macosx/HBPreferencesController.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2007-09-10 13:23:30 +0000
committerritsuka <[email protected]>2007-09-10 13:23:30 +0000
commitee9802a07ae486348ad7c1d5c6f5e27ff0b063ad (patch)
treeee9b66dde9c29b0190796a9e1fd3f6e1799a9997 /macosx/HBPreferencesController.m
parent1431511b085cf5389d67bebec9149e12ca24ba75 (diff)
MacGui: New preferences window. We need some new icons for the toolbar.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@942 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBPreferencesController.m')
-rw-r--r--macosx/HBPreferencesController.m146
1 files changed, 137 insertions, 9 deletions
diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m
index ace2866db..587214ca6 100644
--- a/macosx/HBPreferencesController.m
+++ b/macosx/HBPreferencesController.m
@@ -4,6 +4,10 @@
*/
#import "HBPreferencesController.h"
+#define TOOLBAR_GENERAL @"TOOLBAR_GENERAL"
+#define TOOLBAR_PICTURE @"TOOLBAR_PICTURE"
+#define TOOLBAR_AUDIO @"TOOLBAR_AUDIO"
+#define TOOLBAR_ADVANCED @"TOOLBAR_ADVANCED"
/**
* This class controls the preferences window of HandBrake. Default values for
@@ -15,6 +19,13 @@
* no getter/setter code is needed in this file (unless more complicated
* preference settings are added that cannot be handled with Cocoa bindings).
*/
+
+@interface HBPreferencesController (Private)
+
+- (void) setPrefView: (id) sender;
+
+@end
+
@implementation HBPreferencesController
/**
@@ -42,7 +53,7 @@
@"NO", @"ShowVerboseOutput",
@"NO", @"AllowLargeFiles",
@"NO", @"DisableDvdAutoDetect",
- @"Alert Window", @"AlertWhenDone",
+ @"Alert Window", @"AlertWhenDone",
nil]];
}
@@ -58,12 +69,80 @@
return self;
}
-/**
- * Shows the preferences window in modal state.
- */
-- (IBAction)runModal:(id)sender
+- (void) awakeFromNib
{
- [NSApp runModalForWindow:[self window]];
+ NSToolbar * toolbar = [[NSToolbar alloc] initWithIdentifier: @"Preferences Toolbar"];
+ [toolbar setDelegate: self];
+ [toolbar setAllowsUserCustomization: NO];
+ [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
+ [toolbar setSizeMode: NSToolbarSizeModeRegular];
+ [[self window] setToolbar: toolbar];
+
+ [toolbar setSelectedItemIdentifier: TOOLBAR_GENERAL];
+ [self setPrefView:nil];
+}
+
+- (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident
+ willBeInsertedIntoToolbar: (BOOL) flag
+{
+ NSToolbarItem * item;
+ item = [[NSToolbarItem alloc] initWithItemIdentifier: ident];
+
+ if ([ident isEqualToString: TOOLBAR_GENERAL])
+ {
+ [item setLabel: NSLocalizedString(@"General", "General")];
+ [item setImage: [NSImage imageNamed: @"Preferences.png"]];
+ [item setTarget: self];
+ [item setAction: @selector(setPrefView:)];
+ [item setAutovalidates: NO];
+ }
+ else if ([ident isEqualToString: TOOLBAR_PICTURE])
+ {
+ [item setLabel: NSLocalizedString(@"Picture", "Picture")];
+// [item setImage: [NSImage imageNamed: @"???.png"]];
+ [item setTarget: self];
+ [item setAction: @selector(setPrefView:)];
+ [item setAutovalidates: NO];
+ }
+ else if ([ident isEqualToString: TOOLBAR_AUDIO])
+ {
+ [item setLabel: NSLocalizedString(@"Audio", "Audio")];
+ // [item setImage: [NSImage imageNamed: @"???.png"]];
+ [item setTarget: self];
+ [item setAction: @selector(setPrefView:)];
+ [item setAutovalidates: NO];
+ }
+ else if ([ident isEqualToString: TOOLBAR_ADVANCED])
+ {
+ [item setLabel: NSLocalizedString(@"Advanced", "Advanced")];
+ // [item setImage: [NSImage imageNamed: @"???.png"]];
+ [item setTarget: self];
+ [item setAction: @selector(setPrefView:)];
+ [item setAutovalidates: NO];
+ }
+ else
+ {
+ [item release];
+ return nil;
+ }
+
+ return item;
+}
+
+- (NSArray *) toolbarSelectableItemIdentifiers: (NSToolbar *) toolbar
+{
+ return [self toolbarDefaultItemIdentifiers: toolbar];
+}
+
+- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar
+{
+ return [self toolbarAllowedItemIdentifiers: toolbar];
+}
+
+- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
+{
+ return [NSArray arrayWithObjects: TOOLBAR_GENERAL, TOOLBAR_PICTURE,
+ TOOLBAR_AUDIO, TOOLBAR_ADVANCED, nil];
}
/**
@@ -72,9 +151,58 @@
*/
- (IBAction)close:(id)sender
{
- [[self window] endEditingFor:nil];
- [[self window] orderOut:sender];
- [NSApp stopModal];
+ //[self makeFirstResponder: nil];
+}
+
+@end
+
+@implementation HBPreferencesController (Private)
+
+- (void) setPrefView: (id) sender
+{
+ NSView * view = fGeneralView;
+ if (sender)
+ {
+ NSString * identifier = [sender itemIdentifier];
+ if ([identifier isEqualToString: TOOLBAR_PICTURE])
+ view = fPictureView;
+ else if ([identifier isEqualToString: TOOLBAR_AUDIO])
+ view = fAudioView;
+ else if ([identifier isEqualToString: TOOLBAR_ADVANCED])
+ view = fAdvancedView;
+ else;
+ }
+
+ NSWindow * window = [self window];
+ if ([window contentView] == view)
+ return;
+
+ NSRect windowRect = [window frame];
+ float difference = ([view frame].size.height - [[window contentView] frame].size.height) * [window userSpaceScaleFactor];
+ windowRect.origin.y -= difference;
+ windowRect.size.height += difference;
+
+ [view setHidden: YES];
+ [window setContentView: view];
+ [window setFrame: windowRect display: YES animate: YES];
+ [view setHidden: NO];
+
+ //set title label
+ if (sender)
+ [window setTitle: [sender label]];
+ else
+ {
+ NSToolbar * toolbar = [window toolbar];
+ NSString * itemIdentifier = [toolbar selectedItemIdentifier];
+ NSEnumerator * enumerator = [[toolbar items] objectEnumerator];
+ NSToolbarItem * item;
+ while ((item = [enumerator nextObject]))
+ if ([[item itemIdentifier] isEqualToString: itemIdentifier])
+ {
+ [window setTitle: [item label]];
+ break;
+ }
+ }
}
@end