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.m0k.org/>.
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 "HBQueueController.h"
15 #import "MVMenuButton.h"
16 #import "HBAdvancedController.h"
17 #import "HBPreferencesController.h"
19 @class HBOutputPanelController;
21 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
24 IBOutlet NSWindow * fWindow;
27 /* Main Menu Outlets */
28 NSMenuItem * fOpenSourceTitleMMenu;
30 /* Source Title Scan Outlets */
31 IBOutlet NSPanel * fScanSrcTitlePanel;
32 IBOutlet NSTextField * fScanSrcTitlePathField;
33 IBOutlet NSTextField * fSrcDsplyNameTitleScan;
34 IBOutlet NSTextField * fScanSrcTitleNumField;
35 IBOutlet NSButton * fScanSrcTitleCancelButton;
36 IBOutlet NSButton * fScanSrcTitleOpenButton;
39 PictureController * fPictureController;
41 /* Advanced options tab */
42 HBAdvancedController * fAdvancedOptions;
43 IBOutlet NSBox * fAdvancedView;
45 HBPreferencesController * fPreferencesController;
48 HBQueueController * fQueueController;
49 IBOutlet NSTextField * fQueueStatus;
52 HBOutputPanelController *outputPanel;
55 IBOutlet NSProgressIndicator * fScanIndicator;
56 NSString * sourceDisplayName;
57 IBOutlet NSTextField * fSrcDVD2Field;
58 IBOutlet NSTextField * fSrcTitleField;
59 IBOutlet NSPopUpButton * fSrcTitlePopUp;
60 IBOutlet NSTextField * fSrcChapterField;
61 IBOutlet NSPopUpButton * fSrcChapterStartPopUp;
62 IBOutlet NSTextField * fSrcChapterToField;
63 IBOutlet NSPopUpButton * fSrcChapterEndPopUp;
64 IBOutlet NSTextField * fSrcDuration1Field;
65 IBOutlet NSTextField * fSrcDuration2Field;
68 IBOutlet NSTextField * fDstFormatField;
69 IBOutlet NSPopUpButton * fDstFormatPopUp;
70 IBOutlet NSTextField * fDstCodecsField;
71 IBOutlet NSPopUpButton * fDstCodecsPopUp;
72 IBOutlet NSTextField * fDstFile1Field;
73 IBOutlet NSTextField * fDstFile2Field;
74 IBOutlet NSButton * fDstBrowseButton;
76 // Creates 64 bit mp4's that allow file sizes over 4gb
77 IBOutlet NSButton * fDstMp4LargeFileCheck;
78 // Optimizes mp4's for http
79 IBOutlet NSButton * fDstMp4HttpOptFileCheck;
80 // Creates iPod compatible mp4's (add ipod uuid atom)
81 IBOutlet NSButton * fDstMp4iPodFileCheck;
84 IBOutlet NSTextField * fVidRateField;
85 IBOutlet NSPopUpButton * fVidRatePopUp;
86 IBOutlet NSTextField * fVidEncoderField;
87 IBOutlet NSPopUpButton * fVidEncoderPopUp;
88 IBOutlet NSTextField * fVidQualityField;
89 IBOutlet NSMatrix * fVidQualityMatrix;
90 IBOutlet NSButtonCell * fVidTargetCell;
91 IBOutlet NSTextField * fVidTargetSizeField;
92 IBOutlet NSButtonCell * fVidBitrateCell;
93 IBOutlet NSTextField * fVidBitrateField;
94 IBOutlet NSButtonCell * fVidConstantCell;
95 IBOutlet NSSlider * fVidQualitySlider;
96 IBOutlet NSButton * fVidGrayscaleCheck;
97 IBOutlet NSButton * fVidTwoPassCheck;
98 IBOutlet NSButton * fVidTurboPassCheck;
100 /* Picture Settings box */
101 IBOutlet NSTextField * fPicLabelSettings;
102 IBOutlet NSTextField * fPicLabelSrc;
103 IBOutlet NSTextField * fPicSettingsSrc;
104 IBOutlet NSTextField * fPicLabelOutp;
105 IBOutlet NSTextField * fPicSettingsOutp;
106 IBOutlet NSTextField * fPicLabelAnamorphic;
107 IBOutlet NSTextField * fPicSettingsAnamorphic;
109 IBOutlet NSTextField * fPicLabelAr;
110 IBOutlet NSTextField * fPicLabelAutoCrop;
111 IBOutlet NSTextField * fPicLabelDetelecine;
112 IBOutlet NSTextField * fPicLabelDeinterlace;
113 IBOutlet NSTextField * fPicLabelDenoise;
114 IBOutlet NSTextField * fPicLabelDeblock;
115 IBOutlet NSTextField * fPicSettingDeinterlace;
116 IBOutlet NSTextField * fPicSettingARkeep;
117 IBOutlet NSTextField * fPicSettingPAR;
118 IBOutlet NSTextField * fPicSettingAutoCrop;
119 IBOutlet NSTextField * fPicSettingDetelecine;
120 IBOutlet NSTextField * fPicSettingDenoise;
121 IBOutlet NSTextField * fPicSettingDeblock;
123 /* Picture variables */
124 int PicOrigOutputWidth;
125 int PicOrigOutputHeight;
131 IBOutlet NSTextField * fSubField;
132 IBOutlet NSPopUpButton * fSubPopUp;
133 IBOutlet NSButton * fSubForcedCheck;
136 IBOutlet NSTextField * fAudLang1Field;
137 IBOutlet NSPopUpButton * fAudLang1PopUp;
138 IBOutlet NSTextField * fAudLang2Field;
139 IBOutlet NSPopUpButton * fAudLang2PopUp;
140 /* New Audio Mix PopUps */
142 IBOutlet NSTextField * fAudTrack1MixLabel;
143 IBOutlet NSPopUpButton * fAudTrack1MixPopUp;
144 IBOutlet NSTextField * fAudTrack2MixLabel;
145 IBOutlet NSPopUpButton * fAudTrack2MixPopUp;
148 IBOutlet NSTextField * fAudRateField;
149 IBOutlet NSPopUpButton * fAudRatePopUp;
150 IBOutlet NSTextField * fAudBitrateField;
151 IBOutlet NSPopUpButton * fAudBitratePopUp;
152 /*Dynamic Range Compression */
153 IBOutlet NSSlider * fAudDrcSlider;
154 IBOutlet NSTextField * fAudDrcField;
155 IBOutlet NSTextField * fAudDrcLabel;
156 IBOutlet NSTextField * fAudDrcDescLabel1;
157 IBOutlet NSTextField * fAudDrcDescLabel2;
158 IBOutlet NSTextField * fAudDrcDescLabel3;
159 IBOutlet NSTextField * fAudDrcDescLabel4;
162 IBOutlet NSButton * fCreateChapterMarkers;
163 IBOutlet NSTableView * fChapterTable;
164 ChapterTitles * fChapterTitlesDelegate;
167 IBOutlet NSButton * fPictureButton;
168 IBOutlet NSTextField * fStatusField;
169 IBOutlet NSProgressIndicator * fRipIndicator;
170 BOOL fRipIndicatorShown;
172 /* User Preset variables here */
173 HBPresets * fPresetsBuiltin;
174 IBOutlet NSDrawer * fPresetDrawer;
175 IBOutlet NSTextField * fPresetNewName;
176 IBOutlet NSTextField * fPresetNewDesc;
177 IBOutlet NSPopUpButton * fPresetNewPicSettingsPopUp;
178 IBOutlet NSButton * fPresetNewPicFiltersCheck;
179 IBOutlet NSTextField * fPresetSelectedDisplay;
181 NSString * AppSupportDirectory;
182 NSString * UserPresetsFile;
183 NSMutableArray * UserPresets;
184 NSMutableArray * UserPresetssortedArray;
185 NSMutableDictionary * chosenPreset;
186 int curUserPresetChosenNum;
188 int presetHbDefault; // this is 1 in "Default" preset key
189 int presetUserDefault;// this is 2 in "Default" preset key
190 IBOutlet NSPanel * fAddPresetPanel;
191 /* new NSOutline View for the presets */
192 NSArray *fDraggedNodes;
193 IBOutlet NSOutlineView * fPresetsOutlineView;
194 IBOutlet NSButton * fPresetsAdd;
195 IBOutlet NSButton * fPresetsDelete;
196 IBOutlet MVMenuButton * fPresetsActionButton;
197 IBOutlet NSMenu * fPresetsActionMenu;
199 hb_handle_t * fHandle;
201 /* integer to set to determine the previous state
202 of encode 0==idle, 1==encoding, 2==cancelled*/
204 int currentScanCount;
205 int currentSuccessfulScanCount;
207 NSString * currentSource;
208 NSString * browsedSourceDisplayName;
210 - (void) writeToActivityLog:(char *) format, ...;
211 - (IBAction) browseSources: (id) sender;
212 - (void) browseSourcesDone: (NSOpenPanel *) sheet
213 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
214 - (IBAction) showSourceTitleScanPanel: (id) sender;
215 - (IBAction) closeSourceTitleScanPanel: (id) sender;
216 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
217 - (IBAction) showNewScan: (id) sender;
219 - (void) TranslateStrings;
221 - (void) updateUI: (NSTimer *) timer;
222 - (void) enableUI: (bool) enable;
224 - (IBAction) titlePopUpChanged: (id) sender;
225 - (IBAction) chapterPopUpChanged: (id) sender;
227 - (IBAction) formatPopUpChanged: (id) sender;
228 - (IBAction) codecsPopUpChanged: (id) sender;
229 - (IBAction) encoderPopUpChanged: (id) sender;
230 - (IBAction) autoSetM4vExtension: (id) sender;
231 - (IBAction) twoPassCheckboxChanged: (id) sender;
232 - (IBAction) videoFrameRateChanged: (id) sender;
233 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
234 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
235 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
236 - (IBAction) audioTrackPopUpChanged: (id) sender;
237 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
238 - (IBAction) audioTrackMixdownChanged: (id) sender;
239 - (IBAction) subtitleSelectionChanged: (id) sender;
241 - (IBAction) browseFile: (id) sender;
242 - (void) browseFileDone: (NSSavePanel *) sheet
243 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
245 - (IBAction) videoMatrixChanged: (id) sender;
246 - (IBAction) qualitySliderChanged: (id) sender;
247 - (IBAction) audioDRCSliderChanged: (id) sender;
249 - (IBAction) showPicturePanel: (id) sender;
250 - (IBAction) calculatePictureSizing: (id) sender;
251 - (IBAction) openMainWindow: (id) sender;
253 - (IBAction) addToQueue: (id) sender;
254 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
255 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
256 - (void) doAddToQueue;
258 - (IBAction) showQueueWindow:(id)sender;
260 - (IBAction)showPreferencesWindow:(id)sender;
262 - (IBAction) Rip: (id) sender;
263 - (void) overWriteAlertDone: (NSWindow *) sheet
264 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
267 - (IBAction) Cancel: (id) sender;
268 - (void) doCancelCurrentJob;
270 - (IBAction) Pause: (id) sender;
272 - (IBAction) calculateBitrate: (id) sender;
273 - (void) controlTextDidChange: (NSNotification *) notification;
275 - (IBAction) openHomepage: (id) sender;
276 - (IBAction) openForums: (id) sender;
277 - (IBAction) openUserGuide: (id) sender;
279 // Preset Methods Here
281 /* These are required by the NSOutlineView Datasource Delegate */
282 /* We use this to deterimine children of an item */
283 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
284 /* We use this to determine if an item should be expandable */
285 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
286 /* used to specify the number of levels to show for each item */
287 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
288 /* Used to tell the outline view which information is to be displayed per item */
289 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
290 /* Use to customize the font and display characteristics of the title cell */
291 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
292 /* We use this to edit the name field in the outline view */
293 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
294 /* We use this to provide tooltips for the items in the presets outline view */
295 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
297 /* We use this to actually select the preset and act accordingly */
298 - (IBAction)selectPreset:(id)sender;
300 /* Manage User presets */
301 - (void) loadPresets;
302 - (IBAction) customSettingUsed: (id) sender;
303 - (IBAction) showAddPresetPanel: (id) sender;
304 - (IBAction) closeAddPresetPanel: (id) sender;
305 - (NSDictionary *)createPreset;
307 - (IBAction) revertPictureSizeToMax:(id)sender;
309 - (IBAction)setDefaultPreset:(id)sender;
310 - (IBAction)selectDefaultPreset:(id)sender;
313 - (IBAction)addFactoryPresets:(id)sender;
314 - (IBAction)deleteFactoryPresets:(id)sender;
315 - (IBAction)addUserPreset:(id)sender;
317 - (IBAction)insertPreset:(id)sender;
318 - (IBAction)deletePreset:(id)sender;
319 - (IBAction)getDefaultPresets:(id)sender;
323 - (NSDictionary *) registrationDictionaryForGrowl;
324 -(IBAction)showGrowlDoneNotification:(id)sender;
325 - (IBAction)showDebugOutputPanel:(id)sender;
326 - (void)setupToolbar;
328 - (void) remindUserOfSleepOrShutdown;