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 /* this was introduced in Darwin 9. We need to declare it to prevent both
41 * compilation warnings and errors */
46 /*****************************************************************************
48 *****************************************************************************/
49 int ExecuteOnMainThread( id target, SEL sel, void * p_arg );
50 unsigned int CocoaKeyToVLC( unichar i_key );
52 #define VLCIntf [[VLCMain sharedInstance] getIntf]
54 #define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
55 /* Get an alternate version of the string.
56 * This string is stored as '1:string' but when displayed it only displays
57 * the translated string. the translation should be '1:translatedstring' though */
58 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
60 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
61 @"/System/Library/CoreServices/SystemVersion.plist"] \
62 objectForKey: @"ProductVersion"] floatValue]
64 /*****************************************************************************
65 * intf_sys_t: description and status of the interface
66 *****************************************************************************/
69 NSAutoreleasePool * o_pool;
72 /* the current input */
73 input_thread_t * p_input;
79 /* interface update */
81 bool b_playlist_update;
82 bool b_playmode_update;
83 bool b_current_title_update;
84 bool b_fullscreen_update;
93 /* The messages window */
94 msg_subscription_t * p_sub;
98 /*****************************************************************************
100 *****************************************************************************/
102 @interface VLCMain : NSObject
104 intf_thread_t *p_intf; /* The main intf object */
105 id o_prefs; /* VLCPrefs */
106 id o_sprefs; /* VLCSimplePrefs */
107 id o_about; /* VLAboutBox */
108 id o_open; /* VLCOpen */
109 id o_wizard; /* VLCWizard */
110 id o_extended; /* VLCExtended */
111 id o_bookmarks; /* VLCBookmarks */
112 id o_embedded_list; /* VLCEmbeddedList*/
113 id o_interaction_list; /* VLCInteractionList*/
114 id o_sfilters; /* VLCsFilters */
115 id o_info; /* VLCInformation */
117 id o_update; /* VLCUpdate */
119 id o_eyetv; /* VLCEyeTVController */
120 BOOL nib_main_loaded; /* main nibfile */
121 BOOL nib_open_loaded; /* open nibfile */
122 BOOL nib_about_loaded; /* about nibfile */
123 BOOL nib_wizard_loaded; /* wizard nibfile */
124 BOOL nib_extended_loaded; /* extended nibfile */
125 BOOL nib_bookmarks_loaded; /* bookmarks nibfile */
126 BOOL nib_sfilters_loaded; /* sfilters nibfile */
127 BOOL nib_prefs_loaded; /* preferences nibfile */
128 BOOL nib_update_loaded; /* update nibfile */
129 BOOL nib_info_loaded; /* information panel nibfile */
131 IBOutlet id o_window; /* main window */
132 IBOutlet id o_playlist_view;/* playlist view */
133 IBOutlet id o_scrollfield; /* info field */
134 IBOutlet id o_timefield; /* time field */
135 IBOutlet id o_timeslider; /* time slider */
136 IBOutlet id o_embedded_window; /* Embedded Vout Window */
137 float f_slider; /* slider value */
138 float f_slider_old; /* old slider val */
139 IBOutlet id o_volumeslider; /* volume slider */
141 IBOutlet id o_main_pgbar; /* playlist window progress bar */
142 IBOutlet id o_btn_prev; /* btn previous */
143 IBOutlet id o_btn_rewind; /* btn rewind */
144 IBOutlet id o_btn_play; /* btn play */
145 IBOutlet id o_btn_stop; /* btn stop */
146 IBOutlet id o_btn_ff; /* btn fast forward */
147 IBOutlet id o_btn_next; /* btn next */
148 IBOutlet id o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
149 IBOutlet id o_btn_playlist; /* btn playlist */
150 IBOutlet id o_btn_equalizer; /* eq btn */
152 NSImage * o_img_play; /* btn play img */
153 NSImage * o_img_pause; /* btn pause img */
154 NSImage * o_img_play_pressed; /* btn play img */
155 NSImage * o_img_pause_pressed; /* btn pause img */
157 IBOutlet id o_controls; /* VLCControls */
158 IBOutlet id o_playlist; /* VLCPlaylist */
160 IBOutlet id o_messages; /* messages tv */
161 IBOutlet id o_msgs_panel; /* messages panel */
162 NSMutableArray * o_msg_arr; /* messages array */
163 NSLock * o_msg_lock; /* messages lock */
164 IBOutlet id o_msgs_btn_crashlog; /* messages open crashlog */
168 IBOutlet id o_mi_about;
169 IBOutlet id o_mi_prefs;
170 IBOutlet id o_mi_sprefs;
171 IBOutlet id o_mi_checkForUpdate;
172 IBOutlet id o_mi_add_intf;
173 IBOutlet id o_mu_add_intf;
174 IBOutlet id o_mi_services;
175 IBOutlet id o_mi_hide;
176 IBOutlet id o_mi_hide_others;
177 IBOutlet id o_mi_show_all;
178 IBOutlet id o_mi_quit;
180 IBOutlet id o_mu_file;
181 IBOutlet id o_mi_open_file;
182 IBOutlet id o_mi_open_generic;
183 IBOutlet id o_mi_open_disc;
184 IBOutlet id o_mi_open_net;
185 IBOutlet id o_mi_open_capture;
186 IBOutlet id o_mi_open_recent;
187 IBOutlet id o_mi_open_recent_cm;
188 IBOutlet id o_mi_open_wizard;
190 IBOutlet id o_mu_edit;
191 IBOutlet id o_mi_cut;
192 IBOutlet id o_mi_copy;
193 IBOutlet id o_mi_paste;
194 IBOutlet id o_mi_clear;
195 IBOutlet id o_mi_select_all;
197 IBOutlet id o_mu_controls;
198 IBOutlet id o_mi_play;
199 IBOutlet id o_mi_stop;
200 IBOutlet id o_mi_faster;
201 IBOutlet id o_mi_slower;
202 IBOutlet id o_mi_previous;
203 IBOutlet id o_mi_next;
204 IBOutlet id o_mi_random;
205 IBOutlet id o_mi_repeat;
206 IBOutlet id o_mi_loop;
207 IBOutlet id o_mi_fwd;
208 IBOutlet id o_mi_bwd;
209 IBOutlet id o_mi_fwd1m;
210 IBOutlet id o_mi_bwd1m;
211 IBOutlet id o_mi_fwd5m;
212 IBOutlet id o_mi_bwd5m;
213 IBOutlet id o_mi_program;
214 IBOutlet id o_mu_program;
215 IBOutlet id o_mi_title;
216 IBOutlet id o_mu_title;
217 IBOutlet id o_mi_chapter;
218 IBOutlet id o_mu_chapter;
220 IBOutlet id o_mu_audio;
221 IBOutlet id o_mi_vol_up;
222 IBOutlet id o_mi_vol_down;
223 IBOutlet id o_mi_mute;
224 IBOutlet id o_mi_audiotrack;
225 IBOutlet id o_mu_audiotrack;
226 IBOutlet id o_mi_channels;
227 IBOutlet id o_mu_channels;
228 IBOutlet id o_mi_device;
229 IBOutlet id o_mu_device;
230 IBOutlet id o_mi_visual;
231 IBOutlet id o_mu_visual;
233 IBOutlet id o_mu_video;
234 IBOutlet id o_mi_half_window;
235 IBOutlet id o_mi_normal_window;
236 IBOutlet id o_mi_double_window;
237 IBOutlet id o_mi_fittoscreen;
238 IBOutlet id o_mi_fullscreen;
239 IBOutlet id o_mi_floatontop;
240 IBOutlet id o_mi_snapshot;
241 IBOutlet id o_mi_videotrack;
242 IBOutlet id o_mu_videotrack;
243 IBOutlet id o_mi_screen;
244 IBOutlet id o_mu_screen;
245 IBOutlet id o_mi_aspect_ratio;
246 IBOutlet id o_mu_aspect_ratio;
247 IBOutlet id o_mi_crop;
248 IBOutlet id o_mu_crop;
249 IBOutlet id o_mi_subtitle;
250 IBOutlet id o_mu_subtitle;
251 IBOutlet id o_mi_deinterlace;
252 IBOutlet id o_mu_deinterlace;
253 IBOutlet id o_mi_ffmpeg_pp;
254 IBOutlet id o_mu_ffmpeg_pp;
256 IBOutlet id o_mu_window;
257 IBOutlet id o_mi_minimize;
258 IBOutlet id o_mi_close_window;
259 IBOutlet id o_mi_controller;
260 IBOutlet id o_mi_equalizer;
261 IBOutlet id o_mi_extended;
262 IBOutlet id o_mi_bookmarks;
263 IBOutlet id o_mi_playlist;
264 IBOutlet id o_mi_info;
265 IBOutlet id o_mi_messages;
266 IBOutlet id o_mi_bring_atf;
268 IBOutlet id o_mu_help;
269 IBOutlet id o_mi_help;
270 IBOutlet id o_mi_readme;
271 IBOutlet id o_mi_documentation;
272 IBOutlet id o_mi_license;
273 IBOutlet id o_mi_website;
274 IBOutlet id o_mi_donation;
275 IBOutlet id o_mi_forum;
276 IBOutlet id o_mi_errorsAndWarnings;
279 IBOutlet id o_dmi_play;
280 IBOutlet id o_dmi_stop;
281 IBOutlet id o_dmi_next;
282 IBOutlet id o_dmi_previous;
283 IBOutlet id o_dmi_mute;
286 IBOutlet id o_vout_menu;
287 IBOutlet id o_vmi_play;
288 IBOutlet id o_vmi_stop;
289 IBOutlet id o_vmi_prev;
290 IBOutlet id o_vmi_next;
291 IBOutlet id o_vmi_volup;
292 IBOutlet id o_vmi_voldown;
293 IBOutlet id o_vmi_mute;
294 IBOutlet id o_vmi_fullscreen;
295 IBOutlet id o_vmi_snapshot;
300 NSRect o_restore_rect;
302 mtime_t i_end_scroll;
304 NSSize o_size_with_playlist;
306 NSThread * manageThread;
308 int i_lastShownVolume;
310 AppleRemote * o_remote;
311 BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
314 + (VLCMain *)sharedInstance;
316 - (intf_thread_t *)getIntf;
317 - (void)setIntf:(intf_thread_t *)p_mainintf;
319 - (void)controlTintChanged;
322 - (id)getSimplePreferences;
323 - (id)getPreferences;
328 - (id)getEmbeddedList;
329 - (id)getInteractionList;
330 - (id)getMainIntfPgbar;
331 - (id)getControllerWindow;
333 - (id)getEyeTVController;
334 - (void)applicationWillTerminate:(NSNotification *)notification;
335 - (NSString *)localizedString:(const char *)psz;
336 - (char *)delocalizeString:(NSString *)psz;
337 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
338 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
343 - (void)manageIntf:(NSTimer *)o_timer;
345 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
346 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
347 - (void)resetScrollField;
349 - (void)updateMessageArray;
350 - (void)playStatusUpdated:(int) i_status;
351 - (void)setSubmenusEnabled:(BOOL)b_enabled;
352 - (void)manageVolumeSlider;
353 - (IBAction)timesliderUpdate:(id)sender;
355 - (IBAction)clearRecentItems:(id)sender;
356 - (void)openRecentItem:(id)sender;
358 - (IBAction)intfOpenFile:(id)sender;
359 - (IBAction)intfOpenFileGeneric:(id)sender;
360 - (IBAction)intfOpenDisc:(id)sender;
361 - (IBAction)intfOpenNet:(id)sender;
362 - (IBAction)intfOpenCapture:(id)sender;
364 - (IBAction)showWizard:(id)sender;
365 - (IBAction)showExtended:(id)sender;
366 - (IBAction)showBookmarks:(id)sender;
367 - (IBAction)showSFilters:(id)sender;
369 - (IBAction)viewAbout:(id)sender;
370 - (IBAction)showLicense:(id)sender;
371 - (IBAction)viewPreferences:(id)sender;
372 - (IBAction)checkForUpdate:(id)sender;
373 - (IBAction)viewHelp:(id)sender;
374 - (IBAction)openReadMe:(id)sender;
375 - (IBAction)openDocumentation:(id)sender;
376 - (IBAction)openWebsite:(id)sender;
377 - (IBAction)openForum:(id)sender;
378 - (IBAction)openDonate:(id)sender;
379 - (IBAction)openCrashLog:(id)sender;
380 - (IBAction)viewErrorsAndWarnings:(id)sender;
381 - (IBAction)showMessagesPanel:(id)sender;
382 - (IBAction)showInformationPanel:(id)sender;
384 - (IBAction)togglePlaylist:(id)sender;
385 - (void)updateTogglePlaylistState;
387 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
391 @interface VLCMain (Internal)
392 - (void)handlePortMessage:(NSPortMessage *)o_msg;