e774752f215d3ccaf1737bbf44343d5823f0cf48
[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 - (void)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column
755 {
756     NSInteger i_tag = [o_ptc_menuorder indexOfObject: o_column];
757     [[o_mu_playlistTableColumns            itemWithTag: i_tag] setState: i_state];
758     [[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_state];
759     [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_state translationDict: o_ptc_translation_dict];
760 }
761
762 #pragma mark -
763 #pragma mark Playback
764
765 - (IBAction)quitAfterPlayback:(id)sender
766 {
767     playlist_t *p_playlist = pl_Get(VLCIntf);
768     bool b_value = !var_CreateGetBool(p_playlist, "play-and-exit");
769     var_SetBool(p_playlist, "play-and-exit", b_value);
770     config_PutInt(p_intf, "play-and-exit", b_value);
771 }
772
773 - (IBAction)toggleRecord:(id)sender
774 {
775     [[VLCCoreInteraction sharedInstance] toggleRecord];
776 }
777
778 - (void)updateRecordState:(BOOL)b_value
779 {
780     [o_mi_record setState:b_value];
781 }
782
783 - (IBAction)setPlaybackRate:(id)sender
784 {
785     [[VLCCoreInteraction sharedInstance] setPlaybackRate: [o_mi_rate_sld intValue]];
786     int i = [[VLCCoreInteraction sharedInstance] playbackRate];
787     double speed =  pow(2, (double)i / 17);
788     [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
789 }
790
791 - (void)updatePlaybackRate
792 {
793     int i = [[VLCCoreInteraction sharedInstance] playbackRate];
794     double speed =  pow(2, (double)i / 17);
795     [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%.2fx", speed]];
796     [o_mi_rate_sld setIntValue: i];
797 }
798
799 - (IBAction)toggleAtoBloop:(id)sender
800 {
801     [[VLCCoreInteraction sharedInstance] setAtoB];
802 }
803
804 #pragma mark -
805 #pragma mark audio menu
806 - (void)refreshAudioDeviceList
807 {
808     char **ids, **names;
809     char *currentDevice;
810
811     [o_mu_device removeAllItems];
812
813     audio_output_t * p_aout = getAout();
814     if (!p_aout)
815         return;
816
817     int n = aout_DevicesList(p_aout, &ids, &names);
818     if (n == -1) {
819         vlc_object_release(p_aout);
820         return;
821     }
822
823     currentDevice = aout_DeviceGet(p_aout);
824     NSMenuItem * o_mi_tmp;
825
826     for (NSUInteger x = 0; x < n; x++) {
827         o_mi_tmp = [o_mu_device addItemWithTitle:toNSStr(names[x]) action:@selector(toggleAudioDevice:) keyEquivalent:@""];
828         [o_mi_tmp setTarget:self];
829         [o_mi_tmp setTag:[[NSString stringWithFormat:@"%s", ids[x]] intValue]];
830     }
831     vlc_object_release(p_aout);
832
833     [[o_mu_device itemWithTag:[[NSString stringWithFormat:@"%s", currentDevice] intValue]] setState:NSOnState];
834
835     free(currentDevice);
836
837     for (NSUInteger x = 0; x < n; x++) {
838         free(ids[x]);
839         free(names[x]);
840     }
841     free(ids);
842     free(names);
843
844     [o_mu_device setAutoenablesItems:YES];
845     [o_mi_device setEnabled:YES];
846 }
847
848 - (IBAction)toggleAudioDevice:(id)sender
849 {
850     audio_output_t * p_aout = getAout();
851     if (!p_aout)
852         return;
853
854     int returnValue = 0;
855
856     if ([sender tag] > 0)
857         returnValue = aout_DeviceSet(p_aout, [[NSString stringWithFormat:@"%li", [sender tag]] UTF8String]);
858     else
859         returnValue = aout_DeviceSet(p_aout, NULL);
860
861     if (returnValue != 0)
862         msg_Warn(VLCIntf, "failed to set audio device %li", [sender tag]);
863
864     vlc_object_release(p_aout);
865     [self refreshAudioDeviceList];
866 }
867
868 #pragma mark -
869 #pragma mark video menu
870
871 - (IBAction)toggleFullscreen:(id)sender
872 {
873     [[VLCCoreInteraction sharedInstance] toggleFullscreen];
874 }
875
876 - (IBAction)resizeVideoWindow:(id)sender
877 {
878     input_thread_t *p_input = pl_CurrentInput(VLCIntf);
879     if (p_input) {
880         vout_thread_t *p_vout = getVoutForActiveWindow();
881         if (p_vout) {
882             if (sender == o_mi_half_window)
883                 var_SetFloat(p_vout, "zoom", 0.5);
884             else if (sender == o_mi_normal_window)
885                 var_SetFloat(p_vout, "zoom", 1.0);
886             else if (sender == o_mi_double_window)
887                 var_SetFloat(p_vout, "zoom", 2.0);
888             else
889             {
890                 [[NSApp keyWindow] performZoom:sender];
891             }
892             vlc_object_release(p_vout);
893         }
894         vlc_object_release(p_input);
895     }
896 }
897
898 - (IBAction)floatOnTop:(id)sender
899 {
900     input_thread_t *p_input = pl_CurrentInput(VLCIntf);
901     if (p_input) {
902         vout_thread_t *p_vout = getVoutForActiveWindow();
903         if (p_vout) {
904             var_ToggleBool(p_vout, "video-on-top");
905             vlc_object_release(p_vout);
906         }
907         vlc_object_release(p_input);
908     }
909 }
910
911 - (IBAction)createVideoSnapshot:(id)sender
912 {
913     input_thread_t *p_input = pl_CurrentInput(VLCIntf);
914     if (p_input) {
915         vout_thread_t *p_vout = getVoutForActiveWindow();
916         if (p_vout) {
917             var_TriggerCallback(p_vout, "video-snapshot");
918             vlc_object_release(p_vout);
919         }
920         vlc_object_release(p_input);
921     }
922 }
923
924 - (IBAction)toggleFullscreenDevice:(id)sender
925 {
926     config_PutInt(VLCIntf, "macosx-vdev", [sender tag]);
927     [self refreshVoutDeviceMenu: nil];
928 }
929
930 - (id)voutMenu
931 {
932     return o_vout_menu;
933 }
934
935 #pragma mark - Subtitles Menu
936 - (IBAction)addSubtitleFile:(id)sender
937 {
938     NSInteger i_returnValue = 0;
939     input_thread_t * p_input = pl_CurrentInput(VLCIntf);
940     if (!p_input)
941         return;
942
943     input_item_t *p_item = input_GetItem(p_input);
944     if (!p_item) {
945         vlc_object_release(p_input);
946         return;
947     }
948
949     char *path = input_item_GetURI(p_item);
950
951     if (!path)
952         path = strdup("");
953
954     NSOpenPanel * openPanel = [NSOpenPanel openPanel];
955     [openPanel setCanChooseFiles: YES];
956     [openPanel setCanChooseDirectories: NO];
957     [openPanel setAllowsMultipleSelection: YES];
958
959     [openPanel setAllowedFileTypes: [NSArray arrayWithObjects:@"cdg",@"idx",@"srt",@"sub",@"utf",@"ass",@"ssa",@"aqt",@"jss",@"psb",@"rt",@"smi",@"txt",@"smil",nil]];
960
961     NSURL *o_url = [NSURL URLWithString:[[NSString stringWithUTF8String:path] stringByExpandingTildeInPath]];
962     o_url = [o_url URLByDeletingLastPathComponent];
963     [openPanel setDirectoryURL: o_url];
964     free(path);
965
966     i_returnValue = [openPanel runModal];
967
968     if (i_returnValue == NSOKButton) {
969         NSUInteger c = 0;
970         if (!p_input)
971             return;
972
973         c = [[openPanel URLs] count];
974
975         for (int i = 0; i < c ; i++) {
976             msg_Dbg(VLCIntf, "loading subs from %s", [[[[openPanel URLs] objectAtIndex:i] path] UTF8String]);
977             if (input_AddSubtitle(p_input, [[[[openPanel URLs] objectAtIndex:i] path] UTF8String], TRUE))
978                 msg_Warn(VLCIntf, "unable to load subtitles from '%s'",
979                          [[[[openPanel URLs] objectAtIndex:i] path] UTF8String]);
980         }
981     }
982     vlc_object_release(p_input);
983 }
984
985 - (IBAction)switchSubtitleOption:(id)sender
986 {
987     int intValue = [sender tag];
988     NSString *representedObject = [sender representedObject];
989
990     config_PutInt(p_intf, [representedObject UTF8String], intValue);
991
992     NSMenu *menu = [sender menu];
993     NSUInteger count = (NSUInteger) [menu numberOfItems];
994     for (NSUInteger x = 0; x < count; x++)
995         [[menu itemAtIndex:x] setState:NSOffState];
996     [[menu itemWithTag:intValue] setState:NSOnState];
997 }
998
999 - (IBAction)switchSubtitleBackgroundOpacity:(id)sender
1000 {
1001     config_PutInt(p_intf, "freetype-background-opacity", [sender intValue]);
1002 }
1003
1004 - (IBAction)telxTransparent:(id)sender
1005 {
1006     vlc_object_t *p_vbi;
1007     p_vbi = (vlc_object_t *) vlc_object_find_name(pl_Get(VLCIntf), "zvbi");
1008     if (p_vbi) {
1009         var_SetBool(p_vbi, "vbi-opaque", [sender state]);
1010         [sender setState: ![sender state]];
1011         vlc_object_release(p_vbi);
1012     }
1013 }
1014
1015 - (IBAction)telxNavLink:(id)sender
1016 {
1017     vlc_object_t *p_vbi;
1018     int i_page = 0;
1019
1020     if ([[sender title] isEqualToString: _NS("Index")])
1021         i_page = 'i' << 16;
1022     else if ([[sender title] isEqualToString: _NS("Red")])
1023         i_page = 'r' << 16;
1024     else if ([[sender title] isEqualToString: _NS("Green")])
1025         i_page = 'g' << 16;
1026     else if ([[sender title] isEqualToString: _NS("Yellow")])
1027         i_page = 'y' << 16;
1028     else if ([[sender title] isEqualToString: _NS("Blue")])
1029         i_page = 'b' << 16;
1030     if (i_page == 0) return;
1031
1032     p_vbi = (vlc_object_t *) vlc_object_find_name(pl_Get(VLCIntf), "zvbi");
1033     if (p_vbi) {
1034         var_SetInteger(p_vbi, "vbi-page", i_page);
1035         vlc_object_release(p_vbi);
1036     }
1037 }
1038
1039 #pragma mark -
1040 #pragma mark Panels
1041
1042 - (IBAction)intfOpenFile:(id)sender
1043 {
1044     [[[VLCMain sharedInstance] open] openFile];
1045 }
1046
1047 - (IBAction)intfOpenFileGeneric:(id)sender
1048 {
1049     [[[VLCMain sharedInstance] open] openFileGeneric];
1050 }
1051
1052 - (IBAction)intfOpenDisc:(id)sender
1053 {
1054     [[[VLCMain sharedInstance] open] openDisc];
1055 }
1056
1057 - (IBAction)intfOpenNet:(id)sender
1058 {
1059     [[[VLCMain sharedInstance] open] openNet];
1060 }
1061
1062 - (IBAction)intfOpenCapture:(id)sender
1063 {
1064     [[[VLCMain sharedInstance] open] openCapture];
1065 }
1066
1067 - (IBAction)showWizard:(id)sender
1068 {
1069     [[[VLCMain sharedInstance] wizard] resetWizard];
1070     [[[VLCMain sharedInstance] wizard] showWizard];
1071 }
1072
1073 - (IBAction)savePlaylist:(id)sender
1074 {
1075     [[[VLCMain sharedInstance] playlist] savePlaylist:sender];
1076 }
1077
1078 - (IBAction)showConvertAndSave:(id)sender
1079 {
1080     if (o_convertandsave == nil)
1081         o_convertandsave = [[VLCConvertAndSave alloc] init];
1082
1083     if (!b_nib_convertandsave_loaded)
1084         b_nib_convertandsave_loaded = [NSBundle loadNibNamed:@"ConvertAndSave" owner: NSApp];
1085
1086     [o_convertandsave toggleWindow];
1087 }
1088
1089 - (IBAction)showVideoEffects:(id)sender
1090 {
1091     if (o_videoeffects == nil)
1092         o_videoeffects = [[VLCVideoEffects alloc] init];
1093
1094     if (!b_nib_videoeffects_loaded)
1095         b_nib_videoeffects_loaded = [NSBundle loadNibNamed:@"VideoEffects" owner: NSApp];
1096
1097     [o_videoeffects toggleWindow:sender];
1098 }
1099
1100 - (IBAction)showTrackSynchronization:(id)sender
1101 {
1102     if (!o_trackSynchronization)
1103         o_trackSynchronization = [[VLCTrackSynchronization alloc] init];
1104
1105     if (!b_nib_tracksynchro_loaded)
1106         b_nib_tracksynchro_loaded = [NSBundle loadNibNamed:@"SyncTracks" owner:NSApp];
1107
1108     [o_trackSynchronization toggleWindow:sender];
1109 }
1110
1111 - (IBAction)showAudioEffects:(id)sender
1112 {
1113     if (!o_audioeffects)
1114         o_audioeffects = [[VLCAudioEffects alloc] init];
1115
1116     if (!b_nib_audioeffects_loaded)
1117         b_nib_audioeffects_loaded = [NSBundle loadNibNamed:@"AudioEffects" owner:NSApp];
1118
1119     [o_audioeffects toggleWindow:sender];
1120 }
1121
1122 - (IBAction)showBookmarks:(id)sender
1123 {
1124     [[[VLCMain sharedInstance] bookmarks] showBookmarks];
1125 }
1126
1127 - (IBAction)viewPreferences:(id)sender
1128 {
1129     NSInteger i_level = [[[VLCMain sharedInstance] voutController] currentWindowLevel];
1130     [[[VLCMain sharedInstance] simplePreferences] showSimplePrefsWithLevel:i_level];
1131 }
1132
1133 - (IBAction)openAddonManager:(id)sender
1134 {
1135     if (!o_addonManager)
1136         o_addonManager = [[VLCAddonManager alloc] init];
1137
1138     if (!b_nib_addonmanager_loaded)
1139         b_nib_addonmanager_loaded = [NSBundle loadNibNamed:@"AddonManager" owner:NSApp];
1140
1141     [o_addonManager showWindow];
1142 }
1143
1144 - (IBAction)showMessagesPanel:(id)showMessagesPanel
1145 {
1146     [[VLCDebugMessageVisualizer sharedInstance] showPanel];
1147 }
1148
1149 - (IBAction)showMainWindow:(id)sender
1150 {
1151     [[VLCMainWindow sharedInstance] makeKeyAndOrderFront:sender];
1152 }
1153
1154 - (IBAction)showPlaylist:(id)sender
1155 {
1156     [[VLCMainWindow sharedInstance] changePlaylistState: psUserMenuEvent];
1157 }
1158
1159 #pragma mark -
1160 #pragma mark Help and Docs
1161
1162 - (void)initAbout
1163 {
1164     if (! o_about)
1165         o_about = [[VLAboutBox alloc] init];
1166
1167     if (!b_nib_about_loaded)
1168         b_nib_about_loaded = [NSBundle loadNibNamed:@"About" owner: NSApp];
1169 }
1170
1171 - (IBAction)viewAbout:(id)sender
1172 {
1173     [self initAbout];
1174     [o_about showAbout];
1175 }
1176
1177 - (IBAction)showLicense:(id)sender
1178 {
1179     [self initAbout];
1180     [o_about showGPL];
1181 }
1182
1183 - (IBAction)viewHelp:(id)sender
1184 {
1185     [self initAbout];
1186     [o_about showHelp];
1187 }
1188
1189 - (IBAction)openReadMe:(id)sender
1190 {
1191     NSString * o_path = [[NSBundle mainBundle] pathForResource: @"README.MacOSX" ofType: @"rtf"];
1192
1193     [[NSWorkspace sharedWorkspace] openFile: o_path withApplication: @"TextEdit"];
1194 }
1195
1196 - (IBAction)openDocumentation:(id)sender
1197 {
1198     NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/doc/"];
1199
1200     [[NSWorkspace sharedWorkspace] openURL: o_url];
1201 }
1202
1203 - (IBAction)openWebsite:(id)sender
1204 {
1205     NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/"];
1206
1207     [[NSWorkspace sharedWorkspace] openURL: o_url];
1208 }
1209
1210 - (IBAction)openForum:(id)sender
1211 {
1212     NSURL * o_url = [NSURL URLWithString: @"http://forum.videolan.org/"];
1213
1214     [[NSWorkspace sharedWorkspace] openURL: o_url];
1215 }
1216
1217 - (IBAction)openDonate:(id)sender
1218 {
1219     NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/contribute.html#paypal"];
1220
1221     [[NSWorkspace sharedWorkspace] openURL: o_url];
1222 }
1223
1224 #pragma mark -
1225 #pragma mark Errors, warnings and messages
1226
1227 - (IBAction)viewErrorsAndWarnings:(id)sender
1228 {
1229     [[[[VLCMain sharedInstance] coreDialogProvider] errorPanel] showPanel];
1230 }
1231
1232 - (IBAction)showInformationPanel:(id)sender
1233 {
1234     [[[VLCMain sharedInstance] info] initPanel];
1235 }
1236
1237 #pragma mark -
1238 #pragma mark convinience stuff for other objects
1239 - (void)setPlay
1240 {
1241     [o_mi_play setTitle: _NS("Play")];
1242     [o_dmi_play setTitle: _NS("Play")];
1243     [o_vmi_play setTitle: _NS("Play")];
1244 }
1245
1246 - (void)setPause
1247 {
1248     [o_mi_play setTitle: _NS("Pause")];
1249     [o_dmi_play setTitle: _NS("Pause")];
1250     [o_vmi_play setTitle: _NS("Pause")];
1251 }
1252
1253 - (void)setRepeatOne
1254 {
1255     [o_mi_repeat setState: NSOnState];
1256     [o_mi_loop setState: NSOffState];
1257 }
1258
1259 - (void)setRepeatAll
1260 {
1261     [o_mi_repeat setState: NSOffState];
1262     [o_mi_loop setState: NSOnState];
1263 }
1264
1265 - (void)setRepeatOff
1266 {
1267     [o_mi_repeat setState: NSOffState];
1268     [o_mi_loop setState: NSOffState];
1269 }
1270
1271 - (void)setShuffle
1272 {
1273     bool b_value;
1274     playlist_t *p_playlist = pl_Get(VLCIntf);
1275     b_value = var_GetBool(p_playlist, "random");
1276
1277     [o_mi_random setState: b_value];
1278 }
1279
1280 #pragma mark -
1281 #pragma mark Dynamic menu creation and validation
1282
1283 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
1284                   target:(vlc_object_t *)p_object
1285                      var:(const char *)psz_variable
1286                 selector:(SEL)pf_callback
1287 {
1288     vlc_value_t val, text;
1289     int i_type = var_Type(p_object, psz_variable);
1290
1291     switch(i_type & VLC_VAR_TYPE) {
1292         case VLC_VAR_VOID:
1293         case VLC_VAR_BOOL:
1294         case VLC_VAR_VARIABLE:
1295         case VLC_VAR_STRING:
1296         case VLC_VAR_INTEGER:
1297             break;
1298         default:
1299             /* Variable doesn't exist or isn't handled */
1300             msg_Warn(p_object, "variable %s doesn't exist or isn't handled", psz_variable);
1301             return;
1302     }
1303
1304     /* Get the descriptive name of the variable */
1305     var_Change(p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL);
1306     [o_mi setTitle: _NS(text.psz_string ? text.psz_string : psz_variable)];
1307
1308     if (i_type & VLC_VAR_HASCHOICE) {
1309         NSMenu *o_menu = [o_mi submenu];
1310
1311         [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
1312                        var:psz_variable selector:pf_callback];
1313
1314         free(text.psz_string);
1315         return;
1316     }
1317
1318     if (var_Get(p_object, psz_variable, &val) < 0)
1319         return;
1320
1321     VLCAutoGeneratedMenuContent *o_data;
1322     switch(i_type & VLC_VAR_TYPE) {
1323         case VLC_VAR_VOID:
1324             o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1325                                                                       andValue: val ofType: i_type];
1326             [o_mi setRepresentedObject: [o_data autorelease]];
1327             break;
1328
1329         case VLC_VAR_BOOL:
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             if (!(i_type & VLC_VAR_ISCOMMAND))
1334                 [o_mi setState: val.b_bool ? TRUE : FALSE ];
1335             break;
1336
1337         default:
1338             break;
1339     }
1340
1341     if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
1342     free(text.psz_string);
1343 }
1344
1345
1346 - (void)setupVarMenu:(NSMenu *)o_menu
1347          forMenuItem: (NSMenuItem *)o_parent
1348               target:(vlc_object_t *)p_object
1349                  var:(const char *)psz_variable
1350             selector:(SEL)pf_callback
1351 {
1352     vlc_value_t val, val_list, text_list;
1353     int i_type, i;
1354
1355     /* remove previous items */
1356     [o_menu removeAllItems];
1357
1358     /* we disable everything here, and enable it again when needed, below */
1359     [o_parent setEnabled:NO];
1360
1361     /* Aspect Ratio */
1362     if ([[o_parent title] isEqualToString: _NS("Aspect ratio")] == YES) {
1363         NSMenuItem *o_lmi_tmp2;
1364         o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""];
1365         [o_lmi_tmp2 setTarget: [[VLCMain sharedInstance] controls]];
1366         [o_lmi_tmp2 setEnabled: YES];
1367         [o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
1368         [o_parent setEnabled: YES];
1369         [o_menu addItem: [NSMenuItem separatorItem]];
1370     }
1371
1372     /* Check the type of the object variable */
1373     i_type = var_Type(p_object, psz_variable);
1374
1375     /* Make sure we want to display the variable */
1376     if (i_type & VLC_VAR_HASCHOICE) {
1377         var_Change(p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL);
1378         if (val.i_int == 0)
1379             return;
1380         if ((i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1)
1381             return;
1382     }
1383     else
1384         return;
1385
1386     switch(i_type & VLC_VAR_TYPE) {
1387         case VLC_VAR_VOID:
1388         case VLC_VAR_BOOL:
1389         case VLC_VAR_VARIABLE:
1390         case VLC_VAR_STRING:
1391         case VLC_VAR_INTEGER:
1392             break;
1393         default:
1394             /* Variable doesn't exist or isn't handled */
1395             return;
1396     }
1397
1398     if (var_Get(p_object, psz_variable, &val) < 0) {
1399         return;
1400     }
1401
1402     if (var_Change(p_object, psz_variable, VLC_VAR_GETLIST,
1403                    &val_list, &text_list) < 0) {
1404         if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
1405         return;
1406     }
1407
1408     /* make (un)sensitive */
1409     [o_parent setEnabled: (val_list.p_list->i_count > 1)];
1410
1411     for (i = 0; i < val_list.p_list->i_count; i++) {
1412         NSMenuItem * o_lmi;
1413         NSString *o_title = @"";
1414         VLCAutoGeneratedMenuContent *o_data;
1415
1416         switch(i_type & VLC_VAR_TYPE) {
1417             case VLC_VAR_STRING:
1418
1419                 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);
1420
1421                 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
1422                 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1423                                                                           andValue: val_list.p_list->p_values[i] ofType: i_type];
1424                 [o_lmi setRepresentedObject: [o_data autorelease]];
1425                 [o_lmi setTarget: self];
1426
1427                 if (!strcmp(val.psz_string, val_list.p_list->p_values[i].psz_string) && !(i_type & VLC_VAR_ISCOMMAND))
1428                     [o_lmi setState: TRUE ];
1429
1430                 break;
1431
1432             case VLC_VAR_INTEGER:
1433
1434                 o_title = text_list.p_list->p_values[i].psz_string ?
1435                 _NS(text_list.p_list->p_values[i].psz_string) : [NSString stringWithFormat: @"%"PRId64, val_list.p_list->p_values[i].i_int];
1436
1437                 o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
1438                 o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
1439                                                                           andValue: val_list.p_list->p_values[i] ofType: i_type];
1440                 [o_lmi setRepresentedObject: [o_data autorelease]];
1441                 [o_lmi setTarget: self];
1442
1443                 if (val_list.p_list->p_values[i].i_int == val.i_int && !(i_type & VLC_VAR_ISCOMMAND))
1444                     [o_lmi setState: TRUE ];
1445                 break;
1446
1447             default:
1448                 break;
1449         }
1450     }
1451
1452     /* clean up everything */
1453     if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
1454     var_FreeList(&val_list, &text_list);
1455 }
1456
1457 - (IBAction)toggleVar:(id)sender
1458 {
1459     NSMenuItem *o_mi = (NSMenuItem *)sender;
1460     VLCAutoGeneratedMenuContent *o_data = [o_mi representedObject];
1461     [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
1462                              toTarget: self withObject: o_data];
1463
1464     return;
1465 }
1466
1467 - (int)toggleVarThread: (id)data
1468 {
1469     vlc_object_t *p_object;
1470     NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
1471
1472     assert([data isKindOfClass:[VLCAutoGeneratedMenuContent class]]);
1473     VLCAutoGeneratedMenuContent *menuContent = (VLCAutoGeneratedMenuContent *)data;
1474
1475     /* Preserve settings across vouts via the playlist object: */
1476     if (!strcmp([menuContent name], "fullscreen") || !strcmp([menuContent name], "video-on-top"))
1477         var_Set(pl_Get(VLCIntf), [menuContent name] , [menuContent value]);
1478
1479     p_object = [menuContent vlcObject];
1480
1481     if (p_object != NULL) {
1482         var_Set(p_object, [menuContent name], [menuContent value]);
1483         vlc_object_release(p_object);
1484         [o_pool release];
1485         return true;
1486     }
1487     [o_pool release];
1488     return VLC_EGENERIC;
1489 }
1490
1491 @end
1492
1493 @implementation VLCMainMenu (NSMenuValidation)
1494
1495 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
1496 {
1497     NSString *o_title = [o_mi title];
1498     BOOL bEnabled = TRUE;
1499     vlc_value_t val;
1500     playlist_t * p_playlist = pl_Get(p_intf);
1501     input_thread_t * p_input = playlist_CurrentInput(p_playlist);
1502
1503     if ([o_title isEqualToString: _NS("Stop")]) {
1504         if (!p_input)
1505             bEnabled = FALSE;
1506         [self setupMenus]; /* Make sure input menu is up to date */
1507     } else if ([o_title isEqualToString: _NS("Previous")] ||
1508             [o_title isEqualToString: _NS("Next")]) {
1509         PL_LOCK;
1510         bEnabled = playlist_CurrentSize(p_playlist) > 1;
1511         PL_UNLOCK;
1512     } else if ([o_title isEqualToString: _NS("Random")]) {
1513         int i_state;
1514         var_Get(p_playlist, "random", &val);
1515         i_state = val.b_bool ? NSOnState : NSOffState;
1516         [o_mi setState: i_state];
1517     } else if ([o_title isEqualToString: _NS("Repeat One")]) {
1518         int i_state;
1519         var_Get(p_playlist, "repeat", &val);
1520         i_state = val.b_bool ? NSOnState : NSOffState;
1521         [o_mi setState: i_state];
1522     } else if ([o_title isEqualToString: _NS("Repeat All")]) {
1523         int i_state;
1524         var_Get(p_playlist, "loop", &val);
1525         i_state = val.b_bool ? NSOnState : NSOffState;
1526         [o_mi setState: i_state];
1527     } else if ([o_title isEqualToString: _NS("Quit after Playback")]) {
1528         int i_state;
1529         bool b_value = var_InheritBool(p_playlist, "play-and-exit");
1530         i_state = b_value ? NSOnState : NSOffState;
1531         [o_mi setState: i_state];
1532     } else if ([o_title isEqualToString: _NS("Step Forward")] ||
1533                [o_title isEqualToString: _NS("Step Backward")] ||
1534                [o_title isEqualToString: _NS("Jump to Time")]) {
1535         if (p_input != NULL) {
1536             var_Get(p_input, "can-seek", &val);
1537             bEnabled = val.b_bool;
1538         }
1539         else bEnabled = FALSE;
1540     } else if ([o_title isEqualToString: _NS("Mute")]) {
1541         [o_mi setState: [[VLCCoreInteraction sharedInstance] mute] ? NSOnState : NSOffState];
1542         [self setupMenus]; /* Make sure audio menu is up to date */
1543         [self refreshAudioDeviceList];
1544     } else if ([o_title isEqualToString: _NS("Half Size")] ||
1545                [o_title isEqualToString: _NS("Normal Size")] ||
1546                [o_title isEqualToString: _NS("Double Size")] ||
1547                [o_title isEqualToString: _NS("Fit to Screen")] ||
1548                [o_title isEqualToString: _NS("Snapshot")] ||
1549                [o_title isEqualToString: _NS("Fullscreen")] ||
1550                [o_title isEqualToString: _NS("Float on Top")]) {
1551         bEnabled = FALSE;
1552
1553         if (p_input != NULL) {
1554             vout_thread_t *p_vout = getVoutForActiveWindow();
1555             if (p_vout != NULL) {
1556                 if ([o_title isEqualToString: _NS("Float on Top")])
1557                     [o_mi setState: var_GetBool(p_vout, "video-on-top")];
1558
1559                 if ([o_title isEqualToString: _NS("Fullscreen")])
1560                     [o_mi setState: var_GetBool(p_vout, "fullscreen")];
1561
1562                 bEnabled = TRUE;
1563                 vlc_object_release(p_vout);
1564             }
1565         }
1566
1567         [self setupMenus]; /* Make sure video menu is up to date */
1568
1569     } else if ([o_title isEqualToString: _NS("Add Subtitle File...")]) {
1570         bEnabled = [o_mi isEnabled];
1571         [self setupMenus]; /* Make sure subtitles menu is up to date */
1572     } else {
1573         NSMenuItem *o_mi_parent = [o_mi parentItem];
1574         if (o_mi_parent == o_mi_subtitle_size || o_mi == o_mi_subtitle_size ||
1575             o_mi_parent == o_mi_subtitle_textcolor || o_mi == o_mi_subtitle_textcolor ||
1576             o_mi_parent == o_mi_subtitle_bgcolor || o_mi == o_mi_subtitle_bgcolor ||
1577             o_mi_parent == o_mi_subtitle_bgopacity || o_mi == o_mi_subtitle_bgopacity ||
1578             o_mi_parent == o_mi_subtitle_outlinethickness || o_mi == o_mi_subtitle_outlinethickness ||
1579             o_mi_parent == o_mi_teletext || o_mi == o_mi_teletext)
1580             bEnabled = o_mi_openSubtitleFile.isEnabled;
1581     }
1582
1583     /* Special case for telx menu */
1584     if ([o_title isEqualToString: _NS("Normal Size")]) {
1585         NSMenuItem *item = [[o_mi menu] itemWithTitle:_NS("Teletext")];
1586         bool b_telx = p_input && var_GetInteger(p_input, "teletext-es") >= 0;
1587
1588         [[item submenu] setAutoenablesItems:NO];
1589
1590         for (int k=0; k < [[item submenu] numberOfItems]; k++)
1591             [[[item submenu] itemAtIndex:k] setEnabled: b_telx];
1592     }
1593
1594     if (p_input)
1595         vlc_object_release(p_input);
1596
1597     return bEnabled;
1598 }
1599
1600 @end
1601
1602
1603 /*****************************************************************************
1604  * VLCAutoGeneratedMenuContent implementation
1605  *****************************************************************************
1606  * Object connected to a playlistitem which remembers the data belonging to
1607  * the variable of the autogenerated menu
1608  *****************************************************************************/
1609 @implementation VLCAutoGeneratedMenuContent
1610
1611 -(id) initWithVariableName:(const char *)name ofObject:(vlc_object_t *)object
1612                   andValue:(vlc_value_t)val ofType:(int)type
1613 {
1614     self = [super init];
1615
1616     if (self != nil) {
1617         _vlc_object = vlc_object_hold(object);
1618         psz_name = strdup(name);
1619         i_type = type;
1620         value = val;
1621         if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
1622             value.psz_string = strdup(val.psz_string);
1623     }
1624
1625     return(self);
1626 }
1627
1628 - (void)dealloc
1629 {
1630     if (_vlc_object)
1631         vlc_object_release(_vlc_object);
1632     if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
1633         free(value.psz_string);
1634     free(psz_name);
1635     [super dealloc];
1636 }
1637
1638 - (const char *)name
1639 {
1640     return psz_name;
1641 }
1642
1643 - (vlc_value_t)value
1644 {
1645     return value;
1646 }
1647
1648 - (vlc_object_t *)vlcObject
1649 {
1650     return vlc_object_hold(_vlc_object);
1651 }
1652
1653
1654 - (int)type
1655 {
1656     return i_type;
1657 }
1658
1659 @end