diff options
-rw-r--r-- | macosx/Controller.h | 5 | ||||
-rw-r--r-- | macosx/Controller.mm | 33 | ||||
-rw-r--r-- | macosx/English.lproj/Preferences.nib/classes.nib | 6 | ||||
-rw-r--r-- | macosx/English.lproj/Preferences.nib/info.nib | 17 | ||||
-rw-r--r-- | macosx/English.lproj/Preferences.nib/keyedobjects.nib | bin | 20759 -> 18353 bytes | |||
-rw-r--r-- | macosx/HBPreferencesController.h | 2 | ||||
-rw-r--r-- | macosx/HBPreferencesController.m | 146 | ||||
-rw-r--r-- | macosx/HandBrake.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | macosx/icons/Preferences.png | bin | 0 -> 1195 bytes |
9 files changed, 175 insertions, 40 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h index 088ce15f7..dd985a7b1 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -14,6 +14,7 @@ #import "HBQueueController.h" #import "MVMenuButton.h" #import "HBAdvancedController.h" +#import "HBPreferencesController.h" @class HBOutputPanelController; @@ -30,6 +31,8 @@ HBAdvancedController * fAdvancedOptions; IBOutlet NSBox * fAdvancedView; + HBPreferencesController * fPreferencesController; + /* Queue panel */ HBQueueController * fQueueController; IBOutlet NSTextField * fQueueStatus; @@ -234,8 +237,6 @@ - (IBAction) Pause: (id) sender; - (IBAction) calculateBitrate: (id) sender; -- (void) controlTextDidBeginEditing: (NSNotification *) notification; -- (void) controlTextDidEndEditing: (NSNotification *) notification; - (void) controlTextDidChange: (NSNotification *) notification; - (IBAction) openHomepage: (id) sender; diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 856ab2125..b2fb41fe6 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -83,6 +83,7 @@ static int hb_group_count(hb_handle_t * h) fPictureController = [[PictureController alloc] initWithDelegate:self]; fQueueController = [[HBQueueController alloc] init]; fAdvancedOptions = [[HBAdvancedController alloc] init]; + fPreferencesController = [[HBPreferencesController alloc] init]; return self; } @@ -1286,7 +1287,7 @@ static int hb_group_count(hb_handle_t * h) } [self qualitySliderChanged: sender]; - [self calculateBitrate: sender]; + [self calculateBitrate: sender]; [self customSettingUsed: sender]; } @@ -1767,7 +1768,7 @@ static int hb_group_count(hb_handle_t * h) { hb_list_t * list = hb_get_titles( fHandle ); hb_title_t * title = (hb_title_t*) - hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] ); + hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] ); /* If Auto Naming is on. We create an output filename of dvd name - title number */ @@ -2003,8 +2004,7 @@ static int hb_group_count(hb_handle_t * h) _( @"AVC/H.264 Video / MP3 Audio" )]; [fDstCodecsPopUp addItemWithTitle: _( @"AVC/H.264 Video / Vorbis Audio" )]; - /* We disable the create chapters checkbox here since we are NOT .mp4 - and make sure it is unchecked*/ + /* We enable the create chapters checkbox here since */ [fCreateChapterMarkers setEnabled: YES]; break; } @@ -2665,8 +2665,6 @@ static int hb_group_count(hb_handle_t * h) [fVidBitrateField setIntValue: hb_calc_bitrate( job, [fVidTargetSizeField intValue] )]; - - [self customSettingUsed:sender]; } /* Method to determine if we should change the UI @@ -4436,16 +4434,6 @@ id theRecord, theValue; } -- (void) controlTextDidBeginEditing: (NSNotification *) notification -{ - [self calculateBitrate: NULL]; -} - -- (void) controlTextDidEndEditing: (NSNotification *) notification -{ - [self calculateBitrate: NULL]; -} - - (void) controlTextDidChange: (NSNotification *) notification { [self calculateBitrate: NULL]; @@ -4477,14 +4465,15 @@ id theRecord, theValue; } /** - * Creates preferences controller, shows preferences window modally, and - * releases the controller after user has closed the window. + * Shows preferences window modally. */ -- (IBAction)showPreferencesWindow:(id)sender +- (IBAction) showPreferencesWindow: (id) sender { - HBPreferencesController *controller = [[HBPreferencesController alloc] init]; - [controller runModal:nil]; - [controller release]; + NSWindow * window = [fPreferencesController window]; + if (![window isVisible]) + [window center]; + + [window makeKeyAndOrderFront: nil]; } /** diff --git a/macosx/English.lproj/Preferences.nib/classes.nib b/macosx/English.lproj/Preferences.nib/classes.nib index 0451c4903..266686202 100644 --- a/macosx/English.lproj/Preferences.nib/classes.nib +++ b/macosx/English.lproj/Preferences.nib/classes.nib @@ -4,6 +4,12 @@ ACTIONS = {close = id; runModal = id; }; CLASS = HBPreferencesController; LANGUAGE = ObjC; + OUTLETS = { + fAdvancedView = NSView; + fAudioView = NSView; + fGeneralView = NSView; + fPictureView = NSView; + }; SUPERCLASS = NSWindowController; } ); diff --git a/macosx/English.lproj/Preferences.nib/info.nib b/macosx/English.lproj/Preferences.nib/info.nib index a13174b48..521deb9a4 100644 --- a/macosx/English.lproj/Preferences.nib/info.nib +++ b/macosx/English.lproj/Preferences.nib/info.nib @@ -3,13 +3,20 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>84 122 674 609 0 0 1440 878 </string> + <string>202 77 589 436 0 0 1440 878 </string> + <key>IBEditorPositions</key> + <dict> + <key>233</key> + <string>506 481 468 208 0 0 1440 878 </string> + <key>234</key> + <string>529 520 421 130 0 0 1440 878 </string> + <key>235</key> + <string>490 525 499 119 0 0 1440 878 </string> + <key>236</key> + <string>361 513 456 172 0 0 1440 878 </string> + </dict> <key>IBFramework Version</key> <string>446.1</string> - <key>IBOpenObjects</key> - <array> - <integer>5</integer> - </array> <key>IBSystem Version</key> <string>8R2218</string> </dict> diff --git a/macosx/English.lproj/Preferences.nib/keyedobjects.nib b/macosx/English.lproj/Preferences.nib/keyedobjects.nib Binary files differindex 224206b9d..687039922 100644 --- a/macosx/English.lproj/Preferences.nib/keyedobjects.nib +++ b/macosx/English.lproj/Preferences.nib/keyedobjects.nib diff --git a/macosx/HBPreferencesController.h b/macosx/HBPreferencesController.h index 221a088b4..63b62d69c 100644 --- a/macosx/HBPreferencesController.h +++ b/macosx/HBPreferencesController.h @@ -7,11 +7,11 @@ @interface HBPreferencesController : NSWindowController { + IBOutlet NSView * fGeneralView, * fPictureView, * fAudioView, * fAdvancedView; } + (void)registerUserDefaults; - (id)init; -- (IBAction)runModal:(id)sender; - (IBAction)close:(id)sender; @end 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 diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index 448a4c31c..08ba0d626 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -129,6 +129,7 @@ A9AC41DF0C918DB500DDF9B8 /* HBAdvancedController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AC41DD0C918DB500DDF9B8 /* HBAdvancedController.m */; }; A9AC41E00C918DB500DDF9B8 /* HBAdvancedController.h in Headers */ = {isa = PBXBuildFile; fileRef = A9AC41DE0C918DB500DDF9B8 /* HBAdvancedController.h */; }; A9AC41E70C918DC000DDF9B8 /* AdvancedView.nib in Resources */ = {isa = PBXBuildFile; fileRef = A9AC41E50C918DC000DDF9B8 /* AdvancedView.nib */; }; + A9B4CEC80C95752B0086548A /* Preferences.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B4CEC70C95752B0086548A /* Preferences.png */; }; B48359A80C82960500E04440 /* lang.c in Sources */ = {isa = PBXBuildFile; fileRef = B48359A70C82960500E04440 /* lang.c */; }; D4D49FED0C83355600F01215 /* lang.c in Sources */ = {isa = PBXBuildFile; fileRef = B48359A70C82960500E04440 /* lang.c */; }; E3003C7F0C88505D0072F2A8 /* DeleteHighlightPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = E3003C7E0C88505D0072F2A8 /* DeleteHighlightPressed.png */; }; @@ -290,6 +291,7 @@ A9AC41DD0C918DB500DDF9B8 /* HBAdvancedController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = HBAdvancedController.m; sourceTree = "<group>"; }; A9AC41DE0C918DB500DDF9B8 /* HBAdvancedController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HBAdvancedController.h; sourceTree = "<group>"; }; A9AC41E60C918DC000DDF9B8 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/AdvancedView.nib; sourceTree = "<group>"; }; + A9B4CEC70C95752B0086548A /* Preferences.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Preferences.png; sourceTree = "<group>"; }; B48359A70C82960500E04440 /* lang.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = lang.c; path = ../libhb/lang.c; sourceTree = SOURCE_ROOT; }; E3003C7E0C88505D0072F2A8 /* DeleteHighlightPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DeleteHighlightPressed.png; sourceTree = "<group>"; }; E3003CB40C8852B70072F2A8 /* DeletePressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DeletePressed.png; sourceTree = "<group>"; }; @@ -377,7 +379,6 @@ 29B97314FDCFA39411CA2CEA /* HandBrake */ = { isa = PBXGroup; children = ( - A273E0460C57B39A00493A45 /* icons */, 526FBC940B4CAA310064E04C /* Instant HandBrake Sources */, 526FBC930B4CAA260064E04C /* HandBrake Sources */, 526FBC920B4CAA120064E04C /* HandBrakeCLI Sources */, @@ -402,6 +403,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + A273E0460C57B39A00493A45 /* icons */, 0DFA5C7A0B8DD1E90020BC09 /* HandBrake.icns */, 29B97318FDCFA39411CA2CEA /* MainMenu.nib */, A9ABA2250C92AECA00D98324 /* PictureSettings.nib */, @@ -529,6 +531,7 @@ A273E0460C57B39A00493A45 /* icons */ = { isa = PBXGroup; children = ( + A9B4CEC70C95752B0086548A /* Preferences.png */, A2DFC66C0C6196D900E66E89 /* actionWidget.png */, A2DFC66D0C6196D900E66E89 /* actionWidgetPressed.png */, A28468670C5A43D900EF9A98 /* Disc.tiff */, @@ -751,6 +754,7 @@ A9AC41E70C918DC000DDF9B8 /* AdvancedView.nib in Resources */, A97A1DB40C91A6800015BC08 /* Express.nib in Resources */, A9ABA2270C92AECA00D98324 /* PictureSettings.nib in Resources */, + A9B4CEC80C95752B0086548A /* Preferences.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/macosx/icons/Preferences.png b/macosx/icons/Preferences.png Binary files differnew file mode 100644 index 000000000..4f13bb989 --- /dev/null +++ b/macosx/icons/Preferences.png |