OSDN Git Service

import 0.9.4
[handbrake-jp/handbrake-jp.git] / macosx / Controller.h
1 /* $Id: Controller.h,v 1.35 2005/08/01 14:29:50 titer Exp $
2
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. */
6
7 #import <Cocoa/Cocoa.h>
8 #import <Growl/Growl.h>
9
10 #include "hb.h"
11
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"
19 #import "HBPresets.h"
20
21 @class HBOutputPanelController;
22
23 /* We subclass NSView so that our drags show both the icon as well as PresetName columns */
24 @interface HBPresetsOutlineView : NSOutlineView
25 {
26
27 BOOL                        fIsDragging;
28
29 }
30 @end
31
32 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
33 {
34     NSImage                      * fApplicationIcon;
35     IBOutlet NSWindow            * fWindow;
36
37     /* Main Menu Outlets */
38     NSMenuItem                   * fOpenSourceTitleMMenu;
39     
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;
47
48     
49     /* Picture Settings */
50     PictureController            * fPictureController;
51     
52     /* Picture Preview */
53     PreviewController            * fPreviewController;
54     
55     /* Advanced options tab */
56     HBAdvancedController         * fAdvancedOptions;
57         IBOutlet NSBox               * fAdvancedView;
58     
59     HBPreferencesController      * fPreferencesController;
60     
61     /* Queue panel */
62     HBQueueController            * fQueueController;
63     IBOutlet NSTextField         * fQueueStatus;
64     
65     /* Output panel */
66     HBOutputPanelController       *outputPanel;
67         
68     /* Source box */
69         IBOutlet NSProgressIndicator * fScanIndicator;
70         NSString                     * sourceDisplayName;
71     IBOutlet NSTextField         * fSrcDVD2Field;
72     IBOutlet NSTextField         * fSrcTitleField;
73     IBOutlet NSPopUpButton       * fSrcTitlePopUp;
74     
75     
76     /* lib dvd nav specific */
77     IBOutlet NSTextField         * fSrcAngleLabel;
78     IBOutlet NSPopUpButton       * fSrcAnglePopUp;
79     
80     IBOutlet NSTextField         * fSrcChapterField;
81     IBOutlet NSPopUpButton       * fSrcChapterStartPopUp;
82     IBOutlet NSTextField         * fSrcChapterToField;
83     IBOutlet NSPopUpButton       * fSrcChapterEndPopUp;
84     IBOutlet NSTextField         * fSrcDuration1Field;
85     IBOutlet NSTextField         * fSrcDuration2Field;
86         
87     /* Destination box */
88     IBOutlet NSTextField         * fDstFormatField;
89         IBOutlet NSPopUpButton       * fDstFormatPopUp;
90         
91     IBOutlet NSTextField         * fDstFile1Field;
92     IBOutlet NSTextField         * fDstFile2Field;
93     IBOutlet NSButton            * fDstBrowseButton;
94     /* MP4 Options */
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;
101         
102     /* Video box */
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;
119         
120         /* Status read out fileds for picture sizing */
121     IBOutlet NSTextField         * fPictureSizeField;
122     IBOutlet NSTextField         * fPictureCroppingField;
123         
124     /* Status read out fileds for video filters */
125     IBOutlet NSTextField         * fVideoFiltersField;
126         
127         /* Picture variables */
128         int                        PicOrigOutputWidth;
129         int                        PicOrigOutputHeight;
130         int                        AutoCropTop;
131         int                        AutoCropBottom;
132         int                        AutoCropLeft;
133         int                        AutoCropRight;
134     /* Subtitles box */
135     IBOutlet NSTextField         * fSubField;
136     IBOutlet NSPopUpButton       * fSubPopUp;
137         IBOutlet NSButton            * fSubForcedCheck;
138     
139     
140     IBOutlet NSTableView         * fSubtitlesTable;
141         HBSubtitles                  * fSubtitlesDelegate;
142     IBOutlet NSButton            * fBrowseSrtFileButton;
143     
144         
145     /* Audio box */
146     /* Track Labels */
147     IBOutlet NSTextField         * fAudSourceLabel;
148     IBOutlet NSTextField         * fAudCodecLabel;
149     IBOutlet NSTextField         * fAudMixdownLabel;
150     IBOutlet NSTextField         * fAudSamplerateLabel;
151     IBOutlet NSTextField         * fAudBitrateLabel;
152     IBOutlet NSTextField         * fAudDrcLabel;
153     
154     IBOutlet NSTextField         * fAudTrack1Label;
155     IBOutlet NSTextField         * fAudTrack2Label;
156     IBOutlet NSTextField         * fAudTrack3Label;
157     IBOutlet NSTextField         * fAudTrack4Label;
158     
159     /* Source Audio PopUps */
160     IBOutlet NSPopUpButton       * fAudLang1PopUp;
161     IBOutlet NSPopUpButton       * fAudLang2PopUp;
162     IBOutlet NSPopUpButton       * fAudLang3PopUp;
163     IBOutlet NSPopUpButton       * fAudLang4PopUp;
164     
165     /* Codec Popups */
166     IBOutlet NSPopUpButton       * fAudTrack1CodecPopUp;
167     IBOutlet NSPopUpButton       * fAudTrack2CodecPopUp;
168     IBOutlet NSPopUpButton       * fAudTrack3CodecPopUp;
169     IBOutlet NSPopUpButton       * fAudTrack4CodecPopUp;
170     
171         /* Mixdown PopUps */
172         IBOutlet NSPopUpButton       * fAudTrack1MixPopUp;
173     IBOutlet NSPopUpButton       * fAudTrack2MixPopUp;
174     IBOutlet NSPopUpButton       * fAudTrack3MixPopUp;
175     IBOutlet NSPopUpButton       * fAudTrack4MixPopUp;
176         
177     /* Samplerate PopUps */
178         IBOutlet NSPopUpButton       * fAudTrack1RatePopUp;
179     IBOutlet NSPopUpButton       * fAudTrack2RatePopUp;
180     IBOutlet NSPopUpButton       * fAudTrack3RatePopUp;
181     IBOutlet NSPopUpButton       * fAudTrack4RatePopUp;
182     
183     /* Bitrate PopUps */
184     IBOutlet NSPopUpButton       * fAudTrack1BitratePopUp;
185     IBOutlet NSPopUpButton       * fAudTrack2BitratePopUp;
186     IBOutlet NSPopUpButton       * fAudTrack3BitratePopUp;
187     IBOutlet NSPopUpButton       * fAudTrack4BitratePopUp;
188     
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;
198     
199     /* Chapters box */
200     IBOutlet NSButton            * fCreateChapterMarkers;
201     IBOutlet NSTableView         * fChapterTable;
202         ChapterTitles                * fChapterTitlesDelegate;
203         
204     /* Bottom */
205     IBOutlet NSTextField         * fStatusField;
206     IBOutlet NSProgressIndicator * fRipIndicator;
207         BOOL                           fRipIndicatorShown;
208     
209     /* Queue File variables */
210     NSString                     * QueueFile;
211         NSMutableArray               * QueueFileArray;
212     int                            currentQueueEncodeIndex; // Used to track the currently encoding queueu item
213     
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;
223         
224         NSString                     * AppSupportDirectory;
225         NSString                     * UserPresetsFile;
226         NSMutableArray               * UserPresets;
227         NSMutableArray               * UserPresetssortedArray;
228         NSMutableDictionary          * chosenPreset;
229     int                            curUserPresetChosenNum;
230          
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;
237         
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;
244
245     hb_handle_t                  * fHandle;
246     
247     /* Queue variables */
248     hb_handle_t              * fQueueEncodeLibhb;           // libhb for HB Encoding
249         hb_title_t                   * fTitle;
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.
253     int                          fCompletedCount;
254     int                          fCanceledCount;
255     int                          fWorkingCount;
256     
257     
258     /* integer to set to determine the previous state
259                 of encode 0==idle, 1==encoding, 2==cancelled*/
260     int                            fEncodeState;
261         int                            currentScanCount;
262         int                            currentSuccessfulScanCount;
263     BOOL                           SuccessfulScan;
264     BOOL                           applyQueueToScan;
265         NSString                      * currentSource;
266     NSString                     * browsedSourceDisplayName;
267     
268     double                         dockIconProgress;
269 }
270
271 - (IBAction) showAboutPanel:(id)sender;
272
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;
281
282 - (void)     updateUI: (NSTimer *) timer;
283 - (void)     enableUI: (bool) enable;
284
285 - (IBAction) titlePopUpChanged: (id) sender;
286 - (IBAction) chapterPopUpChanged: (id) sender;
287
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;
301 - (void) prepareJob;
302 - (IBAction) browseFile: (id) sender;
303 - (void)     browseFileDone: (NSSavePanel *) sheet
304                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
305
306 - (IBAction) videoMatrixChanged: (id) sender;
307
308 - (IBAction) qualitySliderChanged: (id) sender;
309 - (void) setupQualitySlider;
310
311 - (IBAction) audioDRCSliderChanged: (id) sender;
312 - (IBAction) browseImportSrtFile: (id) sender;
313 - (void) browseImportSrtFileDone: (NSSavePanel *) sheet
314                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
315
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;
323
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;
342
343 - (IBAction) showQueueWindow:(id)sender;
344
345 - (IBAction)showPreferencesWindow:(id)sender;
346
347 - (IBAction) Rip: (id) sender;
348 - (void)     overWriteAlertDone: (NSWindow *) sheet
349                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
350 - (void)     doRip;
351
352 - (IBAction) Cancel: (id) sender;
353 - (void)     doCancelCurrentJob;
354 - (void) doCancelCurrentJobAndStop;
355 - (IBAction) Pause: (id) sender;
356
357 - (IBAction) calculateBitrate: (id) sender;
358 - (void) controlTextDidChange: (NSNotification *) notification;
359
360 - (IBAction) openHomepage: (id) sender;
361 - (IBAction) openForums:   (id) sender;
362 - (IBAction) openUserGuide:   (id) sender;
363
364 // Preset Methods Here
365     
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;    
384
385 /* Export / Import Presets */
386 - (IBAction) browseExportPresetFile: (id) sender;
387 - (void) browseExportPresetFileDone: (NSSavePanel *) sheet
388              returnCode: (int) returnCode contextInfo: (void *) contextInfo;
389              
390 - (IBAction) browseImportPresetFile: (id) sender;
391 - (void) browseImportPresetDone: (NSSavePanel *) sheet
392                    returnCode: (int) returnCode contextInfo: (void *) contextInfo;
393
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;
400
401 - (IBAction) revertPictureSizeToMax:(id)sender;
402
403 - (IBAction)setDefaultPreset:(id)sender;
404 - (IBAction)selectDefaultPreset:(id)sender;
405 - (void) savePreset;
406 - (void)sortPresets;
407 - (IBAction)addFactoryPresets:(id)sender;
408 - (IBAction)deleteFactoryPresets:(id)sender;
409 - (IBAction)addUserPreset:(id)sender;
410 - (void)addPreset;
411 - (IBAction)insertPreset:(id)sender;
412 - (IBAction)deletePreset:(id)sender;
413 - (IBAction)getDefaultPresets:(id)sender;
414
415 -(void)sendToMetaX:(NSString *) filePath;
416     // Growl methods
417 - (NSDictionary *) registrationDictionaryForGrowl;
418 -(void)showGrowlDoneNotification:(NSString *) filePath;
419 - (IBAction)showDebugOutputPanel:(id)sender;
420 - (void)setupToolbar;
421
422 - (void) prepareJobForPreview;
423 - (void) remindUserOfSleepOrShutdown;
424
425 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
426
427 - (int) hbInstances;
428
429
430
431
432 @end
433