1 /* $Id: Controller.h,v 1.35 2005/08/01 14:29:50 titer Exp $
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.fr/>.
5 It may be used under the terms of the GNU General Public License. */
7 #import <Cocoa/Cocoa.h>
8 #import <Growl/Growl.h>
12 #import "ChapterTitles.h"
13 #import "PictureController.h"
14 #import "HBFilterController.h"
15 #import "HBPreviewController.h"
16 #import "HBQueueController.h"
17 #import "HBAdvancedController.h"
18 #import "HBPreferencesController.h"
21 @class HBOutputPanelController;
22 @class PictureFilterController;
24 /* We subclass NSView so that our drags show both the icon as well as PresetName columns */
25 @interface HBPresetsOutlineView : NSOutlineView
33 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
35 IBOutlet NSWindow * fWindow;
37 /* Main Menu Outlets */
38 NSMenuItem * fOpenSourceTitleMMenu;
40 /* Source Title Scan Outlets */
41 IBOutlet NSPanel * fScanSrcTitlePanel;
42 IBOutlet NSTextField * fScanSrcTitlePathField;
43 IBOutlet NSTextField * fSrcDsplyNameTitleScan;
44 IBOutlet NSTextField * fScanSrcTitleNumField;
45 IBOutlet NSButton * fScanSrcTitleCancelButton;
46 IBOutlet NSButton * fScanSrcTitleOpenButton;
48 /* Picture Settings */
49 PictureController * fPictureController;
51 PictureFilterController * fPictureFilterController;
53 PreviewController * fPreviewController;
55 /* Advanced options tab */
56 HBAdvancedController * fAdvancedOptions;
57 IBOutlet NSBox * fAdvancedView;
59 HBPreferencesController * fPreferencesController;
62 HBQueueController * fQueueController;
63 IBOutlet NSTextField * fQueueStatus;
66 HBOutputPanelController *outputPanel;
69 IBOutlet NSProgressIndicator * fScanIndicator;
70 NSString * sourceDisplayName;
71 IBOutlet NSTextField * fSrcDVD2Field;
72 IBOutlet NSTextField * fSrcTitleField;
73 IBOutlet NSPopUpButton * fSrcTitlePopUp;
74 IBOutlet NSTextField * fSrcChapterField;
75 IBOutlet NSPopUpButton * fSrcChapterStartPopUp;
76 IBOutlet NSTextField * fSrcChapterToField;
77 IBOutlet NSPopUpButton * fSrcChapterEndPopUp;
78 IBOutlet NSTextField * fSrcDuration1Field;
79 IBOutlet NSTextField * fSrcDuration2Field;
82 IBOutlet NSTextField * fDstFormatField;
83 IBOutlet NSPopUpButton * fDstFormatPopUp;
85 IBOutlet NSTextField * fDstFile1Field;
86 IBOutlet NSTextField * fDstFile2Field;
87 IBOutlet NSButton * fDstBrowseButton;
89 // Creates 64 bit mp4's that allow file sizes over 4gb
90 IBOutlet NSButton * fDstMp4LargeFileCheck;
91 // Optimizes mp4's for http
92 IBOutlet NSButton * fDstMp4HttpOptFileCheck;
93 // Creates iPod compatible mp4's (add ipod uuid atom)
94 IBOutlet NSButton * fDstMp4iPodFileCheck;
97 IBOutlet NSTextField * fVidRateField;
98 IBOutlet NSPopUpButton * fVidRatePopUp;
99 IBOutlet NSTextField * fVidEncoderField;
100 IBOutlet NSPopUpButton * fVidEncoderPopUp;
101 IBOutlet NSTextField * fVidQualityField;
102 IBOutlet NSMatrix * fVidQualityMatrix;
103 IBOutlet NSButtonCell * fVidTargetCell;
104 IBOutlet NSTextField * fVidTargetSizeField;
105 IBOutlet NSButtonCell * fVidBitrateCell;
106 IBOutlet NSTextField * fVidBitrateField;
107 IBOutlet NSButtonCell * fVidConstantCell;
108 IBOutlet NSSlider * fVidQualitySlider;
109 IBOutlet NSButton * fVidTwoPassCheck;
110 IBOutlet NSButton * fVidTurboPassCheck;
112 /* Status read out fileds for picture sizing */
113 IBOutlet NSTextField * fPictureSizeField;
114 IBOutlet NSTextField * fPictureCroppingField;
116 /* Status read out fileds for video filters */
117 IBOutlet NSTextField * fVideoFiltersField;
119 /* Picture variables */
120 int PicOrigOutputWidth;
121 int PicOrigOutputHeight;
127 IBOutlet NSTextField * fSubField;
128 IBOutlet NSPopUpButton * fSubPopUp;
129 IBOutlet NSButton * fSubForcedCheck;
133 IBOutlet NSTextField * fAudSourceLabel;
134 IBOutlet NSTextField * fAudCodecLabel;
135 IBOutlet NSTextField * fAudMixdownLabel;
136 IBOutlet NSTextField * fAudSamplerateLabel;
137 IBOutlet NSTextField * fAudBitrateLabel;
138 IBOutlet NSTextField * fAudDrcLabel;
140 IBOutlet NSTextField * fAudTrack1Label;
141 IBOutlet NSTextField * fAudTrack2Label;
142 IBOutlet NSTextField * fAudTrack3Label;
143 IBOutlet NSTextField * fAudTrack4Label;
145 /* Source Audio PopUps */
146 IBOutlet NSPopUpButton * fAudLang1PopUp;
147 IBOutlet NSPopUpButton * fAudLang2PopUp;
148 IBOutlet NSPopUpButton * fAudLang3PopUp;
149 IBOutlet NSPopUpButton * fAudLang4PopUp;
152 IBOutlet NSPopUpButton * fAudTrack1CodecPopUp;
153 IBOutlet NSPopUpButton * fAudTrack2CodecPopUp;
154 IBOutlet NSPopUpButton * fAudTrack3CodecPopUp;
155 IBOutlet NSPopUpButton * fAudTrack4CodecPopUp;
158 IBOutlet NSPopUpButton * fAudTrack1MixPopUp;
159 IBOutlet NSPopUpButton * fAudTrack2MixPopUp;
160 IBOutlet NSPopUpButton * fAudTrack3MixPopUp;
161 IBOutlet NSPopUpButton * fAudTrack4MixPopUp;
163 /* Samplerate PopUps */
164 IBOutlet NSPopUpButton * fAudTrack1RatePopUp;
165 IBOutlet NSPopUpButton * fAudTrack2RatePopUp;
166 IBOutlet NSPopUpButton * fAudTrack3RatePopUp;
167 IBOutlet NSPopUpButton * fAudTrack4RatePopUp;
170 IBOutlet NSPopUpButton * fAudTrack1BitratePopUp;
171 IBOutlet NSPopUpButton * fAudTrack2BitratePopUp;
172 IBOutlet NSPopUpButton * fAudTrack3BitratePopUp;
173 IBOutlet NSPopUpButton * fAudTrack4BitratePopUp;
175 /* Dynamic Range Compression */
176 IBOutlet NSSlider * fAudTrack1DrcSlider;
177 IBOutlet NSTextField * fAudTrack1DrcField;
178 IBOutlet NSSlider * fAudTrack2DrcSlider;
179 IBOutlet NSTextField * fAudTrack2DrcField;
180 IBOutlet NSSlider * fAudTrack3DrcSlider;
181 IBOutlet NSTextField * fAudTrack3DrcField;
182 IBOutlet NSSlider * fAudTrack4DrcSlider;
183 IBOutlet NSTextField * fAudTrack4DrcField;
186 IBOutlet NSButton * fCreateChapterMarkers;
187 IBOutlet NSTableView * fChapterTable;
188 ChapterTitles * fChapterTitlesDelegate;
191 IBOutlet NSTextField * fStatusField;
192 IBOutlet NSProgressIndicator * fRipIndicator;
193 BOOL fRipIndicatorShown;
195 /* Queue File variables */
196 NSString * QueueFile;
197 NSMutableArray * QueueFileArray;
198 int currentQueueEncodeIndex; // Used to track the currently encoding queueu item
200 /* User Preset variables here */
201 HBPresets * fPresetsBuiltin;
202 IBOutlet NSDrawer * fPresetDrawer;
203 IBOutlet NSTextField * fPresetNewName;
204 IBOutlet NSTextField * fPresetNewDesc;
205 IBOutlet NSPopUpButton * fPresetNewPicSettingsPopUp;
206 IBOutlet NSButton * fPresetNewPicFiltersCheck;
207 IBOutlet NSButton * fPresetNewFolderCheck;
208 IBOutlet NSTextField * fPresetSelectedDisplay;
210 NSString * AppSupportDirectory;
211 NSString * UserPresetsFile;
212 NSMutableArray * UserPresets;
213 NSMutableArray * UserPresetssortedArray;
214 NSMutableDictionary * chosenPreset;
215 int curUserPresetChosenNum;
217 NSMutableDictionary *presetHbDefault; // this is 1 in "Default" preset key
218 NSMutableDictionary *presetUserDefault;// this is 2 in "Default" preset key
219 NSMutableDictionary *presetUserDefaultParent;
220 NSMutableDictionary *presetUserDefaultParentParent;
221 int presetCurrentBuiltInCount; // keeps track of the current number of built in presets
222 IBOutlet NSPanel * fAddPresetPanel;
224 /* NSOutline View for the presets */
225 NSArray *fDraggedNodes;
226 IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
227 IBOutlet NSButton * fPresetsAdd;
228 IBOutlet NSButton * fPresetsDelete;
229 IBOutlet NSPopUpButton * fPresetsActionButton;
231 hb_handle_t * fHandle;
233 /* Queue variables */
234 hb_handle_t * fQueueEncodeLibhb; // libhb for HB Encoding
236 hb_title_t * fQueueEncodeTitle;
237 int fEncodingQueueItem; // corresponds to the index of fJobGroups encoding item
238 int fPendingCount; // Number of various kinds of job groups in fJobGroups.
244 /* integer to set to determine the previous state
245 of encode 0==idle, 1==encoding, 2==cancelled*/
247 int currentScanCount;
248 int currentSuccessfulScanCount;
250 BOOL applyQueueToScan;
251 NSString * currentSource;
252 NSString * browsedSourceDisplayName;
255 - (void) writeToActivityLog:(char *) format, ...;
256 - (IBAction) browseSources: (id) sender;
257 - (void) browseSourcesDone: (NSOpenPanel *) sheet
258 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
259 - (IBAction) showSourceTitleScanPanel: (id) sender;
260 - (IBAction) closeSourceTitleScanPanel: (id) sender;
261 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
262 - (IBAction) showNewScan: (id) sender;
264 - (void) updateUI: (NSTimer *) timer;
265 - (void) enableUI: (bool) enable;
267 - (IBAction) titlePopUpChanged: (id) sender;
268 - (IBAction) chapterPopUpChanged: (id) sender;
270 - (IBAction) formatPopUpChanged: (id) sender;
271 - (IBAction) videoEncoderPopUpChanged: (id) sender;
272 - (IBAction) autoSetM4vExtension: (id) sender;
273 - (IBAction) twoPassCheckboxChanged: (id) sender;
274 - (IBAction) videoFrameRateChanged: (id) sender;
275 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
276 - (IBAction) audioCodecsPopUpChanged: (id) sender;
277 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
278 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
279 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
280 - (IBAction) audioTrackPopUpChanged: (id) sender;
281 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
282 - (IBAction) audioTrackMixdownChanged: (id) sender;
283 - (IBAction) subtitleSelectionChanged: (id) sender;
285 - (IBAction) browseFile: (id) sender;
286 - (void) browseFileDone: (NSSavePanel *) sheet
287 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
289 - (IBAction) videoMatrixChanged: (id) sender;
290 - (IBAction) qualitySliderChanged: (id) sender;
291 - (IBAction) audioDRCSliderChanged: (id) sender;
293 - (IBAction) showPicturePanel: (id) sender;
294 - (void) picturePanelFullScreen;
295 - (void) picturePanelWindowed;
296 - (IBAction) showFiltersPanel: (id) sender;
297 - (IBAction) showPreviewWindow: (id) sender;
298 - (void)pictureSettingsDidChange;
299 - (IBAction) calculatePictureSizing: (id) sender;
300 - (IBAction) openMainWindow: (id) sender;
302 /* Queue File Stuff */
303 - (void) loadQueueFile;
304 - (NSDictionary *)createQueueFileItem;
305 - (void)saveQueueFileItem;
306 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
307 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
308 - (void) processNewQueueEncode;
309 - (void) clearQueueEncodedItems;
310 - (IBAction)applyQueueSettings:(id)sender;
311 - (void) removeQueueFileItem:(int) queueItemToRemove;
312 - (void) clearQueueAllItems;
313 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex;
314 - (void)getQueueStats;
315 - (void)setQueueEncodingItemsAsPending;
316 - (IBAction) addToQueue: (id) sender;
317 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
318 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
319 - (void) doAddToQueue;
321 - (IBAction) showQueueWindow:(id)sender;
323 - (IBAction)showPreferencesWindow:(id)sender;
325 - (IBAction) Rip: (id) sender;
326 - (void) overWriteAlertDone: (NSWindow *) sheet
327 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
330 - (IBAction) Cancel: (id) sender;
331 - (void) doCancelCurrentJob;
332 - (void) doCancelCurrentJobAndStop;
333 - (IBAction) Pause: (id) sender;
335 - (IBAction) calculateBitrate: (id) sender;
336 - (void) controlTextDidChange: (NSNotification *) notification;
338 - (IBAction) openHomepage: (id) sender;
339 - (IBAction) openForums: (id) sender;
340 - (IBAction) openUserGuide: (id) sender;
342 // Preset Methods Here
344 /* These are required by the NSOutlineView Datasource Delegate */
345 /* We use this to deterimine children of an item */
346 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
347 /* We use this to determine if an item should be expandable */
348 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
349 /* used to specify the number of levels to show for each item */
350 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
351 /* Used to tell the outline view which information is to be displayed per item */
352 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
353 /* Use to customize the font and display characteristics of the title cell */
354 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
355 /* We use this to edit the name field in the outline view */
356 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
357 /* We use this to provide tooltips for the items in the presets outline view */
358 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
360 /* We use this to actually select the preset and act accordingly */
361 - (IBAction)selectPreset:(id)sender;
363 /* Manage User presets */
364 - (void) loadPresets;
365 - (IBAction) customSettingUsed: (id) sender;
366 - (IBAction) showAddPresetPanel: (id) sender;
367 - (IBAction) closeAddPresetPanel: (id) sender;
368 - (NSDictionary *)createPreset;
370 - (IBAction) revertPictureSizeToMax:(id)sender;
372 - (IBAction)setDefaultPreset:(id)sender;
373 - (IBAction)selectDefaultPreset:(id)sender;
376 - (IBAction)addFactoryPresets:(id)sender;
377 - (IBAction)deleteFactoryPresets:(id)sender;
378 - (IBAction)addUserPreset:(id)sender;
380 - (IBAction)insertPreset:(id)sender;
381 - (IBAction)deletePreset:(id)sender;
382 - (IBAction)getDefaultPresets:(id)sender;
384 -(void)sendToMetaX:(NSString *) filePath;
386 - (NSDictionary *) registrationDictionaryForGrowl;
387 -(void)showGrowlDoneNotification:(NSString *) filePath;
388 - (IBAction)showDebugOutputPanel:(id)sender;
389 - (void)setupToolbar;
391 - (void) prepareJobForPreview;
392 - (void) remindUserOfSleepOrShutdown;
394 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex;