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 IBOutlet NSWindow * fWindow;
36 /* Main Menu Outlets */
37 NSMenuItem * fOpenSourceTitleMMenu;
39 /* Source Title Scan Outlets */
40 IBOutlet NSPanel * fScanSrcTitlePanel;
41 IBOutlet NSTextField * fScanSrcTitlePathField;
42 IBOutlet NSTextField * fSrcDsplyNameTitleScan;
43 IBOutlet NSTextField * fScanSrcTitleNumField;
44 IBOutlet NSButton * fScanSrcTitleCancelButton;
45 IBOutlet NSButton * fScanSrcTitleOpenButton;
48 /* Picture Settings */
49 PictureController * fPictureController;
52 PreviewController * fPreviewController;
54 /* Advanced options tab */
55 HBAdvancedController * fAdvancedOptions;
56 IBOutlet NSBox * fAdvancedView;
58 HBPreferencesController * fPreferencesController;
61 HBQueueController * fQueueController;
62 IBOutlet NSTextField * fQueueStatus;
65 HBOutputPanelController *outputPanel;
68 IBOutlet NSProgressIndicator * fScanIndicator;
69 NSString * sourceDisplayName;
70 IBOutlet NSTextField * fSrcDVD2Field;
71 IBOutlet NSTextField * fSrcTitleField;
72 IBOutlet NSPopUpButton * fSrcTitlePopUp;
75 /* lib dvd nav specific */
76 IBOutlet NSTextField * fSrcAngleLabel;
77 IBOutlet NSPopUpButton * fSrcAnglePopUp;
79 IBOutlet NSTextField * fSrcChapterField;
80 IBOutlet NSPopUpButton * fSrcChapterStartPopUp;
81 IBOutlet NSTextField * fSrcChapterToField;
82 IBOutlet NSPopUpButton * fSrcChapterEndPopUp;
83 IBOutlet NSTextField * fSrcDuration1Field;
84 IBOutlet NSTextField * fSrcDuration2Field;
87 IBOutlet NSTextField * fDstFormatField;
88 IBOutlet NSPopUpButton * fDstFormatPopUp;
90 IBOutlet NSTextField * fDstFile1Field;
91 IBOutlet NSTextField * fDstFile2Field;
92 IBOutlet NSButton * fDstBrowseButton;
94 // Creates 64 bit mp4's that allow file sizes over 4gb
95 IBOutlet NSButton * fDstMp4LargeFileCheck;
96 // Optimizes mp4's for http
97 IBOutlet NSButton * fDstMp4HttpOptFileCheck;
98 // Creates iPod compatible mp4's (add ipod uuid atom)
99 IBOutlet NSButton * fDstMp4iPodFileCheck;
102 IBOutlet NSTextField * fVidRateField;
103 IBOutlet NSPopUpButton * fVidRatePopUp;
104 IBOutlet NSTextField * fVidEncoderField;
105 IBOutlet NSPopUpButton * fVidEncoderPopUp;
106 IBOutlet NSTextField * fVidQualityField;
107 IBOutlet NSTextField * fVidQualityRFLabel;
108 IBOutlet NSTextField * fVidQualityRFField;
109 IBOutlet NSMatrix * fVidQualityMatrix;
110 IBOutlet NSButtonCell * fVidTargetCell;
111 IBOutlet NSTextField * fVidTargetSizeField;
112 IBOutlet NSButtonCell * fVidBitrateCell;
113 IBOutlet NSTextField * fVidBitrateField;
114 IBOutlet NSButtonCell * fVidConstantCell;
115 IBOutlet NSSlider * fVidQualitySlider;
116 IBOutlet NSButton * fVidTwoPassCheck;
117 IBOutlet NSButton * fVidTurboPassCheck;
119 /* Status read out fileds for picture sizing */
120 IBOutlet NSTextField * fPictureSizeField;
121 IBOutlet NSTextField * fPictureCroppingField;
123 /* Status read out fileds for video filters */
124 IBOutlet NSTextField * fVideoFiltersField;
126 /* Picture variables */
127 int PicOrigOutputWidth;
128 int PicOrigOutputHeight;
134 IBOutlet NSTextField * fSubField;
135 IBOutlet NSPopUpButton * fSubPopUp;
136 IBOutlet NSButton * fSubForcedCheck;
139 IBOutlet NSTableView * fSubtitlesTable;
140 HBSubtitles * fSubtitlesDelegate;
141 //NSMutableArray * subtitleArray;
146 IBOutlet NSTextField * fAudSourceLabel;
147 IBOutlet NSTextField * fAudCodecLabel;
148 IBOutlet NSTextField * fAudMixdownLabel;
149 IBOutlet NSTextField * fAudSamplerateLabel;
150 IBOutlet NSTextField * fAudBitrateLabel;
151 IBOutlet NSTextField * fAudDrcLabel;
153 IBOutlet NSTextField * fAudTrack1Label;
154 IBOutlet NSTextField * fAudTrack2Label;
155 IBOutlet NSTextField * fAudTrack3Label;
156 IBOutlet NSTextField * fAudTrack4Label;
158 /* Source Audio PopUps */
159 IBOutlet NSPopUpButton * fAudLang1PopUp;
160 IBOutlet NSPopUpButton * fAudLang2PopUp;
161 IBOutlet NSPopUpButton * fAudLang3PopUp;
162 IBOutlet NSPopUpButton * fAudLang4PopUp;
165 IBOutlet NSPopUpButton * fAudTrack1CodecPopUp;
166 IBOutlet NSPopUpButton * fAudTrack2CodecPopUp;
167 IBOutlet NSPopUpButton * fAudTrack3CodecPopUp;
168 IBOutlet NSPopUpButton * fAudTrack4CodecPopUp;
171 IBOutlet NSPopUpButton * fAudTrack1MixPopUp;
172 IBOutlet NSPopUpButton * fAudTrack2MixPopUp;
173 IBOutlet NSPopUpButton * fAudTrack3MixPopUp;
174 IBOutlet NSPopUpButton * fAudTrack4MixPopUp;
176 /* Samplerate PopUps */
177 IBOutlet NSPopUpButton * fAudTrack1RatePopUp;
178 IBOutlet NSPopUpButton * fAudTrack2RatePopUp;
179 IBOutlet NSPopUpButton * fAudTrack3RatePopUp;
180 IBOutlet NSPopUpButton * fAudTrack4RatePopUp;
183 IBOutlet NSPopUpButton * fAudTrack1BitratePopUp;
184 IBOutlet NSPopUpButton * fAudTrack2BitratePopUp;
185 IBOutlet NSPopUpButton * fAudTrack3BitratePopUp;
186 IBOutlet NSPopUpButton * fAudTrack4BitratePopUp;
188 /* Dynamic Range Compression */
189 IBOutlet NSSlider * fAudTrack1DrcSlider;
190 IBOutlet NSTextField * fAudTrack1DrcField;
191 IBOutlet NSSlider * fAudTrack2DrcSlider;
192 IBOutlet NSTextField * fAudTrack2DrcField;
193 IBOutlet NSSlider * fAudTrack3DrcSlider;
194 IBOutlet NSTextField * fAudTrack3DrcField;
195 IBOutlet NSSlider * fAudTrack4DrcSlider;
196 IBOutlet NSTextField * fAudTrack4DrcField;
199 IBOutlet NSButton * fCreateChapterMarkers;
200 IBOutlet NSTableView * fChapterTable;
201 ChapterTitles * fChapterTitlesDelegate;
204 IBOutlet NSTextField * fStatusField;
205 IBOutlet NSProgressIndicator * fRipIndicator;
206 BOOL fRipIndicatorShown;
208 /* Queue File variables */
209 NSString * QueueFile;
210 NSMutableArray * QueueFileArray;
211 int currentQueueEncodeIndex; // Used to track the currently encoding queueu item
213 /* User Preset variables here */
214 HBPresets * fPresetsBuiltin;
215 IBOutlet NSDrawer * fPresetDrawer;
216 IBOutlet NSTextField * fPresetNewName;
217 IBOutlet NSTextField * fPresetNewDesc;
218 IBOutlet NSPopUpButton * fPresetNewPicSettingsPopUp;
219 IBOutlet NSButton * fPresetNewPicFiltersCheck;
220 IBOutlet NSButton * fPresetNewFolderCheck;
221 IBOutlet NSTextField * fPresetSelectedDisplay;
223 NSString * AppSupportDirectory;
224 NSString * UserPresetsFile;
225 NSMutableArray * UserPresets;
226 NSMutableArray * UserPresetssortedArray;
227 NSMutableDictionary * chosenPreset;
228 int curUserPresetChosenNum;
230 NSMutableDictionary *presetHbDefault; // this is 1 in "Default" preset key
231 NSMutableDictionary *presetUserDefault;// this is 2 in "Default" preset key
232 NSMutableDictionary *presetUserDefaultParent;
233 NSMutableDictionary *presetUserDefaultParentParent;
234 int presetCurrentBuiltInCount; // keeps track of the current number of built in presets
235 IBOutlet NSPanel * fAddPresetPanel;
237 /* NSOutline View for the presets */
238 NSArray *fDraggedNodes;
239 IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
240 IBOutlet NSButton * fPresetsAdd;
241 IBOutlet NSButton * fPresetsDelete;
242 IBOutlet NSPopUpButton * fPresetsActionButton;
244 hb_handle_t * fHandle;
246 /* Queue variables */
247 hb_handle_t * fQueueEncodeLibhb; // libhb for HB Encoding
249 hb_title_t * fQueueEncodeTitle;
250 int fEncodingQueueItem; // corresponds to the index of fJobGroups encoding item
251 int fPendingCount; // Number of various kinds of job groups in fJobGroups.
257 /* integer to set to determine the previous state
258 of encode 0==idle, 1==encoding, 2==cancelled*/
260 int currentScanCount;
261 int currentSuccessfulScanCount;
263 BOOL applyQueueToScan;
264 NSString * currentSource;
265 NSString * browsedSourceDisplayName;
267 double dockIconProgress;
270 - (void) writeToActivityLog:(const char *) format, ...;
271 - (IBAction) browseSources: (id) sender;
272 - (void) browseSourcesDone: (NSOpenPanel *) sheet
273 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
274 - (IBAction) showSourceTitleScanPanel: (id) sender;
275 - (IBAction) closeSourceTitleScanPanel: (id) sender;
276 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
277 - (IBAction) showNewScan: (id) sender;
279 - (void) updateUI: (NSTimer *) timer;
280 - (void) enableUI: (bool) enable;
282 - (IBAction) titlePopUpChanged: (id) sender;
283 - (IBAction) chapterPopUpChanged: (id) sender;
285 - (IBAction) formatPopUpChanged: (id) sender;
286 - (IBAction) videoEncoderPopUpChanged: (id) sender;
287 - (IBAction) autoSetM4vExtension: (id) sender;
288 - (IBAction) twoPassCheckboxChanged: (id) sender;
289 - (IBAction) videoFrameRateChanged: (id) sender;
290 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
291 - (IBAction) audioCodecsPopUpChanged: (id) sender;
292 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
293 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
294 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
295 - (IBAction) audioTrackPopUpChanged: (id) sender;
296 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
297 - (IBAction) audioTrackMixdownChanged: (id) sender;
299 - (IBAction) browseFile: (id) sender;
300 - (void) browseFileDone: (NSSavePanel *) sheet
301 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
303 - (IBAction) videoMatrixChanged: (id) sender;
304 - (IBAction) qualitySliderChanged: (id) sender;
305 - (void) setupQualitySlider;
307 - (IBAction) audioDRCSliderChanged: (id) sender;
309 - (IBAction) showPicturePanel: (id) sender;
310 - (void) picturePanelFullScreen;
311 - (void) picturePanelWindowed;
312 - (IBAction) showPreviewWindow: (id) sender;
313 - (void)pictureSettingsDidChange;
314 - (IBAction) calculatePictureSizing: (id) sender;
315 - (IBAction) openMainWindow: (id) sender;
317 /* Queue File Stuff */
318 - (void) loadQueueFile;
319 - (NSDictionary *)createQueueFileItem;
320 - (void)saveQueueFileItem;
321 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
322 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
323 - (void) processNewQueueEncode;
324 - (void) clearQueueEncodedItems;
325 - (IBAction)applyQueueSettings:(id)sender;
326 - (void) removeQueueFileItem:(int) queueItemToRemove;
327 - (void) clearQueueAllItems;
328 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
329 - (void)getQueueStats;
330 - (void)setQueueEncodingItemsAsPending;
331 - (IBAction) addToQueue: (id) sender;
332 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
333 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
334 - (void) doAddToQueue;
336 - (IBAction) showQueueWindow:(id)sender;
338 - (IBAction)showPreferencesWindow:(id)sender;
340 - (IBAction) Rip: (id) sender;
341 - (void) overWriteAlertDone: (NSWindow *) sheet
342 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
345 - (IBAction) Cancel: (id) sender;
346 - (void) doCancelCurrentJob;
347 - (void) doCancelCurrentJobAndStop;
348 - (IBAction) Pause: (id) sender;
350 - (IBAction) calculateBitrate: (id) sender;
351 - (void) controlTextDidChange: (NSNotification *) notification;
353 - (IBAction) openHomepage: (id) sender;
354 - (IBAction) openForums: (id) sender;
355 - (IBAction) openUserGuide: (id) sender;
357 // Preset Methods Here
359 /* These are required by the NSOutlineView Datasource Delegate */
360 /* We use this to deterimine children of an item */
361 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
362 /* We use this to determine if an item should be expandable */
363 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
364 /* used to specify the number of levels to show for each item */
365 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
366 /* Used to tell the outline view which information is to be displayed per item */
367 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
368 /* Use to customize the font and display characteristics of the title cell */
369 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
370 /* We use this to edit the name field in the outline view */
371 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
372 /* We use this to provide tooltips for the items in the presets outline view */
373 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
374 - (void) checkBuiltInsForUpdates;
375 /* We use this to actually select the preset and act accordingly */
376 - (IBAction)selectPreset:(id)sender;
378 /* Export / Import Presets */
379 - (IBAction) browseExportPresetFile: (id) sender;
380 - (void) browseExportPresetFileDone: (NSSavePanel *) sheet
381 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
383 - (IBAction) browseImportPresetFile: (id) sender;
384 - (void) browseImportPresetDone: (NSSavePanel *) sheet
385 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
387 /* Manage User presets */
388 - (void) loadPresets;
389 - (IBAction) customSettingUsed: (id) sender;
390 - (IBAction) showAddPresetPanel: (id) sender;
391 - (IBAction) closeAddPresetPanel: (id) sender;
392 - (NSDictionary *)createPreset;
394 - (IBAction) revertPictureSizeToMax:(id)sender;
396 - (IBAction)setDefaultPreset:(id)sender;
397 - (IBAction)selectDefaultPreset:(id)sender;
400 - (IBAction)addFactoryPresets:(id)sender;
401 - (IBAction)deleteFactoryPresets:(id)sender;
402 - (IBAction)addUserPreset:(id)sender;
404 - (IBAction)insertPreset:(id)sender;
405 - (IBAction)deletePreset:(id)sender;
406 - (IBAction)getDefaultPresets:(id)sender;
408 -(void)sendToMetaX:(NSString *) filePath;
410 - (NSDictionary *) registrationDictionaryForGrowl;
411 -(void)showGrowlDoneNotification:(NSString *) filePath;
412 - (IBAction)showDebugOutputPanel:(id)sender;
413 - (void)setupToolbar;
415 - (void) prepareJobForPreview;
416 - (void) remindUserOfSleepOrShutdown;
418 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;