macosx: robustify playlist table columns initialization
[vlc.git] / modules / gui / macosx / MainMenu.m
1 /*****************************************************************************
2  * MainMenu.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2011-2013 Felix Paul Kühne
5  * $Id$
6  *
7  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #import "MainMenu.h"
25 #import <vlc_common.h>
26 #import <vlc_playlist.h>
27
28 #import "intf.h"
29 #import "open.h"
30 #import "wizard.h"
31 #import "about.h"
32 #import "AudioEffects.h"
33 #import "TrackSynchronization.h"
34 #import "VideoEffects.h"
35 #import "bookmarks.h"
36 #import "simple_prefs.h"
37 #import "coredialogs.h"
38 #import "controls.h"
39 #import "playlist.h"
40 #import "playlistinfo.h"
41 #import "VideoView.h"
42 #import "CoreInteraction.h"
43 #import "MainWindow.h"
44 #import "ControlsBar.h"
45 #import "ExtensionsManager.h"
46 #import "ConvertAndSave.h"
47 #import "DebugMessageVisualizer.h"
48 #import "AddonManager.h"
49
50 @implementation VLCMainMenu
51 static VLCMainMenu *_o_sharedInstance = nil;
52
53 + (VLCMainMenu *)sharedInstance
54 {
55     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
56 }
57
58 #pragma mark -
59 #pragma mark Initialization
60
61 - (id)init
62 {
63     if (_o_sharedInstance) {
64         [self dealloc];
65         return _o_sharedInstance;
66     } else {
67         _o_sharedInstance = [super init];
68
69         o_ptc_translation_dict = [[NSDictionary alloc] initWithObjectsAndKeys:
70                       _NS("Track Number"),  TRACKNUM_COLUMN,
71                       _NS("Title"),         TITLE_COLUMN,
72                       _NS("Author"),        ARTIST_COLUMN,
73                       _NS("Duration"),      DURATION_COLUMN,
74                       _NS("Genre"),         GENRE_COLUMN,
75                       _NS("Album"),         ALBUM_COLUMN,
76                       _NS("Description"),   DESCRIPTION_COLUMN,
77                       _NS("Date"),          DATE_COLUMN,
78                       _NS("Language"),      LANGUAGE_COLUMN,
79                       _NS("URI"),           URI_COLUMN,
80                       _NS("File Size"),     FILESIZE_COLUMN,
81                       nil];
82         // this array also assigns tags (index) to type of menu item
83         o_ptc_menuorder = [[NSArray alloc] initWithObjects: TRACKNUM_COLUMN, TITLE_COLUMN,
84                            ARTIST_COLUMN, DURATION_COLUMN, GENRE_COLUMN, ALBUM_COLUMN,
85                            DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN,
86                            FILESIZE_COLUMN,nil];
87     }
88
89     return _o_sharedInstance;
90 }
91
92 - (void)dealloc
93 {
94     [[NSNotificationCenter defaultCenter] removeObserver: self];
95
96     if (b_nib_about_loaded)
97         [o_about release];
98
99     if (b_nib_videoeffects_loaded)
100         [o_videoeffects release];
101
102     if (b_nib_audioeffects_loaded)
103         [o_audioeffects release];
104
105     if (b_nib_tracksynchro_loaded)
106         [o_trackSynchronization release];
107
108     if (b_nib_convertandsave_loaded)
109         [o_convertandsave release];
110
111     [o_extMgr release];
112
113     if (o_mu_playlistTableColumnsContextMenu)
114         [o_mu_playlistTableColumnsContextMenu release];
115
116     [self releaseRepresentedObjects:[NSApp mainMenu]];
117
118     [o_ptc_translation_dict release];
119     [o_ptc_menuorder release];
120
121     [super dealloc];
122 }
123
124 - (void)awakeFromNib
125 {
126     [[NSNotificationCenter defaultCenter] addObserver: self
127                                              selector: @selector(applicationWillFinishLaunching:)
128                                                  name: NSApplicationWillFinishLaunchingNotification
129                                                object: nil];
130
131     /* check whether the user runs OSX with a RTL language */
132     NSArray* languages = [NSLocale preferredLanguages];
133     NSString* preferredLanguage = [languages objectAtIndex:0];
134
135     if ([NSLocale characterDirectionForLanguage:preferredLanguage] == NSLocaleLanguageDirectionRightToLeft) {
136         msg_Dbg(VLCIntf, "adapting interface since '%s' is a RTL language", [preferredLanguage UTF8String]);
137         [o_mi_rate_fld setAlignment: NSLeftTextAlignment];
138     }
139 }
140
141 - (void)applicationWillFinishLaunching:(NSNotification *)o_notification
142 {
143     p_intf = VLCIntf;
144
145     NSString* o_key;
146     playlist_t *p_playlist;
147     vlc_value_t val;
148     id o_vlcstringutility = [VLCStringUtility sharedInstance];
149     char * key;
150
151     /* Check if we already did this once. Opening the other nibs calls it too,
152      because VLCMain is the owner */
153     if (b_mainMenu_setup)
154         return;
155
156     /* Get ExtensionsManager */
157     o_extMgr = [ExtensionsManager getInstance:p_intf];
158     [o_extMgr retain];
159
160     [self initStrings];
161
162     key = config_GetPsz(p_intf, "key-quit");
163     o_key = [NSString stringWithFormat:@"%s", key];
164     [o_mi_quit setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
165     [o_mi_quit setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
166     FREENULL(key);
167
168     // do not assign play/pause key
169
170     key = config_GetPsz(p_intf, "key-stop");
171     o_key = [NSString stringWithFormat:@"%s", key];
172     [o_mi_stop setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
173     [o_mi_stop setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
174     FREENULL(key);
175
176     key = config_GetPsz(p_intf, "key-prev");
177     o_key = [NSString stringWithFormat:@"%s", key];
178     [o_mi_previous setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
179     [o_mi_previous setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
180     FREENULL(key);
181
182     key = config_GetPsz(p_intf, "key-next");
183     o_key = [NSString stringWithFormat:@"%s", key];
184     [o_mi_next setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
185     [o_mi_next setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
186     FREENULL(key);
187
188     key = config_GetPsz(p_intf, "key-jump+short");
189     o_key = [NSString stringWithFormat:@"%s", key];
190     [o_mi_fwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
191     [o_mi_fwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
192     FREENULL(key);
193
194     key = config_GetPsz(p_intf, "key-jump-short");
195     o_key = [NSString stringWithFormat:@"%s", key];
196     [o_mi_bwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
197     [o_mi_bwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
198     FREENULL(key);
199
200     key = config_GetPsz(p_intf, "key-vol-up");
201     o_key = [NSString stringWithFormat:@"%s", key];
202     [o_mi_vol_up setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
203     [o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
204     FREENULL(key);
205
206     key = config_GetPsz(p_intf, "key-vol-down");
207     o_key = [NSString stringWithFormat:@"%s", key];
208     [o_mi_vol_down setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
209     [o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
210     FREENULL(key);
211
212     key = config_GetPsz(p_intf, "key-vol-mute");
213     o_key = [NSString stringWithFormat:@"%s", key];
214     [o_mi_mute setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
215     [o_mi_mute setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
216     FREENULL(key);
217
218     key = config_GetPsz(p_intf, "key-toggle-fullscreen");
219     o_key = [NSString stringWithFormat:@"%s", key];
220     [o_mi_fullscreen setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
221     [o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
222     FREENULL(key);
223
224     key = config_GetPsz(p_intf, "key-snapshot");
225     o_key = [NSString stringWithFormat:@"%s", key];
226     [o_mi_snapshot setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
227     [o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
228     FREENULL(key);
229
230     key = config_GetPsz(p_intf, "key-random");
231     o_key = [NSString stringWithFormat:@"%s", key];
232     [o_mi_random setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
233     [o_mi_random setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
234     FREENULL(key);
235
236     key = config_GetPsz(p_intf, "key-zoom-half");
237     o_key = [NSString stringWithFormat:@"%s", key];
238     [o_mi_half_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
239     [o_mi_half_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
240     FREENULL(key);
241
242     key = config_GetPsz(p_intf, "key-zoom-original");
243     o_key = [NSString stringWithFormat:@"%s", key];
244     [o_mi_normal_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
245     [o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
246     FREENULL(key);
247
248     key = config_GetPsz(p_intf, "key-zoom-double");
249     o_key = [NSString stringWithFormat:@"%s", key];
250     [o_mi_double_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
251     [o_mi_double_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
252     FREENULL(key);
253
254     [self setSubmenusEnabled: FALSE];
255
256     [[NSNotificationCenter defaultCenter] addObserver: self
257                                              selector: @selector(refreshVoutDeviceMenu:)
258                                                  name: NSApplicationDidChangeScreenParametersNotification
259                                                object: nil];
260
261     /* we're done */
262     b_mainMenu_setup = YES;
263
264     [self setupVarMenuItem: o_mi_add_intf target: (vlc_object_t *)p_intf
265                              var: "intf-add" selector: @selector(toggleVar:)];
266
267     [self setupExtensionsMenu];
268
269     [self refreshAudioDeviceList];
270
271     /* setup subtitles menu */
272     [self setupMenu: o_mu_subtitle_size withIntList:"freetype-rel-fontsize" andSelector:@selector(switchSubtitleOption:)];
273     [self setupMenu: o_mu_subtitle_textcolor withIntList:"freetype-color" andSelector:@selector(switchSubtitleOption:)];
274     [o_mi_subtitle_bgopacity_sld setIntValue: config_GetInt(VLC_OBJECT(p_intf), "freetype-background-opacity")];
275     [self setupMenu: o_mu_subtitle_bgcolor withIntList:"freetype-background-color" andSelector:@selector(switchSubtitleOption:)];
276     [self setupMenu: o_mu_subtitle_outlinethickness withIntList:"freetype-outline-thickness" andSelector:@selector(switchSubtitleOption:)];
277 }
278
279 - (void)setupMenu: (NSMenu*)menu withIntList: (char *)psz_name andSelector:(SEL)selector
280 {
281     module_config_t *p_item;
282
283     [menu removeAllItems];
284     p_item = config_FindConfig(VLC_OBJECT(p_intf), psz_name);
285
286     /* serious problem, if no item found */
287     assert(p_item);
288
289     for (int i = 0; i < p_item->list_count; i++) {
290         NSMenuItem *mi;
291         if (p_item->list_text != NULL)
292             mi = [[NSMenuItem alloc] initWithTitle: _NS(p_item->list_text[i]) action:NULL keyEquivalent: @""];
293         else if (p_item->list.i[i])
294             mi = [[NSMenuItem alloc] initWithTitle: [NSString stringWithFormat: @"%d", p_item->list.i[i]] action:NULL keyEquivalent: @""];
295         else {
296             msg_Err(p_intf, "item %d of pref %s failed to be created", i, psz_name);
297             continue;
298         }
299
300         [mi setTarget:self];
301         [mi setAction:selector];
302         [mi setTag:p_item->list.i[i]];
303         [mi setRepresentedObject:[NSString stringWithUTF8String:psz_name]];
304         [menu addItem: [mi autorelease]];
305         if (p_item->value.i == p_item->list.i[i])
306             [mi setState:NSOnState];
307     }
308 }
309
310 - (void)initStrings
311 {
312     /* main menu */
313     [o_mi_about setTitle: [_NS("About VLC media player") \
314                            stringByAppendingString: @"..."]];
315     [o_mi_checkForUpdate setTitle: _NS("Check for Update...")];
316     [o_mi_prefs setTitle: _NS("Preferences...")];
317     [o_mi_extensions setTitle: _NS("Extensions")];
318     [o_mu_extensions setTitle: _NS("Extensions")];
319     [o_mi_addonManager setTitle: _NS("Addon Manager")];
320     [o_mi_add_intf setTitle: _NS("Add Interface")];
321     [o_mu_add_intf setTitle: _NS("Add Interface")];
322     [o_mi_services setTitle: _NS("Services")];
323     [o_mi_hide setTitle: _NS("Hide VLC")];
324     [o_mi_hide_others setTitle: _NS("Hide Others")];
325     [o_mi_show_all setTitle: _NS("Show All")];
326     [o_mi_quit setTitle: _NS("Quit VLC")];
327
328     [o_mu_file setTitle: _ANS("1:File")];
329     [o_mi_open_generic setTitle: _NS("Advanced Open File...")];
330     [o_mi_open_file setTitle: _NS("Open File...")];
331     [o_mi_open_disc setTitle: _NS("Open Disc...")];
332     [o_mi_open_net setTitle: _NS("Open Network...")];
333     [o_mi_open_capture setTitle: _NS("Open Capture Device...")];
334     [o_mi_open_recent setTitle: _NS("Open Recent")];
335     [o_mi_close_window setTitle: _NS("Close Window")];
336     [o_mi_open_wizard setTitle: _NS("Streaming/Exporting Wizard...")];
337     [o_mi_convertandsave setTitle: _NS("Convert / Stream...")];
338     [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
339
340     [o_mu_edit setTitle: _NS("Edit")];
341     [o_mi_cut setTitle: _NS("Cut")];
342     [o_mi_copy setTitle: _NS("Copy")];
343     [o_mi_paste setTitle: _NS("Paste")];
344     [o_mi_clear setTitle: _NS("Clear")];
345     [o_mi_select_all setTitle: _NS("Select All")];
346
347     [o_mu_view setTitle: _NS("View")];
348     [o_mi_toggleJumpButtons setTitle: _NS("Show Previous & Next Buttons")];
349     [o_mi_toggleJumpButtons setState: config_GetInt(VLCIntf, "macosx-show-playback-buttons")];
350     [o_mi_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")];
351     [o_mi_togglePlaymodeButtons setState: config_GetInt(VLCIntf, "macosx-show-playmode-buttons")];
352     [o_mi_toggleEffectsButton setTitle: _NS("Show Audio Effects Button")];
353     [o_mi_toggleEffectsButton setState: config_GetInt(VLCIntf, "macosx-show-effects-button")];
354     [o_mi_toggleSidebar setTitle: _NS("Show Sidebar")];
355     [o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")];
356     [o_mu_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
357     [o_mi_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
358
359     [o_mu_controls setTitle: _NS("Playback")];
360     [o_mi_play setTitle: _NS("Play")];
361     [o_mi_stop setTitle: _NS("Stop")];
362     [o_mi_record setTitle: _NS("Record")];
363     [o_mi_rate setView: o_mi_rate_view];
364     [o_mi_rate_lbl setStringValue: _NS("Playback Speed")];
365     [o_mi_rate_lbl_gray setStringValue: _NS("Playback Speed")];
366     [o_mi_rate_slower_lbl setStringValue: _NS("Slower")];
367     [o_mi_rate_normal_lbl setStringValue: _NS("Normal")];
368     [o_mi_rate_faster_lbl setStringValue: _NS("Faster")];
369     [o_mi_trackSynchronization setTitle: _NS("Track Synchronization")];
370     [o_mi_previous setTitle: _NS("Previous")];
371     [o_mi_next setTitle: _NS("Next")];
372     [o_mi_random setTitle: _NS("Random")];
373     [o_mi_repeat setTitle: _NS("Repeat One")];
374     [o_mi_loop setTitle: _NS("Repeat All")];
375     [o_mi_AtoBloop setTitle: _NS("A→B Loop")];
376     [o_mi_quitAfterPB setTitle: _NS("Quit after Playback")];
377     [o_mi_fwd setTitle: _NS("Step Forward")];
378     [o_mi_bwd setTitle: _NS("Step Backward")];
379
380     [o_mi_program setTitle: _NS("Program")];
381     [o_mu_program setTitle: _NS("Program")];
382     [o_mi_title setTitle: _NS("Title")];
383     [o_mu_title setTitle: _NS("Title")];
384     [o_mi_chapter setTitle: _NS("Chapter")];
385     [o_mu_chapter setTitle: _NS("Chapter")];
386
387     [o_mu_audio setTitle: _NS("Audio")];
388     [o_mi_vol_up setTitle: _NS("Increase Volume")];
389     [o_mi_vol_down setTitle: _NS("Decrease Volume")];
390     [o_mi_mute setTitle: _NS("Mute")];
391     [o_mi_audiotrack setTitle: _NS("Audio Track")];
392     [o_mu_audiotrack setTitle: _NS("Audio Track")];
393     [o_mi_channels setTitle: _NS("Stereo audio mode")];
394     [o_mu_channels setTitle: _NS("Stereo audio mode")];
395     [o_mi_device setTitle: _NS("Audio Device")];
396     [o_mu_device setTitle: _NS("Audio Device")];
397     [o_mi_visual setTitle: _NS("Visualizations")];
398     [o_mu_visual setTitle: _NS("Visualizations")];
399
400     [o_mu_video setTitle: _NS("Video")];
401     [o_mi_half_window setTitle: _NS("Half Size")];
402     [o_mi_normal_window setTitle: _NS("Normal Size")];
403     [o_mi_double_window setTitle: _NS("Double Size")];
404     [o_mi_fittoscreen setTitle: _NS("Fit to Screen")];
405     [o_mi_fullscreen setTitle: _NS("Fullscreen")];
406     [o_mi_floatontop setTitle: _NS("Float on Top")];
407     [o_mi_snapshot setTitle: _NS("Snapshot")];
408     [o_mi_videotrack setTitle: _NS("Video Track")];
409     [o_mu_videotrack setTitle: _NS("Video Track")];
410     [o_mi_aspect_ratio setTitle: _NS("Aspect ratio")];
411     [o_mu_aspect_ratio setTitle: _NS("Aspect ratio")];
412     [o_mi_crop setTitle: _NS("Crop")];
413     [o_mu_crop setTitle: _NS("Crop")];
414     [o_mi_screen setTitle: _NS("Fullscreen Video Device")];
415     [o_mu_screen setTitle: _NS("Fullscreen Video Device")];
416     [o_mi_deinterlace setTitle: _NS("Deinterlace")];
417     [o_mu_deinterlace setTitle: _NS("Deinterlace")];
418     [o_mi_deinterlace_mode setTitle: _NS("Deinterlace mode")];
419     [o_mu_deinterlace_mode setTitle: _NS("Deinterlace mode")];
420     [o_mi_ffmpeg_pp setTitle: _NS("Post processing")];
421     [o_mu_ffmpeg_pp setTitle: _NS("Post processing")];
422
423     [o_mu_subtitles setTitle:_NS("Subtitles")];
424     [o_mi_openSubtitleFile setTitle: _NS("Add Subtitle File...")];
425     [o_mi_subtitle_track setTitle: _NS("Subtitles Track")];
426     [o_mu_subtitle_tracks setTitle: _NS("Subtitles Track")];
427     [o_mi_subtitle_size setTitle: _NS("Text Size")];
428     [o_mi_subtitle_textcolor setTitle: _NS("Text Color")];
429     [o_mi_subtitle_outlinethickness setTitle: _NS("Outline Thickness")];
430     [o_mi_subtitle_bgopacity setView: o_mi_subtitle_bgopacity_view];
431     [o_mi_subtitle_bgopacity_lbl setStringValue: _NS("Background Opacity")];
432     [o_mi_subtitle_bgopacity_lbl_gray setStringValue: _NS("Background Opacity")];
433     [o_mi_subtitle_bgcolor setTitle: _NS("Background Color")];
434     [o_mi_teletext setTitle: _NS("Teletext")];
435     [o_mi_teletext_transparent setTitle: _NS("Transparent")];
436     [o_mi_teletext_index setTitle: _NS("Index")];
437     [o_mi_teletext_red setTitle: _NS("Red")];
438     [o_mi_teletext_green setTitle: _NS("Green")];
439     [o_mi_teletext_yellow setTitle: _NS("Yellow")];
440     [o_mi_teletext_blue setTitle: _NS("Blue")];
441
442     [o_mu_window setTitle: _NS("Window")];
443     [o_mi_minimize setTitle: _NS("Minimize")];
444     [o_mi_zoom_window setTitle: _NS("Zoom")];
445     [o_mi_player setTitle: _NS("Player...")];
446     [o_mi_controller setTitle: _NS("Main Window...")];
447     [o_mi_audioeffects setTitle: _NS("Audio Effects...")];
448     [o_mi_videoeffects setTitle: _NS("Video Effects...")];
449     [o_mi_bookmarks setTitle: _NS("Bookmarks...")];
450     [o_mi_playlist setTitle: _NS("Playlist...")];
451     [o_mi_info setTitle: _NS("Media Information...")];
452     [o_mi_messages setTitle: _NS("Messages...")];
453     [o_mi_errorsAndWarnings setTitle: _NS("Errors and Warnings...")];
454
455     [o_mi_bring_atf setTitle: _NS("Bring All to Front")];
456
457     [o_mu_help setTitle: _NS("Help")];
458     [o_mi_help setTitle: _NS("VLC media player Help...")];
459     [o_mi_readme setTitle: _NS("ReadMe / FAQ...")];
460     [o_mi_license setTitle: _NS("License")];
461     [o_mi_documentation setTitle: _NS("Online Documentation...")];
462     [o_mi_website setTitle: _NS("VideoLAN Website...")];
463     [o_mi_donation setTitle: _NS("Make a donation...")];
464     [o_mi_forum setTitle: _NS("Online Forum...")];
465
466     /* dock menu */
467     [o_dmi_play setTitle: _NS("Play")];
468     [o_dmi_stop setTitle: _NS("Stop")];
469     [o_dmi_next setTitle: _NS("Next")];
470     [o_dmi_previous setTitle: _NS("Previous")];
471     [o_dmi_mute setTitle: _NS("Mute")];
472
473     /* vout menu */
474     [o_vmi_play setTitle: _NS("Play")];
475     [o_vmi_stop setTitle: _NS("Stop")];
476     [o_vmi_prev setTitle: _NS("Previous")];
477     [o_vmi_next setTitle: _NS("Next")];
478     [o_vmi_volup setTitle: _NS("Volume Up")];
479     [o_vmi_voldown setTitle: _NS("Volume Down")];
480     [o_vmi_mute setTitle: _NS("Mute")];
481     [o_vmi_fullscreen setTitle: _NS("Fullscreen")];
482     [o_vmi_snapshot setTitle: _NS("Snapshot")];
483 }
484
485 - (NSMenu *)setupPlaylistTableColumnsMenu
486 {
487     NSMenu *o_context_menu = [[NSMenu alloc] init];
488
489     NSMenuItem *o_mi_tmp;
490     NSUInteger count = [o_ptc_menuorder count];
491     for (NSUInteger i = 0; i < count; i++) {
492         NSString *o_title = [o_ptc_translation_dict objectForKey:[o_ptc_menuorder objectAtIndex:i]];
493         o_mi_tmp = [o_mu_playlistTableColumns addItemWithTitle:o_title
494                                                         action:@selector(togglePlaylistColumnTable:)
495                                                  keyEquivalent:@""];
496         /* don't set a valid target for the title column selector, since we want it to be disabled */
497         if (![[o_ptc_menuorder objectAtIndex:i] isEqualToString: TITLE_COLUMN])
498             [o_mi_tmp setTarget:self];
499         [o_mi_tmp setTag:i];
500
501         o_mi_tmp = [o_context_menu addItemWithTitle:o_title
502                                              action:@selector(togglePlaylistColumnTable:)
503                                       keyEquivalent:@""];
504         /* don't set a valid target for the title column selector, since we want it to be disabled */
505         if (![[o_ptc_menuorder objectAtIndex:i] isEqualToString: TITLE_COLUMN])
506             [o_mi_tmp setTarget:self];
507         [o_mi_tmp setTag:i];
508     }
509     if (!o_mu_playlistTableColumnsContextMenu)
510         o_mu_playlistTableColumnsContextMenu = [o_context_menu retain];
511     return [o_context_menu autorelease];
512 }
513
514 #pragma mark -
515 #pragma mark Termination
516
517 - (void)releaseRepresentedObjects:(NSMenu *)the_menu
518 {
519     if (!p_intf) return;
520
521     NSArray *menuitems_array = [the_menu itemArray];
522     NSUInteger menuItemCount = [menuitems_array count];
523     for (NSUInteger i=0; i < menuItemCount; i++) {
524         NSMenuItem *one_item = [menuitems_array objectAtIndex:i];
525         if ([one_item hasSubmenu])
526             [self releaseRepresentedObjects: [one_item submenu]];
527
528         [one_item setRepresentedObject:NULL];
529     }
530 }
531
532 #pragma mark -
533 #pragma mark Interface update
534
535 - (void)setupMenus
536 {
537     playlist_t * p_playlist = pl_Get(p_intf);
538     input_thread_t * p_input = playlist_CurrentInput(p_playlist);
539     if (p_input != NULL) {
540         [o_mi_record setEnabled: var_GetBool(p_input, "can-record")];
541
542         [self setupVarMenuItem: o_mi_program target: (vlc_object_t *)p_input
543                                  var: "program" selector: @selector(toggleVar:)];
544
545         [self setupVarMenuItem: o_mi_title target: (vlc_object_t *)p_input
546                                  var: "title" selector: @selector(toggleVar:)];
547
548         [self setupVarMenuItem: o_mi_chapter target: (vlc_object_t *)p_input
549                                  var: "chapter" selector: @selector(toggleVar:)];
550
551         [self setupVarMenuItem: o_mi_audiotrack target: (vlc_object_t *)p_input
552                                  var: "audio-es" selector: @selector(toggleVar:)];
553
554         [self setupVarMenuItem: o_mi_videotrack target: (vlc_object_t *)p_input
555                                  var: "video-es" selector: @selector(toggleVar:)];
556
557         [self setupVarMenuItem: o_mi_subtitle_track target: (vlc_object_t *)p_input
558                                  var: "spu-es" selector: @selector(toggleVar:)];
559
560         audio_output_t * p_aout = playlist_GetAout(p_playlist);
561         if (p_aout != NULL) {
562             [self setupVarMenuItem: o_mi_channels target: (vlc_object_t *)p_aout
563                                      var: "stereo-mode" selector: @selector(toggleVar:)];
564
565             [self setupVarMenuItem: o_mi_visual target: (vlc_object_t *)p_aout
566                                      var: "visual" selector: @selector(toggleVar:)];
567             vlc_object_release(p_aout);
568         }
569
570         vout_thread_t * p_vout = getVoutForActiveWindow();
571
572         if (p_vout != NULL) {
573             [self setupVarMenuItem: o_mi_aspect_ratio target: (vlc_object_t *)p_vout
574                                      var: "aspect-ratio" selector: @selector(toggleVar:)];
575
576             [self setupVarMenuItem: o_mi_crop target: (vlc_object_t *) p_vout
577                                      var: "crop" selector: @selector(toggleVar:)];
578
579             [self setupVarMenuItem: o_mi_deinterlace target: (vlc_object_t *)p_vout
580                                      var: "deinterlace" selector: @selector(toggleVar:)];
581
582             [self setupVarMenuItem: o_mi_deinterlace_mode target: (vlc_object_t *)p_vout
583                                      var: "deinterlace-mode" selector: @selector(toggleVar:)];
584
585             [self setupVarMenuItem: o_mi_ffmpeg_pp target: (vlc_object_t *)p_vout
586                                var:"postprocess" selector: @selector(toggleVar:)];
587
588             vlc_object_release(p_vout);
589
590             [self refreshVoutDeviceMenu:nil];
591         }
592         vlc_object_release(p_input);
593     }
594     else
595         [o_mi_record setEnabled: NO];
596 }
597
598 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification
599 {
600     NSUInteger count = (NSUInteger) [o_mu_screen numberOfItems];
601     NSMenu * o_submenu = o_mu_screen;
602     if (count > 0)
603         [o_submenu removeAllItems];
604
605     NSArray * o_screens = [NSScreen screens];
606     NSMenuItem * o_mitem;
607     count = [o_screens count];
608     [o_mi_screen setEnabled: YES];
609     [o_submenu addItemWithTitle: _NS("Default") action:@selector(toggleFullscreenDevice:) keyEquivalent:@""];
610     o_mitem = [o_submenu itemAtIndex: 0];
611     [o_mitem setTag: 0];
612     [o_mitem setEnabled: YES];
613     [o_mitem setTarget: self];
614     NSRect s_rect;
615     for (NSUInteger i = 0; i < count; i++) {
616         s_rect = [[o_screens objectAtIndex:i] frame];
617         [o_submenu addItemWithTitle: [NSString stringWithFormat: @"%@ %li (%ix%i)", _NS("Screen"), i+1,
618                                       (int)s_rect.size.width, (int)s_rect.size.height] action:@selector(toggleFullscreenDevice:) keyEquivalent:@""];
619         o_mitem = [o_submenu itemAtIndex:i+1];
620         [o_mitem setTag: (int)[[o_screens objectAtIndex:i] displayID]];
621         [o_mitem setEnabled: YES];
622         [o_mitem setTarget: self];
623     }
624     [[o_submenu itemWithTag: var_InheritInteger(VLCIntf, "macosx-vdev")] setState: NSOnState];
625 }
626
627 - (void)setSubmenusEnabled:(BOOL)b_enabled
628 {
629     [o_mi_program setEnabled: b_enabled];
630     [o_mi_title setEnabled: b_enabled];
631     [o_mi_chapter setEnabled: b_enabled];
632     [o_mi_audiotrack setEnabled: b_enabled];
633     [o_mi_visual setEnabled: b_enabled];
634     [o_mi_videotrack setEnabled: b_enabled];
635     [o_mi_subtitle_track setEnabled: b_enabled];
636     [o_mi_channels setEnabled: b_enabled];
637     [o_mi_deinterlace setEnabled: b_enabled];
638     [o_mi_deinterlace_mode setEnabled: b_enabled];
639     [o_mi_ffmpeg_pp setEnabled: b_enabled];
640     [o_mi_screen setEnabled: b_enabled];
641     [o_mi_aspect_ratio setEnabled: b_enabled];
642     [o_mi_crop setEnabled: b_enabled];
643 }
644
645 - (void)setSubtitleMenuEnabled:(BOOL)b_enabled
646 {
647     [o_mi_openSubtitleFile setEnabled: b_enabled];
648     if (b_enabled) {
649         [o_mi_subtitle_bgopacity_lbl_gray setHidden: YES];
650         [o_mi_subtitle_bgopacity_lbl setHidden: NO];
651     } else {
652         [o_mi_subtitle_bgopacity_lbl_gray setHidden: NO];
653         [o_mi_subtitle_bgopacity_lbl setHidden: YES];
654     }
655     [o_mi_subtitle_bgopacity_sld setEnabled: b_enabled];
656     [o_mi_teletext setEnabled: b_enabled];
657 }
658
659 - (void)setRateControlsEnabled:(BOOL)b_enabled
660 {
661     NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
662     [o_mi_rate_sld setEnabled: b_enabled];
663     [o_mi_rate_sld setIntValue: [[VLCCoreInteraction sharedInstance] playbackRate]];
664     int i = [[VLCCoreInteraction sharedInstance] playbackRate];
665     double speed =  pow(2, (double)i / 17);
666     [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
667     if (b_enabled) {
668         [o_mi_rate_lbl setHidden: NO];
669         [o_mi_rate_lbl_gray setHidden: YES];
670     } else {
671         [o_mi_rate_lbl setHidden: YES];
672         [o_mi_rate_lbl_gray setHidden: NO];
673     }
674     [self setSubtitleMenuEnabled: b_enabled];
675     [o_pool release];
676 }
677
678 #pragma mark -
679 #pragma mark Extensions
680
681 - (void)setupExtensionsMenu
682 {
683     /* Load extensions if needed */
684     // TODO: Implement preference for autoloading extensions on mac
685
686     // if (!var_InheritBool(p_intf, "qt-autoload-extensions")
687     //     && ![o_extMgr isLoaded])
688     // {
689     //     return;
690     // }
691
692     if (![o_extMgr isLoaded] && ![o_extMgr cannotLoad]) {
693         [o_extMgr loadExtensions];
694     }
695
696     /* Let the ExtensionsManager itself build the menu */
697     [o_extMgr buildMenu:o_mu_extensions];
698     [o_mi_extensions setEnabled: ([o_mu_extensions numberOfItems] > 0)];
699 }
700
701 #pragma mark -
702 #pragma mark View
703
704 - (IBAction)toggleEffectsButton:(id)sender
705 {
706     BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-effects-button");
707     config_PutInt(VLCIntf, "macosx-show-effects-button", b_value);
708     [[[[VLCMain sharedInstance] mainWindow] controlsBar] toggleEffectsButton];
709     [o_mi_toggleEffectsButton setState: b_value];
710 }
711
712 - (IBAction)toggleJumpButtons:(id)sender
713 {
714     BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-playback-buttons");
715     config_PutInt(VLCIntf, "macosx-show-playback-buttons", b_value);
716
717     [[[[VLCMain sharedInstance] mainWindow] controlsBar] toggleJumpButtons];
718     [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
719         [[o_window controlsBar] toggleForwardBackwardMode: b_value];
720     }];
721
722     [o_mi_toggleJumpButtons setState: b_value];
723 }
724
725 - (IBAction)togglePlaymodeButtons:(id)sender
726 {
727     BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-playmode-buttons");
728     config_PutInt(VLCIntf, "macosx-show-playmode-buttons", b_value);
729     [[[[VLCMain sharedInstance] mainWindow] controlsBar] togglePlaymodeButtons];
730     [o_mi_togglePlaymodeButtons setState: b_value];
731 }
732
733 - (IBAction)toggleSidebar:(id)sender
734 {
735     [[[VLCMain sharedInstance] mainWindow] toggleLeftSubSplitView];
736 }
737
738 - (void)updateSidebarMenuItem
739 {
740     [o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")];
741 }
742
743 - (IBAction)togglePlaylistColumnTable:(id)sender
744 {
745     NSInteger i_new_state = ![sender state];
746     NSInteger i_tag = [sender tag];
747     [[o_mu_playlistTableColumns            itemWithTag: i_tag] setState: i_new_state];
748     [[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_new_state];
749
750     NSString *o_column = [o_ptc_menuorder objectAtIndex:i_tag];
751     [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_new_state translationDict: o_ptc_translation_dict];
752 }
753
754 - (BOOL)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column
755 {
756     NSUInteger i_tag = [o_ptc_menuorder indexOfObject: o_column];
757     // prevent setting unknown columns
758     if(i_tag == NSNotFound)
759         return NO;
760
761     [[o_mu_playlistTableColumns            itemWithTag: i_tag] setState: i_state];
762     [[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_state];
763     [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_state translationDict: o_ptc_translation_dict];
764
765     return YES;
766 }
767
768 #pragma mark -
769 #pragma mark Playback
770
771 - (IBAction)quitAfterPlayback:(id)sender
772 {
773     playlist_t *p_playlist = pl_Get(VLCIntf);
774     bool b_value = !var_CreateGetBool(p_playlist, "play-and-exit");
775     var_SetBool(p_playlist, "play-and-exit", b_value);
776     config_PutInt(p_intf, "play-and-exit", b_value);
777 }
778
779 - (IBAction)toggleRecord:(id)sender
780 {
781     [[VLCCoreInteraction sharedInstance] toggleRecord];
782 }
783
784 - (void)updateRecordState:(BOOL)b_value
785 {
786     [o_mi_record setState:b_value];
787 }
788
789 - (IBAction)setPlaybackRate:(id)sender
790 {
791     [[VLCCoreInteraction sharedInstance] setPlaybackRate: [o_mi_rate_sld intValue]];
792     int i = [[VLCCoreInteraction sharedInstance] playbackRate];
793     double speed =  pow(2, (double)i / 17);
794     [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
795 }
796
797 - (void)updatePlaybackRate
798 {
799     int i = [[VLCCoreInteraction sharedInstance] playbackRate];
800     double speed =  pow(2, (double)i / 17);
801     [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
802     [o_mi_rate_sld setIntValue: i];
803 }
804
805 - (IBAction)toggleAtoBloop:(id)sender
806 {
807     [[VLCCoreInteraction sharedInstance] setAtoB];
808 }
809
810 #pragma mark -
811 #pragma mark audio menu
812 - (void)refreshAudioDeviceList
813 {
814     char **ids, **names;
815     char *currentDevice;
816
817     [o_mu_device removeAllItems];
818
819     audio_output_t * p_aout = getAout();
820     if (!p_aout)
821         return;
822
823     int n = aout_DevicesList(p_aout, &ids, &names);
824     if (n == -1) {
825         vlc_object_release(p_aout);
826         return;
827     }
828
829     currentDevice = aout_DeviceGet(p_aout);
830     NSMenuItem * o_mi_tmp;
831
832     for (NSUInteger x = 0; x < n; x++) {
833         o_mi_tmp = [o_mu_device addItemWithTitle:toNSStr(names[x]) action:@selector(toggleAudioDevice:) keyEquivalent:@""];
834         [o_mi_tmp setTarget:self];
835         [o_mi_tmp setTag:[[NSString stringWithFormat:@"%s", ids[x]] intValue]];
836     }
837     vlc_object_release(p_aout);
838
839     [[o_mu_device itemWithTag:[[NSString stringWithFormat:@"%s", currentDevice] intValue]] setState:NSOnState];
840
841     free(currentDevice);
842
843     for (NSUInteger x = 0; x < n; x++) {
844         free(ids[x]);
845         free(names[x]);
846     }
847     free(ids);
848     free(names);
849
850     [o_mu_device setAutoenablesItems:YES];
851     [o_mi_device setEnabled:YES];
852 }
853
854 - (IBAction)toggleAudioDevice:(id)sender
855 {
856     audio_output_t * p_aout = getAout();
857     if (!p_aout)
858         return;
859
860     int returnValue = 0;
861
862     if ([sender tag] > 0)
863         returnValue = aout_DeviceSet(p_aout, [[NSString stringWithFormat:@"%li", [sender tag]] UTF8String]);
864     else
865         returnValue = aout_DeviceSet(p_aout, NULL);
866
867     if (returnValue != 0)
868         msg_Warn(VLCIntf, "failed to set audio device %li", [sender tag]);
869
870     vlc_object_release(p_aout);
871     [self refreshAudioDeviceList];
872 }
873
874 #pragma mark -
875 #pragma mark video menu
876
877 - (IBAction)toggleFullscreen:(id)sender
878 {
879     [[VLCCoreInteraction sharedInstance] toggleFullscreen];
880 }
881
882 - (IBAction)resizeVideoWindow:(id)sender
883 {
884     input_thread_t *p_input = pl_CurrentInput(VLCIntf);
885     if (p_input) {
886         vout_thread_t *p_vout = getVoutForActiveWindow();
887         if (p_vout) {
888             if (sender == o_mi_half_window)
889                 var_SetFloat(p_vout, "zoom", 0.5);
890             else if (sender == o_mi_normal_window)
891                 var_SetFloat(p_vout, "zoom", 1.0);
892             else if (sender == o_mi_double_window)
893                 var_SetFloat(p_vout, "zoom", 2.0);
894             else
895             {
896                 [[NSApp keyWindow] performZoom:sender];
897             }
898             vlc_object_release(p_vout);
899         }
900         vlc_object_release(p_input);
901     }
902 }
903
904 - (IBAction)floatOnTop:(id)sender
905 {
906     input_thread_t *p_input = pl_CurrentInput(VLCIntf);
907     if (p_input) {
908         vout_thread_t *p_vout = getVoutForActiveWindow();
909         if (p_vout) {
910             var_ToggleBool(p_vout, "video-on-top");
911             vlc_object_release(p_vout);
912         }
913         vlc_object_release(p_input);
914     }
915 }
916
917 - (IBAction)createVideoSnapshot:(id)sender
918 {
919     input_thread_t *p_input = pl_CurrentInput(VLCIntf);
920     if (p_input) {
921         vout_thread_t *p_vout = getVoutForActiveWindow();
922         if (p_vout) {
923             var_TriggerCallback(p_vout, "video-snapshot");
924             vlc_object_release(p_vout);
925         }
926         vlc_object_release(p_input);
927     }
928 }
929
930 - (IBAction)toggleFullscreenDevice:(id)sender
931 {
932     config_PutInt(VLCIntf, "macosx-vdev", [sender tag]);
933     [self refreshVoutDeviceMenu: nil];
934 }
935
936 - (id)voutMenu
937 {
938     return o_vout_menu;
939 }
940
941 #pragma mark - Subtitles Menu
942 - (IBAction)addSubtitleFile:(id)sender
943 {
944     NSInteger i_returnValue = 0;
945     input_thread_t * p_input = pl_CurrentInput(VLCIntf);
946     if (!p_input)
947         return;
948
949     input_item_t *p_item = input_GetItem(p_input);
950     if (!p_item) {
951         vlc_object_release(p_input);
952         return;
953     }
954
955     char *path = input_item_GetURI(p_item);
956
957     if (!path)
958         path = strdup("");
959
960     NSOpenPanel * openPanel = [NSOpenPanel openPanel];
961     [openPanel setCanChooseFiles: YES];
962     [openPanel setCanChooseDirectories: NO];
963     [openPanel setAllowsMultipleSelection: YES];
964
965     [openPanel setAllowedFileTypes: [NSArray arrayWithObjects:@"cdg",@"idx",@"srt",@"sub",@"utf",@"ass",@"ssa",@"aqt",@"jss",@"psb",@"rt",@"smi",@"txt",@"smil",nil]];
966
967     NSURL *o_url = [NSURL URLWithString:[[NSString stringWithUTF8String:path] stringByExpandingTildeInPath]];
968     o_url = [o_url URLByDeletingLastPathComponent];
969     [openPanel setDirectoryURL: o_url];
970     free(path);
971
972     i_returnValue = [openPanel runModal];
973
974     if (i_returnValue == NSOKButton) {
975         NSUInteger c = 0;
976         if (!p_input)
977             return;
978
979         c = [[openPanel URLs] count];
980
981         for (int i = 0; i < c ; i++) {
982             msg_Dbg(VLCIntf, "loading subs from %s", [[[[openPanel URLs] objectAtIndex:i] path] UTF8String]);
983             if (input_AddSubtitle(p_input, [[[[openPanel URLs] objectAtIndex:i] path] UTF8String], TRUE))
984                 msg_Warn(VLCIntf, "unable to load subtitles from '%s'",
985                          [[[[openPanel URLs] objectAtIndex:i] path] UTF8String]);
986         }
987     }
988     vlc_object_release(p_input);
989 }
990
991 - (IBAction)switchSubtitleOption:(id)sender
992 {
993     int intValue = [sender tag];
994     NSString *representedObject = [sender representedObject];
995
996     config_PutInt(p_intf, [representedObject UTF8String], intValue);
997
998     NSMenu *menu = [sender menu];
999     NSUInteger count = (NSUInteger) [menu numberOfItems];
1000     for (NSUInteger x = 0; x < count; x++)
1001         [[menu itemAtIndex:x] setState:NSOffState];
1002     [[menu itemWithTag:intValue] setState:NSOnState];
1003 }
1004
1005 - (IBAction)switchSubtitleBackgroundOpacity:(id)sender
1006 {
1007     config_PutInt(p_intf, "freetype-background-opacity", [sender intValue]);
1008 }
1009
1010 - (IBAction)telxTransparent:(id)sender
1011 {
1012     vlc_object_t *p_vbi;
1013     p_vbi = (vlc_object_t *) vlc_object_find_name(pl_Get(VLCIntf), "zvbi");
1014     if (p_vbi) {
1015         var_SetBool(p_vbi, "vbi-opaque", [sender state]);
1016         [sender setState: ![sender state]];
1017         vlc_object_release(p_vbi);
1018     }
1019 }
1020
1021 - (IBAction)telxNavLink:(id)sender
1022 {
1023     vlc_object_t *p_vbi;
1024     int i_page = 0;
1025
1026     if ([[sender title] isEqualToString: _NS("Index")])
1027         i_page = 'i' << 16;
1028     else if ([[sender title] isEqualToString: _NS("Red")])
1029         i_page = 'r' << 16;
1030     else if ([[sender title] isEqualToString: _NS("Green")])
1031         i_page = 'g' << 16;
1032     else if ([[sender title] isEqualToString: _NS("Yellow")])
1033         i_page = 'y' << 16;
1034     else if ([[sender title] isEqualToString: _NS("Blue")])
1035         i_page = 'b' << 16;
1036     if (i_page == 0) return;
1037
1038     p_vbi = (vlc_object_t *) vlc_object_find_name(pl_Get(VLCIntf), "zvbi");
1039     if (p_vbi) {
1040         var_SetInteger(p_vbi, "vbi-page", i_page);
1041         vlc_object_release(p_vbi);
1042     }
1043 }
1044
1045 #pragma mark -
1046 #pragma mark Panels
1047
1048 - (IBAction)intfOpenFile:(id)sender
1049 {
1050     [[[VLCMain sharedInstance] open] openFile];
1051 }
1052
1053 - (IBAction)intfOpenFileGeneric:(id)sender
1054 {
1055     [[[VLCMain sharedInstance] open] openFileGeneric];
1056 }
1057
1058 - (IBAction)intfOpenDisc:(id)sender
1059 {
1060     [[[VLCMain sharedInstance] open] openDisc];
1061 }
1062
1063 - (IBAction)intfOpenNet:(id)sender
1064 {
1065     [[[VLCMain sharedInstance] open] openNet];
1066 }
1067
1068 - (IBAction)intfOpenCapture:(id)sender
1069 {
1070     [[[VLCMain sharedInstance] open] openCapture];
1071 }
1072
1073 - (IBAction)showWizard:(id)sender
1074 {
1075     [[[VLCMain sharedInstance] wizard] resetWizard];
1076     [[[VLCMain sharedInstance] wizard] showWizard];
1077 }
1078
1079 - (IBAction)savePlaylist:(id)sender
1080 {
1081     [[[VLCMain sharedInstance] playlist] savePlaylist:sender];
1082 }
1083
1084 - (IBAction)showConvertAndSave:(id)sender
1085 {
1086     if (o_convertandsave == nil)
1087         o_convertandsave = [[VLCConvertAndSave alloc] init];
1088
1089     if (!b_nib_convertandsave_loaded)
1090         b_nib_convertandsave_loaded = [NSBundle loadNibNamed:@"ConvertAndSave" owner: NSApp];
1091
1092     [o_convertandsave toggleWindow];
1093 }
1094
1095 - (IBAction)showVideoEffects:(id)sender
1096 {
1097     if (o_videoeffects == nil)
1098         o_videoeffects = [[VLCVideoEffects alloc] init];
1099
1100     if (!b_nib_videoeffects_loaded)
1101         b_nib_videoeffects_loaded = [NSBundle loadNibNamed:@"VideoEffects" owner: NSApp];
1102
1103     [o_videoeffects toggleWindow:sender];
1104 }
1105
1106 - (IBAction)showTrackSynchronization:(id)sender
1107 {
1108     if (!o_trackSynchronization)
1109         o_trackSynchronization = [[VLCTrackSynchronization alloc] init];
1110
1111     if (!b_nib_tracksynchro_loaded)
1112         b_nib_tracksynchro_loaded = [NSBundle loadNibNamed:@"SyncTracks" owner:NSApp];
1113
1114     [o_trackSynchronization toggleWindow:sender];
1115 }
1116
1117 - (IBAction)showAudioEffects:(id)sender
1118 {
1119     if (!o_audioeffects)
1120         o_audioeffects = [[VLCAudioEffects alloc] init];
1121
1122     if (!b_nib_audioeffects_loaded)
1123         b_nib_audioeffects_loaded = [NSBundle loadNibNamed:@"AudioEffects" owner:NSApp];
1124
1125     [o_audioeffects toggleWindow:sender];
1126 }
1127
1128 - (IBAction)showBookmarks:(id)sender
1129 {
1130     [[[VLCMain sharedInstance] bookmarks] showBookmarks];
1131 }
1132
1133 - (IBAction)viewPreferences:(id)sender
1134 {
1135     NSInteger i_level = [[[VLCMain sharedInstance] voutController] currentWindowLevel];
1136     [[[VLCMain sharedInstance] simplePreferences] showSimplePrefsWithLevel:i_level];
1137 }
1138
1139 - (IBAction)openAddonManager:(id)sender
1140 {
1141     if (!o_addonManager)
1142         o_addonManager = [[VLCAddonManager alloc] init];
1143
1144     if (!b_nib_addonmanager_loaded)
1145         b_nib_addonmanager_loaded = [NSBundle loadNibNamed:@"AddonManager" owner:NSApp];
1146
1147     [o_addonManager showWindow];
1148 }
1149
1150 - (IBAction)showMessagesPanel:(id)showMessagesPanel
1151 {
1152     [[VLCDebugMessageVisualizer sharedInstance] showPanel];
1153 }
1154
1155 - (IBAction)showMainWindow:(id)sender
1156 {
1157     [[VLCMainWindow sharedInstance] makeKeyAndOrderFront:sender];
1158 }
1159
1160 - (IBAction)showPlaylist:(id)sender
1161 {
1162     [[VLCMainWindow sharedInstance] changePlaylistState: psUserMenuEvent];
1163 }
1164
1165 #pragma mark -
1166 #pragma mark Help and Docs
1167
1168 - (void)initAbout
1169 {
1170     if (! o_about)
1171         o_about = [[VLAboutBox alloc] init];
1172
1173     if (!b_nib_about_loaded)
1174         b_nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp];
1175 }
1176
1177 - (IBAction)viewAbout:(id)sender
1178 {
1179     [self initAbout];
1180     [o_about showAbout];
1181 }
1182
1183 - (IBAction)showLicense:(id)sender
1184 {
1185     [self initAbout];
1186     [o_about showGPL];
1187 }
1188
1189 - (IBAction)viewHelp:(id)sender
1190 {
1191     [self initAbout];
1192     [o_about showHelp];
1193 }
1194
1195 - (IBAction)openReadMe:(id)sender
1196 {
1197     NSString * o_path = [[NSBundle mainBundle] pathForResource: @"README.MacOSX" ofType: @"rtf"];
1198
1199     [[NSWorkspace sharedWorkspace] openFile: o_path withApplication: @"TextEdit"];
1200 }
1201
1202 - (IBAction)openDocumentation:(id)sender
1203 {
1204     NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/doc/"];
1205
1206     [[NSWorkspace sharedWorkspace] openURL: o_url];
1207 }
1208
1209 - (IBAction)openWebsite:(id)sender
1210 {
1211     NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/"];
1212
1213     [[NSWorkspace sharedWorkspace] openURL: o_url];
1214 }
1215
1216 - (IBAction)openForum:(id)sender
1217 {
1218     NSURL * o_url = [NSURL URLWithString: @"http://forum.videolan.org/"];
1219
1220     [[NSWorkspace sharedWorkspace] openURL: o_url];
1221 }
1222
1223 - (IBAction)openDonate:(id)sender
1224 {
1225     NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/contribute.html#paypal"];
1226
1227     [[NSWorkspace sharedWorkspace] openURL: o_url];
1228 }
1229
1230 #pragma mark -
1231 #pragma mark Errors, warnings and messages
1232
1233 - (IBAction)viewErrorsAndWarnings:(id)sender
1234 {
1235     [[[[VLCMain sharedInstance] coreDialogProvider] errorPanel] showPanel];
1236 }
1237
1238 - (IBAction)showInformationPanel:(id)sender
1239 {
1240     [[[VLCMain sharedInstance] info] initPanel];
1241 }
1242
1243 #pragma mark -
1244 #pragma mark convinience stuff for other objects
1245 - (void)setPlay
1246 {
1247     [o_mi_play setTitle: _NS("Play")];
1248     [o_dmi_play setTitle: _NS("Play")];
1249     [o_vmi_play setTitle: _NS("Play")];
1250 }
1251
1252 - (void)setPause
1253 {
1254     [o_mi_play setTitle: _NS("Pause")];
1255     [o_dmi_play setTitle: _NS("Pause")];
1256     [o_vmi_play setTitle: _NS("Pause")];
1257 }
1258
1259 - (void)setRepeatOne
1260 {
1261     [o_mi_repeat setState: NSOnState];
1262     [o_mi_loop setState: NSOffState];
1263 }
1264
1265 - (void)setRepeatAll
1266 {
1267     [o_mi_repeat setState: NSOffState];
1268     [o_mi_loop setState: NSOnState];
1269 }
1270
1271 - (void)setRepeatOff
1272 {
1273     [o_mi_repeat setState: NSOffState];
1274     [o_mi_loop setState: NSOffState];
1275 }
1276
1277 - (void)setShuffle
1278 {
1279     bool b_value;
1280     playlist_t *p_playlist = pl_Get(VLCIntf);
1281     b_value = var_GetBool(p_playlist, "random");
1282
1283     [o_mi_random setState: b_value];
1284 }
1285
1286 #pragma mark -
1287 #pragma mark Dynamic menu creation and validation
1288
1289 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
1290                   target:(vlc_object_t *)p_object
1291                      var:(const char *)psz_variable
1292                 selector:(SEL)pf_callback
1293 {
1294     vlc_value_t val, text;
1295     int i_type = var_Type(p_object, psz_variable);
1296
1297     switch(i_type & VLC_VAR_TYPE) {
1298         case VLC_VAR_VOID:
1299         case VLC_VAR_BOOL:
1300         case VLC_VAR_VARIABLE:
1301         case VLC_VAR_STRING:
1302         case VLC_VAR_INTEGER:
1303             break;
1304         default:
1305             /* Variable doesn't exist or isn't handled */
1306             msg_Warn(p_object, "variable %s doesn't exist or isn't handled", psz_variable);
1307             return;
1308     }
1309
1310     /* Get the descriptive name of the variable */
1311     var_Change(p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL);
1312     [o_mi setTitle: _NS(text.psz_string ? text.psz_string : psz_variable)];
1313
1314     if (i_type & VLC_VAR_HASCHOICE) {
1315         NSMenu *o_menu = [o_mi submenu];
1316
1317         [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
1318                        var:psz_variable selector:pf_callback];
1319
1320         free(text.psz_string);
1321         return;
1322     }
1323
1324     if (var_Get(p_object, psz_variable, &val) < 0)
1325         return;
1326
1327     VLCAutoGeneratedMenuContent *o_data;
1328     switch(i_type & VLC_VAR_TYPE) {
1329         case VLC_VAR_VOID:
1330             o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1331                                                                       andValue: val ofType: i_type];
1332             [o_mi setRepresentedObject: [o_data autorelease]];
1333             break;
1334
1335         case VLC_VAR_BOOL:
1336             o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1337                                                                       andValue: val ofType: i_type];
1338             [o_mi setRepresentedObject: [o_data autorelease]];
1339             if (!(i_type & VLC_VAR_ISCOMMAND))
1340                 [o_mi setState: val.b_bool ? TRUE : FALSE ];
1341             break;
1342
1343         default:
1344             break;
1345     }
1346
1347     if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
1348     free(text.psz_string);
1349 }
1350
1351
1352 - (void)setupVarMenu:(NSMenu *)o_menu
1353          forMenuItem: (NSMenuItem *)o_parent
1354               target:(vlc_object_t *)p_object
1355                  var:(const char *)psz_variable
1356             selector:(SEL)pf_callback
1357 {
1358     vlc_value_t val, val_list, text_list;
1359     int i_type, i;
1360
1361     /* remove previous items */
1362     [o_menu removeAllItems];
1363
1364     /* we disable everything here, and enable it again when needed, below */
1365     [o_parent setEnabled:NO];
1366
1367     /* Aspect Ratio */
1368     if ([[o_parent title] isEqualToString: _NS("Aspect ratio")] == YES) {
1369         NSMenuItem *o_lmi_tmp2;
1370         o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""];
1371         [o_lmi_tmp2 setTarget: [[VLCMain sharedInstance] controls]];
1372         [o_lmi_tmp2 setEnabled: YES];
1373         [o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
1374         [o_parent setEnabled: YES];
1375         [o_menu addItem: [NSMenuItem separatorItem]];
1376     }
1377
1378     /* Check the type of the object variable */
1379     i_type = var_Type(p_object, psz_variable);
1380
1381     /* Make sure we want to display the variable */
1382     if (i_type & VLC_VAR_HASCHOICE) {
1383         var_Change(p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL);
1384         if (val.i_int == 0)
1385             return;
1386         if ((i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1)
1387             return;
1388     }
1389     else
1390         return;
1391
1392     switch(i_type & VLC_VAR_TYPE) {
1393         case VLC_VAR_VOID:
1394         case VLC_VAR_BOOL:
1395         case VLC_VAR_VARIABLE:
1396         case VLC_VAR_STRING:
1397         case VLC_VAR_INTEGER:
1398             break;
1399         default:
1400             /* Variable doesn't exist or isn't handled */
1401             return;
1402     }
1403
1404     if (var_Get(p_object, psz_variable, &val) < 0) {
1405         return;
1406     }
1407
1408     if (var_Change(p_object, psz_variable, VLC_VAR_GETLIST,
1409                    &val_list, &text_list) < 0) {
1410         if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
1411         return;
1412     }
1413
1414     /* make (un)sensitive */
1415     [o_parent setEnabled: (val_list.p_list->i_count > 1)];
1416
1417     for (i = 0; i < val_list.p_list->i_count; i++) {
1418         NSMenuItem * o_lmi;
1419         NSString *o_title = @"";
1420         VLCAutoGeneratedMenuContent *o_data;
1421
1422         switch(i_type & VLC_VAR_TYPE) {
1423             case VLC_VAR_STRING:
1424
1425                 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);
1426
1427                 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
1428                 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1429                                                                           andValue: val_list.p_list->p_values[i] ofType: i_type];
1430                 [o_lmi setRepresentedObject: [o_data autorelease]];
1431                 [o_lmi setTarget: self];
1432
1433                 if (!strcmp(val.psz_string, val_list.p_list->p_values[i].psz_string) && !(i_type & VLC_VAR_ISCOMMAND))
1434                     [o_lmi setState: TRUE ];
1435
1436                 break;
1437
1438             case VLC_VAR_INTEGER:
1439
1440                 o_title = text_list.p_list->p_values[i].psz_string ?
1441                 _NS(text_list.p_list->p_values[i].psz_string) : [NSString stringWithFormat: @"%"PRId64, val_list.p_list->p_values[i].i_int];
1442
1443                 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
1444                 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1445                                                                           andValue: val_list.p_list->p_values[i] ofType: i_type];
1446                 [o_lmi setRepresentedObject: [o_data autorelease]];
1447                 [o_lmi setTarget: self];
1448
1449                 if (val_list.p_list->p_values[i].i_int == val.i_int && !(i_type & VLC_VAR_ISCOMMAND))
1450                     [o_lmi setState: TRUE ];
1451                 break;
1452
1453             default:
1454                 break;
1455         }
1456     }
1457
1458     /* clean up everything */
1459     if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
1460     var_FreeList(&val_list, &text_list);
1461 }
1462
1463 - (IBAction)toggleVar:(id)sender
1464 {
1465     NSMenuItem *o_mi = (NSMenuItem *)sender;
1466     VLCAutoGeneratedMenuContent *o_data = [o_mi representedObject];
1467     [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
1468                              toTarget: self withObject: o_data];
1469
1470     return;
1471 }
1472
1473 - (int)toggleVarThread: (id)data
1474 {
1475     vlc_object_t *p_object;
1476     NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
1477
1478     assert([data isKindOfClass:[VLCAutoGeneratedMenuContent class]]);
1479     VLCAutoGeneratedMenuContent *menuContent = (VLCAutoGeneratedMenuContent *)data;
1480
1481     /* Preserve settings across vouts via the playlist object: */
1482     if (!strcmp([menuContent name], "fullscreen") || !strcmp([menuContent name], "video-on-top"))
1483         var_Set(pl_Get(VLCIntf), [menuContent name] , [menuContent value]);
1484
1485     p_object = [menuContent vlcObject];
1486
1487     if (p_object != NULL) {
1488         var_Set(p_object, [menuContent name], [menuContent value]);
1489         vlc_object_release(p_object);
1490         [o_pool release];
1491         return true;
1492     }
1493     [o_pool release];
1494     return VLC_EGENERIC;
1495 }
1496
1497 @end
1498
1499 @implementation VLCMainMenu (NSMenuValidation)
1500
1501 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
1502 {
1503     NSString *o_title = [o_mi title];
1504     BOOL bEnabled = TRUE;
1505     vlc_value_t val;
1506     playlist_t * p_playlist = pl_Get(p_intf);
1507     input_thread_t * p_input = playlist_CurrentInput(p_playlist);
1508
1509     if ([o_title isEqualToString: _NS("Stop")]) {
1510         if (!p_input)
1511             bEnabled = FALSE;
1512         [self setupMenus]; /* Make sure input menu is up to date */
1513     } else if ([o_title isEqualToString: _NS("Previous")] ||
1514             [o_title isEqualToString: _NS("Next")]) {
1515         PL_LOCK;
1516         bEnabled = playlist_CurrentSize(p_playlist) > 1;
1517         PL_UNLOCK;
1518     } else if ([o_title isEqualToString: _NS("Random")]) {
1519         int i_state;
1520         var_Get(p_playlist, "random", &val);
1521         i_state = val.b_bool ? NSOnState : NSOffState;
1522         [o_mi setState: i_state];
1523     } else if ([o_title isEqualToString: _NS("Repeat One")]) {
1524         int i_state;
1525         var_Get(p_playlist, "repeat", &val);
1526         i_state = val.b_bool ? NSOnState : NSOffState;
1527         [o_mi setState: i_state];
1528     } else if ([o_title isEqualToString: _NS("Repeat All")]) {
1529         int i_state;
1530         var_Get(p_playlist, "loop", &val);
1531         i_state = val.b_bool ? NSOnState : NSOffState;
1532         [o_mi setState: i_state];
1533     } else if ([o_title isEqualToString: _NS("Quit after Playback")]) {
1534         int i_state;
1535         bool b_value = var_InheritBool(p_playlist, "play-and-exit");
1536         i_state = b_value ? NSOnState : NSOffState;
1537         [o_mi setState: i_state];
1538     } else if ([o_title isEqualToString: _NS("Step Forward")] ||
1539                [o_title isEqualToString: _NS("Step Backward")] ||
1540                [o_title isEqualToString: _NS("Jump to Time")]) {
1541         if (p_input != NULL) {
1542             var_Get(p_input, "can-seek", &val);
1543             bEnabled = val.b_bool;
1544         }
1545         else bEnabled = FALSE;
1546     } else if ([o_title isEqualToString: _NS("Mute")]) {
1547         [o_mi setState: [[VLCCoreInteraction sharedInstance] mute] ? NSOnState : NSOffState];
1548         [self setupMenus]; /* Make sure audio menu is up to date */
1549         [self refreshAudioDeviceList];
1550     } else if ([o_title isEqualToString: _NS("Half Size")] ||
1551                [o_title isEqualToString: _NS("Normal Size")] ||
1552                [o_title isEqualToString: _NS("Double Size")] ||
1553                [o_title isEqualToString: _NS("Fit to Screen")] ||
1554                [o_title isEqualToString: _NS("Snapshot")] ||
1555                [o_title isEqualToString: _NS("Fullscreen")] ||
1556                [o_title isEqualToString: _NS("Float on Top")]) {
1557         bEnabled = FALSE;
1558
1559         if (p_input != NULL) {
1560             vout_thread_t *p_vout = getVoutForActiveWindow();
1561             if (p_vout != NULL) {
1562                 if ([o_title isEqualToString: _NS("Float on Top")])
1563                     [o_mi setState: var_GetBool(p_vout, "video-on-top")];
1564
1565                 if ([o_title isEqualToString: _NS("Fullscreen")])
1566                     [o_mi setState: var_GetBool(p_vout, "fullscreen")];
1567
1568                 bEnabled = TRUE;
1569                 vlc_object_release(p_vout);
1570             }
1571         }
1572
1573         [self setupMenus]; /* Make sure video menu is up to date */
1574
1575     } else if ([o_title isEqualToString: _NS("Add Subtitle File...")]) {
1576         bEnabled = [o_mi isEnabled];
1577         [self setupMenus]; /* Make sure subtitles menu is up to date */
1578     } else {
1579         NSMenuItem *o_mi_parent = [o_mi parentItem];
1580         if (o_mi_parent == o_mi_subtitle_size || o_mi == o_mi_subtitle_size ||
1581             o_mi_parent == o_mi_subtitle_textcolor || o_mi == o_mi_subtitle_textcolor ||
1582             o_mi_parent == o_mi_subtitle_bgcolor || o_mi == o_mi_subtitle_bgcolor ||
1583             o_mi_parent == o_mi_subtitle_bgopacity || o_mi == o_mi_subtitle_bgopacity ||
1584             o_mi_parent == o_mi_subtitle_outlinethickness || o_mi == o_mi_subtitle_outlinethickness ||
1585             o_mi_parent == o_mi_teletext || o_mi == o_mi_teletext)
1586             bEnabled = o_mi_openSubtitleFile.isEnabled;
1587     }
1588
1589     /* Special case for telx menu */
1590     if ([o_title isEqualToString: _NS("Normal Size")]) {
1591         NSMenuItem *item = [[o_mi menu] itemWithTitle:_NS("Teletext")];
1592         bool b_telx = p_input && var_GetInteger(p_input, "teletext-es") >= 0;
1593
1594         [[item submenu] setAutoenablesItems:NO];
1595
1596         for (int k=0; k < [[item submenu] numberOfItems]; k++)
1597             [[[item submenu] itemAtIndex:k] setEnabled: b_telx];
1598     }
1599
1600     if (p_input)
1601         vlc_object_release(p_input);
1602
1603     return bEnabled;
1604 }
1605
1606 @end
1607
1608
1609 /*****************************************************************************
1610  * VLCAutoGeneratedMenuContent implementation
1611  *****************************************************************************
1612  * Object connected to a playlistitem which remembers the data belonging to
1613  * the variable of the autogenerated menu
1614  *****************************************************************************/
1615 @implementation VLCAutoGeneratedMenuContent
1616
1617 -(id) initWithVariableName:(const char *)name ofObject:(vlc_object_t *)object
1618                   andValue:(vlc_value_t)val ofType:(int)type
1619 {
1620     self = [super init];
1621
1622     if (self != nil) {
1623         _vlc_object = vlc_object_hold(object);
1624         psz_name = strdup(name);
1625         i_type = type;
1626         value = val;
1627         if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
1628             value.psz_string = strdup(val.psz_string);
1629     }
1630
1631     return(self);
1632 }
1633
1634 - (void)dealloc
1635 {
1636     if (_vlc_object)
1637         vlc_object_release(_vlc_object);
1638     if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
1639         free(value.psz_string);
1640     free(psz_name);
1641     [super dealloc];
1642 }
1643
1644 - (const char *)name
1645 {
1646     return psz_name;
1647 }
1648
1649 - (vlc_value_t)value
1650 {
1651     return value;
1652 }
1653
1654 - (vlc_object_t *)vlcObject
1655 {
1656     return vlc_object_hold(_vlc_object);
1657 }
1658
1659
1660 - (int)type
1661 {
1662     return i_type;
1663 }
1664
1665 @end