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 "ControlsBar.h"
45 #import "ExtensionsManager.h"
46 #import "ConvertAndSave.h"
48 @implementation VLCMainMenu
49 static VLCMainMenu *_o_sharedInstance = nil;
51 + (VLCMainMenu *)sharedInstance
53 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
57 #pragma mark Initialization
61 if (_o_sharedInstance) {
63 return _o_sharedInstance;
65 _o_sharedInstance = [super init];
67 o_ptc_translation_dict = [NSDictionary dictionaryWithObjectsAndKeys:
68 _NS("Track Number"), TRACKNUM_COLUMN,
69 _NS("Title"), TITLE_COLUMN,
70 _NS("Author"), ARTIST_COLUMN,
71 _NS("Duration"), DURATION_COLUMN,
72 _NS("Genre"), GENRE_COLUMN,
73 _NS("Album"), ALBUM_COLUMN,
74 _NS("Description"), DESCRIPTION_COLUMN,
75 _NS("Date"), DATE_COLUMN,
76 _NS("Language"), LANGUAGE_COLUMN,
77 _NS("URI"), URI_COLUMN,
79 // this array also assigns tags (index) to type of menu item
80 o_ptc_menuorder = [NSArray arrayWithObjects:TRACKNUM_COLUMN, TITLE_COLUMN, ARTIST_COLUMN, DURATION_COLUMN,
81 GENRE_COLUMN, ALBUM_COLUMN, DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN, nil];
84 return _o_sharedInstance;
89 [[NSNotificationCenter defaultCenter] removeObserver: self];
91 if (b_nib_about_loaded)
94 if (b_nib_videoeffects_loaded)
95 [o_videoeffects release];
97 if (b_nib_audioeffects_loaded)
98 [o_audioeffects release];
100 if (b_nib_tracksynchro_loaded)
101 [o_trackSynchronization release];
103 if (b_nib_convertandsave_loaded)
104 [o_convertandsave release];
108 if (o_mu_playlistTableColumnsContextMenu)
109 [o_mu_playlistTableColumnsContextMenu release];
111 [self releaseRepresentedObjects:[NSApp mainMenu]];
118 [[NSNotificationCenter defaultCenter] addObserver: self
119 selector: @selector(applicationWillFinishLaunching:)
120 name: NSApplicationWillFinishLaunchingNotification
123 /* check whether the user runs OSX with a RTL language */
124 NSArray* languages = [NSLocale preferredLanguages];
125 NSString* preferredLanguage = [languages objectAtIndex:0];
127 if ([NSLocale characterDirectionForLanguage:preferredLanguage] == NSLocaleLanguageDirectionRightToLeft) {
128 msg_Dbg(VLCIntf, "adapting interface since '%s' is a RTL language", [preferredLanguage UTF8String]);
129 [o_mi_rate_fld setAlignment: NSLeftTextAlignment];
133 - (void)applicationWillFinishLaunching:(NSNotification *)o_notification
138 playlist_t *p_playlist;
140 id o_vlcstringutility = [VLCStringUtility sharedInstance];
143 /* Check if we already did this once. Opening the other nibs calls it too,
144 because VLCMain is the owner */
145 if (b_mainMenu_setup)
148 /* Get ExtensionsManager */
149 o_extMgr = [ExtensionsManager getInstance:p_intf];
154 key = config_GetPsz(p_intf, "key-quit");
155 o_key = [NSString stringWithFormat:@"%s", key];
156 [o_mi_quit setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
157 [o_mi_quit setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
160 key = config_GetPsz(p_intf, "key-play-pause");
161 o_key = [NSString stringWithFormat:@"%s", key];
162 [o_mi_play setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
163 [o_mi_play setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
166 key = config_GetPsz(p_intf, "key-stop");
167 o_key = [NSString stringWithFormat:@"%s", key];
168 [o_mi_stop setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
169 [o_mi_stop setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
172 key = config_GetPsz(p_intf, "key-prev");
173 o_key = [NSString stringWithFormat:@"%s", key];
174 [o_mi_previous setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
175 [o_mi_previous setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
178 key = config_GetPsz(p_intf, "key-next");
179 o_key = [NSString stringWithFormat:@"%s", key];
180 [o_mi_next setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
181 [o_mi_next setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
184 key = config_GetPsz(p_intf, "key-jump+short");
185 o_key = [NSString stringWithFormat:@"%s", key];
186 [o_mi_fwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
187 [o_mi_fwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
190 key = config_GetPsz(p_intf, "key-jump-short");
191 o_key = [NSString stringWithFormat:@"%s", key];
192 [o_mi_bwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
193 [o_mi_bwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
196 key = config_GetPsz(p_intf, "key-vol-up");
197 o_key = [NSString stringWithFormat:@"%s", key];
198 [o_mi_vol_up setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
199 [o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
202 key = config_GetPsz(p_intf, "key-vol-down");
203 o_key = [NSString stringWithFormat:@"%s", key];
204 [o_mi_vol_down setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
205 [o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
208 key = config_GetPsz(p_intf, "key-vol-mute");
209 o_key = [NSString stringWithFormat:@"%s", key];
210 [o_mi_mute setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
211 [o_mi_mute setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
214 key = config_GetPsz(p_intf, "key-toggle-fullscreen");
215 o_key = [NSString stringWithFormat:@"%s", key];
216 [o_mi_fullscreen setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
217 [o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
220 key = config_GetPsz(p_intf, "key-snapshot");
221 o_key = [NSString stringWithFormat:@"%s", key];
222 [o_mi_snapshot setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
223 [o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
226 key = config_GetPsz(p_intf, "key-random");
227 o_key = [NSString stringWithFormat:@"%s", key];
228 [o_mi_random setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
229 [o_mi_random setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
232 key = config_GetPsz(p_intf, "key-zoom-half");
233 o_key = [NSString stringWithFormat:@"%s", key];
234 [o_mi_half_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
235 [o_mi_half_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
238 key = config_GetPsz(p_intf, "key-zoom-original");
239 o_key = [NSString stringWithFormat:@"%s", key];
240 [o_mi_normal_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
241 [o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
244 key = config_GetPsz(p_intf, "key-zoom-double");
245 o_key = [NSString stringWithFormat:@"%s", key];
246 [o_mi_double_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
247 [o_mi_double_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
250 [self setSubmenusEnabled: FALSE];
252 [[NSNotificationCenter defaultCenter] addObserver: self
253 selector: @selector(refreshVoutDeviceMenu:)
254 name: NSApplicationDidChangeScreenParametersNotification
258 b_mainMenu_setup = YES;
260 [self setupVarMenuItem: o_mi_add_intf target: (vlc_object_t *)p_intf
261 var: "intf-add" selector: @selector(toggleVar:)];
263 [self setupExtensionsMenu];
269 [o_mi_about setTitle: [_NS("About VLC media player") \
270 stringByAppendingString: @"..."]];
271 [o_mi_checkForUpdate setTitle: _NS("Check for Update...")];
272 [o_mi_prefs setTitle: _NS("Preferences...")];
273 [o_mi_extensions setTitle: _NS("Extensions")];
274 [o_mu_extensions setTitle: _NS("Extensions")];
275 [o_mi_add_intf setTitle: _NS("Add Interface")];
276 [o_mu_add_intf setTitle: _NS("Add Interface")];
277 [o_mi_services setTitle: _NS("Services")];
278 [o_mi_hide setTitle: _NS("Hide VLC")];
279 [o_mi_hide_others setTitle: _NS("Hide Others")];
280 [o_mi_show_all setTitle: _NS("Show All")];
281 [o_mi_quit setTitle: _NS("Quit VLC")];
283 [o_mu_file setTitle: _ANS("1:File")];
284 [o_mi_open_generic setTitle: _NS("Advanced Open File...")];
285 [o_mi_open_file setTitle: _NS("Open File...")];
286 [o_mi_open_disc setTitle: _NS("Open Disc...")];
287 [o_mi_open_net setTitle: _NS("Open Network...")];
288 [o_mi_open_capture setTitle: _NS("Open Capture Device...")];
289 [o_mi_open_recent setTitle: _NS("Open Recent")];
290 [o_mi_open_wizard setTitle: _NS("Streaming/Exporting Wizard...")];
291 [o_mi_convertandsave setTitle: _NS("Convert / Save...")];
293 [o_mu_edit setTitle: _NS("Edit")];
294 [o_mi_cut setTitle: _NS("Cut")];
295 [o_mi_copy setTitle: _NS("Copy")];
296 [o_mi_paste setTitle: _NS("Paste")];
297 [o_mi_clear setTitle: _NS("Clear")];
298 [o_mi_select_all setTitle: _NS("Select All")];
300 [o_mu_view setTitle: _NS("View")];
301 [o_mi_toggleJumpButtons setTitle: _NS("Show Previous & Next Buttons")];
302 [o_mi_toggleJumpButtons setState: config_GetInt(VLCIntf, "macosx-show-playback-buttons")];
303 [o_mi_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")];
304 [o_mi_togglePlaymodeButtons setState: config_GetInt(VLCIntf, "macosx-show-playmode-buttons")];
305 [o_mu_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
307 [o_mu_controls setTitle: _NS("Playback")];
308 [o_mi_play setTitle: _NS("Play")];
309 [o_mi_stop setTitle: _NS("Stop")];
310 [o_mi_record setTitle: _NS("Record")];
311 [o_mi_rate setView: o_mi_rate_view];
312 [o_mi_rate_lbl setStringValue: _NS("Playback Speed")];
313 [o_mi_rate_lbl_gray setStringValue: _NS("Playback Speed")];
314 [o_mi_rate_slower_lbl setStringValue: _NS("Slower")];
315 [o_mi_rate_normal_lbl setStringValue: _NS("Normal")];
316 [o_mi_rate_faster_lbl setStringValue: _NS("Faster")];
317 [o_mi_trackSynchronization setTitle: _NS("Track Synchronization")];
318 [o_mi_previous setTitle: _NS("Previous")];
319 [o_mi_next setTitle: _NS("Next")];
320 [o_mi_random setTitle: _NS("Random")];
321 [o_mi_repeat setTitle: _NS("Repeat One")];
322 [o_mi_loop setTitle: _NS("Repeat All")];
323 [o_mi_quitAfterPB setTitle: _NS("Quit after Playback")];
324 [o_mi_fwd setTitle: _NS("Step Forward")];
325 [o_mi_bwd setTitle: _NS("Step Backward")];
327 [o_mi_program setTitle: _NS("Program")];
328 [o_mu_program setTitle: _NS("Program")];
329 [o_mi_title setTitle: _NS("Title")];
330 [o_mu_title setTitle: _NS("Title")];
331 [o_mi_chapter setTitle: _NS("Chapter")];
332 [o_mu_chapter setTitle: _NS("Chapter")];
334 [o_mu_audio setTitle: _NS("Audio")];
335 [o_mi_vol_up setTitle: _NS("Increase Volume")];
336 [o_mi_vol_down setTitle: _NS("Decrease Volume")];
337 [o_mi_mute setTitle: _NS("Mute")];
338 [o_mi_audiotrack setTitle: _NS("Audio Track")];
339 [o_mu_audiotrack setTitle: _NS("Audio Track")];
340 [o_mi_channels setTitle: _NS("Audio Channels")];
341 [o_mu_channels setTitle: _NS("Audio Channels")];
342 [o_mi_device setTitle: _NS("Audio Device")];
343 [o_mu_device setTitle: _NS("Audio Device")];
344 [o_mi_visual setTitle: _NS("Visualizations")];
345 [o_mu_visual setTitle: _NS("Visualizations")];
347 [o_mu_video setTitle: _NS("Video")];
348 [o_mi_half_window setTitle: _NS("Half Size")];
349 [o_mi_normal_window setTitle: _NS("Normal Size")];
350 [o_mi_double_window setTitle: _NS("Double Size")];
351 [o_mi_fittoscreen setTitle: _NS("Fit to Screen")];
352 [o_mi_fullscreen setTitle: _NS("Fullscreen")];
353 [o_mi_floatontop setTitle: _NS("Float on Top")];
354 [o_mi_snapshot setTitle: _NS("Snapshot")];
355 [o_mi_videotrack setTitle: _NS("Video Track")];
356 [o_mu_videotrack setTitle: _NS("Video Track")];
357 [o_mi_aspect_ratio setTitle: _NS("Aspect-ratio")];
358 [o_mu_aspect_ratio setTitle: _NS("Aspect-ratio")];
359 [o_mi_crop setTitle: _NS("Crop")];
360 [o_mu_crop setTitle: _NS("Crop")];
361 [o_mi_screen setTitle: _NS("Fullscreen Video Device")];
362 [o_mu_screen setTitle: _NS("Fullscreen Video Device")];
363 [o_mi_subtitle setTitle: _NS("Subtitles Track")];
364 [o_mu_subtitle setTitle: _NS("Subtitles Track")];
365 [o_mi_addSub setTitle: _NS("Open File...")];
366 [o_mi_deinterlace setTitle: _NS("Deinterlace")];
367 [o_mu_deinterlace setTitle: _NS("Deinterlace")];
368 [o_mi_deinterlace_mode setTitle: _NS("Deinterlace mode")];
369 [o_mu_deinterlace_mode setTitle: _NS("Deinterlace mode")];
370 [o_mi_ffmpeg_pp setTitle: _NS("Post processing")];
371 [o_mu_ffmpeg_pp setTitle: _NS("Post processing")];
372 [o_mi_teletext setTitle: _NS("Teletext")];
373 [o_mi_teletext_transparent setTitle: _NS("Transparent")];
374 [o_mi_teletext_index setTitle: _NS("Index")];
375 [o_mi_teletext_red setTitle: _NS("Red")];
376 [o_mi_teletext_green setTitle: _NS("Green")];
377 [o_mi_teletext_yellow setTitle: _NS("Yellow")];
378 [o_mi_teletext_blue setTitle: _NS("Blue")];
380 [o_mu_window setTitle: _NS("Window")];
381 [o_mi_minimize setTitle: _NS("Minimize Window")];
382 [o_mi_close_window setTitle: _NS("Close Window")];
383 [o_mi_player setTitle: _NS("Player...")];
384 [o_mi_controller setTitle: _NS("Main Window...")];
385 [o_mi_audioeffects setTitle: _NS("Audio Effects...")];
386 [o_mi_videoeffects setTitle: _NS("Video Effects...")];
387 [o_mi_bookmarks setTitle: _NS("Bookmarks...")];
388 [o_mi_playlist setTitle: _NS("Playlist...")];
389 [o_mi_info setTitle: _NS("Media Information...")];
390 [o_mi_messages setTitle: _NS("Messages...")];
391 [o_mi_errorsAndWarnings setTitle: _NS("Errors and Warnings...")];
393 [o_mi_bring_atf setTitle: _NS("Bring All to Front")];
395 [o_mu_help setTitle: _NS("Help")];
396 [o_mi_help setTitle: _NS("VLC media player Help...")];
397 [o_mi_readme setTitle: _NS("ReadMe / FAQ...")];
398 [o_mi_license setTitle: _NS("License")];
399 [o_mi_documentation setTitle: _NS("Online Documentation...")];
400 [o_mi_website setTitle: _NS("VideoLAN Website...")];
401 [o_mi_donation setTitle: _NS("Make a donation...")];
402 [o_mi_forum setTitle: _NS("Online Forum...")];
405 [o_dmi_play setTitle: _NS("Play")];
406 [o_dmi_stop setTitle: _NS("Stop")];
407 [o_dmi_next setTitle: _NS("Next")];
408 [o_dmi_previous setTitle: _NS("Previous")];
409 [o_dmi_mute setTitle: _NS("Mute")];
412 [o_vmi_play setTitle: _NS("Play")];
413 [o_vmi_stop setTitle: _NS("Stop")];
414 [o_vmi_prev setTitle: _NS("Previous")];
415 [o_vmi_next setTitle: _NS("Next")];
416 [o_vmi_volup setTitle: _NS("Volume Up")];
417 [o_vmi_voldown setTitle: _NS("Volume Down")];
418 [o_vmi_mute setTitle: _NS("Mute")];
419 [o_vmi_fullscreen setTitle: _NS("Fullscreen")];
420 [o_vmi_snapshot setTitle: _NS("Snapshot")];
423 - (NSMenu *)setupPlaylistTableColumnsMenu
425 NSMenu *o_context_menu = [[NSMenu alloc] init];
427 NSMenuItem *o_mi_tmp;
428 NSUInteger count = [o_ptc_menuorder count];
429 for (NSUInteger i = 0; i < count; i++) {
430 NSString *o_title = [o_ptc_translation_dict objectForKey:[o_ptc_menuorder objectAtIndex:i]];
431 o_mi_tmp = [o_mu_playlistTableColumns addItemWithTitle:o_title
432 action:@selector(togglePlaylistColumnTable:)
434 [o_mi_tmp setTarget:self];
437 o_mi_tmp = [o_context_menu addItemWithTitle:o_title
438 action:@selector(togglePlaylistColumnTable:)
440 [o_mi_tmp setTarget:self];
443 if (!o_mu_playlistTableColumnsContextMenu)
444 o_mu_playlistTableColumnsContextMenu = [o_context_menu retain];
445 return [o_context_menu autorelease];
449 #pragma mark Termination
451 - (void)releaseRepresentedObjects:(NSMenu *)the_menu
455 NSArray *menuitems_array = [the_menu itemArray];
456 NSUInteger menuItemCount = [menuitems_array count];
457 for (NSUInteger i=0; i < menuItemCount; i++) {
458 NSMenuItem *one_item = [menuitems_array objectAtIndex: i];
459 if ([one_item hasSubmenu])
460 [self releaseRepresentedObjects: [one_item submenu]];
462 [one_item setRepresentedObject:NULL];
467 #pragma mark Interface update
471 playlist_t * p_playlist = pl_Get(p_intf);
472 input_thread_t * p_input = playlist_CurrentInput(p_playlist);
473 if (p_input != NULL) {
474 [o_mi_record setEnabled: var_GetBool(p_input, "can-record")];
476 [self setupVarMenuItem: o_mi_program target: (vlc_object_t *)p_input
477 var: "program" selector: @selector(toggleVar:)];
479 [self setupVarMenuItem: o_mi_title target: (vlc_object_t *)p_input
480 var: "title" selector: @selector(toggleVar:)];
482 [self setupVarMenuItem: o_mi_chapter target: (vlc_object_t *)p_input
483 var: "chapter" selector: @selector(toggleVar:)];
485 [self setupVarMenuItem: o_mi_audiotrack target: (vlc_object_t *)p_input
486 var: "audio-es" selector: @selector(toggleVar:)];
488 [self setupVarMenuItem: o_mi_videotrack target: (vlc_object_t *)p_input
489 var: "video-es" selector: @selector(toggleVar:)];
491 [self setupVarMenuItem: o_mi_subtitle target: (vlc_object_t *)p_input
492 var: "spu-es" selector: @selector(toggleVar:)];
494 /* special case for "Open File" inside the subtitles menu item */
495 if ([o_mi_videotrack isEnabled] == YES)
496 [o_mi_subtitle setEnabled: YES];
498 audio_output_t * p_aout = input_GetAout(p_input);
499 if (p_aout != NULL) {
500 [self setupVarMenuItem: o_mi_channels target: (vlc_object_t *)p_aout
501 var: "audio-channels" selector: @selector(toggleVar:)];
503 [self setupVarMenuItem: o_mi_device target: (vlc_object_t *)p_aout
504 var: "audio-device" selector: @selector(toggleVar:)];
506 [self setupVarMenuItem: o_mi_visual target: (vlc_object_t *)p_aout
507 var: "visual" selector: @selector(toggleVar:)];
508 vlc_object_release(p_aout);
511 vout_thread_t * p_vout = input_GetVout(p_input);
513 if (p_vout != NULL) {
514 [self setupVarMenuItem: o_mi_aspect_ratio target: (vlc_object_t *)p_vout
515 var: "aspect-ratio" selector: @selector(toggleVar:)];
517 [self setupVarMenuItem: o_mi_crop target: (vlc_object_t *) p_vout
518 var: "crop" selector: @selector(toggleVar:)];
520 [self setupVarMenuItem: o_mi_deinterlace target: (vlc_object_t *)p_vout
521 var: "deinterlace" selector: @selector(toggleVar:)];
523 [self setupVarMenuItem: o_mi_deinterlace_mode target: (vlc_object_t *)p_vout
524 var: "deinterlace-mode" selector: @selector(toggleVar:)];
527 [self setupVarMenuItem: o_mi_ffmpeg_pp target:
528 (vlc_object_t *)p_vout var:"postprocess" selector:
529 @selector(toggleVar:)];
531 vlc_object_release(p_vout);
533 [self refreshVoutDeviceMenu:nil];
535 vlc_object_release(p_input);
538 [o_mi_record setEnabled: NO];
541 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification
543 NSUInteger count = [o_mu_screen numberOfItems];
544 NSMenu * o_submenu = o_mu_screen;
546 [o_submenu removeAllItems];
548 NSArray * o_screens = [NSScreen screens];
549 NSMenuItem * o_mitem;
550 count = [o_screens count];
551 [o_mi_screen setEnabled: YES];
552 [o_submenu addItemWithTitle: _NS("Default") action:@selector(toggleFullscreenDevice:) keyEquivalent:@""];
553 o_mitem = [o_submenu itemAtIndex: 0];
555 [o_mitem setEnabled: YES];
556 [o_mitem setTarget: self];
558 for (NSUInteger i = 0; i < count; i++) {
559 s_rect = [[o_screens objectAtIndex: i] frame];
560 [o_submenu addItemWithTitle: [NSString stringWithFormat: @"%@ %li (%ix%i)", _NS("Screen"), i+1,
561 (int)s_rect.size.width, (int)s_rect.size.height] action:@selector(toggleFullscreenDevice:) keyEquivalent:@""];
562 o_mitem = [o_submenu itemAtIndex:i+1];
563 [o_mitem setTag: (int)[[o_screens objectAtIndex: i] displayID]];
564 [o_mitem setEnabled: YES];
565 [o_mitem setTarget: self];
567 [[o_submenu itemWithTag: var_InheritInteger(VLCIntf, "macosx-vdev")] setState: NSOnState];
570 - (void)setSubmenusEnabled:(BOOL)b_enabled
572 [o_mi_program setEnabled: b_enabled];
573 [o_mi_title setEnabled: b_enabled];
574 [o_mi_chapter setEnabled: b_enabled];
575 [o_mi_audiotrack setEnabled: b_enabled];
576 [o_mi_visual setEnabled: b_enabled];
577 [o_mi_videotrack setEnabled: b_enabled];
578 [o_mi_subtitle setEnabled: b_enabled];
579 [o_mi_channels setEnabled: b_enabled];
580 [o_mi_deinterlace setEnabled: b_enabled];
581 [o_mi_deinterlace_mode setEnabled: b_enabled];
582 [o_mi_ffmpeg_pp setEnabled: b_enabled];
583 [o_mi_device setEnabled: b_enabled];
584 [o_mi_screen setEnabled: b_enabled];
585 [o_mi_aspect_ratio setEnabled: b_enabled];
586 [o_mi_crop setEnabled: b_enabled];
587 [o_mi_teletext setEnabled: b_enabled];
590 - (void)setRateControlsEnabled:(BOOL)b_enabled
592 NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
593 [o_mi_rate_sld setEnabled: b_enabled];
594 [o_mi_rate_sld setIntValue: [[VLCCoreInteraction sharedInstance] playbackRate]];
595 int i = [[VLCCoreInteraction sharedInstance] playbackRate];
596 double speed = pow(2, (double)i / 17);
597 [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
599 [o_mi_rate_lbl setHidden: NO];
600 [o_mi_rate_lbl_gray setHidden: YES];
602 [o_mi_rate_lbl setHidden: YES];
603 [o_mi_rate_lbl_gray setHidden: NO];
609 #pragma mark Extensions
611 - (void)setupExtensionsMenu
613 /* Load extensions if needed */
614 // TODO: Implement preference for autoloading extensions on mac
616 // if (!var_InheritBool(p_intf, "qt-autoload-extensions")
617 // && ![o_extMgr isLoaded])
622 if (![o_extMgr isLoaded] && ![o_extMgr cannotLoad]) {
623 [o_extMgr loadExtensions];
626 /* Let the ExtensionsManager itself build the menu */
627 [o_extMgr buildMenu:o_mu_extensions];
628 [o_mi_extensions setEnabled: ([o_mu_extensions numberOfItems] > 0)];
633 - (IBAction)toggleJumpButtons:(id)sender
635 BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-playback-buttons");
636 config_PutInt(VLCIntf, "macosx-show-playback-buttons", b_value);
637 [[[[VLCMain sharedInstance] mainWindow] controlsBar] toggleJumpButtons];
638 [o_mi_toggleJumpButtons setState: b_value];
641 - (IBAction)togglePlaymodeButtons:(id)sender
643 BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-playmode-buttons");
644 config_PutInt(VLCIntf, "macosx-show-playmode-buttons", b_value);
645 [[[[VLCMain sharedInstance] mainWindow] controlsBar] togglePlaymodeButtons];
646 [o_mi_togglePlaymodeButtons setState: b_value];
649 - (IBAction)togglePlaylistColumnTable:(id)sender
651 NSInteger i_new_state = ![sender state];
652 NSInteger i_tag = [sender tag];
653 [[o_mu_playlistTableColumns itemWithTag: i_tag] setState: i_new_state];
654 [[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_new_state];
656 NSString *o_column = [o_ptc_menuorder objectAtIndex: i_tag];
657 [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_new_state translationDict: o_ptc_translation_dict];
660 - (void)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column
662 NSInteger i_tag = [o_ptc_menuorder indexOfObject: o_column];
663 [[o_mu_playlistTableColumns itemWithTag: i_tag] setState: i_state];
664 [[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_state];
665 [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_state translationDict: o_ptc_translation_dict];
669 #pragma mark Playback
670 - (IBAction)toggleRecord:(id)sender
672 [[VLCCoreInteraction sharedInstance] toggleRecord];
675 - (void)updateRecordState:(BOOL)b_value
677 [o_mi_record setState:b_value];
680 - (IBAction)setPlaybackRate:(id)sender
682 [[VLCCoreInteraction sharedInstance] setPlaybackRate: [o_mi_rate_sld intValue]];
683 int i = [[VLCCoreInteraction sharedInstance] playbackRate];
684 double speed = pow(2, (double)i / 17);
685 [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
688 - (void)updatePlaybackRate
690 int i = [[VLCCoreInteraction sharedInstance] playbackRate];
691 double speed = pow(2, (double)i / 17);
692 [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
693 [o_mi_rate_sld setIntValue: i];
697 #pragma mark video menu
698 - (IBAction)toggleFullscreen:(id)sender
700 [[VLCCoreInteraction sharedInstance] toggleFullscreen];
703 - (IBAction)resizeVideoWindow:(id)sender
705 input_thread_t *p_input = pl_CurrentInput(VLCIntf);
707 vout_thread_t *p_vout = getVout();
709 if (sender == o_mi_half_window)
710 var_SetFloat(p_vout, "zoom", 0.5);
711 else if (sender == o_mi_normal_window)
712 var_SetFloat(p_vout, "zoom", 1.0);
713 else if (sender == o_mi_double_window)
714 var_SetFloat(p_vout, "zoom", 2.0);
717 [[[[[VLCMain sharedInstance] mainWindow] videoView] window] performZoom:sender];
719 vlc_object_release(p_vout);
721 vlc_object_release(p_input);
725 - (IBAction)floatOnTop:(id)sender
727 input_thread_t *p_input = pl_CurrentInput(VLCIntf);
729 vout_thread_t *p_vout = getVout();
731 var_ToggleBool(p_vout, "video-on-top");
732 vlc_object_release(p_vout);
734 vlc_object_release(p_input);
738 - (IBAction)createVideoSnapshot:(id)sender
740 input_thread_t *p_input = pl_CurrentInput(VLCIntf);
742 vout_thread_t *p_vout = getVout();
744 var_TriggerCallback(p_vout, "video-snapshot");
745 vlc_object_release(p_vout);
747 vlc_object_release(p_input);
751 - (IBAction)toggleFullscreenDevice:(id)sender
753 config_PutInt(VLCIntf, "macosx-vdev", [sender tag]);
754 [self refreshVoutDeviceMenu: nil];
765 - (IBAction)intfOpenFile:(id)sender
767 [[[VLCMain sharedInstance] open] openFile];
770 - (IBAction)intfOpenFileGeneric:(id)sender
772 [[[VLCMain sharedInstance] open] openFileGeneric];
775 - (IBAction)intfOpenDisc:(id)sender
777 [[[VLCMain sharedInstance] open] openDisc];
780 - (IBAction)intfOpenNet:(id)sender
782 [[[VLCMain sharedInstance] open] openNet];
785 - (IBAction)intfOpenCapture:(id)sender
787 [[[VLCMain sharedInstance] open] openCapture];
790 - (IBAction)showWizard:(id)sender
792 [[[VLCMain sharedInstance] wizard] resetWizard];
793 [[[VLCMain sharedInstance] wizard] showWizard];
796 - (IBAction)showConvertAndSave:(id)sender
798 if (o_convertandsave == nil)
799 o_convertandsave = [[VLCConvertAndSave alloc] init];
801 if (!b_nib_convertandsave_loaded)
802 b_nib_convertandsave_loaded = [NSBundle loadNibNamed:@"ConvertAndSave" owner: NSApp];
804 [o_convertandsave toggleWindow];
807 - (IBAction)showVideoEffects:(id)sender
809 if (o_videoeffects == nil)
810 o_videoeffects = [[VLCVideoEffects alloc] init];
812 if (!b_nib_videoeffects_loaded)
813 b_nib_videoeffects_loaded = [NSBundle loadNibNamed:@"VideoEffects" owner: NSApp];
815 [o_videoeffects toggleWindow:sender];
818 - (IBAction)showTrackSynchronization:(id)sender
820 if (!o_trackSynchronization)
821 o_trackSynchronization = [[VLCTrackSynchronization alloc] init];
823 if (!b_nib_tracksynchro_loaded)
824 b_nib_tracksynchro_loaded = [NSBundle loadNibNamed:@"SyncTracks" owner:NSApp];
826 [o_trackSynchronization toggleWindow:sender];
829 - (IBAction)showAudioEffects:(id)sender
832 o_audioeffects = [[VLCAudioEffects alloc] init];
834 if (!b_nib_audioeffects_loaded)
835 b_nib_audioeffects_loaded = [NSBundle loadNibNamed:@"AudioEffects" owner:NSApp];
837 [o_audioeffects toggleWindow:sender];
840 - (IBAction)showBookmarks:(id)sender
842 [[[VLCMain sharedInstance] bookmarks] showBookmarks];
845 - (IBAction)viewPreferences:(id)sender
847 NSInteger i_level = NSNormalWindowLevel;
848 NSInteger i_video_window_level = [[[[VLCMainWindow sharedInstance] videoView] window] level];
849 if (i_video_window_level == NSStatusWindowLevel)
850 i_level = NSStatusWindowLevel;
851 [[[VLCMain sharedInstance] simplePreferences] showSimplePrefsWithLevel:i_level];
855 #pragma mark Help and Docs
860 o_about = [[VLAboutBox alloc] init];
862 if (!b_nib_about_loaded)
863 b_nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp];
866 - (IBAction)viewAbout:(id)sender
872 - (IBAction)showLicense:(id)sender
875 [o_about showGPL: sender];
878 - (IBAction)viewHelp:(id)sender
884 - (IBAction)openReadMe:(id)sender
886 NSString * o_path = [[NSBundle mainBundle] pathForResource: @"README.MacOSX" ofType: @"rtf"];
888 [[NSWorkspace sharedWorkspace] openFile: o_path withApplication: @"TextEdit"];
891 - (IBAction)openDocumentation:(id)sender
893 NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/doc/"];
895 [[NSWorkspace sharedWorkspace] openURL: o_url];
898 - (IBAction)openWebsite:(id)sender
900 NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/"];
902 [[NSWorkspace sharedWorkspace] openURL: o_url];
905 - (IBAction)openForum:(id)sender
907 NSURL * o_url = [NSURL URLWithString: @"http://forum.videolan.org/"];
909 [[NSWorkspace sharedWorkspace] openURL: o_url];
912 - (IBAction)openDonate:(id)sender
914 NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/contribute.html#paypal"];
916 [[NSWorkspace sharedWorkspace] openURL: o_url];
920 #pragma mark Errors, warnings and messages
922 - (IBAction)viewErrorsAndWarnings:(id)sender
924 [[[[VLCMain sharedInstance] coreDialogProvider] errorPanel] showPanel];
927 - (IBAction)showInformationPanel:(id)sender
929 [[[VLCMain sharedInstance] info] initPanel];
933 #pragma mark convinience stuff for other objects
936 [o_mi_play setTitle: _NS("Play")];
937 [o_dmi_play setTitle: _NS("Play")];
938 [o_vmi_play setTitle: _NS("Play")];
943 [o_mi_play setTitle: _NS("Pause")];
944 [o_dmi_play setTitle: _NS("Pause")];
945 [o_vmi_play setTitle: _NS("Pause")];
950 [o_mi_repeat setState: NSOnState];
951 [o_mi_loop setState: NSOffState];
956 [o_mi_repeat setState: NSOffState];
957 [o_mi_loop setState: NSOnState];
962 [o_mi_repeat setState: NSOffState];
963 [o_mi_loop setState: NSOffState];
969 playlist_t *p_playlist = pl_Get(VLCIntf);
970 b_value = var_GetBool(p_playlist, "random");
972 [o_mi_random setState: b_value];
976 #pragma mark Dynamic menu creation and validation
978 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
979 target:(vlc_object_t *)p_object
980 var:(const char *)psz_variable
981 selector:(SEL)pf_callback
983 vlc_value_t val, text;
984 int i_type = var_Type(p_object, psz_variable);
986 switch(i_type & VLC_VAR_TYPE) {
989 case VLC_VAR_VARIABLE:
991 case VLC_VAR_INTEGER:
994 /* Variable doesn't exist or isn't handled */
998 /* Get the descriptive name of the variable */
999 var_Change(p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL);
1000 [o_mi setTitle: _NS(text.psz_string ? text.psz_string : psz_variable)];
1002 if (i_type & VLC_VAR_HASCHOICE) {
1003 NSMenu *o_menu = [o_mi submenu];
1005 [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
1006 var:psz_variable selector:pf_callback];
1008 free(text.psz_string);
1012 if (var_Get(p_object, psz_variable, &val) < 0) {
1016 VLCAutoGeneratedMenuContent *o_data;
1017 switch(i_type & VLC_VAR_TYPE) {
1019 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1020 andValue: val ofType: i_type];
1021 [o_mi setRepresentedObject: [o_data autorelease]];
1025 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1026 andValue: val ofType: i_type];
1027 [o_mi setRepresentedObject: [o_data autorelease]];
1028 if (!(i_type & VLC_VAR_ISCOMMAND))
1029 [o_mi setState: val.b_bool ? TRUE : FALSE ];
1036 if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
1037 free(text.psz_string);
1041 - (void)setupVarMenu:(NSMenu *)o_menu
1042 forMenuItem: (NSMenuItem *)o_parent
1043 target:(vlc_object_t *)p_object
1044 var:(const char *)psz_variable
1045 selector:(SEL)pf_callback
1047 vlc_value_t val, val_list, text_list;
1050 /* remove previous items */
1051 [o_menu removeAllItems];
1053 /* we disable everything here, and enable it again when needed, below */
1054 [o_parent setEnabled:NO];
1057 if ([[o_parent title] isEqualToString: _NS("Aspect-ratio")] == YES) {
1058 NSMenuItem *o_lmi_tmp2;
1059 o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""];
1060 [o_lmi_tmp2 setTarget: [[VLCMain sharedInstance] controls]];
1061 [o_lmi_tmp2 setEnabled: YES];
1062 [o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
1063 [o_parent setEnabled: YES];
1064 [o_menu addItem: [NSMenuItem separatorItem]];
1067 /* special case for the subtitles item */
1068 if ([[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES) {
1069 NSMenuItem * o_lmi_tmp;
1070 o_lmi_tmp = [o_menu addItemWithTitle: _NS("Open File...") action: @selector(addSubtitleFile:) keyEquivalent: @""];
1071 [o_lmi_tmp setTarget: [[VLCMain sharedInstance] controls]];
1072 [o_lmi_tmp setEnabled: YES];
1073 [o_parent setEnabled: YES];
1076 /* Check the type of the object variable */
1077 i_type = var_Type(p_object, psz_variable);
1079 /* Make sure we want to display the variable */
1080 if (i_type & VLC_VAR_HASCHOICE) {
1081 var_Change(p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL);
1084 if ((i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1)
1090 switch(i_type & VLC_VAR_TYPE) {
1093 case VLC_VAR_VARIABLE:
1094 case VLC_VAR_STRING:
1095 case VLC_VAR_INTEGER:
1098 /* Variable doesn't exist or isn't handled */
1102 if (var_Get(p_object, psz_variable, &val) < 0) {
1106 if (var_Change(p_object, psz_variable, VLC_VAR_GETLIST,
1107 &val_list, &text_list) < 0) {
1108 if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
1112 /* make (un)sensitive */
1113 [o_parent setEnabled: (val_list.p_list->i_count > 1)];
1115 /* another special case for the subtitles item */
1116 if ([[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES)
1117 [o_menu addItem: [NSMenuItem separatorItem]];
1119 for (i = 0; i < val_list.p_list->i_count; i++) {
1121 NSString *o_title = @"";
1122 VLCAutoGeneratedMenuContent *o_data;
1124 switch(i_type & VLC_VAR_TYPE) {
1125 case VLC_VAR_STRING:
1127 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);
1129 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
1130 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1131 andValue: val_list.p_list->p_values[i] ofType: i_type];
1132 [o_lmi setRepresentedObject: [o_data autorelease]];
1133 [o_lmi setTarget: self];
1135 if (!strcmp(val.psz_string, val_list.p_list->p_values[i].psz_string) && !(i_type & VLC_VAR_ISCOMMAND))
1136 [o_lmi setState: TRUE ];
1140 case VLC_VAR_INTEGER:
1142 o_title = text_list.p_list->p_values[i].psz_string ?
1143 _NS(text_list.p_list->p_values[i].psz_string) : [NSString stringWithFormat: @"%"PRId64, val_list.p_list->p_values[i].i_int];
1145 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
1146 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1147 andValue: val_list.p_list->p_values[i] ofType: i_type];
1148 [o_lmi setRepresentedObject: [o_data autorelease]];
1149 [o_lmi setTarget: self];
1151 if (val_list.p_list->p_values[i].i_int == val.i_int && !(i_type & VLC_VAR_ISCOMMAND))
1152 [o_lmi setState: TRUE ];
1160 /* special case for the subtitles sub-menu
1161 * In case that we don't have any subs, we don't want a separator item at the end */
1162 if ([[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES) {
1163 if ([o_menu numberOfItems] == 2)
1164 [o_menu removeItemAtIndex: 1];
1167 /* clean up everything */
1168 if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
1169 var_FreeList(&val_list, &text_list);
1172 - (IBAction)toggleVar:(id)sender
1174 NSMenuItem *o_mi = (NSMenuItem *)sender;
1175 VLCAutoGeneratedMenuContent *o_data = [o_mi representedObject];
1176 [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
1177 toTarget: self withObject: o_data];
1182 - (int)toggleVarThread: (id)data
1184 vlc_object_t *p_object;
1185 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
1187 assert([data isKindOfClass:[VLCAutoGeneratedMenuContent class]]);
1188 VLCAutoGeneratedMenuContent *menuContent = (VLCAutoGeneratedMenuContent *)data;
1190 /* Preserve settings across vouts via the playlist object: */
1191 if (!strcmp([menuContent name], "fullscreen") || !strcmp([menuContent name], "video-on-top"))
1192 var_Set(pl_Get(VLCIntf), [menuContent name] , [menuContent value]);
1194 /* save our audio device across multiple sessions */
1195 if (!strcmp([menuContent name], "audio-device"))
1196 config_PutInt(VLCIntf, "macosx-audio-device", [menuContent value].i_int);
1198 p_object = [menuContent vlcObject];
1200 if (p_object != NULL) {
1201 var_Set(p_object, [menuContent name], [menuContent value]);
1202 vlc_object_release(p_object);
1207 return VLC_EGENERIC;
1212 @implementation VLCMainMenu (NSMenuValidation)
1214 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
1216 NSString *o_title = [o_mi title];
1217 BOOL bEnabled = TRUE;
1219 playlist_t * p_playlist = pl_Get(p_intf);
1220 input_thread_t * p_input = playlist_CurrentInput(p_playlist);
1222 if ([o_title isEqualToString: _NS("Stop")]) {
1223 if (p_input == NULL) {
1226 [self setupMenus]; /* Make sure input menu is up to date */
1227 } else if ([o_title isEqualToString: _NS("Previous")] ||
1228 [o_title isEqualToString: _NS("Next")]) {
1230 bEnabled = playlist_CurrentSize(p_playlist) > 1;
1232 } else if ([o_title isEqualToString: _NS("Random")]) {
1234 var_Get(p_playlist, "random", &val);
1235 i_state = val.b_bool ? NSOnState : NSOffState;
1236 [o_mi setState: i_state];
1237 } else if ([o_title isEqualToString: _NS("Repeat One")]) {
1239 var_Get(p_playlist, "repeat", &val);
1240 i_state = val.b_bool ? NSOnState : NSOffState;
1241 [o_mi setState: i_state];
1242 } else if ([o_title isEqualToString: _NS("Repeat All")]) {
1244 var_Get(p_playlist, "loop", &val);
1245 i_state = val.b_bool ? NSOnState : NSOffState;
1246 [o_mi setState: i_state];
1247 } else if ([o_title isEqualToString: _NS("Quit after Playback")]) {
1249 var_Get(p_playlist, "play-and-exit", &val);
1250 i_state = val.b_bool ? NSOnState : NSOffState;
1251 [o_mi setState: i_state];
1252 } else if ([o_title isEqualToString: _NS("Step Forward")] ||
1253 [o_title isEqualToString: _NS("Step Backward")] ||
1254 [o_title isEqualToString: _NS("Jump To Time")]) {
1255 if (p_input != NULL) {
1256 var_Get(p_input, "can-seek", &val);
1257 bEnabled = val.b_bool;
1259 else bEnabled = FALSE;
1260 } else if ([o_title isEqualToString: _NS("Mute")]) {
1261 [o_mi setState: [[VLCCoreInteraction sharedInstance] mute] ? NSOnState : NSOffState];
1262 [self setupMenus]; /* Make sure audio menu is up to date */
1263 } else if ([o_title isEqualToString: _NS("Half Size")] ||
1264 [o_title isEqualToString: _NS("Normal Size")] ||
1265 [o_title isEqualToString: _NS("Double Size")] ||
1266 [o_title isEqualToString: _NS("Fit to Screen")] ||
1267 [o_title isEqualToString: _NS("Snapshot")] ||
1268 [o_title isEqualToString: _NS("Fullscreen")] ||
1269 [o_title isEqualToString: _NS("Float on Top")]) {
1272 if (p_input != NULL) {
1273 vout_thread_t *p_vout = input_GetVout(p_input);
1274 if (p_vout != NULL) {
1275 if ([o_title isEqualToString: _NS("Float on Top")])
1276 [o_mi setState: var_GetBool(p_vout, "video-on-top")];
1280 vlc_object_release(p_vout);
1283 if ([o_title isEqualToString: _NS("Fullscreen")]) {
1284 [o_mi setState: var_GetBool(p_playlist, "fullscreen")];
1287 [self setupMenus]; /* Make sure video menu is up to date */
1290 /* Special case for telx menu */
1291 if ([o_title isEqualToString: _NS("Normal Size")]) {
1292 NSMenuItem *item = [[o_mi menu] itemWithTitle:_NS("Teletext")];
1293 bool b_telx = p_input && var_GetInteger(p_input, "teletext-es") >= 0;
1295 [[item submenu] setAutoenablesItems:NO];
1297 for (int k=0; k < [[item submenu] numberOfItems]; k++)
1298 [[[item submenu] itemAtIndex:k] setEnabled: b_telx];
1302 vlc_object_release(p_input);
1310 /*****************************************************************************
1311 * VLCAutoGeneratedMenuContent implementation
1312 *****************************************************************************
1313 * Object connected to a playlistitem which remembers the data belonging to
1314 * the variable of the autogenerated menu
1315 *****************************************************************************/
1316 @implementation VLCAutoGeneratedMenuContent
1318 -(id) initWithVariableName:(const char *)name ofObject:(vlc_object_t *)object
1319 andValue:(vlc_value_t)val ofType:(int)type
1321 self = [super init];
1324 _vlc_object = vlc_object_hold(object);
1325 psz_name = strdup(name);
1328 if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
1329 value.psz_string = strdup(val.psz_string);
1338 vlc_object_release(_vlc_object);
1339 if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
1340 free(value.psz_string);
1345 - (const char *)name
1350 - (vlc_value_t)value
1355 - (vlc_object_t *)vlcObject
1357 return vlc_object_hold(_vlc_object);