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 "HBSubtitles.h"
14 #import "PictureController.h"
15 #import "HBPreviewController.h"
16 #import "HBQueueController.h"
17 #import "HBAdvancedController.h"
18 #import "HBPreferencesController.h"
21 @class HBOutputPanelController;
23 /* We subclass NSView so that our drags show both the icon as well as PresetName columns */
24 @interface HBPresetsOutlineView : NSOutlineView
32 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
34 NSImage * fApplicationIcon;
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;
49 /* Picture Settings */
50 PictureController * fPictureController;
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;
76 /* lib dvd nav specific */
77 IBOutlet NSTextField * fSrcAngleLabel;
78 IBOutlet NSPopUpButton * fSrcAnglePopUp;
80 IBOutlet NSTextField * fSrcChapterField;
81 IBOutlet NSPopUpButton * fSrcChapterStartPopUp;
82 IBOutlet NSTextField * fSrcChapterToField;
83 IBOutlet NSPopUpButton * fSrcChapterEndPopUp;
84 IBOutlet NSTextField * fSrcDuration1Field;
85 IBOutlet NSTextField * fSrcDuration2Field;
88 IBOutlet NSTextField * fDstFormatField;
89 IBOutlet NSPopUpButton * fDstFormatPopUp;
91 IBOutlet NSTextField * fDstFile1Field;
92 IBOutlet NSTextField * fDstFile2Field;
93 IBOutlet NSButton * fDstBrowseButton;
95 // Creates 64 bit mp4's that allow file sizes over 4gb
96 IBOutlet NSButton * fDstMp4LargeFileCheck;
97 // Optimizes mp4's for http
98 IBOutlet NSButton * fDstMp4HttpOptFileCheck;
99 // Creates iPod compatible mp4's (add ipod uuid atom)
100 IBOutlet NSButton * fDstMp4iPodFileCheck;
103 IBOutlet NSTextField * fVidRateField;
104 IBOutlet NSPopUpButton * fVidRatePopUp;
105 IBOutlet NSTextField * fVidEncoderField;
106 IBOutlet NSPopUpButton * fVidEncoderPopUp;
107 IBOutlet NSTextField * fVidQualityField;
108 IBOutlet NSTextField * fVidQualityRFLabel;
109 IBOutlet NSTextField * fVidQualityRFField;
110 IBOutlet NSMatrix * fVidQualityMatrix;
111 IBOutlet NSButtonCell * fVidTargetCell;
112 IBOutlet NSTextField * fVidTargetSizeField;
113 IBOutlet NSButtonCell * fVidBitrateCell;
114 IBOutlet NSTextField * fVidBitrateField;
115 IBOutlet NSButtonCell * fVidConstantCell;
116 IBOutlet NSSlider * fVidQualitySlider;
117 IBOutlet NSButton * fVidTwoPassCheck;
118 IBOutlet NSButton * fVidTurboPassCheck;
120 /* Status read out fileds for picture sizing */
121 IBOutlet NSTextField * fPictureSizeField;
122 IBOutlet NSTextField * fPictureCroppingField;
124 /* Status read out fileds for video filters */
125 IBOutlet NSTextField * fVideoFiltersField;
127 /* Picture variables */
128 int PicOrigOutputWidth;
129 int PicOrigOutputHeight;
135 IBOutlet NSTextField * fSubField;
136 IBOutlet NSPopUpButton * fSubPopUp;
137 IBOutlet NSButton * fSubForcedCheck;
140 IBOutlet NSTableView * fSubtitlesTable;
141 HBSubtitles * fSubtitlesDelegate;
142 IBOutlet NSButton * fBrowseSrtFileButton;
147 IBOutlet NSTextField * fAudSourceLabel;
148 IBOutlet NSTextField * fAudCodecLabel;
149 IBOutlet NSTextField * fAudMixdownLabel;
150 IBOutlet NSTextField * fAudSamplerateLabel;
151 IBOutlet NSTextField * fAudBitrateLabel;
152 IBOutlet NSTextField * fAudDrcLabel;
154 IBOutlet NSTextField * fAudTrack1Label;
155 IBOutlet NSTextField * fAudTrack2Label;
156 IBOutlet NSTextField * fAudTrack3Label;
157 IBOutlet NSTextField * fAudTrack4Label;
159 /* Source Audio PopUps */
160 IBOutlet NSPopUpButton * fAudLang1PopUp;
161 IBOutlet NSPopUpButton * fAudLang2PopUp;
162 IBOutlet NSPopUpButton * fAudLang3PopUp;
163 IBOutlet NSPopUpButton * fAudLang4PopUp;
166 IBOutlet NSPopUpButton * fAudTrack1CodecPopUp;
167 IBOutlet NSPopUpButton * fAudTrack2CodecPopUp;
168 IBOutlet NSPopUpButton * fAudTrack3CodecPopUp;
169 IBOutlet NSPopUpButton * fAudTrack4CodecPopUp;
172 IBOutlet NSPopUpButton * fAudTrack1MixPopUp;
173 IBOutlet NSPopUpButton * fAudTrack2MixPopUp;
174 IBOutlet NSPopUpButton * fAudTrack3MixPopUp;
175 IBOutlet NSPopUpButton * fAudTrack4MixPopUp;
177 /* Samplerate PopUps */
178 IBOutlet NSPopUpButton * fAudTrack1RatePopUp;
179 IBOutlet NSPopUpButton * fAudTrack2RatePopUp;
180 IBOutlet NSPopUpButton * fAudTrack3RatePopUp;
181 IBOutlet NSPopUpButton * fAudTrack4RatePopUp;
184 IBOutlet NSPopUpButton * fAudTrack1BitratePopUp;
185 IBOutlet NSPopUpButton * fAudTrack2BitratePopUp;
186 IBOutlet NSPopUpButton * fAudTrack3BitratePopUp;
187 IBOutlet NSPopUpButton * fAudTrack4BitratePopUp;
189 /* Dynamic Range Compression */
190 IBOutlet NSSlider * fAudTrack1DrcSlider;
191 IBOutlet NSTextField * fAudTrack1DrcField;
192 IBOutlet NSSlider * fAudTrack2DrcSlider;
193 IBOutlet NSTextField * fAudTrack2DrcField;
194 IBOutlet NSSlider * fAudTrack3DrcSlider;
195 IBOutlet NSTextField * fAudTrack3DrcField;
196 IBOutlet NSSlider * fAudTrack4DrcSlider;
197 IBOutlet NSTextField * fAudTrack4DrcField;
200 IBOutlet NSButton * fCreateChapterMarkers;
201 IBOutlet NSTableView * fChapterTable;
202 ChapterTitles * fChapterTitlesDelegate;
205 IBOutlet NSTextField * fStatusField;
206 IBOutlet NSProgressIndicator * fRipIndicator;
207 BOOL fRipIndicatorShown;
209 /* Queue File variables */
210 NSString * QueueFile;
211 NSMutableArray * QueueFileArray;
212 int currentQueueEncodeIndex; // Used to track the currently encoding queueu item
214 /* User Preset variables here */
215 HBPresets * fPresetsBuiltin;
216 IBOutlet NSDrawer * fPresetDrawer;
217 IBOutlet NSTextField * fPresetNewName;
218 IBOutlet NSTextField * fPresetNewDesc;
219 IBOutlet NSPopUpButton * fPresetNewPicSettingsPopUp;
220 IBOutlet NSButton * fPresetNewPicFiltersCheck;
221 IBOutlet NSButton * fPresetNewFolderCheck;
222 IBOutlet NSTextField * fPresetSelectedDisplay;
224 NSString * AppSupportDirectory;
225 NSString * UserPresetsFile;
226 NSMutableArray * UserPresets;
227 NSMutableArray * UserPresetssortedArray;
228 NSMutableDictionary * chosenPreset;
229 int curUserPresetChosenNum;
231 NSMutableDictionary *presetHbDefault; // this is 1 in "Default" preset key
232 NSMutableDictionary *presetUserDefault;// this is 2 in "Default" preset key
233 NSMutableDictionary *presetUserDefaultParent;
234 NSMutableDictionary *presetUserDefaultParentParent;
235 int presetCurrentBuiltInCount; // keeps track of the current number of built in presets
236 IBOutlet NSPanel * fAddPresetPanel;
238 /* NSOutline View for the presets */
239 NSArray *fDraggedNodes;
240 IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
241 IBOutlet NSButton * fPresetsAdd;
242 IBOutlet NSButton * fPresetsDelete;
243 IBOutlet NSPopUpButton * fPresetsActionButton;
245 hb_handle_t * fHandle;
247 /* Queue variables */
248 hb_handle_t * fQueueEncodeLibhb; // libhb for HB Encoding
250 hb_title_t * fQueueEncodeTitle;
251 int fEncodingQueueItem; // corresponds to the index of fJobGroups encoding item
252 int fPendingCount; // Number of various kinds of job groups in fJobGroups.
258 /* integer to set to determine the previous state
259 of encode 0==idle, 1==encoding, 2==cancelled*/
261 int currentScanCount;
262 int currentSuccessfulScanCount;
264 BOOL applyQueueToScan;
265 NSString * currentSource;
266 NSString * browsedSourceDisplayName;
268 double dockIconProgress;
271 - (IBAction) showAboutPanel:(id)sender;
273 - (void) writeToActivityLog:(const char *) format, ...;
274 - (IBAction) browseSources: (id) sender;
275 - (void) browseSourcesDone: (NSOpenPanel *) sheet
276 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
277 - (IBAction) showSourceTitleScanPanel: (id) sender;
278 - (IBAction) closeSourceTitleScanPanel: (id) sender;
279 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
280 - (IBAction) showNewScan: (id) sender;
282 - (void) updateUI: (NSTimer *) timer;
283 - (void) enableUI: (bool) enable;
285 - (IBAction) titlePopUpChanged: (id) sender;
286 - (IBAction) chapterPopUpChanged: (id) sender;
288 - (IBAction) formatPopUpChanged: (id) sender;
289 - (IBAction) videoEncoderPopUpChanged: (id) sender;
290 - (IBAction) autoSetM4vExtension: (id) sender;
291 - (IBAction) twoPassCheckboxChanged: (id) sender;
292 - (IBAction) videoFrameRateChanged: (id) sender;
293 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
294 - (IBAction) audioCodecsPopUpChanged: (id) sender;
295 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
296 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
297 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
298 - (IBAction) audioTrackPopUpChanged: (id) sender;
299 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
300 - (IBAction) audioTrackMixdownChanged: (id) sender;
302 - (IBAction) browseFile: (id) sender;
303 - (void) browseFileDone: (NSSavePanel *) sheet
304 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
306 - (IBAction) videoMatrixChanged: (id) sender;
308 - (IBAction) qualitySliderChanged: (id) sender;
309 - (void) setupQualitySlider;
311 - (IBAction) audioDRCSliderChanged: (id) sender;
312 - (IBAction) browseImportSrtFile: (id) sender;
313 - (void) browseImportSrtFileDone: (NSSavePanel *) sheet
314 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
316 - (IBAction) showPicturePanel: (id) sender;
317 - (void) picturePanelFullScreen;
318 - (void) picturePanelWindowed;
319 - (IBAction) showPreviewWindow: (id) sender;
320 - (void)pictureSettingsDidChange;
321 - (IBAction) calculatePictureSizing: (id) sender;
322 - (IBAction) openMainWindow: (id) sender;
324 /* Queue File Stuff */
325 - (void) loadQueueFile;
326 - (NSDictionary *)createQueueFileItem;
327 - (void)saveQueueFileItem;
328 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
329 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
330 - (void) processNewQueueEncode;
331 - (void) clearQueueEncodedItems;
332 - (IBAction)applyQueueSettings:(id)sender;
333 - (void) removeQueueFileItem:(int) queueItemToRemove;
334 - (void) clearQueueAllItems;
335 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
336 - (void)getQueueStats;
337 - (void)setQueueEncodingItemsAsPending;
338 - (IBAction) addToQueue: (id) sender;
339 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
340 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
341 - (void) doAddToQueue;
343 - (IBAction) showQueueWindow:(id)sender;
345 - (IBAction)showPreferencesWindow:(id)sender;
347 - (IBAction) Rip: (id) sender;
348 - (void) overWriteAlertDone: (NSWindow *) sheet
349 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
352 - (IBAction) Cancel: (id) sender;
353 - (void) doCancelCurrentJob;
354 - (void) doCancelCurrentJobAndStop;
355 - (IBAction) Pause: (id) sender;
357 - (IBAction) calculateBitrate: (id) sender;
358 - (void) controlTextDidChange: (NSNotification *) notification;
360 - (IBAction) openHomepage: (id) sender;
361 - (IBAction) openForums: (id) sender;
362 - (IBAction) openUserGuide: (id) sender;
364 // Preset Methods Here
366 /* These are required by the NSOutlineView Datasource Delegate */
367 /* We use this to deterimine children of an item */
368 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
369 /* We use this to determine if an item should be expandable */
370 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
371 /* used to specify the number of levels to show for each item */
372 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
373 /* Used to tell the outline view which information is to be displayed per item */
374 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
375 /* Use to customize the font and display characteristics of the title cell */
376 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
377 /* We use this to edit the name field in the outline view */
378 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
379 /* We use this to provide tooltips for the items in the presets outline view */
380 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
381 - (void) checkBuiltInsForUpdates;
382 /* We use this to actually select the preset and act accordingly */
383 - (IBAction)selectPreset:(id)sender;
385 /* Export / Import Presets */
386 - (IBAction) browseExportPresetFile: (id) sender;
387 - (void) browseExportPresetFileDone: (NSSavePanel *) sheet
388 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
390 - (IBAction) browseImportPresetFile: (id) sender;
391 - (void) browseImportPresetDone: (NSSavePanel *) sheet
392 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
394 /* Manage User presets */
395 - (void) loadPresets;
396 - (IBAction) customSettingUsed: (id) sender;
397 - (IBAction) showAddPresetPanel: (id) sender;
398 - (IBAction) closeAddPresetPanel: (id) sender;
399 - (NSDictionary *)createPreset;
401 - (IBAction) revertPictureSizeToMax:(id)sender;
403 - (IBAction)setDefaultPreset:(id)sender;
404 - (IBAction)selectDefaultPreset:(id)sender;
407 - (IBAction)addFactoryPresets:(id)sender;
408 - (IBAction)deleteFactoryPresets:(id)sender;
409 - (IBAction)addUserPreset:(id)sender;
411 - (IBAction)insertPreset:(id)sender;
412 - (IBAction)deletePreset:(id)sender;
413 - (IBAction)getDefaultPresets:(id)sender;
415 -(void)sendToMetaX:(NSString *) filePath;
417 - (NSDictionary *) registrationDictionaryForGrowl;
418 -(void)showGrowlDoneNotification:(NSString *) filePath;
419 - (IBAction)showDebugOutputPanel:(id)sender;
420 - (void)setupToolbar;
422 - (void) prepareJobForPreview;
423 - (void) remindUserOfSleepOrShutdown;
425 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;