1 /*****************************************************************************
2 * intf.h: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2008 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>
40 /*****************************************************************************
42 *****************************************************************************/
43 unsigned int CocoaKeyToVLC( unichar i_key );
45 #define VLCIntf [[VLCMain sharedInstance] getIntf]
47 #define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
48 /* Get an alternate version of the string.
49 * This string is stored as '1:string' but when displayed it only displays
50 * the translated string. the translation should be '1:translatedstring' though */
51 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
53 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
54 @"/System/Library/CoreServices/SystemVersion.plist"] \
55 objectForKey: @"ProductVersion"] floatValue]
57 /*****************************************************************************
58 * intf_sys_t: description and status of the interface
59 *****************************************************************************/
62 NSAutoreleasePool * o_pool;
68 /* interface update */
70 bool b_playlist_update;
71 bool b_playmode_update;
72 bool b_current_title_update;
73 bool b_fullscreen_update;
82 /* The messages window */
83 msg_subscription_t * p_sub;
86 /*****************************************************************************
88 *****************************************************************************/
90 @class VLCInformation;
91 @class VLControllerWindow;
92 @class VLCEmbeddedWindow;
95 @interface VLCMain : NSObject
97 intf_thread_t *p_intf; /* The main intf object */
98 id o_prefs; /* VLCPrefs */
99 id o_sprefs; /* VLCSimplePrefs */
100 id o_about; /* VLAboutBox */
101 id o_open; /* VLCOpen */
102 id o_wizard; /* VLCWizard */
103 id o_extended; /* VLCExtended */
104 id o_bookmarks; /* VLCBookmarks */
105 id o_embedded_list; /* VLCEmbeddedList*/
106 id o_interaction_list; /* VLCInteractionList*/
107 VLCInformation * o_info; /* VLCInformation */
109 id o_update; /* VLCUpdate */
111 id o_eyetv; /* VLCEyeTVController */
112 BOOL nib_main_loaded; /* main nibfile */
113 BOOL nib_open_loaded; /* open nibfile */
114 BOOL nib_about_loaded; /* about nibfile */
115 BOOL nib_wizard_loaded; /* wizard nibfile */
116 BOOL nib_extended_loaded; /* extended nibfile */
117 BOOL nib_bookmarks_loaded; /* bookmarks nibfile */
118 BOOL nib_prefs_loaded; /* preferences nibfile */
119 BOOL nib_update_loaded; /* update nibfile */
120 BOOL nib_info_loaded; /* information panel nibfile */
122 IBOutlet VLControllerWindow * o_window; /* main window */
123 IBOutlet NSView * o_playlist_view;/* playlist view */
124 IBOutlet id o_scrollfield; /* info field */
125 IBOutlet NSTextField * o_timefield; /* time field */
126 IBOutlet NSSlider * o_timeslider; /* time slider */
127 IBOutlet VLCEmbeddedWindow * o_embedded_window; /* Embedded Vout Window */
128 float f_slider; /* slider value */
129 float f_slider_old; /* old slider val */
130 IBOutlet NSSlider * o_volumeslider; /* volume slider */
132 IBOutlet NSView * toolbarMediaControl; /* view with the controls */
134 IBOutlet NSProgressIndicator * o_main_pgbar; /* playlist window progress bar */
135 IBOutlet NSButton * o_btn_prev; /* btn previous */
136 IBOutlet NSButton * o_btn_rewind; /* btn rewind */
137 IBOutlet NSButton * o_btn_play; /* btn play */
138 IBOutlet NSButton * o_btn_stop; /* btn stop */
139 IBOutlet NSButton * o_btn_ff; /* btn fast forward */
140 IBOutlet NSButton * o_btn_next; /* btn next */
141 IBOutlet NSButton * o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
142 IBOutlet NSButton * o_btn_playlist; /* btn playlist */
143 IBOutlet NSButton * o_btn_equalizer; /* eq btn */
145 NSImage * o_img_play; /* btn play img */
146 NSImage * o_img_pause; /* btn pause img */
147 NSImage * o_img_play_pressed; /* btn play img */
148 NSImage * o_img_pause_pressed; /* btn pause img */
150 IBOutlet VLCControls * o_controls; /* VLCControls */
151 IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
153 IBOutlet id o_messages; /* messages tv */
154 IBOutlet id o_msgs_panel; /* messages panel */
155 NSMutableArray * o_msg_arr; /* messages array */
156 NSLock * o_msg_lock; /* messages lock */
157 IBOutlet NSButton * o_msgs_btn_crashlog; /* messages open crashlog */
159 /* CrashReporter panel */
160 IBOutlet NSButton * o_crashrep_dontSend_btn;
161 IBOutlet NSButton * o_crashrep_send_btn;
162 IBOutlet NSTextView * o_crashrep_fld;
163 IBOutlet NSTextField * o_crashrep_title_txt;
164 IBOutlet NSTextField * o_crashrep_desc_txt;
165 IBOutlet NSWindow * o_crashrep_win;
166 IBOutlet NSButton * o_crashrep_includeEmail_ckb;
167 IBOutlet NSTextField * o_crashrep_includeEmail_txt;
171 IBOutlet NSMenuItem * o_mi_about;
172 IBOutlet NSMenuItem * o_mi_prefs;
173 IBOutlet NSMenuItem * o_mi_sprefs;
174 IBOutlet NSMenuItem * o_mi_checkForUpdate;
175 IBOutlet NSMenuItem * o_mi_add_intf;
176 IBOutlet NSMenu * o_mu_add_intf;
177 IBOutlet NSMenuItem * o_mi_services;
178 IBOutlet NSMenuItem * o_mi_hide;
179 IBOutlet NSMenuItem * o_mi_hide_others;
180 IBOutlet NSMenuItem * o_mi_show_all;
181 IBOutlet NSMenuItem * o_mi_quit;
183 IBOutlet NSMenu * o_mu_file;
184 IBOutlet NSMenuItem * o_mi_open_file;
185 IBOutlet NSMenuItem * o_mi_open_generic;
186 IBOutlet NSMenuItem * o_mi_open_disc;
187 IBOutlet NSMenuItem * o_mi_open_net;
188 IBOutlet NSMenuItem * o_mi_open_capture;
189 IBOutlet NSMenuItem * o_mi_open_recent;
190 IBOutlet NSMenuItem * o_mi_open_recent_cm;
191 IBOutlet NSMenuItem * o_mi_open_wizard;
193 IBOutlet NSMenu * o_mu_edit;
194 IBOutlet NSMenuItem * o_mi_cut;
195 IBOutlet NSMenuItem * o_mi_copy;
196 IBOutlet NSMenuItem * o_mi_paste;
197 IBOutlet NSMenuItem * o_mi_clear;
198 IBOutlet NSMenuItem * o_mi_select_all;
200 IBOutlet NSMenu * o_mu_controls;
201 IBOutlet NSMenuItem * o_mi_play;
202 IBOutlet NSMenuItem * o_mi_stop;
203 IBOutlet NSMenuItem * o_mi_faster;
204 IBOutlet NSMenuItem * o_mi_slower;
205 IBOutlet NSMenuItem * o_mi_previous;
206 IBOutlet NSMenuItem * o_mi_next;
207 IBOutlet NSMenuItem * o_mi_random;
208 IBOutlet NSMenuItem * o_mi_repeat;
209 IBOutlet NSMenuItem * o_mi_loop;
210 IBOutlet NSMenuItem * o_mi_fwd;
211 IBOutlet NSMenuItem * o_mi_bwd;
212 IBOutlet NSMenuItem * o_mi_fwd1m;
213 IBOutlet NSMenuItem * o_mi_bwd1m;
214 IBOutlet NSMenuItem * o_mi_fwd5m;
215 IBOutlet NSMenuItem * o_mi_bwd5m;
216 IBOutlet NSMenuItem * o_mi_program;
217 IBOutlet NSMenuItem * o_mu_program;
218 IBOutlet NSMenuItem * o_mi_title;
219 IBOutlet NSMenu * o_mu_title;
220 IBOutlet NSMenuItem * o_mi_chapter;
221 IBOutlet NSMenu * o_mu_chapter;
223 IBOutlet NSMenu * o_mu_audio;
224 IBOutlet NSMenuItem * o_mi_vol_up;
225 IBOutlet NSMenuItem * o_mi_vol_down;
226 IBOutlet NSMenuItem * o_mi_mute;
227 IBOutlet NSMenuItem * o_mi_audiotrack;
228 IBOutlet NSMenu * o_mu_audiotrack;
229 IBOutlet NSMenuItem * o_mi_channels;
230 IBOutlet NSMenu * o_mu_channels;
231 IBOutlet NSMenuItem * o_mi_device;
232 IBOutlet NSMenu * o_mu_device;
233 IBOutlet NSMenuItem * o_mi_visual;
234 IBOutlet NSMenu * o_mu_visual;
236 IBOutlet NSMenu * o_mu_video;
237 IBOutlet NSMenuItem * o_mi_half_window;
238 IBOutlet NSMenuItem * o_mi_normal_window;
239 IBOutlet NSMenuItem * o_mi_double_window;
240 IBOutlet NSMenuItem * o_mi_fittoscreen;
241 IBOutlet NSMenuItem * o_mi_fullscreen;
242 IBOutlet NSMenuItem * o_mi_floatontop;
243 IBOutlet NSMenuItem * o_mi_snapshot;
244 IBOutlet NSMenuItem * o_mi_videotrack;
245 IBOutlet NSMenu * o_mu_videotrack;
246 IBOutlet NSMenuItem * o_mi_screen;
247 IBOutlet NSMenu * o_mu_screen;
248 IBOutlet NSMenuItem * o_mi_aspect_ratio;
249 IBOutlet NSMenu * o_mu_aspect_ratio;
250 IBOutlet NSMenuItem * o_mi_crop;
251 IBOutlet NSMenu * o_mu_crop;
252 IBOutlet NSMenuItem * o_mi_subtitle;
253 IBOutlet NSMenu * o_mu_subtitle;
254 IBOutlet NSMenuItem * o_mi_deinterlace;
255 IBOutlet NSMenu * o_mu_deinterlace;
256 IBOutlet NSMenuItem * o_mi_ffmpeg_pp;
257 IBOutlet NSMenuItem * o_mu_ffmpeg_pp;
258 IBOutlet NSMenuItem * o_mi_teletext;
259 IBOutlet NSMenuItem * o_mi_teletext_transparent;
260 IBOutlet NSMenuItem * o_mi_teletext_index;
261 IBOutlet NSMenuItem * o_mi_teletext_red;
262 IBOutlet NSMenuItem * o_mi_teletext_green;
263 IBOutlet NSMenuItem * o_mi_teletext_yellow;
264 IBOutlet NSMenuItem * o_mi_teletext_blue;
266 IBOutlet NSMenu * o_mu_window;
267 IBOutlet NSMenuItem * o_mi_minimize;
268 IBOutlet NSMenuItem * o_mi_close_window;
269 IBOutlet NSMenuItem * o_mi_controller;
270 IBOutlet NSMenuItem * o_mi_equalizer;
271 IBOutlet NSMenuItem * o_mi_extended;
272 IBOutlet NSMenuItem * o_mi_bookmarks;
273 IBOutlet NSMenuItem * o_mi_playlist;
274 IBOutlet NSMenuItem * o_mi_info;
275 IBOutlet NSMenuItem * o_mi_messages;
276 IBOutlet NSMenuItem * o_mi_bring_atf;
278 IBOutlet NSMenu * o_mu_help;
279 IBOutlet NSMenuItem * o_mi_help;
280 IBOutlet NSMenuItem * o_mi_readme;
281 IBOutlet NSMenuItem * o_mi_documentation;
282 IBOutlet NSMenuItem * o_mi_license;
283 IBOutlet NSMenuItem * o_mi_website;
284 IBOutlet NSMenuItem * o_mi_donation;
285 IBOutlet NSMenuItem * o_mi_forum;
286 IBOutlet NSMenuItem * o_mi_errorsAndWarnings;
289 IBOutlet NSMenuItem * o_dmi_play;
290 IBOutlet NSMenuItem * o_dmi_stop;
291 IBOutlet NSMenuItem * o_dmi_next;
292 IBOutlet NSMenuItem * o_dmi_previous;
293 IBOutlet NSMenuItem * o_dmi_mute;
296 IBOutlet NSMenu * o_vout_menu;
297 IBOutlet NSMenuItem * o_vmi_play;
298 IBOutlet NSMenuItem * o_vmi_stop;
299 IBOutlet NSMenuItem * o_vmi_prev;
300 IBOutlet NSMenuItem * o_vmi_next;
301 IBOutlet NSMenuItem * o_vmi_volup;
302 IBOutlet NSMenuItem * o_vmi_voldown;
303 IBOutlet NSMenuItem * o_vmi_mute;
304 IBOutlet NSMenuItem * o_vmi_fullscreen;
305 IBOutlet NSMenuItem * o_vmi_snapshot;
310 NSRect o_restore_rect;
312 mtime_t i_end_scroll;
314 NSSize o_size_with_playlist;
316 int i_lastShownVolume;
318 input_state_e cachedInputState;
320 /* the manage thread */
321 pthread_t manage_thread;
323 /* The timer that update the interface */
324 NSTimer * interfaceTimer;
326 NSURLConnection * crashLogURLConnection;
328 AppleRemote * o_remote;
329 BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
332 + (VLCMain *)sharedInstance;
334 - (intf_thread_t *)getIntf;
335 - (void)setIntf:(intf_thread_t *)p_mainintf;
337 - (void)controlTintChanged;
340 - (id)getSimplePreferences;
341 - (id)getPreferences;
346 - (id)getEmbeddedList;
347 - (id)getInteractionList;
348 - (id)getMainIntfPgbar;
349 - (id)getControllerWindow;
351 - (id)getEyeTVController;
352 - (void)applicationWillTerminate:(NSNotification *)notification;
353 - (NSString *)localizedString:(const char *)psz;
354 - (char *)delocalizeString:(NSString *)psz;
355 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
356 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
361 - (void)manageIntf:(NSTimer *)o_timer;
363 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
364 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
365 - (void)resetScrollField;
367 - (void)updateMessageArray;
368 - (void)playStatusUpdated:(int) i_status;
369 - (void)setSubmenusEnabled:(BOOL)b_enabled;
370 - (void)manageVolumeSlider;
371 - (IBAction)timesliderUpdate:(id)sender;
373 - (IBAction)clearRecentItems:(id)sender;
374 - (void)openRecentItem:(id)sender;
376 - (IBAction)intfOpenFile:(id)sender;
377 - (IBAction)intfOpenFileGeneric:(id)sender;
378 - (IBAction)intfOpenDisc:(id)sender;
379 - (IBAction)intfOpenNet:(id)sender;
380 - (IBAction)intfOpenCapture:(id)sender;
382 - (IBAction)showWizard:(id)sender;
383 - (IBAction)showExtended:(id)sender;
384 - (IBAction)showBookmarks:(id)sender;
386 - (IBAction)viewAbout:(id)sender;
387 - (IBAction)showLicense:(id)sender;
388 - (IBAction)viewPreferences:(id)sender;
389 - (IBAction)checkForUpdate:(id)sender;
390 - (IBAction)viewHelp:(id)sender;
391 - (IBAction)openReadMe:(id)sender;
392 - (IBAction)openDocumentation:(id)sender;
393 - (IBAction)openWebsite:(id)sender;
394 - (IBAction)openForum:(id)sender;
395 - (IBAction)openDonate:(id)sender;
396 - (IBAction)openCrashLog:(id)sender;
397 - (IBAction)viewErrorsAndWarnings:(id)sender;
398 - (IBAction)showMessagesPanel:(id)sender;
399 - (IBAction)showInformationPanel:(id)sender;
401 - (IBAction)crashReporterAction:(id)sender;
403 - (IBAction)togglePlaylist:(id)sender;
404 - (void)updateTogglePlaylistState;
406 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
410 @interface VLCMain (Internal)
411 - (void)handlePortMessage:(NSPortMessage *)o_msg;