From: ritsuka Date: Sat, 27 Dec 2014 12:29:00 +0000 (+0000) Subject: MacGui: remove redundant "enabled" property in a few view controller. Cosmetics in... X-Git-Tag: 1.0.0~1641 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f6ec5084e21a88d662fa453be6186724658bc9b;p=handbrake MacGui: remove redundant "enabled" property in a few view controller. Cosmetics in HBController. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6660 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/macosx/Controller.h b/macosx/Controller.h index 8fdbdb155..c8292fcda 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -25,7 +25,7 @@ @class HBPresetsManager; @class HBDockTile; -@interface HBController : NSObject +@interface HBController : NSObject { IBOutlet NSWindow * fWindow; @@ -196,8 +196,7 @@ - (void) processNewQueueEncode; - (void) clearQueueEncodedItems; /* Queue Editing */ -- (IBAction)rescanQueueItemToMainWindow:(NSUInteger) selectedQueueItem; - +- (void)rescanQueueItemToMainWindow:(NSUInteger) selectedQueueItem; - (void) removeQueueFileItem:(NSUInteger) queueItemToRemove; - (void) clearQueueAllItems; @@ -235,11 +234,6 @@ - (IBAction) showAddPresetPanel: (id) sender; - (IBAction)selectDefaultPreset:(id)sender; - (IBAction)addFactoryPresets:(id)sender; - --(void)sendToMetaX:(NSString *) filePath; -// Growl methods -- (NSDictionary *) registrationDictionaryForGrowl; --(void)showGrowlDoneNotification:(NSString *) filePath; - (IBAction)showDebugOutputPanel:(id)sender; - (void) remindUserOfSleepOrShutdown; diff --git a/macosx/Controller.m b/macosx/Controller.m index 9aa015781..a31a522a1 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -25,7 +25,7 @@ // DockTile update freqency in total percent increment #define dockTileUpdateFrequency 0.1f -@interface HBController () +@interface HBController () @property (nonatomic, copy) NSString *browsedSourceDisplayName; @@ -680,9 +680,6 @@ } fPresetsView.enabled = b; - fVideoController.enabled = b; - fAudioController.enabled = b; - fSubtitlesViewController.enabled = b; } /** @@ -949,10 +946,8 @@ // to determine if we should check for encode done notifications. if (fEncodeState != 2) { - NSString *pathOfFinishedEncode; // Get the output file name for the finished encode HBJob *finishedJob = QueueFileArray[currentQueueEncodeIndex]; - pathOfFinishedEncode = finishedJob.destURL.path; // Both the Growl Alert and Sending to tagger can be done as encodes roll off the queue if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] || @@ -963,11 +958,11 @@ { NSBeep(); } - [self showGrowlDoneNotification:pathOfFinishedEncode]; + [self showGrowlDoneNotification:finishedJob.destURL]; } // Send to tagger - [self sendToMetaX:pathOfFinishedEncode]; + [self sendToExternalApp:finishedJob.destURL]; // since we have successfully completed an encode, we increment the queue counter [self incrementQueueItemDone:currentQueueEncodeIndex]; @@ -1173,50 +1168,46 @@ #pragma mark - #pragma mark Encode Done Actions -// register a test notification and make -// it enabled by default + #define SERVICE_NAME @"Encode Done" + +/** + * Register a test notification and make + * it enabled by default + */ - (NSDictionary *)registrationDictionaryForGrowl { - NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys: - [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL, - [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT, - nil]; - - return registrationDictionary; -} - --(void)showGrowlDoneNotification:(NSString *) filePath -{ - /* This end of encode action is called as each encode rolls off of the queue */ - /* Setup the Growl stuff */ - NSString * finishedEncode = filePath; - /* strip off the path to just show the file name */ - finishedEncode = [finishedEncode lastPathComponent]; - NSString * growlMssg = [NSString stringWithFormat: @"your HandBrake encode %@ is done!",finishedEncode]; - [GrowlApplicationBridge - notifyWithTitle:@"Put down that cocktail…" - description:growlMssg - notificationName:SERVICE_NAME - iconData:nil - priority:0 - isSticky:1 - clickContext:nil]; -} --(void)sendToMetaX:(NSString *) filePath -{ - /* This end of encode action is called as each encode rolls off of the queue */ + return @{GROWL_NOTIFICATIONS_ALL: @[SERVICE_NAME], + GROWL_NOTIFICATIONS_DEFAULT: @[SERVICE_NAME]}; +} + +- (void)showGrowlDoneNotification:(NSURL *)fileURL +{ + // This end of encode action is called as each encode rolls off of the queue + // Setup the Growl stuff + NSString *growlMssg = [NSString stringWithFormat:@"your HandBrake encode %@ is done!", fileURL.lastPathComponent]; + [GrowlApplicationBridge notifyWithTitle:@"Put down that cocktail…" + description:growlMssg + notificationName:SERVICE_NAME + iconData:nil + priority:0 + isSticky:1 + clickContext:nil]; +} + +- (void)sendToExternalApp:(NSURL *)fileURL +{ + // This end of encode action is called as each encode rolls off of the queue if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES) { - NSString *sendToApp = [[NSUserDefaults standardUserDefaults] objectForKey: @"SendCompletedEncodeToApp"]; + NSString *sendToApp = [[NSUserDefaults standardUserDefaults] objectForKey:@"SendCompletedEncodeToApp"]; if (![sendToApp isEqualToString:@"None"]) { [HBUtilities writeToActivityLog: "trying to send encode to: %s", [sendToApp UTF8String]]; - NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@%@%@", @"tell application \"",sendToApp,@"\" to open (POSIX file \"", filePath, @"\")"]]; + NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@%@%@", @"tell application \"",sendToApp,@"\" to open (POSIX file \"", fileURL.path, @"\")"]]; [myScript executeAndReturnError: nil]; [myScript release]; } - } } diff --git a/macosx/English.lproj/Audio.xib b/macosx/English.lproj/Audio.xib index 51e62d99e..6c3d5cb86 100644 --- a/macosx/English.lproj/Audio.xib +++ b/macosx/English.lproj/Audio.xib @@ -1,8 +1,8 @@ - + - - + + @@ -15,7 +15,7 @@ - + keyAudioTrackName @@ -66,7 +66,7 @@ - + @@ -273,6 +273,11 @@ + + + NSIsNotNil + + @@ -301,6 +306,11 @@ + + + NSIsNotNil + + @@ -337,6 +352,13 @@ + + + + NSIsNotNil + + + diff --git a/macosx/English.lproj/Subtitles.xib b/macosx/English.lproj/Subtitles.xib index ee41c8524..9d971f5ba 100644 --- a/macosx/English.lproj/Subtitles.xib +++ b/macosx/English.lproj/Subtitles.xib @@ -1,8 +1,8 @@ - + - - + + @@ -15,7 +15,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -133,6 +133,11 @@ + + + NSIsNotNil + + @@ -146,7 +151,6 @@ @@ -182,6 +186,13 @@ + + + + NSIsNotNil + + + diff --git a/macosx/English.lproj/Video.xib b/macosx/English.lproj/Video.xib index 3ef74c34f..06c9a60b1 100644 --- a/macosx/English.lproj/Video.xib +++ b/macosx/English.lproj/Video.xib @@ -48,12 +48,13 @@ - + + NSIsNotNil @@ -115,7 +116,11 @@ - + + + NSIsNotNil + + @@ -133,12 +138,13 @@ - + + NSIsNotNil @@ -157,25 +163,26 @@ - + + NSIsNotNil - + NSNegateBoolean - - + NSNegateBoolean + @@ -191,7 +198,11 @@ - + + + NSIsNotNil + + @@ -248,7 +259,11 @@ - + + + NSIsNotNil + + @@ -275,7 +290,11 @@ - + + + NSIsNotNil + + @@ -296,12 +315,13 @@ - + + NSIsNotNil @@ -342,8 +362,12 @@ + + + NSIsNotNil + + - @@ -356,8 +380,12 @@ + + + NSIsNotNil + + - @@ -552,7 +580,11 @@ Set this if your device is struggling to play the output (dropped frames). - + + + NSIsNotNil + + diff --git a/macosx/HBAudioController.h b/macosx/HBAudioController.h index 2476bdfbb..775c6f32b 100644 --- a/macosx/HBAudioController.h +++ b/macosx/HBAudioController.h @@ -6,7 +6,6 @@ // #import -#import "HBViewValidation.h" extern NSString *keyAudioTrackIndex; extern NSString *keyAudioTrackName; @@ -26,7 +25,7 @@ extern NSString *HBMixdownChangedNotification; * * Responds to HBContainerChangedNotification. */ -@interface HBAudioController : NSViewController +@interface HBAudioController : NSViewController @property (nonatomic, readonly, retain) NSArray *masterTrackArray; @property (nonatomic, readonly) NSDictionary *noneTrack; diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index 0c1c49293..d657e773f 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -58,7 +58,6 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; @synthesize masterTrackArray; @synthesize noneTrack; @synthesize videoContainerTag; -@synthesize enabled = _enabled; - (instancetype)init { @@ -97,18 +96,9 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [self switchingTrackFromNone:nil]; } -- (void)setEnabled:(BOOL)enabled -{ - _enabled = enabled; - [fTableView setEnabled:enabled]; - [self.trackPopup setEnabled:enabled]; - [self.configureDefaults setEnabled:enabled]; - [self.reloadDefaults setEnabled:enabled]; -} - - (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem { - return self.enabled; + return (self.job != nil); } #pragma mark - @@ -407,6 +397,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; if (job) { + _job = job; [audioArray release]; audioArray = [job.audioTracks retain]; self.settings = job.audioDefaults; @@ -431,6 +422,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; } else { + _job = nil; [audioArray release]; audioArray = nil; self.settings = nil; diff --git a/macosx/HBSubtitlesController.h b/macosx/HBSubtitlesController.h index 56fc0dcb8..1d681349e 100644 --- a/macosx/HBSubtitlesController.h +++ b/macosx/HBSubtitlesController.h @@ -5,7 +5,6 @@ It may be used under the terms of the GNU General Public License. */ #import -#import "HBViewValidation.h" extern NSString *keySubTrackName; extern NSString *keySubTrackIndex; @@ -27,7 +26,7 @@ extern NSString *keySubTrackSrtCharCode; * HBSubtitlesController * Responds to HBContainerChangedNotification. */ -@interface HBSubtitlesController : NSViewController +@interface HBSubtitlesController : NSViewController - (void)applySettingsFromPreset:(NSDictionary *)preset; diff --git a/macosx/HBSubtitlesController.m b/macosx/HBSubtitlesController.m index 590093f5a..5f836289c 100644 --- a/macosx/HBSubtitlesController.m +++ b/macosx/HBSubtitlesController.m @@ -68,8 +68,6 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; @implementation HBSubtitlesController -@synthesize enabled = _enabled; - - (instancetype)init { self = [super initWithNibName:@"Subtitles" bundle:nil]; @@ -93,15 +91,6 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; return self; } -- (void)setEnabled:(BOOL)enabled -{ - [self.trackPopUp setEnabled:enabled]; - [self.configureDefaults setEnabled:enabled]; - [self.reloadDefaults setEnabled:enabled]; - [self.fTableView setEnabled:enabled]; - _enabled = enabled; -} - - (void)setJob:(HBJob *)job { /* reset the subtitles arrays */ @@ -111,6 +100,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; if (job) { + _job = job; self.subtitleArray = job.subtitlesTracks; self.settings = job.subtitlesDefaults; self.subtitleSourceArray = [[job.title.subtitlesTracks mutableCopy] autorelease]; @@ -172,6 +162,10 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; // to display a "None" row in the table view [self.subtitleArray addObject:[self createSubtitleTrack]]; } + else + { + _job = nil; + } [self.fTableView reloadData]; } @@ -195,7 +189,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; - (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem { - return self.enabled; + return (self.job != nil); } /** diff --git a/macosx/HBVideoController.h b/macosx/HBVideoController.h index 3289b58ee..c0c572fa6 100644 --- a/macosx/HBVideoController.h +++ b/macosx/HBVideoController.h @@ -5,7 +5,6 @@ It may be used under the terms of the GNU General Public License. */ #import -#import "HBViewValidation.h" @class HBController; @class HBAdvancedController; @@ -15,7 +14,7 @@ /** * HBVideoController */ -@interface HBVideoController : NSViewController +@interface HBVideoController : NSViewController - (instancetype)initWithAdvancedController:(HBAdvancedController *)advancedController; @@ -25,6 +24,6 @@ @property (nonatomic, copy, readwrite) NSString *pictureSettings; @property (nonatomic, copy, readwrite) NSString *pictureFilters; -@property (nonatomic, readwrite, retain) HBVideo *video; +@property (nonatomic, readwrite, assign) HBVideo *video; @end diff --git a/macosx/HBVideoController.m b/macosx/HBVideoController.m index fa0bb192e..95a956bda 100644 --- a/macosx/HBVideoController.m +++ b/macosx/HBVideoController.m @@ -45,8 +45,6 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; @implementation HBVideoController -@synthesize enabled = _enabled; - - (instancetype)initWithAdvancedController:(HBAdvancedController *)advancedController { self = [self init]; @@ -62,6 +60,8 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; self = [super initWithNibName:@"Video" bundle:nil]; if (self) { + _labelColor = [[NSColor disabledControlTextColor] retain]; + // Observe the advanced tab pref shown/hided state. [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.HBShowAdvancedTab" @@ -84,11 +84,11 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; return self; } -- (void)setEnabled:(BOOL)flag +- (void)setVideo:(HBVideo *)video { - _enabled = flag; + _video = video; - if (_enabled) + if (_video) { self.labelColor = [NSColor controlTextColor]; } @@ -97,7 +97,7 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; self.labelColor = [NSColor disabledControlTextColor]; } - [self enableEncoderOptionsWidgets:flag]; + [self enableEncoderOptionsWidgets:(video != nil)]; } #pragma mark - KVO @@ -151,7 +151,7 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; } } // enable/disable, populate and update the various widgets - [self enableEncoderOptionsWidgets:self.enabled]; + [self enableEncoderOptionsWidgets:(self.video != nil)]; } else if ([keyPath isEqualToString:@"values.HBShowAdvancedTab"]) {