1 /*****************************************************************************
2 * MainMenu.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2011-2012 Felix Paul Kühne
7 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 #import <vlc_common.h>
26 #import <vlc_playlist.h>
32 #import "AudioEffects.h"
33 #import "TrackSynchronization.h"
34 #import "VideoEffects.h"
36 #import "simple_prefs.h"
37 #import "coredialogs.h"
40 #import "playlistinfo.h"
42 #import "CoreInteraction.h"
43 #import "MainWindow.h"
44 #import "ExtensionsManager.h"
45 #import "ConvertAndSave.h"
47 @implementation VLCMainMenu
48 static VLCMainMenu *_o_sharedInstance = nil;
50 + (VLCMainMenu *)sharedInstance
52 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
56 #pragma mark Initialization
60 if( _o_sharedInstance)
63 return _o_sharedInstance;
67 _o_sharedInstance = [super init];
70 return _o_sharedInstance;
75 [[NSNotificationCenter defaultCenter] removeObserver: self];
77 if (b_nib_about_loaded)
80 if (b_nib_videoeffects_loaded)
81 [o_videoeffects release];
83 if (b_nib_audioeffects_loaded)
84 [o_audioeffects release];
86 if (b_nib_tracksynchro_loaded)
87 [o_trackSynchronization release];
89 if (b_nib_convertandsave_loaded)
90 [o_convertandsave release];
99 [[NSNotificationCenter defaultCenter] addObserver: self
100 selector: @selector(applicationWillFinishLaunching:)
101 name: NSApplicationWillFinishLaunchingNotification
105 - (void)applicationWillFinishLaunching:(NSNotification *)o_notification
110 playlist_t *p_playlist;
112 id o_vlcmain = [VLCMain sharedInstance];
115 /* Check if we already did this once. Opening the other nibs calls it too,
116 because VLCMain is the owner */
117 if( b_mainMenu_setup ) return;
119 /* Get ExtensionsManager */
120 o_extMgr = [ExtensionsManager getInstance:p_intf];
125 key = config_GetPsz( p_intf, "key-quit" );
126 o_key = [NSString stringWithFormat:@"%s", key];
127 [o_mi_quit setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
128 [o_mi_quit setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
131 key = config_GetPsz( p_intf, "key-play-pause" );
132 o_key = [NSString stringWithFormat:@"%s", key];
133 [o_mi_play setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
134 [o_mi_play setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
137 key = config_GetPsz( p_intf, "key-stop" );
138 o_key = [NSString stringWithFormat:@"%s", key];
139 [o_mi_stop setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
140 [o_mi_stop setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
143 key = config_GetPsz( p_intf, "key-prev" );
144 o_key = [NSString stringWithFormat:@"%s", key];
145 [o_mi_previous setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
146 [o_mi_previous setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
149 key = config_GetPsz( p_intf, "key-next" );
150 o_key = [NSString stringWithFormat:@"%s", key];
151 [o_mi_next setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
152 [o_mi_next setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
155 key = config_GetPsz( p_intf, "key-jump+short" );
156 o_key = [NSString stringWithFormat:@"%s", key];
157 [o_mi_fwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
158 [o_mi_fwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
161 key = config_GetPsz( p_intf, "key-jump-short" );
162 o_key = [NSString stringWithFormat:@"%s", key];
163 [o_mi_bwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
164 [o_mi_bwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
167 key = config_GetPsz( p_intf, "key-vol-up" );
168 o_key = [NSString stringWithFormat:@"%s", key];
169 [o_mi_vol_up setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
170 [o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
173 key = config_GetPsz( p_intf, "key-vol-down" );
174 o_key = [NSString stringWithFormat:@"%s", key];
175 [o_mi_vol_down setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
176 [o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
179 key = config_GetPsz( p_intf, "key-vol-mute" );
180 o_key = [NSString stringWithFormat:@"%s", key];
181 [o_mi_mute setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
182 [o_mi_mute setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
185 key = config_GetPsz( p_intf, "key-toggle-fullscreen" );
186 o_key = [NSString stringWithFormat:@"%s", key];
187 [o_mi_fullscreen setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
188 [o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
191 key = config_GetPsz( p_intf, "key-snapshot" );
192 o_key = [NSString stringWithFormat:@"%s", key];
193 [o_mi_snapshot setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
194 [o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
197 key = config_GetPsz( p_intf, "key-random" );
198 o_key = [NSString stringWithFormat:@"%s", key];
199 [o_mi_random setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
200 [o_mi_random setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
203 key = config_GetPsz( p_intf, "key-zoom-half" );
204 o_key = [NSString stringWithFormat:@"%s", key];
205 [o_mi_half_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
206 [o_mi_half_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
209 key = config_GetPsz( p_intf, "key-zoom-original" );
210 o_key = [NSString stringWithFormat:@"%s", key];
211 [o_mi_normal_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
212 [o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
215 key = config_GetPsz( p_intf, "key-zoom-double" );
216 o_key = [NSString stringWithFormat:@"%s", key];
217 [o_mi_double_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
218 [o_mi_double_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
221 [self setSubmenusEnabled: FALSE];
223 [[NSNotificationCenter defaultCenter] addObserver: self
224 selector: @selector(refreshVoutDeviceMenu:)
225 name: NSApplicationDidChangeScreenParametersNotification
229 b_mainMenu_setup = YES;
231 [self setupVarMenuItem: o_mi_add_intf target: (vlc_object_t *)p_intf
232 var: "intf-add" selector: @selector(toggleVar:)];
234 [self setupExtensionsMenu];
240 [o_mi_about setTitle: [_NS("About VLC media player") \
241 stringByAppendingString: @"..."]];
242 [o_mi_checkForUpdate setTitle: _NS("Check for Update...")];
243 [o_mi_prefs setTitle: _NS("Preferences...")];
244 [o_mi_extensions setTitle: _NS("Extensions")];
245 [o_mu_extensions setTitle: _NS("Extensions")];
246 [o_mi_add_intf setTitle: _NS("Add Interface")];
247 [o_mu_add_intf setTitle: _NS("Add Interface")];
248 [o_mi_services setTitle: _NS("Services")];
249 [o_mi_hide setTitle: _NS("Hide VLC")];
250 [o_mi_hide_others setTitle: _NS("Hide Others")];
251 [o_mi_show_all setTitle: _NS("Show All")];
252 [o_mi_quit setTitle: _NS("Quit VLC")];
254 [o_mu_file setTitle: _ANS("1:File")];
255 [o_mi_open_generic setTitle: _NS("Advanced Open File...")];
256 [o_mi_open_file setTitle: _NS("Open File...")];
257 [o_mi_open_disc setTitle: _NS("Open Disc...")];
258 [o_mi_open_net setTitle: _NS("Open Network...")];
259 [o_mi_open_capture setTitle: _NS("Open Capture Device...")];
260 [o_mi_open_recent setTitle: _NS("Open Recent")];
261 [o_mi_open_wizard setTitle: _NS("Streaming/Exporting Wizard...")];
262 [o_mi_convertandsave setTitle: _NS("Convert / Save...")];
264 [o_mu_edit setTitle: _NS("Edit")];
265 [o_mi_cut setTitle: _NS("Cut")];
266 [o_mi_copy setTitle: _NS("Copy")];
267 [o_mi_paste setTitle: _NS("Paste")];
268 [o_mi_clear setTitle: _NS("Clear")];
269 [o_mi_select_all setTitle: _NS("Select All")];
271 [o_mu_controls setTitle: _NS("Playback")];
272 [o_mi_play setTitle: _NS("Play")];
273 [o_mi_stop setTitle: _NS("Stop")];
274 [o_mi_record setTitle: _NS("Record")];
275 [o_mi_rate setView: o_mi_rate_view];
276 [o_mi_rate_lbl setStringValue: _NS("Playback Speed")];
277 [o_mi_rate_lbl_gray setStringValue: _NS("Playback Speed")];
278 [o_mi_rate_slower_lbl setStringValue: _NS("Slower")];
279 [o_mi_rate_normal_lbl setStringValue: _NS("Normal")];
280 [o_mi_rate_faster_lbl setStringValue: _NS("Faster")];
281 [o_mi_trackSynchronization setTitle: _NS("Track Synchronization")];
282 [o_mi_previous setTitle: _NS("Previous")];
283 [o_mi_next setTitle: _NS("Next")];
284 [o_mi_random setTitle: _NS("Random")];
285 [o_mi_repeat setTitle: _NS("Repeat One")];
286 [o_mi_loop setTitle: _NS("Repeat All")];
287 [o_mi_quitAfterPB setTitle: _NS("Quit after Playback")];
288 [o_mi_fwd setTitle: _NS("Step Forward")];
289 [o_mi_bwd setTitle: _NS("Step Backward")];
290 [o_mi_toggleJumpButtons setTitle: _NS("Show Previous & Next Buttons")];
291 [o_mi_toggleJumpButtons setState: config_GetInt( VLCIntf, "macosx-show-playback-buttons")];
292 [o_mi_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")];
293 [o_mi_togglePlaymodeButtons setState: config_GetInt( VLCIntf, "macosx-show-playmode-buttons")];
294 [o_mu_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
295 [o_mi_ptc_tracknum setTitle: _NS("Track Number")];
296 [o_mi_ptc_title setTitle: _NS("Title")];
297 [o_mi_ptc_artist setTitle: _NS("Artist")];
298 [o_mi_ptc_duration setTitle: _NS("Duration")];
299 [o_mi_ptc_genre setTitle: _NS("Genre")];
300 [o_mi_ptc_album setTitle: _NS("Album")];
301 [o_mi_ptc_description setTitle: _NS("Description")];
302 [o_mi_ptc_date setTitle: _NS("Date")];
303 [o_mi_ptc_language setTitle: _NS("Language")];
304 [o_mi_ptc_uri setTitle: _NS("URI")];
306 [o_mi_program setTitle: _NS("Program")];
307 [o_mu_program setTitle: _NS("Program")];
308 [o_mi_title setTitle: _NS("Title")];
309 [o_mu_title setTitle: _NS("Title")];
310 [o_mi_chapter setTitle: _NS("Chapter")];
311 [o_mu_chapter setTitle: _NS("Chapter")];
313 [o_mu_audio setTitle: _NS("Audio")];
314 [o_mi_vol_up setTitle: _NS("Increase Volume")];
315 [o_mi_vol_down setTitle: _NS("Decrease Volume")];
316 [o_mi_mute setTitle: _NS("Mute")];
317 [o_mi_audiotrack setTitle: _NS("Audio Track")];
318 [o_mu_audiotrack setTitle: _NS("Audio Track")];
319 [o_mi_channels setTitle: _NS("Audio Channels")];
320 [o_mu_channels setTitle: _NS("Audio Channels")];
321 [o_mi_device setTitle: _NS("Audio Device")];
322 [o_mu_device setTitle: _NS("Audio Device")];
323 [o_mi_visual setTitle: _NS("Visualizations")];
324 [o_mu_visual setTitle: _NS("Visualizations")];
326 [o_mu_video setTitle: _NS("Video")];
327 [o_mi_half_window setTitle: _NS("Half Size")];
328 [o_mi_normal_window setTitle: _NS("Normal Size")];
329 [o_mi_double_window setTitle: _NS("Double Size")];
330 [o_mi_fittoscreen setTitle: _NS("Fit to Screen")];
331 [o_mi_fullscreen setTitle: _NS("Fullscreen")];
332 [o_mi_floatontop setTitle: _NS("Float on Top")];
333 [o_mi_snapshot setTitle: _NS("Snapshot")];
334 [o_mi_videotrack setTitle: _NS("Video Track")];
335 [o_mu_videotrack setTitle: _NS("Video Track")];
336 [o_mi_aspect_ratio setTitle: _NS("Aspect-ratio")];
337 [o_mu_aspect_ratio setTitle: _NS("Aspect-ratio")];
338 [o_mi_crop setTitle: _NS("Crop")];
339 [o_mu_crop setTitle: _NS("Crop")];
340 [o_mi_screen setTitle: _NS("Fullscreen Video Device")];
341 [o_mu_screen setTitle: _NS("Fullscreen Video Device")];
342 [o_mi_subtitle setTitle: _NS("Subtitles Track")];
343 [o_mu_subtitle setTitle: _NS("Subtitles Track")];
344 [o_mi_addSub setTitle: _NS("Open File...")];
345 [o_mi_deinterlace setTitle: _NS("Deinterlace")];
346 [o_mu_deinterlace setTitle: _NS("Deinterlace")];
347 [o_mi_deinterlace_mode setTitle: _NS("Deinterlace mode")];
348 [o_mu_deinterlace_mode setTitle: _NS("Deinterlace mode")];
349 [o_mi_ffmpeg_pp setTitle: _NS("Post processing")];
350 [o_mu_ffmpeg_pp setTitle: _NS("Post processing")];
351 [o_mi_teletext setTitle: _NS("Teletext")];
352 [o_mi_teletext_transparent setTitle: _NS("Transparent")];
353 [o_mi_teletext_index setTitle: _NS("Index")];
354 [o_mi_teletext_red setTitle: _NS("Red")];
355 [o_mi_teletext_green setTitle: _NS("Green")];
356 [o_mi_teletext_yellow setTitle: _NS("Yellow")];
357 [o_mi_teletext_blue setTitle: _NS("Blue")];
359 [o_mu_window setTitle: _NS("Window")];
360 [o_mi_minimize setTitle: _NS("Minimize Window")];
361 [o_mi_close_window setTitle: _NS("Close Window")];
362 [o_mi_player setTitle: _NS("Player...")];
363 [o_mi_controller setTitle: _NS("Main Window...")];
364 [o_mi_audioeffects setTitle: _NS("Audio Effects...")];
365 [o_mi_videoeffects setTitle: _NS("Video Filters...")];
366 [o_mi_bookmarks setTitle: _NS("Bookmarks...")];
367 [o_mi_playlist setTitle: _NS("Playlist...")];
368 [o_mi_info setTitle: _NS("Media Information...")];
369 [o_mi_messages setTitle: _NS("Messages...")];
370 [o_mi_errorsAndWarnings setTitle: _NS("Errors and Warnings...")];
372 [o_mi_bring_atf setTitle: _NS("Bring All to Front")];
374 [o_mu_help setTitle: _NS("Help")];
375 [o_mi_help setTitle: _NS("VLC media player Help...")];
376 [o_mi_readme setTitle: _NS("ReadMe / FAQ...")];
377 [o_mi_license setTitle: _NS("License")];
378 [o_mi_documentation setTitle: _NS("Online Documentation...")];
379 [o_mi_website setTitle: _NS("VideoLAN Website...")];
380 [o_mi_donation setTitle: _NS("Make a donation...")];
381 [o_mi_forum setTitle: _NS("Online Forum...")];
384 [o_dmi_play setTitle: _NS("Play")];
385 [o_dmi_stop setTitle: _NS("Stop")];
386 [o_dmi_next setTitle: _NS("Next")];
387 [o_dmi_previous setTitle: _NS("Previous")];
388 [o_dmi_mute setTitle: _NS("Mute")];
391 [o_vmi_play setTitle: _NS("Play")];
392 [o_vmi_stop setTitle: _NS("Stop")];
393 [o_vmi_prev setTitle: _NS("Previous")];
394 [o_vmi_next setTitle: _NS("Next")];
395 [o_vmi_volup setTitle: _NS("Volume Up")];
396 [o_vmi_voldown setTitle: _NS("Volume Down")];
397 [o_vmi_mute setTitle: _NS("Mute")];
398 [o_vmi_fullscreen setTitle: _NS("Fullscreen")];
399 [o_vmi_snapshot setTitle: _NS("Snapshot")];
403 #pragma mark Termination
405 - (void)releaseRepresentedObjects:(NSMenu *)the_menu
407 if( !p_intf ) return;
409 NSArray *menuitems_array = [the_menu itemArray];
410 NSUInteger menuItemCount = [menuitems_array count];
411 for( NSUInteger i=0; i < menuItemCount; i++ )
413 NSMenuItem *one_item = [menuitems_array objectAtIndex: i];
414 if( [one_item hasSubmenu] )
415 [self releaseRepresentedObjects: [one_item submenu]];
417 [one_item setRepresentedObject:NULL];
422 #pragma mark Interface update
426 playlist_t * p_playlist = pl_Get( p_intf );
427 input_thread_t * p_input = playlist_CurrentInput( p_playlist );
428 if( p_input != NULL )
430 [o_mi_record setEnabled: var_GetBool( p_input, "can-record" )];
432 [self setupVarMenuItem: o_mi_program target: (vlc_object_t *)p_input
433 var: "program" selector: @selector(toggleVar:)];
435 [self setupVarMenuItem: o_mi_title target: (vlc_object_t *)p_input
436 var: "title" selector: @selector(toggleVar:)];
438 [self setupVarMenuItem: o_mi_chapter target: (vlc_object_t *)p_input
439 var: "chapter" selector: @selector(toggleVar:)];
441 [self setupVarMenuItem: o_mi_audiotrack target: (vlc_object_t *)p_input
442 var: "audio-es" selector: @selector(toggleVar:)];
444 [self setupVarMenuItem: o_mi_videotrack target: (vlc_object_t *)p_input
445 var: "video-es" selector: @selector(toggleVar:)];
447 [self setupVarMenuItem: o_mi_subtitle target: (vlc_object_t *)p_input
448 var: "spu-es" selector: @selector(toggleVar:)];
450 /* special case for "Open File" inside the subtitles menu item */
451 if( [o_mi_videotrack isEnabled] == YES )
452 [o_mi_subtitle setEnabled: YES];
454 audio_output_t * p_aout = input_GetAout( p_input );
457 [self setupVarMenuItem: o_mi_channels target: (vlc_object_t *)p_aout
458 var: "audio-channels" selector: @selector(toggleVar:)];
460 [self setupVarMenuItem: o_mi_device target: (vlc_object_t *)p_aout
461 var: "audio-device" selector: @selector(toggleVar:)];
463 [self setupVarMenuItem: o_mi_visual target: (vlc_object_t *)p_aout
464 var: "visual" selector: @selector(toggleVar:)];
465 vlc_object_release( p_aout );
468 vout_thread_t * p_vout = input_GetVout( p_input );
472 [self setupVarMenuItem: o_mi_aspect_ratio target: (vlc_object_t *)p_vout
473 var: "aspect-ratio" selector: @selector(toggleVar:)];
475 [self setupVarMenuItem: o_mi_crop target: (vlc_object_t *) p_vout
476 var: "crop" selector: @selector(toggleVar:)];
478 [self setupVarMenuItem: o_mi_deinterlace target: (vlc_object_t *)p_vout
479 var: "deinterlace" selector: @selector(toggleVar:)];
481 [self setupVarMenuItem: o_mi_deinterlace_mode target: (vlc_object_t *)p_vout
482 var: "deinterlace-mode" selector: @selector(toggleVar:)];
485 [self setupVarMenuItem: o_mi_ffmpeg_pp target:
486 (vlc_object_t *)p_vout var:"postprocess" selector:
487 @selector(toggleVar:)];
489 vlc_object_release( p_vout );
491 [self refreshVoutDeviceMenu:nil];
493 vlc_object_release( p_input );
497 [o_mi_record setEnabled: NO];
501 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification
503 NSUInteger count = [o_mu_screen numberOfItems];
504 NSMenu * o_submenu = o_mu_screen;
509 NSUInteger count = [o_submenu numberOfItems];
510 for( NSUInteger i = 0; i < count; i++ )
511 [o_submenu removeItemAtIndex: 0];
514 [o_submenu removeAllItems];
517 NSArray * o_screens = [NSScreen screens];
518 NSMenuItem * o_mitem;
519 count = [o_screens count];
520 [o_mi_screen setEnabled: YES];
521 [o_submenu addItemWithTitle: _NS("Default") action:@selector(toggleFullscreenDevice:) keyEquivalent:@""];
522 o_mitem = [o_submenu itemAtIndex: 0];
524 [o_mitem setEnabled: YES];
525 [o_mitem setTarget: self];
527 for (NSUInteger i = 0; i < count; i++)
529 s_rect = [[o_screens objectAtIndex: i] frame];
530 [o_submenu addItemWithTitle: [NSString stringWithFormat: @"%@ %li (%ix%i)", _NS("Screen"), i+1,
531 (int)s_rect.size.width, (int)s_rect.size.height] action:@selector(toggleFullscreenDevice:) keyEquivalent:@""];
532 o_mitem = [o_submenu itemAtIndex:i+1];
533 [o_mitem setTag: (int)[[o_screens objectAtIndex: i] displayID]];
534 [o_mitem setEnabled: YES];
535 [o_mitem setTarget: self];
537 [[o_submenu itemWithTag: config_GetInt( VLCIntf, "macosx-vdev" )] setState: NSOnState];
540 - (void)setSubmenusEnabled:(BOOL)b_enabled
542 [o_mi_program setEnabled: b_enabled];
543 [o_mi_title setEnabled: b_enabled];
544 [o_mi_chapter setEnabled: b_enabled];
545 [o_mi_audiotrack setEnabled: b_enabled];
546 [o_mi_visual setEnabled: b_enabled];
547 [o_mi_videotrack setEnabled: b_enabled];
548 [o_mi_subtitle setEnabled: b_enabled];
549 [o_mi_channels setEnabled: b_enabled];
550 [o_mi_deinterlace setEnabled: b_enabled];
551 [o_mi_deinterlace_mode setEnabled: b_enabled];
552 [o_mi_ffmpeg_pp setEnabled: b_enabled];
553 [o_mi_device setEnabled: b_enabled];
554 [o_mi_screen setEnabled: b_enabled];
555 [o_mi_aspect_ratio setEnabled: b_enabled];
556 [o_mi_crop setEnabled: b_enabled];
557 [o_mi_teletext setEnabled: b_enabled];
560 - (void)setRateControlsEnabled:(BOOL)b_enabled
562 NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
563 [o_mi_rate_sld setEnabled: b_enabled];
564 [o_mi_rate_sld setIntValue: [[VLCCoreInteraction sharedInstance] playbackRate]];
565 int i = [[VLCCoreInteraction sharedInstance] playbackRate];
566 double speed = pow( 2, (double)i / 17 );
567 [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
569 [o_mi_rate_lbl setHidden: NO];
570 [o_mi_rate_lbl_gray setHidden: YES];
574 [o_mi_rate_lbl setHidden: YES];
575 [o_mi_rate_lbl_gray setHidden: NO];
581 #pragma mark Extensions
583 - (void)setupExtensionsMenu
585 /* Load extensions if needed */
586 // TODO: Implement preference for autoloading extensions on mac
588 // if( !var_InheritBool( p_intf, "qt-autoload-extensions")
589 // && ![o_extMgr isLoaded] )
594 if( ![o_extMgr isLoaded] && ![o_extMgr cannotLoad] )
596 [o_extMgr loadExtensions];
599 /* Let the ExtensionsManager itself build the menu */
600 [o_extMgr buildMenu:o_mu_extensions];
601 [o_mi_extensions setEnabled: ( [o_mu_extensions numberOfItems] > 0 )];
605 #pragma mark Playback
606 - (IBAction)toggleRecord:(id)sender
608 [[VLCCoreInteraction sharedInstance] toggleRecord];
611 - (void)updateRecordState:(BOOL)b_value
613 [o_mi_record setState:b_value];
616 - (IBAction)setPlaybackRate:(id)sender
618 [[VLCCoreInteraction sharedInstance] setPlaybackRate: [o_mi_rate_sld intValue]];
619 int i = [[VLCCoreInteraction sharedInstance] playbackRate];
620 double speed = pow( 2, (double)i / 17 );
621 [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
624 - (void)updatePlaybackRate
626 int i = [[VLCCoreInteraction sharedInstance] playbackRate];
627 double speed = pow( 2, (double)i / 17 );
628 [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
629 [o_mi_rate_sld setIntValue: i];
632 - (IBAction)toggleJumpButtons:(id)sender
634 BOOL b_value = !config_GetInt( VLCIntf, "macosx-show-playback-buttons" );
635 config_PutInt( VLCIntf, "macosx-show-playback-buttons", b_value );
636 [[[VLCMain sharedInstance] mainWindow] toggleJumpButtons];
637 [o_mi_toggleJumpButtons setState: b_value];
640 - (IBAction)togglePlaymodeButtons:(id)sender
642 BOOL b_value = !config_GetInt( VLCIntf, "macosx-show-playmode-buttons" );
643 config_PutInt( VLCIntf, "macosx-show-playmode-buttons", b_value );
644 [[[VLCMain sharedInstance] mainWindow] togglePlaymodeButtons];
645 [o_mi_togglePlaymodeButtons setState: b_value];
648 - (IBAction)togglePlaylistColumnTable:(id)sender
650 [sender setState: ![sender state]];
654 if (sender == o_mi_ptc_tracknum)
655 o_column = TRACKNUM_COLUMN;
656 else if (sender == o_mi_ptc_title)
657 o_column = TITLE_COLUMN;
658 else if (sender == o_mi_ptc_artist)
659 o_column = ARTIST_COLUMN;
660 else if (sender == o_mi_ptc_duration)
661 o_column = DURATION_COLUMN;
662 else if (sender == o_mi_ptc_genre)
663 o_column = GENRE_COLUMN;
664 else if (sender == o_mi_ptc_album)
665 o_column = ALBUM_COLUMN;
666 else if (sender == o_mi_ptc_description)
667 o_column = DESCRIPTION_COLUMN;
668 else if (sender == o_mi_ptc_date)
669 o_column = DATE_COLUMN;
670 else if (sender == o_mi_ptc_language)
671 o_column = LANGUAGE_COLUMN;
672 else if (sender == o_mi_ptc_uri)
673 o_column = URI_COLUMN;
675 [[[VLCMain sharedInstance] playlist] setColumn: o_column state: [sender state]];
678 - (void)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column
680 if ([o_column isEqualToString: TRACKNUM_COLUMN])
681 [o_mi_ptc_tracknum setState: i_state];
682 else if ([o_column isEqualToString: TITLE_COLUMN])
683 [o_mi_ptc_title setState: i_state];
684 else if ([o_column isEqualToString: ARTIST_COLUMN])
685 [o_mi_ptc_artist setState: i_state];
686 else if ([o_column isEqualToString: DURATION_COLUMN])
687 [o_mi_ptc_duration setState: i_state];
688 else if ([o_column isEqualToString: GENRE_COLUMN])
689 [o_mi_ptc_genre setState: i_state];
690 else if ([o_column isEqualToString: ALBUM_COLUMN])
691 [o_mi_ptc_album setState: i_state];
692 else if ([o_column isEqualToString: DESCRIPTION_COLUMN])
693 [o_mi_ptc_description setState: i_state];
694 else if ([o_column isEqualToString: DATE_COLUMN])
695 [o_mi_ptc_date setState: i_state];
696 else if ([o_column isEqualToString: LANGUAGE_COLUMN])
697 [o_mi_ptc_language setState: i_state];
698 else if ([o_column isEqualToString: URI_COLUMN])
699 [o_mi_ptc_uri setState: i_state];
703 #pragma mark video menu
704 - (IBAction)toggleFullscreen:(id)sender
706 [[VLCCoreInteraction sharedInstance] toggleFullscreen];
709 - (IBAction)resizeVideoWindow:(id)sender
711 input_thread_t *p_input = pl_CurrentInput( VLCIntf );
714 vout_thread_t *p_vout = getVout();
717 if (sender == o_mi_half_window)
718 var_SetFloat( p_vout, "zoom", 0.5 );
719 else if (sender == o_mi_normal_window)
720 var_SetFloat( p_vout, "zoom", 1.0 );
721 else if (sender == o_mi_double_window)
722 var_SetFloat( p_vout, "zoom", 2.0 );
725 [[[[[VLCMain sharedInstance] mainWindow] videoView] window] performZoom:sender];
727 vlc_object_release( p_vout );
729 vlc_object_release( p_input );
733 - (IBAction)floatOnTop:(id)sender
735 input_thread_t *p_input = pl_CurrentInput( VLCIntf );
738 vout_thread_t *p_vout = getVout();
741 var_ToggleBool( p_vout, "video-on-top" );
742 vlc_object_release( p_vout );
744 vlc_object_release( p_input );
748 - (IBAction)createVideoSnapshot:(id)sender
750 input_thread_t *p_input = pl_CurrentInput( VLCIntf );
753 vout_thread_t *p_vout = getVout();
756 var_TriggerCallback( p_vout, "video-snapshot" );
757 vlc_object_release( p_vout );
759 vlc_object_release( p_input );
763 - (IBAction)toggleFullscreenDevice:(id)sender
765 config_PutInt( VLCIntf, "macosx-vdev", [sender tag] );
766 [self refreshVoutDeviceMenu: nil];
777 - (IBAction)intfOpenFile:(id)sender
779 [[[VLCMain sharedInstance] open] openFile];
782 - (IBAction)intfOpenFileGeneric:(id)sender
784 [[[VLCMain sharedInstance] open] openFileGeneric];
787 - (IBAction)intfOpenDisc:(id)sender
789 [[[VLCMain sharedInstance] open] openDisc];
792 - (IBAction)intfOpenNet:(id)sender
794 [[[VLCMain sharedInstance] open] openNet];
797 - (IBAction)intfOpenCapture:(id)sender
799 [[[VLCMain sharedInstance] open] openCapture];
802 - (IBAction)showWizard:(id)sender
804 [[[VLCMain sharedInstance] wizard] resetWizard];
805 [[[VLCMain sharedInstance] wizard] showWizard];
808 - (IBAction)showConvertAndSave:(id)sender
810 if( o_convertandsave == nil )
811 o_convertandsave = [[VLCConvertAndSave alloc] init];
813 if( !b_nib_convertandsave_loaded )
814 b_nib_convertandsave_loaded = [NSBundle loadNibNamed:@"ConvertAndSave" owner: NSApp];
816 [o_convertandsave toggleWindow];
819 - (IBAction)showVideoEffects:(id)sender
821 if( o_videoeffects == nil )
822 o_videoeffects = [[VLCVideoEffects alloc] init];
824 if( !b_nib_videoeffects_loaded )
825 b_nib_videoeffects_loaded = [NSBundle loadNibNamed:@"VideoEffects" owner: NSApp];
827 [o_videoeffects toggleWindow:sender];
830 - (IBAction)showTrackSynchronization:(id)sender
832 if (!o_trackSynchronization)
833 o_trackSynchronization = [[VLCTrackSynchronization alloc] init];
835 if (!b_nib_tracksynchro_loaded)
836 b_nib_tracksynchro_loaded = [NSBundle loadNibNamed:@"SyncTracks" owner:NSApp];
838 [o_trackSynchronization toggleWindow:sender];
841 - (IBAction)showAudioEffects:(id)sender
844 o_audioeffects = [[VLCAudioEffects alloc] init];
846 if (!b_nib_audioeffects_loaded)
847 b_nib_audioeffects_loaded = [NSBundle loadNibNamed:@"AudioEffects" owner:NSApp];
849 [o_audioeffects toggleWindow:sender];
852 - (IBAction)showBookmarks:(id)sender
854 [[[VLCMain sharedInstance] bookmarks] showBookmarks];
857 - (IBAction)viewPreferences:(id)sender
859 NSInteger i_level = NSNormalWindowLevel;
860 NSInteger i_video_window_level = [[[[VLCMainWindow sharedInstance] videoView] window] level];
861 if( i_video_window_level == NSStatusWindowLevel )
862 i_level = NSStatusWindowLevel;
863 [[[VLCMain sharedInstance] simplePreferences] showSimplePrefsWithLevel:i_level];
867 #pragma mark Help and Docs
872 o_about = [[VLAboutBox alloc] init];
874 if( !b_nib_about_loaded )
875 b_nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp];
878 - (IBAction)viewAbout:(id)sender
884 - (IBAction)showLicense:(id)sender
887 [o_about showGPL: sender];
890 - (IBAction)viewHelp:(id)sender
896 - (IBAction)openReadMe:(id)sender
898 NSString * o_path = [[NSBundle mainBundle] pathForResource: @"README.MacOSX" ofType: @"rtf"];
900 [[NSWorkspace sharedWorkspace] openFile: o_path withApplication: @"TextEdit"];
903 - (IBAction)openDocumentation:(id)sender
905 NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/doc/"];
907 [[NSWorkspace sharedWorkspace] openURL: o_url];
910 - (IBAction)openWebsite:(id)sender
912 NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/"];
914 [[NSWorkspace sharedWorkspace] openURL: o_url];
917 - (IBAction)openForum:(id)sender
919 NSURL * o_url = [NSURL URLWithString: @"http://forum.videolan.org/"];
921 [[NSWorkspace sharedWorkspace] openURL: o_url];
924 - (IBAction)openDonate:(id)sender
926 NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/contribute.html#paypal"];
928 [[NSWorkspace sharedWorkspace] openURL: o_url];
932 #pragma mark Errors, warnings and messages
934 - (IBAction)viewErrorsAndWarnings:(id)sender
936 [[[[VLCMain sharedInstance] coreDialogProvider] errorPanel] showPanel];
939 - (IBAction)showInformationPanel:(id)sender
941 [[[VLCMain sharedInstance] info] initPanel];
945 #pragma mark convinience stuff for other objects
948 [o_mi_play setTitle: _NS("Play")];
949 [o_dmi_play setTitle: _NS("Play")];
950 [o_vmi_play setTitle: _NS("Play")];
955 [o_mi_play setTitle: _NS("Pause")];
956 [o_dmi_play setTitle: _NS("Pause")];
957 [o_vmi_play setTitle: _NS("Pause")];
962 [o_mi_repeat setState: NSOnState];
963 [o_mi_loop setState: NSOffState];
968 [o_mi_repeat setState: NSOffState];
969 [o_mi_loop setState: NSOnState];
974 [o_mi_repeat setState: NSOffState];
975 [o_mi_loop setState: NSOffState];
981 playlist_t *p_playlist = pl_Get( VLCIntf );
982 b_value = var_GetBool( p_playlist, "random" );
984 [o_mi_random setState: b_value];
988 #pragma mark Dynamic menu creation and validation
990 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
991 target:(vlc_object_t *)p_object
992 var:(const char *)psz_variable
993 selector:(SEL)pf_callback
995 vlc_value_t val, text;
996 int i_type = var_Type( p_object, psz_variable );
998 switch( i_type & VLC_VAR_TYPE )
1002 case VLC_VAR_VARIABLE:
1003 case VLC_VAR_STRING:
1004 case VLC_VAR_INTEGER:
1007 /* Variable doesn't exist or isn't handled */
1011 /* Get the descriptive name of the variable */
1012 var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
1013 [o_mi setTitle: _NS( text.psz_string ? text.psz_string : psz_variable )];
1015 if( i_type & VLC_VAR_HASCHOICE )
1017 NSMenu *o_menu = [o_mi submenu];
1019 [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
1020 var:psz_variable selector:pf_callback];
1022 free( text.psz_string );
1026 if( var_Get( p_object, psz_variable, &val ) < 0 )
1031 VLCAutoGeneratedMenuContent *o_data;
1032 switch( i_type & VLC_VAR_TYPE )
1035 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1036 andValue: val ofType: i_type];
1037 [o_mi setRepresentedObject: [o_data autorelease]];
1041 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1042 andValue: val ofType: i_type];
1043 [o_mi setRepresentedObject: [o_data autorelease]];
1044 if( !( i_type & VLC_VAR_ISCOMMAND ) )
1045 [o_mi setState: val.b_bool ? TRUE : FALSE ];
1052 if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
1053 free( text.psz_string );
1057 - (void)setupVarMenu:(NSMenu *)o_menu
1058 forMenuItem: (NSMenuItem *)o_parent
1059 target:(vlc_object_t *)p_object
1060 var:(const char *)psz_variable
1061 selector:(SEL)pf_callback
1063 vlc_value_t val, val_list, text_list;
1066 /* remove previous items */
1070 i_nb_items = [o_menu numberOfItems];
1071 for( i = 0; i < i_nb_items; i++ )
1072 [o_menu removeItemAtIndex: 0];
1076 /* this is more efficient then the legacy code, but 10.6+ only */
1077 [o_menu removeAllItems];
1079 /* we disable everything here, and enable it again when needed, below */
1080 [o_parent setEnabled:NO];
1083 if( [[o_parent title] isEqualToString: _NS("Aspect-ratio")] == YES )
1085 NSMenuItem *o_lmi_tmp2;
1086 o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""];
1087 [o_lmi_tmp2 setTarget: [[VLCMain sharedInstance] controls]];
1088 [o_lmi_tmp2 setEnabled: YES];
1089 [o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
1090 [o_parent setEnabled: YES];
1091 [o_menu addItem: [NSMenuItem separatorItem]];
1094 /* special case for the subtitles item */
1095 if( [[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES )
1097 NSMenuItem * o_lmi_tmp;
1098 o_lmi_tmp = [o_menu addItemWithTitle: _NS("Open File...") action: @selector(addSubtitleFile:) keyEquivalent: @""];
1099 [o_lmi_tmp setTarget: [[VLCMain sharedInstance] controls]];
1100 [o_lmi_tmp setEnabled: YES];
1101 [o_parent setEnabled: YES];
1104 /* Check the type of the object variable */
1105 i_type = var_Type( p_object, psz_variable );
1107 /* Make sure we want to display the variable */
1108 if( i_type & VLC_VAR_HASCHOICE )
1110 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
1111 if( val.i_int == 0 )
1113 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
1119 switch( i_type & VLC_VAR_TYPE )
1123 case VLC_VAR_VARIABLE:
1124 case VLC_VAR_STRING:
1125 case VLC_VAR_INTEGER:
1128 /* Variable doesn't exist or isn't handled */
1132 if( var_Get( p_object, psz_variable, &val ) < 0 )
1137 if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
1138 &val_list, &text_list ) < 0 )
1140 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
1144 /* make (un)sensitive */
1145 [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
1147 /* another special case for the subtitles item */
1148 if( [[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES )
1149 [o_menu addItem: [NSMenuItem separatorItem]];
1151 for( i = 0; i < val_list.p_list->i_count; i++ )
1154 NSString *o_title = @"";
1155 VLCAutoGeneratedMenuContent *o_data;
1157 switch( i_type & VLC_VAR_TYPE )
1159 case VLC_VAR_STRING:
1161 o_title = _NS( text_list.p_list->p_values[i].psz_string ? text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string );
1163 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
1164 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1165 andValue: val_list.p_list->p_values[i] ofType: i_type];
1166 [o_lmi setRepresentedObject: [o_data autorelease]];
1167 [o_lmi setTarget: self];
1169 if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
1170 [o_lmi setState: TRUE ];
1174 case VLC_VAR_INTEGER:
1176 o_title = text_list.p_list->p_values[i].psz_string ?
1177 _NS( text_list.p_list->p_values[i].psz_string ) : [NSString stringWithFormat: @"%"PRId64, val_list.p_list->p_values[i].i_int];
1179 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
1180 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1181 andValue: val_list.p_list->p_values[i] ofType: i_type];
1182 [o_lmi setRepresentedObject: [o_data autorelease]];
1183 [o_lmi setTarget: self];
1185 if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
1186 [o_lmi setState: TRUE ];
1194 /* special case for the subtitles sub-menu
1195 * In case that we don't have any subs, we don't want a separator item at the end */
1196 if( [[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES )
1198 if( [o_menu numberOfItems] == 2 )
1199 [o_menu removeItemAtIndex: 1];
1202 /* clean up everything */
1203 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
1204 var_FreeList( &val_list, &text_list );
1207 - (IBAction)toggleVar:(id)sender
1209 NSMenuItem *o_mi = (NSMenuItem *)sender;
1210 VLCAutoGeneratedMenuContent *o_data = [o_mi representedObject];
1211 [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
1212 toTarget: self withObject: o_data];
1217 - (int)toggleVarThread: (id)data
1219 vlc_object_t *p_object;
1220 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
1222 assert([data isKindOfClass:[VLCAutoGeneratedMenuContent class]]);
1223 VLCAutoGeneratedMenuContent *menuContent = (VLCAutoGeneratedMenuContent *)data;
1225 /* Preserve settings across vouts via the playlist object: */
1226 if( !strcmp( [menuContent name], "fullscreen" ) || !strcmp( [menuContent name], "video-on-top" ) )
1227 var_Set( pl_Get( VLCIntf ), [menuContent name] , [menuContent value] );
1229 /* save our audio device across multiple sessions */
1230 if( !strcmp( [menuContent name], "audio-device" ) )
1231 config_PutInt( VLCIntf, "macosx-audio-device", [menuContent value].i_int );
1233 p_object = [menuContent vlcObject];
1235 if( p_object != NULL )
1237 var_Set( p_object, [menuContent name], [menuContent value] );
1238 vlc_object_release( p_object );
1243 return VLC_EGENERIC;
1248 @implementation VLCMainMenu (NSMenuValidation)
1250 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
1252 NSString *o_title = [o_mi title];
1253 BOOL bEnabled = TRUE;
1255 playlist_t * p_playlist = pl_Get( p_intf );
1256 input_thread_t * p_input = playlist_CurrentInput( p_playlist );
1258 if( [o_title isEqualToString: _NS("Stop")] )
1260 if( p_input == NULL )
1264 [self setupMenus]; /* Make sure input menu is up to date */
1266 else if( [o_title isEqualToString: _NS("Previous")] ||
1267 [o_title isEqualToString: _NS("Next")] )
1270 bEnabled = playlist_CurrentSize( p_playlist ) > 1;
1273 else if( [o_title isEqualToString: _NS("Random")] )
1276 var_Get( p_playlist, "random", &val );
1277 i_state = val.b_bool ? NSOnState : NSOffState;
1278 [o_mi setState: i_state];
1280 else if( [o_title isEqualToString: _NS("Repeat One")] )
1283 var_Get( p_playlist, "repeat", &val );
1284 i_state = val.b_bool ? NSOnState : NSOffState;
1285 [o_mi setState: i_state];
1287 else if( [o_title isEqualToString: _NS("Repeat All")] )
1290 var_Get( p_playlist, "loop", &val );
1291 i_state = val.b_bool ? NSOnState : NSOffState;
1292 [o_mi setState: i_state];
1294 else if( [o_title isEqualToString: _NS("Quit after Playback")] )
1297 var_Get( p_playlist, "play-and-exit", &val );
1298 i_state = val.b_bool ? NSOnState : NSOffState;
1299 [o_mi setState: i_state];
1301 else if( [o_title isEqualToString: _NS("Step Forward")] ||
1302 [o_title isEqualToString: _NS("Step Backward")] ||
1303 [o_title isEqualToString: _NS("Jump To Time")])
1305 if( p_input != NULL )
1307 var_Get( p_input, "can-seek", &val);
1308 bEnabled = val.b_bool;
1310 else bEnabled = FALSE;
1312 else if( [o_title isEqualToString: _NS("Mute")] )
1314 [o_mi setState: [[VLCCoreInteraction sharedInstance] isMuted] ? NSOnState : NSOffState];
1315 [self setupMenus]; /* Make sure audio menu is up to date */
1317 else if( [o_title isEqualToString: _NS("Half Size")] ||
1318 [o_title isEqualToString: _NS("Normal Size")] ||
1319 [o_title isEqualToString: _NS("Double Size")] ||
1320 [o_title isEqualToString: _NS("Fit to Screen")] ||
1321 [o_title isEqualToString: _NS("Snapshot")] ||
1322 [o_title isEqualToString: _NS("Fullscreen")] ||
1323 [o_title isEqualToString: _NS("Float on Top")] )
1327 if( p_input != NULL )
1329 vout_thread_t *p_vout = input_GetVout( p_input );
1330 if( p_vout != NULL )
1332 if( [o_title isEqualToString: _NS("Float on Top")] )
1333 [o_mi setState: var_GetBool( p_vout, "video-on-top" )];
1337 vlc_object_release( p_vout );
1340 if( [o_title isEqualToString: _NS("Fullscreen")] )
1342 [o_mi setState: var_GetBool( p_playlist, "fullscreen" )];
1345 [self setupMenus]; /* Make sure video menu is up to date */
1348 /* Special case for telx menu */
1349 if( [o_title isEqualToString: _NS("Normal Size")] )
1351 NSMenuItem *item = [[o_mi menu] itemWithTitle:_NS("Teletext")];
1354 bool b_telx = p_input && var_GetInteger( p_input, "teletext-es" ) >= 0;
1356 [[item submenu] setAutoenablesItems:NO];
1357 for( int k=0; k < [[item submenu] numberOfItems]; k++ )
1359 [[[item submenu] itemAtIndex:k] setEnabled: b_telx];
1363 if( p_input ) vlc_object_release( p_input );
1371 /*****************************************************************************
1372 * VLCAutoGeneratedMenuContent implementation
1373 *****************************************************************************
1374 * Object connected to a playlistitem which remembers the data belonging to
1375 * the variable of the autogenerated menu
1376 *****************************************************************************/
1377 @implementation VLCAutoGeneratedMenuContent
1379 -(id) initWithVariableName:(const char *)name ofObject:(vlc_object_t *)object
1380 andValue:(vlc_value_t)val ofType:(int)type
1382 self = [super init];
1386 _vlc_object = vlc_object_hold( object );
1387 psz_name = strdup( name );
1390 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING )
1391 value.psz_string = strdup( val.psz_string );
1400 vlc_object_release( _vlc_object );
1401 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING )
1402 free( value.psz_string );
1407 - (const char *)name
1412 - (vlc_value_t)value
1417 - (vlc_object_t *)vlcObject
1419 return vlc_object_hold( _vlc_object );