1 /*****************************************************************************
2 * intf.h: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2011 the VideoLAN team
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Christophe Massiot <massiot@via.ecp.fr>
9 * Derk-Jan Hartman <hartman at videolan dot org>
10 * Felix Paul Kühne <fkuehne at videolan dot org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_interface.h>
33 #include <vlc_playlist.h>
36 #include <vlc_input.h>
38 #include <Cocoa/Cocoa.h>
39 #import "SPMediaKeyTap.h" /* for the media key support */
41 /*****************************************************************************
43 *****************************************************************************/
44 unsigned int CocoaKeyToVLC( unichar i_key );
46 #define VLCIntf [[VLCMain sharedInstance] intf]
48 #define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
49 /* Get an alternate version of the string.
50 * This string is stored as '1:string' but when displayed it only displays
51 * the translated string. the translation should be '1:translatedstring' though */
52 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
54 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
55 @"/System/Library/CoreServices/SystemVersion.plist"] \
56 objectForKey: @"ProductVersion"] floatValue]
59 // You need to release those objects after use
60 input_thread_t *getInput(void);
61 vout_thread_t *getVout(void);
62 aout_instance_t *getAout(void);
64 /*****************************************************************************
65 * intf_sys_t: description and status of the interface
66 *****************************************************************************/
73 /* interface update */
75 bool b_playlist_update;
76 bool b_playmode_update;
77 bool b_current_title_update;
78 bool b_fullscreen_update;
87 /* The messages window */
88 msg_subscription_t * p_sub;
91 /*****************************************************************************
93 *****************************************************************************/
95 @class VLCInformation;
96 @class VLCControllerWindow;
97 @class VLCEmbeddedWindow;
100 @interface VLCMain : NSObject
102 intf_thread_t *p_intf; /* The main intf object */
103 id o_prefs; /* VLCPrefs */
104 id o_sprefs; /* VLCSimplePrefs */
105 id o_about; /* VLAboutBox */
106 id o_open; /* VLCOpen */
107 id o_wizard; /* VLCWizard */
108 id o_extended; /* VLCExtended */
109 id o_bookmarks; /* VLCBookmarks */
110 id o_embedded_list; /* VLCEmbeddedList*/
111 id o_coredialogs; /* VLCCoreDialogProvider */
112 VLCInformation * o_info; /* VLCInformation */
113 id o_eyetv; /* VLCEyeTVController */
114 BOOL nib_main_loaded; /* main nibfile */
115 BOOL nib_open_loaded; /* open nibfile */
116 BOOL nib_about_loaded; /* about nibfile */
117 BOOL nib_wizard_loaded; /* wizard nibfile */
118 BOOL nib_extended_loaded; /* extended nibfile */
119 BOOL nib_bookmarks_loaded; /* bookmarks nibfile */
120 BOOL nib_prefs_loaded; /* preferences nibfile */
121 BOOL nib_info_loaded; /* information panel nibfile */
122 BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
124 IBOutlet VLCControllerWindow * o_window; /* main window */
125 IBOutlet NSView * o_playlist_view; /* playlist view */
126 IBOutlet id o_scrollfield; /* info field */
127 IBOutlet NSTextField * o_timefield; /* time field */
128 IBOutlet NSSlider * o_timeslider; /* time slider */
129 BOOL b_time_remaining; /* show remaining time or playtime ? */
130 IBOutlet VLCEmbeddedWindow * o_embedded_window; /* Embedded Vout Window */
131 float f_slider; /* slider value */
132 float f_slider_old; /* old slider val */
133 IBOutlet NSSlider * o_volumeslider; /* volume slider */
135 IBOutlet NSView * toolbarMediaControl; /* view with the controls */
137 IBOutlet NSProgressIndicator * o_main_pgbar; /* playlist window progress bar */
138 IBOutlet NSButton * o_btn_prev; /* btn previous */
139 IBOutlet NSButton * o_btn_rewind; /* btn rewind */
140 IBOutlet NSButton * o_btn_play; /* btn play */
141 IBOutlet NSButton * o_btn_stop; /* btn stop */
142 IBOutlet NSButton * o_btn_ff; /* btn fast forward */
143 IBOutlet NSButton * o_btn_next; /* btn next */
144 IBOutlet NSButton * o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
145 IBOutlet NSButton * o_btn_playlist; /* btn playlist */
146 IBOutlet NSButton * o_btn_equalizer; /* eq btn */
148 NSImage * o_img_play; /* btn play img */
149 NSImage * o_img_pause; /* btn pause img */
150 NSImage * o_img_play_pressed; /* btn play img */
151 NSImage * o_img_pause_pressed; /* btn pause img */
153 IBOutlet VLCControls * o_controls; /* VLCControls */
154 IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
156 IBOutlet NSTextView * o_messages; /* messages tv */
157 IBOutlet NSWindow * o_msgs_panel; /* messages panel */
158 NSMutableArray * o_msg_arr; /* messages array */
159 NSLock * o_msg_lock; /* messages lock */
160 BOOL b_msg_arr_changed; /* did the array change? */
161 IBOutlet NSButton * o_msgs_crashlog_btn; /* messages open crashlog */
162 IBOutlet NSButton * o_msgs_save_btn; /* save the log as rtf */
164 /* CrashReporter panel */
165 IBOutlet NSButton * o_crashrep_dontSend_btn;
166 IBOutlet NSButton * o_crashrep_send_btn;
167 IBOutlet NSTextView * o_crashrep_fld;
168 IBOutlet NSTextField * o_crashrep_title_txt;
169 IBOutlet NSTextField * o_crashrep_desc_txt;
170 IBOutlet NSWindow * o_crashrep_win;
171 IBOutlet NSButton * o_crashrep_includeEmail_ckb;
172 IBOutlet NSTextField * o_crashrep_includeEmail_txt;
176 IBOutlet NSMenuItem * o_mi_about;
177 IBOutlet NSMenuItem * o_mi_prefs;
178 IBOutlet NSMenuItem * o_mi_sprefs;
179 IBOutlet NSMenuItem * o_mi_checkForUpdate;
180 IBOutlet NSMenuItem * o_mi_add_intf;
181 IBOutlet NSMenu * o_mu_add_intf;
182 IBOutlet NSMenuItem * o_mi_services;
183 IBOutlet NSMenuItem * o_mi_hide;
184 IBOutlet NSMenuItem * o_mi_hide_others;
185 IBOutlet NSMenuItem * o_mi_show_all;
186 IBOutlet NSMenuItem * o_mi_quit;
188 IBOutlet NSMenu * o_mu_file;
189 IBOutlet NSMenuItem * o_mi_open_file;
190 IBOutlet NSMenuItem * o_mi_open_generic;
191 IBOutlet NSMenuItem * o_mi_open_disc;
192 IBOutlet NSMenuItem * o_mi_open_net;
193 IBOutlet NSMenuItem * o_mi_open_capture;
194 IBOutlet NSMenuItem * o_mi_open_recent;
195 IBOutlet NSMenuItem * o_mi_open_recent_cm;
196 IBOutlet NSMenuItem * o_mi_open_wizard;
198 IBOutlet NSMenu * o_mu_edit;
199 IBOutlet NSMenuItem * o_mi_cut;
200 IBOutlet NSMenuItem * o_mi_copy;
201 IBOutlet NSMenuItem * o_mi_paste;
202 IBOutlet NSMenuItem * o_mi_clear;
203 IBOutlet NSMenuItem * o_mi_select_all;
205 IBOutlet NSMenu * o_mu_controls;
206 IBOutlet NSMenuItem * o_mi_play;
207 IBOutlet NSMenuItem * o_mi_stop;
208 IBOutlet NSMenuItem * o_mi_faster;
209 IBOutlet NSMenuItem * o_mi_slower;
210 IBOutlet NSMenuItem * o_mi_normalSpeed;
211 IBOutlet NSMenuItem * o_mi_previous;
212 IBOutlet NSMenuItem * o_mi_next;
213 IBOutlet NSMenuItem * o_mi_random;
214 IBOutlet NSMenuItem * o_mi_repeat;
215 IBOutlet NSMenuItem * o_mi_loop;
216 IBOutlet NSMenuItem * o_mi_quitAfterPB;
217 IBOutlet NSMenuItem * o_mi_fwd;
218 IBOutlet NSMenuItem * o_mi_bwd;
219 IBOutlet NSMenuItem * o_mi_fwd1m;
220 IBOutlet NSMenuItem * o_mi_bwd1m;
221 IBOutlet NSMenuItem * o_mi_fwd5m;
222 IBOutlet NSMenuItem * o_mi_bwd5m;
223 IBOutlet NSMenuItem * o_mi_program;
224 IBOutlet NSMenu * o_mu_program;
225 IBOutlet NSMenuItem * o_mi_title;
226 IBOutlet NSMenu * o_mu_title;
227 IBOutlet NSMenuItem * o_mi_chapter;
228 IBOutlet NSMenu * o_mu_chapter;
230 IBOutlet NSMenu * o_mu_audio;
231 IBOutlet NSMenuItem * o_mi_vol_up;
232 IBOutlet NSMenuItem * o_mi_vol_down;
233 IBOutlet NSMenuItem * o_mi_mute;
234 IBOutlet NSMenuItem * o_mi_audiotrack;
235 IBOutlet NSMenu * o_mu_audiotrack;
236 IBOutlet NSMenuItem * o_mi_channels;
237 IBOutlet NSMenu * o_mu_channels;
238 IBOutlet NSMenuItem * o_mi_device;
239 IBOutlet NSMenu * o_mu_device;
240 IBOutlet NSMenuItem * o_mi_visual;
241 IBOutlet NSMenu * o_mu_visual;
243 IBOutlet NSMenu * o_mu_video;
244 IBOutlet NSMenuItem * o_mi_half_window;
245 IBOutlet NSMenuItem * o_mi_normal_window;
246 IBOutlet NSMenuItem * o_mi_double_window;
247 IBOutlet NSMenuItem * o_mi_fittoscreen;
248 IBOutlet NSMenuItem * o_mi_fullscreen;
249 IBOutlet NSMenuItem * o_mi_floatontop;
250 IBOutlet NSMenuItem * o_mi_snapshot;
251 IBOutlet NSMenuItem * o_mi_videotrack;
252 IBOutlet NSMenu * o_mu_videotrack;
253 IBOutlet NSMenuItem * o_mi_screen;
254 IBOutlet NSMenu * o_mu_screen;
255 IBOutlet NSMenuItem * o_mi_aspect_ratio;
256 IBOutlet NSMenu * o_mu_aspect_ratio;
257 IBOutlet NSMenuItem * o_mi_crop;
258 IBOutlet NSMenu * o_mu_crop;
259 IBOutlet NSMenuItem * o_mi_subtitle;
260 IBOutlet NSMenu * o_mu_subtitle;
261 IBOutlet NSMenuItem * o_mi_addSub;
262 IBOutlet NSMenuItem * o_mi_deinterlace;
263 IBOutlet NSMenu * o_mu_deinterlace;
264 IBOutlet NSMenuItem * o_mi_deinterlace_mode;
265 IBOutlet NSMenu * o_mu_deinterlace_mode;
266 IBOutlet NSMenuItem * o_mi_ffmpeg_pp;
267 IBOutlet NSMenu * o_mu_ffmpeg_pp;
268 IBOutlet NSMenuItem * o_mi_teletext;
269 IBOutlet NSMenuItem * o_mi_teletext_transparent;
270 IBOutlet NSMenuItem * o_mi_teletext_index;
271 IBOutlet NSMenuItem * o_mi_teletext_red;
272 IBOutlet NSMenuItem * o_mi_teletext_green;
273 IBOutlet NSMenuItem * o_mi_teletext_yellow;
274 IBOutlet NSMenuItem * o_mi_teletext_blue;
276 IBOutlet NSMenu * o_mu_window;
277 IBOutlet NSMenuItem * o_mi_minimize;
278 IBOutlet NSMenuItem * o_mi_close_window;
279 IBOutlet NSMenuItem * o_mi_player;
280 IBOutlet NSMenuItem * o_mi_controller;
281 IBOutlet NSMenuItem * o_mi_equalizer;
282 IBOutlet NSMenuItem * o_mi_extended;
283 IBOutlet NSMenuItem * o_mi_bookmarks;
284 IBOutlet NSMenuItem * o_mi_playlist;
285 IBOutlet NSMenuItem * o_mi_info;
286 IBOutlet NSMenuItem * o_mi_messages;
287 IBOutlet NSMenuItem * o_mi_bring_atf;
289 IBOutlet NSMenu * o_mu_help;
290 IBOutlet NSMenuItem * o_mi_help;
291 IBOutlet NSMenuItem * o_mi_readme;
292 IBOutlet NSMenuItem * o_mi_documentation;
293 IBOutlet NSMenuItem * o_mi_license;
294 IBOutlet NSMenuItem * o_mi_website;
295 IBOutlet NSMenuItem * o_mi_donation;
296 IBOutlet NSMenuItem * o_mi_forum;
297 IBOutlet NSMenuItem * o_mi_errorsAndWarnings;
300 IBOutlet NSMenuItem * o_dmi_play;
301 IBOutlet NSMenuItem * o_dmi_stop;
302 IBOutlet NSMenuItem * o_dmi_next;
303 IBOutlet NSMenuItem * o_dmi_previous;
304 IBOutlet NSMenuItem * o_dmi_mute;
307 IBOutlet NSMenu * o_vout_menu;
308 IBOutlet NSMenuItem * o_vmi_play;
309 IBOutlet NSMenuItem * o_vmi_stop;
310 IBOutlet NSMenuItem * o_vmi_prev;
311 IBOutlet NSMenuItem * o_vmi_next;
312 IBOutlet NSMenuItem * o_vmi_volup;
313 IBOutlet NSMenuItem * o_vmi_voldown;
314 IBOutlet NSMenuItem * o_vmi_mute;
315 IBOutlet NSMenuItem * o_vmi_fullscreen;
316 IBOutlet NSMenuItem * o_vmi_snapshot;
321 NSRect o_restore_rect;
323 mtime_t i_end_scroll;
325 NSSize o_size_with_playlist;
327 int i_lastShownVolume;
329 input_state_e cachedInputState;
331 /* the manage thread */
332 pthread_t manage_thread;
334 /* The timer that update the interface */
335 NSTimer * interfaceTimer;
337 NSURLConnection * crashLogURLConnection;
339 AppleRemote * o_remote;
340 BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
342 /* media key support */
343 BOOL b_mediaKeySupport;
344 BOOL b_mediakeyJustJumped;
345 SPMediaKeyTap * o_mediaKeyController;
347 NSArray *o_usedHotkeys;
350 + (VLCMain *)sharedInstance;
352 - (intf_thread_t *)intf;
353 - (void)setIntf:(intf_thread_t *)p_mainintf;
356 - (id)simplePreferences;
359 - (BOOL)isPlaylistCollapsed;
364 - (id)coreDialogProvider;
366 - (id)controllerWindow;
368 - (id)eyeTVController;
369 - (id)appleRemoteController;
370 - (void)applicationWillTerminate:(NSNotification *)notification;
371 - (NSString *)localizedString:(const char *)psz;
372 - (char *)delocalizeString:(NSString *)psz;
373 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
374 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
375 - (NSString *)VLCKeyToString:(NSString *)theString;
376 - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
377 - (void)updateCurrentlyUsedHotkeys;
382 - (void)manageIntf:(NSTimer *)o_timer;
384 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
385 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
386 - (void)resetScrollField;
388 - (void)updateMessageDisplay;
389 - (void)playStatusUpdated:(int) i_status;
390 - (void)setSubmenusEnabled:(BOOL)b_enabled;
391 - (void)manageVolumeSlider;
392 - (IBAction)timesliderUpdate:(id)sender;
393 - (IBAction)timeFieldWasClicked:(id)sender;
395 - (IBAction)clearRecentItems:(id)sender;
396 - (void)openRecentItem:(id)sender;
398 - (IBAction)intfOpenFile:(id)sender;
399 - (IBAction)intfOpenFileGeneric:(id)sender;
400 - (IBAction)intfOpenDisc:(id)sender;
401 - (IBAction)intfOpenNet:(id)sender;
402 - (IBAction)intfOpenCapture:(id)sender;
404 - (IBAction)showWizard:(id)sender;
405 - (IBAction)showExtended:(id)sender;
406 - (IBAction)showBookmarks:(id)sender;
408 - (IBAction)viewAbout:(id)sender;
409 - (IBAction)showLicense:(id)sender;
410 - (IBAction)viewPreferences:(id)sender;
411 - (IBAction)viewHelp:(id)sender;
412 - (IBAction)openReadMe:(id)sender;
413 - (IBAction)openDocumentation:(id)sender;
414 - (IBAction)openWebsite:(id)sender;
415 - (IBAction)openForum:(id)sender;
416 - (IBAction)openDonate:(id)sender;
417 - (IBAction)openCrashLog:(id)sender;
418 - (IBAction)viewErrorsAndWarnings:(id)sender;
419 - (IBAction)showMessagesPanel:(id)sender;
420 - (IBAction)showInformationPanel:(id)sender;
422 - (IBAction)crashReporterAction:(id)sender;
423 - (IBAction)saveDebugLog:(id)sender;
425 - (IBAction)togglePlaylist:(id)sender;
426 - (void)updateTogglePlaylistState;
428 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
430 - (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
433 @interface VLCMain (Internal)
434 - (void)handlePortMessage:(NSPortMessage *)o_msg;
435 - (void)resetMediaKeyJump;
436 - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
439 /*****************************************************************************
440 * VLCApplication interface
441 *****************************************************************************/
443 @interface VLCApplication : NSApplication