OSDN Git Service

import original 0.9.5 release
[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 #import "HBAudioController.h"
21
22 extern NSString *HBContainerChangedNotification;
23 extern NSString *keyContainerTag;
24 extern NSString *HBTitleChangedNotification;
25 extern NSString *keyTitleTag;
26
27 @class HBOutputPanelController;
28
29 /* We subclass NSView so that our drags show both the icon as well as PresetName columns */
30 @interface HBPresetsOutlineView : NSOutlineView
31 {
32
33 BOOL                        fIsDragging;
34
35 }
36 @end
37
38 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
39 {
40     NSImage                      * fApplicationIcon;
41     IBOutlet NSWindow            * fWindow;
42
43     /* Main Menu Outlets */
44     NSMenuItem                   * fOpenSourceTitleMMenu;
45     
46     /* Source Title Scan Outlets */
47     IBOutlet NSPanel              * fScanSrcTitlePanel;
48     IBOutlet NSTextField          * fScanSrcTitlePathField;
49     IBOutlet NSTextField          * fSrcDsplyNameTitleScan;
50     IBOutlet NSTextField          * fScanSrcTitleNumField;
51     IBOutlet NSButton             * fScanSrcTitleCancelButton;
52     IBOutlet NSButton             * fScanSrcTitleOpenButton;
53
54     
55     /* Picture Settings */
56     PictureController            * fPictureController;
57     
58     /* Picture Preview */
59     PreviewController            * fPreviewController;
60     
61     /* Advanced options tab */
62     HBAdvancedController         * fAdvancedOptions;
63         IBOutlet NSBox               * fAdvancedView;
64     
65     HBPreferencesController      * fPreferencesController;
66     
67     /* Queue panel */
68     HBQueueController            * fQueueController;
69     IBOutlet NSTextField         * fQueueStatus;
70     
71     /* Output panel */
72     HBOutputPanelController       *outputPanel;
73         
74     /* Source box */
75         IBOutlet NSProgressIndicator * fScanIndicator;
76         NSString                     * sourceDisplayName;
77     IBOutlet NSTextField         * fSrcDVD2Field;
78     IBOutlet NSTextField         * fSrcTitleField;
79     IBOutlet NSPopUpButton       * fSrcTitlePopUp;
80     
81     
82     /* lib dvd nav specific */
83     IBOutlet NSTextField         * fSrcAngleLabel;
84     IBOutlet NSPopUpButton       * fSrcAnglePopUp;
85     
86     /* Source start and end points */
87     IBOutlet NSPopUpButton       * fEncodeStartStopPopUp;
88     /* pts based start / stop */
89     IBOutlet NSTextField         * fSrcTimeStartEncodingField;
90     IBOutlet NSTextField         * fSrcTimeEndEncodingField;
91     /* frame based based start / stop */
92     IBOutlet NSTextField         * fSrcFrameStartEncodingField;
93     IBOutlet NSTextField         * fSrcFrameEndEncodingField;
94     
95     IBOutlet NSTextField         * fSrcChapterField;
96     IBOutlet NSPopUpButton       * fSrcChapterStartPopUp;
97     IBOutlet NSTextField         * fSrcChapterToField;
98     IBOutlet NSPopUpButton       * fSrcChapterEndPopUp;
99     
100     /* Source duration information */
101     IBOutlet NSTextField         * fSrcDuration1Field;
102     IBOutlet NSTextField         * fSrcDuration2Field;
103         
104     /* Destination box */
105     IBOutlet NSTextField         * fDstFormatField;
106         IBOutlet NSPopUpButton       * fDstFormatPopUp;
107         
108     IBOutlet NSTextField         * fDstFile1Field;
109     IBOutlet NSTextField         * fDstFile2Field;
110     IBOutlet NSButton            * fDstBrowseButton;
111     /* MP4 Options */
112     // Creates 64 bit mp4's that allow file sizes over 4gb
113     IBOutlet NSButton            * fDstMp4LargeFileCheck;
114     // Optimizes mp4's for http
115     IBOutlet NSButton            * fDstMp4HttpOptFileCheck;
116     // Creates iPod compatible mp4's (add ipod uuid atom)
117     IBOutlet NSButton            * fDstMp4iPodFileCheck;
118         
119     /* Video box */
120     IBOutlet NSButton            * fFrameratePfrCheck;
121     
122     IBOutlet NSTextField         * fVidRateField;
123     IBOutlet NSPopUpButton       * fVidRatePopUp;
124     IBOutlet NSTextField         * fVidEncoderField;
125     IBOutlet NSPopUpButton       * fVidEncoderPopUp;
126     IBOutlet NSTextField         * fVidQualityField;
127     IBOutlet NSTextField         * fVidQualityRFLabel;
128     IBOutlet NSTextField         * fVidQualityRFField;
129     IBOutlet NSMatrix            * fVidQualityMatrix;
130     IBOutlet NSButtonCell        * fVidTargetCell;
131     IBOutlet NSTextField         * fVidTargetSizeField;
132     IBOutlet NSButtonCell        * fVidBitrateCell;
133     IBOutlet NSTextField         * fVidBitrateField;
134     IBOutlet NSButtonCell        * fVidConstantCell;
135     IBOutlet NSSlider            * fVidQualitySlider;
136     IBOutlet NSButton            * fVidTwoPassCheck;
137     IBOutlet NSButton            * fVidTurboPassCheck;
138         
139         /* Status read out fileds for picture sizing */
140     IBOutlet NSTextField         * fPictureSizeField;
141     IBOutlet NSTextField         * fPictureCroppingField;
142         
143     /* Status read out fileds for video filters */
144     IBOutlet NSTextField         * fVideoFiltersField;
145         
146         /* Picture variables */
147         int                        PicOrigOutputWidth;
148         int                        PicOrigOutputHeight;
149         int                        AutoCropTop;
150         int                        AutoCropBottom;
151         int                        AutoCropLeft;
152         int                        AutoCropRight;
153     /* Subtitles box */
154     IBOutlet NSTextField         * fSubField;
155     IBOutlet NSPopUpButton       * fSubPopUp;
156         IBOutlet NSButton            * fSubForcedCheck;
157     
158     
159     IBOutlet NSTableView         * fSubtitlesTable;
160         HBSubtitles                  * fSubtitlesDelegate;
161     IBOutlet NSButton            * fBrowseSrtFileButton;
162     
163         /* New Audio box */
164         IBOutlet HBAudioController   * fAudioDelegate;
165             
166     /* Chapters box */
167     IBOutlet NSButton            * fCreateChapterMarkers;
168     IBOutlet NSTableView         * fChapterTable;
169         IBOutlet NSButton            * fLoadChaptersButton;
170         IBOutlet NSButton            * fSaveChaptersButton;
171         IBOutlet NSTableColumn       * fChapterTableNameColumn;
172         ChapterTitles                * fChapterTitlesDelegate;
173         
174     /* Bottom */
175     IBOutlet NSTextField         * fStatusField;
176     IBOutlet NSProgressIndicator * fRipIndicator;
177         BOOL                           fRipIndicatorShown;
178     
179     /* Queue File variables */
180     NSString                     * QueueFile;
181         NSMutableArray               * QueueFileArray;
182     int                            currentQueueEncodeIndex; // Used to track the currently encoding queueu item
183     
184         /* User Preset variables here */
185         HBPresets                    * fPresetsBuiltin;
186         IBOutlet NSDrawer            * fPresetDrawer;
187         IBOutlet NSTextField         * fPresetNewName;
188         IBOutlet NSTextField         * fPresetNewDesc;
189         IBOutlet NSPopUpButton       * fPresetNewPicSettingsPopUp;
190     IBOutlet NSTextField         * fPresetNewPicWidth;
191     IBOutlet NSTextField         * fPresetNewPicHeight;
192     IBOutlet NSBox               * fPresetNewPicWidthHeightBox;
193     
194     IBOutlet NSButton            * fPresetNewPicFiltersCheck;
195     IBOutlet NSButton            * fPresetNewFolderCheck;
196         IBOutlet NSTextField         * fPresetSelectedDisplay;
197         
198         NSString                     * AppSupportDirectory;
199         NSString                     * UserPresetsFile;
200         NSMutableArray               * UserPresets;
201         NSMutableArray               * UserPresetssortedArray;
202         NSMutableDictionary          * chosenPreset;
203     int                            curUserPresetChosenNum;
204          
205         NSMutableDictionary          *presetHbDefault; // this is 1 in "Default" preset key
206         NSMutableDictionary          *presetUserDefault;// this is 2 in "Default" preset key
207     NSMutableDictionary          *presetUserDefaultParent;
208     NSMutableDictionary          *presetUserDefaultParentParent;
209     int                           presetCurrentBuiltInCount; // keeps track of the current number of built in presets
210     IBOutlet NSPanel             * fAddPresetPanel;
211         
212     /* NSOutline View for the presets */
213     NSArray                      *fDraggedNodes;
214     IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
215     IBOutlet NSButton            * fPresetsAdd;
216         IBOutlet NSButton            * fPresetsDelete;
217     IBOutlet NSPopUpButton       * fPresetsActionButton;
218
219     hb_handle_t                  * fHandle;
220     
221     /* Queue variables */
222     int                          hbInstanceNum; //stores the number of HandBrake instances currently running
223     hb_handle_t                  * fQueueEncodeLibhb;           // libhb for HB Encoding
224         hb_title_t                   * fTitle;
225     hb_title_t                   * fQueueEncodeTitle;
226     int                          fEncodingQueueItem;     // corresponds to the index of fJobGroups encoding item
227     int                          fPendingCount;         // Number of various kinds of job groups in fJobGroups.
228     int                          fCompletedCount;
229     int                          fCanceledCount;
230     int                          fWorkingCount;
231     
232     int                          fqueueEditRescanItemNum; // queue array item to be reloaded into the main window
233     int                          pidNum; // The pid number for this instance
234     NSString                     * currentQueueEncodeNameString;
235     
236     /* integer to set to determine the previous state
237                 of encode 0==idle, 1==encoding, 2==cancelled*/
238     int                            fEncodeState;
239         int                            currentScanCount;
240         int                            currentSuccessfulScanCount;
241     BOOL                           SuccessfulScan;
242     BOOL                           applyQueueToScan;
243         NSString                      * currentSource;
244     NSString                      * browsedSourceDisplayName;
245     
246     double                         dockIconProgress;
247 }
248 - (int) getPidnum;
249 - (IBAction) showAboutPanel:(id)sender;
250
251 - (void) writeToActivityLog:(const char *) format, ...;
252 - (IBAction) browseSources: (id) sender;
253 - (void) browseSourcesDone: (NSOpenPanel *) sheet
254                 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
255 - (IBAction) showSourceTitleScanPanel: (id) sender;
256 - (IBAction) closeSourceTitleScanPanel: (id) sender;  
257 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
258 - (IBAction) showNewScan: (id) sender;
259
260
261 - (IBAction) cancelScanning:(id)sender;
262
263 - (void)     updateUI: (NSTimer *) timer;
264 - (void)     enableUI: (bool) enable;
265 - (IBAction) encodeStartStopPopUpChanged: (id) sender;
266 - (IBAction) titlePopUpChanged: (id) sender;
267 - (IBAction) chapterPopUpChanged: (id) sender;
268 - (IBAction) startEndSecValueChanged: (id) sender;
269 - (IBAction) startEndFrameValueChanged: (id) sender;
270
271
272 - (IBAction) formatPopUpChanged: (id) sender;
273 - (IBAction) videoEncoderPopUpChanged: (id) sender;
274 - (IBAction) autoSetM4vExtension: (id) sender;
275 - (IBAction) twoPassCheckboxChanged: (id) sender;
276 - (IBAction) videoFrameRateChanged: (id) sender;
277 - (void) prepareJob;
278 - (IBAction) browseFile: (id) sender;
279 - (void)     browseFileDone: (NSSavePanel *) sheet
280                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
281
282 - (IBAction) videoMatrixChanged: (id) sender;
283
284 - (IBAction) qualitySliderChanged: (id) sender;
285 - (void) setupQualitySlider;
286
287 - (IBAction) browseImportSrtFile: (id) sender;
288 - (void) browseImportSrtFileDone: (NSSavePanel *) sheet
289                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
290
291 - (IBAction) showPicturePanel: (id) sender;
292 - (void) picturePanelFullScreen;
293 - (void) picturePanelWindowed;
294 - (IBAction) showPreviewWindow: (id) sender;
295 - (void)pictureSettingsDidChange;
296 - (IBAction) calculatePictureSizing: (id) sender;
297 - (IBAction) openMainWindow: (id) sender;
298
299 /* Queue File Stuff */
300 - (void) loadQueueFile;
301 - (NSDictionary *)createQueueFileItem;
302 - (void)saveQueueFileItem;
303 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
304 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
305 - (void) processNewQueueEncode;
306 - (void) clearQueueEncodedItems;
307 /* Queue Editing */
308 - (IBAction)applyQueueSettingsToMainWindow:(id)sender;
309 - (IBAction)rescanQueueItemToMainWindow:(NSString *) scanPath scanTitleNum: (int) scanTitleNum selectedQueueItem: (int) selectedQueueItem;
310
311
312 - (void) removeQueueFileItem:(int) queueItemToRemove;
313 - (void) clearQueueAllItems;
314 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
315 - (void)getQueueStats;
316 - (void)setQueueEncodingItemsAsPending;
317 - (IBAction) addToQueue: (id) sender;
318 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
319                            returnCode: (int) returnCode contextInfo: (void *) contextInfo;
320 - (void)     doAddToQueue;
321
322 - (IBAction) showQueueWindow:(id)sender;
323
324 - (IBAction)showPreferencesWindow:(id)sender;
325
326 - (IBAction) Rip: (id) sender;
327 - (void)     overWriteAlertDone: (NSWindow *) sheet
328                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
329 - (void)     doRip;
330
331 - (IBAction) Cancel: (id) sender;
332 - (void)     doCancelCurrentJob;
333 - (void) doCancelCurrentJobAndStop;
334 - (IBAction) Pause: (id) sender;
335
336 - (IBAction) calculateBitrate: (id) sender;
337 - (void) controlTextDidChange: (NSNotification *) notification;
338
339 - (IBAction) openHomepage: (id) sender;
340 - (IBAction) openForums:   (id) sender;
341 - (IBAction) openUserGuide:   (id) sender;
342
343 // Preset Methods Here
344     
345 /* These are required by the NSOutlineView Datasource Delegate */
346 /* We use this to deterimine children of an item */
347 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
348 /* We use this to determine if an item should be expandable */
349 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
350 /* used to specify the number of levels to show for each item */
351 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
352 /* Used to tell the outline view which information is to be displayed per item */
353 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
354 /* Use to customize the font and display characteristics of the title cell */
355 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
356 /* We use this to edit the name field in the outline view */
357 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
358 /* We use this to provide tooltips for the items in the presets outline view */
359 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
360 - (void) checkBuiltInsForUpdates;
361 /* We use this to actually select the preset and act accordingly */
362 - (IBAction)selectPreset:(id)sender;    
363
364 /* Export / Import Presets */
365 - (IBAction) browseExportPresetFile: (id) sender;
366 - (void) browseExportPresetFileDone: (NSSavePanel *) sheet
367              returnCode: (int) returnCode contextInfo: (void *) contextInfo;
368              
369 - (IBAction) browseImportPresetFile: (id) sender;
370 - (void) browseImportPresetDone: (NSSavePanel *) sheet
371                    returnCode: (int) returnCode contextInfo: (void *) contextInfo;
372
373 /* Manage User presets */    
374 - (void) loadPresets;
375 - (IBAction) customSettingUsed: (id) sender;
376 - (IBAction) showAddPresetPanel: (id) sender;
377 - (IBAction) addPresetPicDropdownChanged: (id) sender;
378 - (IBAction) closeAddPresetPanel: (id) sender;
379 - (NSDictionary *)createPreset;
380
381 - (IBAction) revertPictureSizeToMax:(id)sender;
382
383 - (IBAction)setDefaultPreset:(id)sender;
384 - (IBAction)selectDefaultPreset:(id)sender;
385 - (void) savePreset;
386 - (void)sortPresets;
387 - (IBAction)addFactoryPresets:(id)sender;
388 - (IBAction)deleteFactoryPresets:(id)sender;
389 - (IBAction)addUserPreset:(id)sender;
390 - (void)addPreset;
391 - (IBAction)insertPreset:(id)sender;
392 - (IBAction)deletePreset:(id)sender;
393 - (IBAction)getDefaultPresets:(id)sender;
394
395 -(void)sendToMetaX:(NSString *) filePath;
396 // Growl methods
397 - (NSDictionary *) registrationDictionaryForGrowl;
398 -(void)showGrowlDoneNotification:(NSString *) filePath;
399 - (IBAction)showDebugOutputPanel:(id)sender;
400 - (void)setupToolbar;
401
402 - (void) prepareJobForPreview;
403 - (void) remindUserOfSleepOrShutdown;
404
405 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
406
407 - (int) hbInstances;
408
409 // Chapter files methods
410 - (IBAction) browseForChapterFile: (id) sender;
411 - (void)     browseForChapterFileDone: (NSOpenPanel *) sheet
412                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
413
414 - (IBAction) browseForChapterFileSave: (id) sender;
415 - (void)     browseForChapterFileSaveDone: (NSSavePanel *) sheet
416                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
417
418 + (unsigned int) maximumNumberOfAllowedAudioTracks;
419 @property (nonatomic, readonly) BOOL hasValidPresetSelected; 
420 - (IBAction) addAllAudioTracks: (id) sender;
421
422 @end
423