]> git.sesse.net Git - vlc/blob - modules/gui/macosx/wizard.m
* implemented a general, re-usable help-panel used by all 4 "More Info" buttons ...
[vlc] / modules / gui / macosx / wizard.m
1 /*****************************************************************************
2  * wizard.h: MacOS X Streaming Wizard
3  *****************************************************************************
4  * Copyright (C) 2005 VideoLAN
5  * $Id$
6  *
7  * Authors: Felix Kühne <fkuehne@users.sf.net> 
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24  
25 /*****************************************************************************
26  * Note: this code is based upon ../wxwindows/wizard.cpp,
27  *       written by Clément Stenac.
28  *****************************************************************************/ 
29
30 /* TODO:
31     - implementation of the logic, i.e. handling of the collected values, respective manipulation of the GUI, start of the stream
32     - move some arrays to an external header file
33     - some GUI things (e.g. radio buttons on page 2, etc. - see FIXMEs)
34     - l10n string fixes (both in OSX and WX) */
35
36  
37 /*****************************************************************************
38  * Preamble
39  *****************************************************************************/ 
40 #import "wizard.h"
41 #import "intf.h"
42
43
44 /*****************************************************************************
45  * VLCWizard implementation
46  *****************************************************************************/
47
48 @implementation VLCWizard
49
50 static VLCWizard *_o_sharedInstance = nil;
51
52 + (VLCWizard *)sharedInstance
53 {
54     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
55 }
56
57 - (id)init 
58 {
59     if (_o_sharedInstance) {
60         [self dealloc];
61     } else {
62         _o_sharedInstance = [super init];
63     }
64     
65     return _o_sharedInstance;
66 }
67
68 - (void)awakeFromNib
69 {
70     /* some minor cleanup */
71     [o_t2_tbl_plst setEnabled:NO];
72         [o_wizardhelp_window setExcludedFromWindowsMenu:YES];
73         
74
75     /* FIXME: make the both arrays global */
76
77     /* add audio-codecs for transcoding */
78     NSArray * audioBitratesArray;
79     audioBitratesArray = [NSArray arrayWithObjects: @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
80     [o_t4_pop_audioBitrate removeAllItems];
81     [o_t4_pop_audioBitrate addItemsWithTitles: audioBitratesArray];
82     [o_t4_pop_audioBitrate selectItemWithTitle: @"192"];
83     
84     /* add video-codecs for transcoding */
85     NSArray * videoBitratesArray;
86     videoBitratesArray = [NSArray arrayWithObjects: @"3072", @"2048", @"1024", @"768", @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
87     [o_t4_pop_videoBitrate removeAllItems];
88     [o_t4_pop_videoBitrate addItemsWithTitles: videoBitratesArray];
89     [o_t4_pop_videoBitrate selectItemWithTitle: @"1024"];
90     
91     /* FIXME: fill the codec-popups as well */
92 }
93
94 - (void)showWizard
95 {
96     /* just present the window to the user */
97     /* we might need a method to reset the window first */
98     [o_tab_pageHolder selectFirstTabViewItem:self];
99     
100     [o_wizard_window center];
101     [o_wizard_window displayIfNeeded];
102     [o_wizard_window makeKeyAndOrderFront:nil];
103 }
104
105 - (void)initStrings
106 {
107     /* localise all strings to the users lang */
108     /* method is called from intf.m (in method openWizard) */
109     
110     /* general items */
111     [o_btn_backward setTitle: _NS("< Back")];
112     [o_btn_cancel setTitle: _NS("Cancel")];
113     [o_btn_forward setTitle: _NS("Next >")];
114     [o_wizard_window setTitle: _NS("Streaming/Transcoding Wizard")];
115     
116     /* page one ("Hello") */
117     [o_t1_txt_title setStringValue: _NS("Streaming/Transcoding Wizard")];
118     [o_t1_txt_text setStringValue: _NS("This wizard helps you to stream, transcode or save a stream")];
119     [o_t1_btn_mrInfo_strmg setTitle: _NS("More Info")];
120     [o_t1_btn_mrInfo_trnscd setTitle: _NS("More Info")];
121     [o_t1_txt_notice setStringValue: _NS("This wizard only gives access to a small subset of VLC's streaming and transcoding capabilities. Use the Open and Stream Output dialogs to get all of them")];
122     [o_t1_rdo_streaming setTitle: _NS("Stream to network")];
123     [o_t1_rdo_transcode setTitle: _NS("Transcode/Save to file")];
124     
125     /* page two ("Input") */
126     [o_t2_title setStringValue: _NS("Choose input")];
127     [o_t2_text setStringValue: _NS("Choose here your input stream")];
128     [o_t2_rdo_newStrm setTitle: _NS("Select a stream")];
129     [o_t2_rdo_exstPlstItm setTitle: _NS("Existing playlist item")];
130     [o_t2_btn_chooseFile setTitle: _NS("Choose...")];
131     [[[o_t2_tbl_plst tableColumnWithIdentifier:@"name"] headerCell] setStringValue: _NS("Name")];
132     [o_t2_box_prtExtrct setTitle: _NS("Partial Extract")];
133     [o_t2_ckb_enblPartExtrct setTitle: _NS("Enable")];
134     [o_t2_txt_prtExtrctFrom setStringValue: _NS("From")];
135     [o_t2_txt_prtExtrctTo setStringValue: _NS("To")];
136     
137     /* page three ("Streaming 1") */
138     [o_t3_txt_title setStringValue: _NS("Streaming")];
139     [o_t3_txt_text setStringValue: _NS("In this page, you will select how your input stream will be sent.")];
140     [o_t3_box_dest setTitle: _NS("Destination")];
141     [o_t3_box_strmgMthd setTitle: _NS("Streaming method")];
142     [o_t3_txt_destInfo setStringValue: _NS("Enter the address of the computer to stream to")];
143     [[o_t3_matrix_stmgMhd cellAtRow:1 column:0] setTitle: _NS("UDP Unicast")];
144     [[o_t3_matrix_stmgMhd cellAtRow:1 column:1] setTitle: _NS("UDP Multicast")];
145     
146     /* page four ("Transcode 1") */
147     [o_t4_title setStringValue: _NS("Transcode")];
148     [o_t4_text setStringValue: _NS("If you want to change the compression format of the audio or video tracks, fill in this page. (If you only want to change the container format, proceed to next page).")];
149     [o_t4_box_audio setTitle: _NS("Audio")];
150     [o_t4_box_video setTitle: _NS("Video")];
151     [o_t4_ckb_audio setTitle: _NS("Transcode audio")];
152     [o_t4_ckb_video setTitle: _NS("Transcode video")];
153     [o_t4_txt_videoBitrate setStringValue: _NS("Bitrate (kb/s)")];
154     [o_t4_txt_videoCodec setStringValue: _NS("Codec")];
155     [o_t4_txt_hintAudio setStringValue: _NS("If your stream has audio and you want to " \
156                          "transcode it, enable this")];
157     [o_t4_txt_hintVideo setStringValue: _NS("If your stream has video and you want to " \
158                          "transcode it, enable this")];
159     
160     /* page five ("Encap") */
161     [o_t5_title setStringValue: _NS("Encapsulation format")];
162     [o_t5_text setStringValue: _NS("In this page, you will select how the stream will be "\
163                      "encapsulated. Depending on the choices you made, all "\
164                      "formats won't be available.")];
165     
166     /* page six ("Streaming 2") */
167     [o_t6_title setStringValue: _NS("Additional streaming options")];
168     [o_t6_text setStringValue: _NS("In this page, you will define a few " \
169                               "additional parameters for your stream.")];
170     [o_t6_txt_ttl setStringValue: _NS("Time-To-Live (TTL)")];
171     [o_t6_btn_mrInfo_ttl setTitle: _NS("More Info")];
172     [o_t6_ckb_sap setTitle: _NS("SAP Announce")];
173     [o_t6_btn_mrInfo_sap setTitle: _NS("More Info")];
174      
175     /* page seven ("Transcode 2") */
176     [o_t7_title setStringValue: _NS("Additional transcode options")];
177     [o_t7_text setStringValue: _NS("In this page, you will define a few " \
178                               "additionnal parameters for your transcoding.")];
179     [o_t7_txt_saveFileTo setStringValue: _NS("Select the file to save to")];
180     [o_t7_btn_chooseFile setTitle: _NS("Choose...")];
181         
182         /* wizard help window */
183         [o_wh_btn_okay setTitle: _NS("OK")];
184 }
185
186 - (IBAction)cancelRun:(id)sender
187 {
188     [o_wizard_window close];
189 }
190
191 - (IBAction)nextTab:(id)sender
192 {
193     /* only a stub atm; needs to be implemented correctly later on */
194     [o_tab_pageHolder selectNextTabViewItem:self];
195 }
196
197 - (IBAction)prevTab:(id)sender
198 {
199     /* only a stub atm; needs to be implemented correctly later on */
200     [o_tab_pageHolder selectPreviousTabViewItem:self];
201 }
202
203 - (IBAction)t1_mrInfo_streaming:(id)sender
204 {
205     /* show a sheet for the help */
206         /* since NSAlert does not exist on OSX < 10.3, we use our own implementation */
207         [o_wh_txt_title setStringValue: _NS("Stream to network")];
208         [o_wh_txt_text setStringValue: _NS("Use this to stream on a network.")];
209         [NSApp beginSheet: o_wizardhelp_window
210             modalForWindow: o_wizard_window
211             modalDelegate: o_wizardhelp_window
212             didEndSelector: nil
213             contextInfo: nil];
214 }
215
216 - (IBAction)t1_mrInfo_transcode:(id)sender
217 {
218     /* show a sheet for the help */
219         [o_wh_txt_title setStringValue: _NS("Transcode/Save to file")];
220         [o_wh_txt_text setStringValue: _NS("Use this to save a stream to a file. You "\
221                         "have the possibility to reencode the stream. You can save whatever "\
222                         "VLC can read.\nPlease notice that VLC is not very suited " \
223                         "for file to file transcoding. You should use its transcoding " \
224             "features to save network streams, for example.")];
225         [NSApp beginSheet: o_wizardhelp_window
226             modalForWindow: o_wizard_window
227             modalDelegate: o_wizardhelp_window
228             didEndSelector: nil
229             contextInfo: nil];
230 }
231
232 - (IBAction)t2_addNewStream:(id)sender
233 {
234     NSOpenPanel * openPanel = [NSOpenPanel openPanel];
235     SEL sel = @selector(t2_getNewStreamFromDialog:returnCode:contextInfo:);
236     [openPanel beginSheetForDirectory:@"~" file:nil types:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
237 }
238
239 - (void)t2_getNewStreamFromDialog: (NSOpenPanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
240 {
241     if (returnCode == NSOKButton)
242     {
243         [o_t2_fld_pathToNewStrm setStringValue:[sheet filename]];
244         /* FIXME: store path in a global variable */
245     }
246 }
247
248 - (IBAction)t2_chooseStreamOrPlst:(id)sender
249 {
250     /* enable and disable the respective items depending on user's choice */
251     /* TODO */
252 }
253
254 - (IBAction)t2_enableExtract:(id)sender
255 {
256     /* enable/disable the respective items */
257     if([o_t2_ckb_enblPartExtrct state] == NSOnState)
258     {
259         [o_t2_fld_prtExtrctFrom setEnabled:YES];
260         [o_t2_fld_prtExtrctTo setEnabled:YES];
261     } else {
262         [o_t2_fld_prtExtrctFrom setEnabled:NO];
263         [o_t2_fld_prtExtrctTo setEnabled:NO];
264     }
265 }
266
267 - (IBAction)t3_addressEntered:(id)sender
268 {
269     /* check whether the entered address is valid */
270 }
271
272 - (IBAction)t4_AudCdcChanged:(id)sender
273 {
274     /* update codec info */
275 }
276
277 - (IBAction)t4_enblAudTrnscd:(id)sender
278 {
279     /* enable/disable the respective items */
280     if([o_t4_ckb_audio state] == NSOnState)
281     {
282         [o_t4_pop_audioCodec setEnabled:YES];
283         
284         [o_t4_pop_audioBitrate setEnabled:YES];
285     } else {
286         [o_t4_pop_audioCodec setEnabled:NO];
287         [o_t4_pop_audioBitrate setEnabled:NO];
288     }
289 }
290
291 - (IBAction)t4_enblVidTrnscd:(id)sender
292 {
293     /* enable/disable the respective items */
294     if([o_t4_ckb_video state] == NSOnState)
295     {
296         [o_t4_pop_videoCodec setEnabled:YES];
297         [o_t4_pop_videoBitrate setEnabled:YES];
298     } else {
299         [o_t4_pop_videoCodec setEnabled:NO];
300         [o_t4_pop_videoBitrate setEnabled:NO];
301     }
302 }
303
304 - (IBAction)t4_VidCdcChanged:(id)sender
305 {
306     /* update codec info */
307 }
308
309 - (IBAction)t6_enblSapAnnce:(id)sender
310 {
311     /* enable/disable input fld */
312     if([o_t6_ckb_sap state] == NSOnState)
313     {
314         [o_t6_fld_sap setEnabled:YES];
315     } else {
316         [o_t6_fld_sap setEnabled:NO];
317         [o_t6_fld_sap setStringValue:@""];
318     }
319 }
320
321 - (IBAction)t6_mrInfo_ttl:(id)sender
322 {
323     /* show a sheet for the help */
324         [o_wh_txt_title setStringValue: _NS("Time-To-Live (TTL)")];
325         [o_wh_txt_text setStringValue: _NS("Define the TTL (Time-To-Live) of the stream. "\
326                         "This parameter is the maximum number of routers your stream can go "
327                         "through. If you don't know what it means, or if you want to stream on " \
328                         "your local network only, leave this setting to 1.")];
329         [NSApp beginSheet: o_wizardhelp_window
330             modalForWindow: o_wizard_window
331             modalDelegate: o_wizardhelp_window
332             didEndSelector: nil
333             contextInfo: nil];
334 }
335
336 - (IBAction)t6_mrInfo_sap:(id)sender
337 {
338     /* show a sheet for the help */
339         [o_wh_txt_title setStringValue: _NS("SAP Announce")];
340         [o_wh_txt_text setStringValue: _NS("When streaming using UDP, you can " \
341                 "announce your streams using the SAP/SDP announcing protocol. This " \
342                 "way, the clients won't have to type in the multicast address, it " \
343                 "will appear in their playlist if they enable the SAP extra interface.\n" \
344                 "If you want to give a name to your stream, enter it here, " \
345                 "else, a default name will be used.")];
346         [NSApp beginSheet: o_wizardhelp_window
347             modalForWindow: o_wizard_window
348             modalDelegate: o_wizardhelp_window
349             didEndSelector: nil
350             contextInfo: nil];
351 }
352
353 - (IBAction)t7_selectTrnscdDestFile:(id)sender
354 {
355     /* provide a save-to-dialogue, so the user can choose a location for his/her new file */
356     NSSavePanel * savePanel = [NSSavePanel savePanel];
357     SEL sel = @selector(t7_getTrnscdDestFile:returnCode:contextInfo:);
358     [savePanel beginSheetForDirectory:@"~" file:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
359     /* FIXME: insert a suffix in file depending on the chosen encap-format */
360 }
361
362 - (void)t7_getTrnscdDestFile: (NSSavePanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
363 {
364     if (returnCode == NSOKButton)
365     {
366         [o_t7_fld_filePath setStringValue:[sheet filename]];
367         /* FIXME: store path in a global variable and add a suffix depending on the chosen encap-format, if needed */
368     }
369 }
370
371 - (IBAction)wh_closeSheet:(id)sender
372 {
373         /* close the help sheet */
374         [NSApp endSheet:o_wizardhelp_window];
375         [o_wizardhelp_window close];
376 }
377
378 @end