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 NSButton * fDstMpgLargeFileCheck;
71 IBOutlet NSTextField * fDstCodecsField;
72 IBOutlet NSPopUpButton * fDstCodecsPopUp;
73 IBOutlet NSTextField * fDstFile1Field;
74 IBOutlet NSTextField * fDstFile2Field;
75 IBOutlet NSButton * fDstBrowseButton;
78 IBOutlet NSTextField * fVidRateField;
79 IBOutlet NSPopUpButton * fVidRatePopUp;
80 IBOutlet NSTextField * fVidEncoderField;
81 IBOutlet NSPopUpButton * fVidEncoderPopUp;
82 IBOutlet NSTextField * fVidQualityField;
83 IBOutlet NSMatrix * fVidQualityMatrix;
84 IBOutlet NSButtonCell * fVidTargetCell;
85 IBOutlet NSTextField * fVidTargetSizeField;
86 IBOutlet NSButtonCell * fVidBitrateCell;
87 IBOutlet NSTextField * fVidBitrateField;
88 IBOutlet NSButtonCell * fVidConstantCell;
89 IBOutlet NSSlider * fVidQualitySlider;
90 IBOutlet NSButton * fVidGrayscaleCheck;
91 IBOutlet NSButton * fVidTwoPassCheck;
92 IBOutlet NSButton * fVidTurboPassCheck;
94 /* Picture Settings box */
95 IBOutlet NSTextField * fPicLabelSettings;
96 IBOutlet NSTextField * fPicLabelSrc;
97 IBOutlet NSTextField * fPicLabelOutp;
98 IBOutlet NSTextField * fPicLabelAr;
99 IBOutlet NSTextField * fPicLabelSrcX;
100 IBOutlet NSTextField * fPicLabelOutputX;
101 IBOutlet NSTextField * fPicLabelAutoCrop;
102 IBOutlet NSTextField * fPicLabelDetelecine;
103 IBOutlet NSTextField * fPicLabelDeinterlace;
104 IBOutlet NSTextField * fPicLabelDenoise;
105 IBOutlet NSTextField * fPicLabelDeblock;
107 IBOutlet NSTextField * fPicSrcWidth;
108 IBOutlet NSTextField * fPicSrcHeight;
109 IBOutlet NSTextField * fPicSettingWidth;
110 IBOutlet NSTextField * fPicSettingHeight;
111 IBOutlet NSTextField * fPicSettingDeinterlace;
112 IBOutlet NSTextField * fPicSettingARkeep;
113 IBOutlet NSTextField * fPicSettingPAR;
114 IBOutlet NSTextField * fPicSettingAutoCrop;
115 IBOutlet NSTextField * fPicSettingDetelecine;
116 IBOutlet NSTextField * fPicSettingDenoise;
117 IBOutlet NSTextField * fPicSettingDeblock;
119 IBOutlet NSTextField * fPicLabelAnamorphic;
120 IBOutlet NSTextField * fPicLabelPAROutputX;
121 IBOutlet NSTextField * fPicSettingPARWidth;
122 IBOutlet NSTextField * fPicSettingPARHeight;
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;
158 IBOutlet NSButton * fCreateChapterMarkers;
159 IBOutlet NSTableView * fChapterTable;
160 ChapterTitles * fChapterTitlesDelegate;
163 IBOutlet NSButton * fPictureButton;
164 IBOutlet NSTextField * fStatusField;
165 IBOutlet NSProgressIndicator * fRipIndicator;
166 BOOL fRipIndicatorShown;
168 /* User Preset variables here */
169 HBPresets * fPresetsBuiltin;
170 IBOutlet NSDrawer * fPresetDrawer;
171 IBOutlet NSTextField * fPresetNewName;
172 IBOutlet NSTextField * fPresetNewDesc;
173 IBOutlet NSPopUpButton * fPresetNewPicSettingsPopUp;
174 IBOutlet NSButton * fPresetNewPicFiltersCheck;
175 IBOutlet NSTextField * fPresetSelectedDisplay;
177 NSString * AppSupportDirectory;
178 NSString * UserPresetsFile;
179 NSMutableArray * UserPresets;
180 NSMutableArray * UserPresetssortedArray;
181 NSMutableDictionary * chosenPreset;
182 int curUserPresetChosenNum;
184 int presetHbDefault; // this is 1 in "Default" preset key
185 int presetUserDefault;// this is 2 in "Default" preset key
186 IBOutlet NSPanel * fAddPresetPanel;
187 /* new NSOutline View for the presets */
188 NSArray *fDraggedNodes;
189 IBOutlet NSOutlineView * fPresetsOutlineView;
190 IBOutlet NSButton * fPresetsAdd;
191 IBOutlet NSButton * fPresetsDelete;
192 IBOutlet MVMenuButton * fPresetsActionButton;
193 IBOutlet NSMenu * fPresetsActionMenu;
195 hb_handle_t * fHandle;
197 /* integer to set to determine the previous state
198 of encode 0==idle, 1==encoding, 2==cancelled*/
200 int currentScanCount;
201 int currentSuccessfulScanCount;
203 NSString * currentSource;
206 - (IBAction) browseSources: (id) sender;
207 - (void) browseSourcesDone: (NSOpenPanel *) sheet
208 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
209 - (IBAction) showSourceTitleScanPanel: (id) sender;
210 - (IBAction) closeSourceTitleScanPanel: (id) sender;
211 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
212 - (IBAction) showNewScan: (id) sender;
214 - (void) TranslateStrings;
216 - (void) updateUI: (NSTimer *) timer;
217 - (void) enableUI: (bool) enable;
219 - (IBAction) titlePopUpChanged: (id) sender;
220 - (IBAction) chapterPopUpChanged: (id) sender;
222 - (IBAction) formatPopUpChanged: (id) sender;
223 - (IBAction) codecsPopUpChanged: (id) sender;
224 - (IBAction) encoderPopUpChanged: (id) sender;
225 - (IBAction) twoPassCheckboxChanged: (id) sender;
226 - (IBAction) videoFrameRateChanged: (id) sender;
227 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
228 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
229 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
230 - (IBAction) audioTrackPopUpChanged: (id) sender;
231 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
232 - (IBAction) audioTrackMixdownChanged: (id) sender;
233 - (IBAction) subtitleSelectionChanged: (id) sender;
235 - (IBAction) browseFile: (id) sender;
236 - (void) browseFileDone: (NSSavePanel *) sheet
237 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
239 - (IBAction) videoMatrixChanged: (id) sender;
240 - (IBAction) qualitySliderChanged: (id) sender;
241 - (IBAction) audioDRCSliderChanged: (id) sender;
243 - (IBAction) showPicturePanel: (id) sender;
244 - (IBAction) calculatePictureSizing: (id) sender;
245 - (IBAction) openMainWindow: (id) sender;
247 - (IBAction) addToQueue: (id) sender;
248 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
249 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
250 - (void) doAddToQueue;
252 - (IBAction) showQueueWindow:(id)sender;
254 - (IBAction)showPreferencesWindow:(id)sender;
256 - (IBAction) Rip: (id) sender;
257 - (void) overWriteAlertDone: (NSWindow *) sheet
258 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
259 - (void) updateAlertDone: (NSWindow *) sheet
260 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
263 - (IBAction) Cancel: (id) sender;
264 - (void) doCancelCurrentJob;
266 - (IBAction) Pause: (id) sender;
268 - (IBAction) calculateBitrate: (id) sender;
269 - (void) controlTextDidChange: (NSNotification *) notification;
271 - (IBAction) openHomepage: (id) sender;
272 - (IBAction) openForums: (id) sender;
273 - (IBAction) openUserGuide: (id) sender;
275 // Preset Methods Here
277 /* These are required by the NSOutlineView Datasource Delegate */
278 /* We use this to deterimine children of an item */
279 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
280 /* We use this to determine if an item should be expandable */
281 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
282 /* used to specify the number of levels to show for each item */
283 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
284 /* Used to tell the outline view which information is to be displayed per item */
285 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
286 /* Use to customize the font and display characteristics of the title cell */
287 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
288 /* We use this to edit the name field in the outline view */
289 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
290 /* We use this to provide tooltips for the items in the presets outline view */
291 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
293 /* We use this to actually select the preset and act accordingly */
294 - (IBAction)selectPreset:(id)sender;
296 /* Manage User presets */
297 - (void) loadPresets;
298 - (IBAction) customSettingUsed: (id) sender;
299 - (IBAction) showAddPresetPanel: (id) sender;
300 - (IBAction) closeAddPresetPanel: (id) sender;
301 - (NSDictionary *)createPreset;
303 - (IBAction) revertPictureSizeToMax:(id)sender;
305 - (IBAction)setDefaultPreset:(id)sender;
306 - (IBAction)selectDefaultPreset:(id)sender;
308 - (IBAction)addFactoryPresets:(id)sender;
309 - (IBAction)deleteFactoryPresets:(id)sender;
310 - (IBAction)addUserPreset:(id)sender;
312 - (IBAction)insertPreset:(id)sender;
313 - (IBAction)deletePreset:(id)sender;
314 - (IBAction)getDefaultPresets:(id)sender;
318 - (NSDictionary *) registrationDictionaryForGrowl;
319 -(IBAction)showGrowlDoneNotification:(id)sender;
320 - (IBAction)showDebugOutputPanel:(id)sender;
321 - (void)setupToolbar;
323 - (void) remindUserOfSleepOrShutdown;