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 /* Picture Settings box */
113 IBOutlet NSTextField * fPicLabelSettings;
114 IBOutlet NSTextField * fPicLabelSrc;
115 IBOutlet NSTextField * fPicSettingsSrc;
116 IBOutlet NSTextField * fPicLabelOutp;
117 IBOutlet NSTextField * fPicSettingsOutp;
118 IBOutlet NSTextField * fPicLabelAnamorphic;
119 IBOutlet NSTextField * fPicSettingsAnamorphic;
121 IBOutlet NSTextField * fPicLabelAr;
122 IBOutlet NSTextField * fPicLabelAutoCrop;
123 IBOutlet NSTextField * fPicLabelDetelecine;
124 IBOutlet NSTextField * fPicLabelDeinterlace;
125 IBOutlet NSTextField * fPicLabelDecomb;
126 IBOutlet NSTextField * fPicLabelDenoise;
127 IBOutlet NSTextField * fPicLabelDeblock;
128 IBOutlet NSTextField * fPicSettingDeinterlace;
129 IBOutlet NSTextField * fPicSettingDecomb;
130 IBOutlet NSTextField * fPicSettingARkeep;
131 IBOutlet NSTextField * fPicSettingPAR;
132 IBOutlet NSTextField * fPicSettingAutoCrop;
133 IBOutlet NSTextField * fPicSettingDetelecine;
134 IBOutlet NSTextField * fPicSettingDenoise;
135 IBOutlet NSTextField * fPicSettingDeblock;
136 IBOutlet NSTextField * fPicLabelGrayscale;
137 IBOutlet NSTextField * fPicSettingGrayscale;
139 /* Picture variables */
140 int PicOrigOutputWidth;
141 int PicOrigOutputHeight;
147 IBOutlet NSTextField * fSubField;
148 IBOutlet NSPopUpButton * fSubPopUp;
149 IBOutlet NSButton * fSubForcedCheck;
153 IBOutlet NSTextField * fAudSourceLabel;
154 IBOutlet NSTextField * fAudCodecLabel;
155 IBOutlet NSTextField * fAudMixdownLabel;
156 IBOutlet NSTextField * fAudSamplerateLabel;
157 IBOutlet NSTextField * fAudBitrateLabel;
158 IBOutlet NSTextField * fAudDrcLabel;
160 IBOutlet NSTextField * fAudTrack1Label;
161 IBOutlet NSTextField * fAudTrack2Label;
162 IBOutlet NSTextField * fAudTrack3Label;
163 IBOutlet NSTextField * fAudTrack4Label;
165 /* Source Audio PopUps */
166 IBOutlet NSPopUpButton * fAudLang1PopUp;
167 IBOutlet NSPopUpButton * fAudLang2PopUp;
168 IBOutlet NSPopUpButton * fAudLang3PopUp;
169 IBOutlet NSPopUpButton * fAudLang4PopUp;
172 IBOutlet NSPopUpButton * fAudTrack1CodecPopUp;
173 IBOutlet NSPopUpButton * fAudTrack2CodecPopUp;
174 IBOutlet NSPopUpButton * fAudTrack3CodecPopUp;
175 IBOutlet NSPopUpButton * fAudTrack4CodecPopUp;
178 IBOutlet NSPopUpButton * fAudTrack1MixPopUp;
179 IBOutlet NSPopUpButton * fAudTrack2MixPopUp;
180 IBOutlet NSPopUpButton * fAudTrack3MixPopUp;
181 IBOutlet NSPopUpButton * fAudTrack4MixPopUp;
183 /* Samplerate PopUps */
184 IBOutlet NSPopUpButton * fAudTrack1RatePopUp;
185 IBOutlet NSPopUpButton * fAudTrack2RatePopUp;
186 IBOutlet NSPopUpButton * fAudTrack3RatePopUp;
187 IBOutlet NSPopUpButton * fAudTrack4RatePopUp;
190 IBOutlet NSPopUpButton * fAudTrack1BitratePopUp;
191 IBOutlet NSPopUpButton * fAudTrack2BitratePopUp;
192 IBOutlet NSPopUpButton * fAudTrack3BitratePopUp;
193 IBOutlet NSPopUpButton * fAudTrack4BitratePopUp;
195 /* Dynamic Range Compression */
196 IBOutlet NSSlider * fAudTrack1DrcSlider;
197 IBOutlet NSTextField * fAudTrack1DrcField;
198 IBOutlet NSSlider * fAudTrack2DrcSlider;
199 IBOutlet NSTextField * fAudTrack2DrcField;
200 IBOutlet NSSlider * fAudTrack3DrcSlider;
201 IBOutlet NSTextField * fAudTrack3DrcField;
202 IBOutlet NSSlider * fAudTrack4DrcSlider;
203 IBOutlet NSTextField * fAudTrack4DrcField;
206 IBOutlet NSButton * fCreateChapterMarkers;
207 IBOutlet NSTableView * fChapterTable;
208 ChapterTitles * fChapterTitlesDelegate;
211 IBOutlet NSTextField * fStatusField;
212 IBOutlet NSProgressIndicator * fRipIndicator;
213 BOOL fRipIndicatorShown;
215 /* Queue File variables */
216 NSString * QueueFile;
217 NSMutableArray * QueueFileArray;
218 int currentQueueEncodeIndex; // Used to track the currently encoding queueu item
220 /* User Preset variables here */
221 HBPresets * fPresetsBuiltin;
222 IBOutlet NSDrawer * fPresetDrawer;
223 IBOutlet NSTextField * fPresetNewName;
224 IBOutlet NSTextField * fPresetNewDesc;
225 IBOutlet NSPopUpButton * fPresetNewPicSettingsPopUp;
226 IBOutlet NSButton * fPresetNewPicFiltersCheck;
227 IBOutlet NSButton * fPresetNewFolderCheck;
228 IBOutlet NSTextField * fPresetSelectedDisplay;
230 NSString * AppSupportDirectory;
231 NSString * UserPresetsFile;
232 NSMutableArray * UserPresets;
233 NSMutableArray * UserPresetssortedArray;
234 NSMutableDictionary * chosenPreset;
235 int curUserPresetChosenNum;
237 NSMutableDictionary *presetHbDefault; // this is 1 in "Default" preset key
238 NSMutableDictionary *presetUserDefault;// this is 2 in "Default" preset key
239 NSMutableDictionary *presetUserDefaultParent;
240 NSMutableDictionary *presetUserDefaultParentParent;
241 int presetCurrentBuiltInCount; // keeps track of the current number of built in presets
242 IBOutlet NSPanel * fAddPresetPanel;
243 /* new NSOutline View for the presets */
244 NSArray *fDraggedNodes;
245 IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
246 IBOutlet NSButton * fPresetsAdd;
247 IBOutlet NSButton * fPresetsDelete;
248 IBOutlet NSPopUpButton * fPresetsActionButton;
250 hb_handle_t * fHandle;
252 hb_handle_t * fQueueEncodeLibhb; // libhb for HB Encoding
254 hb_title_t * fQueueEncodeTitle;
255 int fEncodingQueueItem; // corresponds to the index of fJobGroups encoding item
256 int fPendingCount; // Number of various kinds of job groups in fJobGroups.
262 /* integer to set to determine the previous state
263 of encode 0==idle, 1==encoding, 2==cancelled*/
265 int currentScanCount;
266 int currentSuccessfulScanCount;
268 BOOL applyQueueToScan;
269 NSString * currentSource;
270 NSString * browsedSourceDisplayName;
272 - (void) writeToActivityLog:(char *) format, ...;
273 - (IBAction) browseSources: (id) sender;
274 - (void) browseSourcesDone: (NSOpenPanel *) sheet
275 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
276 - (IBAction) showSourceTitleScanPanel: (id) sender;
277 - (IBAction) closeSourceTitleScanPanel: (id) sender;
278 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
279 - (IBAction) showNewScan: (id) sender;
281 - (void) updateUI: (NSTimer *) timer;
282 - (void) enableUI: (bool) enable;
284 - (IBAction) titlePopUpChanged: (id) sender;
285 - (IBAction) chapterPopUpChanged: (id) sender;
287 - (IBAction) formatPopUpChanged: (id) sender;
288 - (IBAction) videoEncoderPopUpChanged: (id) sender;
289 - (IBAction) autoSetM4vExtension: (id) sender;
290 - (IBAction) twoPassCheckboxChanged: (id) sender;
291 - (IBAction) videoFrameRateChanged: (id) sender;
292 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
293 - (IBAction) audioCodecsPopUpChanged: (id) sender;
294 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
295 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
296 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
297 - (IBAction) audioTrackPopUpChanged: (id) sender;
298 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
299 - (IBAction) audioTrackMixdownChanged: (id) sender;
300 - (IBAction) subtitleSelectionChanged: (id) sender;
302 - (IBAction) browseFile: (id) sender;
303 - (void) browseFileDone: (NSSavePanel *) sheet
304 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
306 - (IBAction) videoMatrixChanged: (id) sender;
307 - (IBAction) qualitySliderChanged: (id) sender;
308 - (IBAction) audioDRCSliderChanged: (id) sender;
310 - (IBAction) showPicturePanel: (id) sender;
311 - (void) picturePanelFullScreen;
312 - (void) picturePanelWindowed;
313 - (IBAction) showFiltersPanel: (id) sender;
314 - (IBAction) showPreviewWindow: (id) sender;
315 - (void)pictureSettingsDidChange;
316 - (IBAction) calculatePictureSizing: (id) sender;
317 - (IBAction) openMainWindow: (id) sender;
319 /* Queue File Stuff */
320 - (void) loadQueueFile;
321 - (NSDictionary *)createQueueFileItem;
322 - (void)saveQueueFileItem;
323 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
324 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
325 - (void) processNewQueueEncode;
326 - (void) clearQueueEncodedItems;
327 - (IBAction)applyQueueSettings:(id)sender;
328 - (void) removeQueueFileItem:(int) queueItemToRemove;
329 - (void) clearQueueAllItems;
330 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex;
331 - (void)getQueueStats;
332 - (void)setQueueEncodingItemsAsPending;
333 - (IBAction) addToQueue: (id) sender;
334 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
335 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
336 - (void) doAddToQueue;
338 - (IBAction) showQueueWindow:(id)sender;
340 - (IBAction)showPreferencesWindow:(id)sender;
342 - (IBAction) Rip: (id) sender;
343 - (void) overWriteAlertDone: (NSWindow *) sheet
344 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
347 - (IBAction) Cancel: (id) sender;
348 - (void) doCancelCurrentJob;
349 - (void) doCancelCurrentJobAndStop;
350 - (IBAction) Pause: (id) sender;
352 - (IBAction) calculateBitrate: (id) sender;
353 - (void) controlTextDidChange: (NSNotification *) notification;
355 - (IBAction) openHomepage: (id) sender;
356 - (IBAction) openForums: (id) sender;
357 - (IBAction) openUserGuide: (id) sender;
359 // Preset Methods Here
361 /* These are required by the NSOutlineView Datasource Delegate */
362 /* We use this to deterimine children of an item */
363 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
364 /* We use this to determine if an item should be expandable */
365 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
366 /* used to specify the number of levels to show for each item */
367 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
368 /* Used to tell the outline view which information is to be displayed per item */
369 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
370 /* Use to customize the font and display characteristics of the title cell */
371 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
372 /* We use this to edit the name field in the outline view */
373 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
374 /* We use this to provide tooltips for the items in the presets outline view */
375 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
377 /* We use this to actually select the preset and act accordingly */
378 - (IBAction)selectPreset:(id)sender;
380 /* Manage User presets */
381 - (void) loadPresets;
382 - (IBAction) customSettingUsed: (id) sender;
383 - (IBAction) showAddPresetPanel: (id) sender;
384 - (IBAction) closeAddPresetPanel: (id) sender;
385 - (NSDictionary *)createPreset;
387 - (IBAction) revertPictureSizeToMax:(id)sender;
389 - (IBAction)setDefaultPreset:(id)sender;
390 - (IBAction)selectDefaultPreset:(id)sender;
393 - (IBAction)addFactoryPresets:(id)sender;
394 - (IBAction)deleteFactoryPresets:(id)sender;
395 - (IBAction)addUserPreset:(id)sender;
397 - (IBAction)insertPreset:(id)sender;
398 - (IBAction)deletePreset:(id)sender;
399 - (IBAction)getDefaultPresets:(id)sender;
401 -(void)sendToMetaX:(NSString *) filePath;
403 - (NSDictionary *) registrationDictionaryForGrowl;
404 -(void)showGrowlDoneNotification:(NSString *) filePath;
405 - (IBAction)showDebugOutputPanel:(id)sender;
406 - (void)setupToolbar;
408 - (void) prepareJobForPreview;
409 - (void) remindUserOfSleepOrShutdown;
411 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex;