From f4f9ae17636bab751746c41a16c2f329b06cd7bf Mon Sep 17 00:00:00 2001 From: ritsuka Date: Wed, 26 Nov 2008 17:00:28 +0000 Subject: MacGui: Cleanup HBPreferncesController and the preferences nib a little. Original path by blindjimmy git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1956 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/English.lproj/Preferences.xib | 79 +++++++++++++++++++++++--------- macosx/HBPreferencesController.m | 87 ++++++++++++++++++++++-------------- 2 files changed, 112 insertions(+), 54 deletions(-) diff --git a/macosx/English.lproj/Preferences.xib b/macosx/English.lproj/Preferences.xib index 800d4088c..c6bcf1acc 100644 --- a/macosx/English.lproj/Preferences.xib +++ b/macosx/English.lproj/Preferences.xib @@ -3,14 +3,15 @@ 1050 9F33 - 670 + 672 949.34 352.00 YES - + + YES @@ -363,7 +364,7 @@ 268 - {{188, 38}, {113, 22}} + {{207, 40}, {208, 22}} YES @@ -393,7 +394,7 @@ 268 - {{27, 40}, {155, 17}} + {{47, 42}, {155, 17}} YES @@ -407,20 +408,20 @@ - {496, 80} + {496, 82} NSView NSResponder - + 256 YES 256 - {{76, 43}, {114, 17}} + {{76, 42}, {114, 17}} YES @@ -436,7 +437,7 @@ 256 - {{195, 39}, {229, 26}} + {{195, 38}, {229, 26}} YES @@ -629,7 +630,7 @@ YES - + 1.000000e+01 1.000000e+01 1.000000e+03 @@ -697,7 +698,7 @@ -2147483392 - {{18, 18}, {472, 18}} + {{18, 17}, {472, 18}} YES @@ -716,7 +717,8 @@ - {500, 83} + {500, 82} + NSView @@ -730,7 +732,7 @@ 256 - {{83, 146}, {367, 18}} + {{84, 44}, {367, 18}} YES @@ -751,7 +753,7 @@ 256 - {{39, 147}, {41, 17}} + {{40, 45}, {41, 17}} YES @@ -764,10 +766,26 @@ + + + 256 + {{49, 20}, {32, 17}} + + YES + + 67239424 + 272629760 + Log: + + + + + + 256 - {{83, 108}, {367, 18}} + {{84, 18}, {367, 18}} YES @@ -786,7 +804,7 @@ - {500, 184} + {492, 82} NSView @@ -1174,8 +1192,8 @@ YES - + Picture @@ -1226,6 +1244,7 @@ YES + @@ -1415,6 +1434,20 @@ + + 350 + + + YES + + + + + + 351 + + + @@ -1431,6 +1464,7 @@ 234.IBPluginDependency 234.ImportedFromIB2 234.editorWindowContentRectSynchronizationRect + 235.IBEditorWindowLastContentRect 235.IBPluginDependency 235.ImportedFromIB2 236.IBEditorWindowLastContentRect @@ -1485,6 +1519,8 @@ 327.IBPluginDependency 347.IBPluginDependency 347.ImportedFromIB2 + 350.IBPluginDependency + 350.ImportedFromIB2 5.IBPluginDependency 5.ImportedFromIB2 5.windowTemplate.hasMaxSize @@ -1500,17 +1536,18 @@ YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{28, 401}, {492, 189}} + {{418, 501}, {492, 189}} com.apple.InterfaceBuilder.CocoaPlugin {{0, 636}, {500, 209}} - {{27, 609}, {496, 80}} + {{144, 376}, {496, 82}} com.apple.InterfaceBuilder.CocoaPlugin {{0, 726}, {500, 108}} + {{73, 902}, {500, 82}} com.apple.InterfaceBuilder.CocoaPlugin - {{110, 672}, {500, 184}} + {{110, 774}, {492, 82}} com.apple.InterfaceBuilder.CocoaPlugin {{0, 650}, {500, 184}} @@ -1564,7 +1601,9 @@ com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {3.40282e+38, 3.40282e+38} {213, 107} @@ -1594,7 +1633,7 @@ - 349 + 351 diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 701b95fed..758b8b718 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -23,12 +23,17 @@ @interface HBPreferencesController (Private) - (void) setPrefView: (id) sender; +- (NSToolbarItem *)toolbarItemWithIdentifier: (NSString *)identifier + label: (NSString *)label + image: (NSImage *)image; @end @implementation HBPreferencesController /** + * +[HBPreferencesController registerUserDefaults] + * * Registers default values to user defaults. This is called immediately * when HandBrake starts, from [HBController init]. */ @@ -55,7 +60,10 @@ } /** + * -[HBPreferencesController init] + * * Initializes the preferences controller by loading Preferences.nib file. + * */ - (id)init { @@ -66,6 +74,13 @@ return self; } +/** + * -[HBPreferencesController awakeFromNib] + * + * Called after all the outlets in the nib file have been attached. Sets up the + * toolbar and shows the "General" pane. + * + */ - (void) awakeFromNib { NSToolbar * toolbar = [[[NSToolbar alloc] initWithIdentifier: @"Preferences Toolbar"] autorelease]; @@ -79,50 +94,36 @@ [self setPrefView:nil]; } -- (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident - willBeInsertedIntoToolbar: (BOOL) flag +- (NSToolbarItem *)toolbar: (NSToolbar *)toolbar + itemForItemIdentifier: (NSString *)ident + willBeInsertedIntoToolbar: (BOOL)flag { - NSToolbarItem * item; - item = [[[NSToolbarItem alloc] initWithItemIdentifier: ident] autorelease]; - - if ([ident isEqualToString: TOOLBAR_GENERAL]) - { - [item setLabel: NSLocalizedString(@"General", "General")]; - [item setImage: [NSImage imageNamed: @"NSPreferencesGeneral"]]; - [item setTarget: self]; - [item setAction: @selector(setPrefView:)]; - [item setAutovalidates: NO]; - } - else if ([ident isEqualToString: TOOLBAR_PICTURE]) + if ( [ident isEqualToString:TOOLBAR_GENERAL] ) { - [item setLabel: NSLocalizedString(@"Picture", "Picture")]; - [item setImage: [NSImage imageNamed: @"pref-picture"]]; - [item setTarget: self]; - [item setAction: @selector(setPrefView:)]; - [item setAutovalidates: NO]; + return [self toolbarItemWithIdentifier:ident + label:NSLocalizedString(@"General", @"Preferences General Toolbar Item") + image:[NSImage imageNamed:NSImageNamePreferencesGeneral]]; } - else if ([ident isEqualToString: TOOLBAR_AUDIO]) + else if ( [ident isEqualToString:TOOLBAR_PICTURE] ) { - [item setLabel: NSLocalizedString(@"Audio", "Audio")]; - [item setImage: [NSImage imageNamed: @"pref-audio"]]; - [item setTarget: self]; - [item setAction: @selector(setPrefView:)]; - [item setAutovalidates: NO]; + return [self toolbarItemWithIdentifier:ident + label:NSLocalizedString(@"Picture", @"Preferences Picture Toolbar Item") + image:[NSImage imageNamed:@"pref-picture"]]; } - else if ([ident isEqualToString: TOOLBAR_ADVANCED]) + else if ( [ident isEqualToString:TOOLBAR_AUDIO] ) { - [item setLabel: NSLocalizedString(@"Advanced", "Advanced")]; - [item setImage: [NSImage imageNamed: @"NSAdvanced"]]; - [item setTarget: self]; - [item setAction: @selector(setPrefView:)]; - [item setAutovalidates: NO]; + return [self toolbarItemWithIdentifier:ident + label:NSLocalizedString(@"Audio", @"Preferences Audio Toolbar Item") + image:[NSImage imageNamed:@"pref-audio"]]; } - else + else if ( [ident isEqualToString:TOOLBAR_ADVANCED] ) { - return nil; + return [self toolbarItemWithIdentifier:ident + label:NSLocalizedString(@"Advanced", @"Preferences Advanced Toolbar Item") + image:[NSImage imageNamed:NSImageNameAdvanced]]; } - return item; + return nil; } - (NSArray *) toolbarSelectableItemIdentifiers: (NSToolbar *) toolbar @@ -190,4 +191,22 @@ } } +/** + * -[HBPreferencesController(Private) toolbarItemWithIdentifier:label:image:] + * + * Shared code for creating the NSToolbarItems for the Preferences toolbar. + * + */ +- (NSToolbarItem *)toolbarItemWithIdentifier: (NSString *)identifier + label: (NSString *)label + image: (NSImage *)image +{ + NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:identifier]; + [item setLabel:label]; + [item setImage:image]; + [item setAction:@selector(setPrefView:)]; + [item setAutovalidates:NO]; + return [item autorelease]; +} + @end -- cgit v1.2.3