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 unsigned int CocoaKeyToVLC( unichar i_key );
51 #define VLCIntf [[VLCMain sharedInstance] getIntf]
53 #define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
54 /* Get an alternate version of the string.
55 * This string is stored as '1:string' but when displayed it only displays
56 * the translated string. the translation should be '1:translatedstring' though */
57 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
59 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
60 @"/System/Library/CoreServices/SystemVersion.plist"] \
61 objectForKey: @"ProductVersion"] floatValue]
63 /*****************************************************************************
64 * intf_sys_t: description and status of the interface
65 *****************************************************************************/
68 NSAutoreleasePool * o_pool;
74 /* interface update */
76 bool b_playlist_update;
77 bool b_playmode_update;
78 bool b_current_title_update;
79 bool b_fullscreen_update;
88 /* The messages window */
89 msg_subscription_t * p_sub;
92 /*****************************************************************************
94 *****************************************************************************/
96 @class VLCInformation;
97 @interface VLCMain : NSObject
99 intf_thread_t *p_intf; /* The main intf object */
100 id o_prefs; /* VLCPrefs */
101 id o_sprefs; /* VLCSimplePrefs */
102 id o_about; /* VLAboutBox */
103 id o_open; /* VLCOpen */
104 id o_wizard; /* VLCWizard */
105 id o_extended; /* VLCExtended */
106 id o_bookmarks; /* VLCBookmarks */
107 id o_embedded_list; /* VLCEmbeddedList*/
108 id o_interaction_list; /* VLCInteractionList*/
109 VLCInformation * o_info; /* VLCInformation */
111 id o_update; /* VLCUpdate */
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_update_loaded; /* update nibfile */
122 BOOL nib_info_loaded; /* information panel nibfile */
124 IBOutlet id o_window; /* main window */
125 IBOutlet id o_playlist_view;/* playlist view */
126 IBOutlet id o_scrollfield; /* info field */
127 IBOutlet id o_timefield; /* time field */
128 IBOutlet id o_timeslider; /* time slider */
129 IBOutlet id o_embedded_window; /* Embedded Vout Window */
130 float f_slider; /* slider value */
131 float f_slider_old; /* old slider val */
132 IBOutlet id o_volumeslider; /* volume slider */
134 IBOutlet id o_main_pgbar; /* playlist window progress bar */
135 IBOutlet id o_btn_prev; /* btn previous */
136 IBOutlet id o_btn_rewind; /* btn rewind */
137 IBOutlet id o_btn_play; /* btn play */
138 IBOutlet id o_btn_stop; /* btn stop */
139 IBOutlet id o_btn_ff; /* btn fast forward */
140 IBOutlet id o_btn_next; /* btn next */
141 IBOutlet id o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
142 IBOutlet id o_btn_playlist; /* btn playlist */
143 IBOutlet id 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 id o_controls; /* VLCControls */
151 IBOutlet id 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 id o_msgs_btn_crashlog; /* messages open crashlog */
161 IBOutlet id o_mi_about;
162 IBOutlet id o_mi_prefs;
163 IBOutlet id o_mi_sprefs;
164 IBOutlet id o_mi_checkForUpdate;
165 IBOutlet id o_mi_add_intf;
166 IBOutlet id o_mu_add_intf;
167 IBOutlet id o_mi_services;
168 IBOutlet id o_mi_hide;
169 IBOutlet id o_mi_hide_others;
170 IBOutlet id o_mi_show_all;
171 IBOutlet id o_mi_quit;
173 IBOutlet id o_mu_file;
174 IBOutlet id o_mi_open_file;
175 IBOutlet id o_mi_open_generic;
176 IBOutlet id o_mi_open_disc;
177 IBOutlet id o_mi_open_net;
178 IBOutlet id o_mi_open_capture;
179 IBOutlet id o_mi_open_recent;
180 IBOutlet id o_mi_open_recent_cm;
181 IBOutlet id o_mi_open_wizard;
183 IBOutlet id o_mu_edit;
184 IBOutlet id o_mi_cut;
185 IBOutlet id o_mi_copy;
186 IBOutlet id o_mi_paste;
187 IBOutlet id o_mi_clear;
188 IBOutlet id o_mi_select_all;
190 IBOutlet id o_mu_controls;
191 IBOutlet id o_mi_play;
192 IBOutlet id o_mi_stop;
193 IBOutlet id o_mi_faster;
194 IBOutlet id o_mi_slower;
195 IBOutlet id o_mi_previous;
196 IBOutlet id o_mi_next;
197 IBOutlet id o_mi_random;
198 IBOutlet id o_mi_repeat;
199 IBOutlet id o_mi_loop;
200 IBOutlet id o_mi_fwd;
201 IBOutlet id o_mi_bwd;
202 IBOutlet id o_mi_fwd1m;
203 IBOutlet id o_mi_bwd1m;
204 IBOutlet id o_mi_fwd5m;
205 IBOutlet id o_mi_bwd5m;
206 IBOutlet id o_mi_program;
207 IBOutlet id o_mu_program;
208 IBOutlet id o_mi_title;
209 IBOutlet id o_mu_title;
210 IBOutlet id o_mi_chapter;
211 IBOutlet id o_mu_chapter;
213 IBOutlet id o_mu_audio;
214 IBOutlet id o_mi_vol_up;
215 IBOutlet id o_mi_vol_down;
216 IBOutlet id o_mi_mute;
217 IBOutlet id o_mi_audiotrack;
218 IBOutlet id o_mu_audiotrack;
219 IBOutlet id o_mi_channels;
220 IBOutlet id o_mu_channels;
221 IBOutlet id o_mi_device;
222 IBOutlet id o_mu_device;
223 IBOutlet id o_mi_visual;
224 IBOutlet id o_mu_visual;
226 IBOutlet id o_mu_video;
227 IBOutlet id o_mi_half_window;
228 IBOutlet id o_mi_normal_window;
229 IBOutlet id o_mi_double_window;
230 IBOutlet id o_mi_fittoscreen;
231 IBOutlet id o_mi_fullscreen;
232 IBOutlet id o_mi_floatontop;
233 IBOutlet id o_mi_snapshot;
234 IBOutlet id o_mi_videotrack;
235 IBOutlet id o_mu_videotrack;
236 IBOutlet id o_mi_screen;
237 IBOutlet id o_mu_screen;
238 IBOutlet id o_mi_aspect_ratio;
239 IBOutlet id o_mu_aspect_ratio;
240 IBOutlet id o_mi_crop;
241 IBOutlet id o_mu_crop;
242 IBOutlet id o_mi_subtitle;
243 IBOutlet id o_mu_subtitle;
244 IBOutlet id o_mi_deinterlace;
245 IBOutlet id o_mu_deinterlace;
246 IBOutlet id o_mi_ffmpeg_pp;
247 IBOutlet id o_mu_ffmpeg_pp;
249 IBOutlet id o_mu_window;
250 IBOutlet id o_mi_minimize;
251 IBOutlet id o_mi_close_window;
252 IBOutlet id o_mi_controller;
253 IBOutlet id o_mi_equalizer;
254 IBOutlet id o_mi_extended;
255 IBOutlet id o_mi_bookmarks;
256 IBOutlet id o_mi_playlist;
257 IBOutlet id o_mi_info;
258 IBOutlet id o_mi_messages;
259 IBOutlet id o_mi_bring_atf;
261 IBOutlet id o_mu_help;
262 IBOutlet id o_mi_help;
263 IBOutlet id o_mi_readme;
264 IBOutlet id o_mi_documentation;
265 IBOutlet id o_mi_license;
266 IBOutlet id o_mi_website;
267 IBOutlet id o_mi_donation;
268 IBOutlet id o_mi_forum;
269 IBOutlet id o_mi_errorsAndWarnings;
272 IBOutlet id o_dmi_play;
273 IBOutlet id o_dmi_stop;
274 IBOutlet id o_dmi_next;
275 IBOutlet id o_dmi_previous;
276 IBOutlet id o_dmi_mute;
279 IBOutlet id o_vout_menu;
280 IBOutlet id o_vmi_play;
281 IBOutlet id o_vmi_stop;
282 IBOutlet id o_vmi_prev;
283 IBOutlet id o_vmi_next;
284 IBOutlet id o_vmi_volup;
285 IBOutlet id o_vmi_voldown;
286 IBOutlet id o_vmi_mute;
287 IBOutlet id o_vmi_fullscreen;
288 IBOutlet id o_vmi_snapshot;
293 NSRect o_restore_rect;
295 mtime_t i_end_scroll;
297 NSSize o_size_with_playlist;
299 int i_lastShownVolume;
301 /* the manage thread */
302 pthread_t manage_thread;
304 /* The timer that update the interface */
305 NSTimer * interfaceTimer;
307 AppleRemote * o_remote;
308 BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
311 + (VLCMain *)sharedInstance;
313 - (intf_thread_t *)getIntf;
314 - (void)setIntf:(intf_thread_t *)p_mainintf;
316 - (void)controlTintChanged;
319 - (id)getSimplePreferences;
320 - (id)getPreferences;
325 - (id)getEmbeddedList;
326 - (id)getInteractionList;
327 - (id)getMainIntfPgbar;
328 - (id)getControllerWindow;
330 - (id)getEyeTVController;
331 - (void)applicationWillTerminate:(NSNotification *)notification;
332 - (NSString *)localizedString:(const char *)psz;
333 - (char *)delocalizeString:(NSString *)psz;
334 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
335 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
340 - (void)manageIntf:(NSTimer *)o_timer;
342 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
343 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
344 - (void)resetScrollField;
346 - (void)updateMessageArray;
347 - (void)playStatusUpdated:(int) i_status;
348 - (void)setSubmenusEnabled:(BOOL)b_enabled;
349 - (void)manageVolumeSlider;
350 - (IBAction)timesliderUpdate:(id)sender;
352 - (IBAction)clearRecentItems:(id)sender;
353 - (void)openRecentItem:(id)sender;
355 - (IBAction)intfOpenFile:(id)sender;
356 - (IBAction)intfOpenFileGeneric:(id)sender;
357 - (IBAction)intfOpenDisc:(id)sender;
358 - (IBAction)intfOpenNet:(id)sender;
359 - (IBAction)intfOpenCapture:(id)sender;
361 - (IBAction)showWizard:(id)sender;
362 - (IBAction)showExtended:(id)sender;
363 - (IBAction)showBookmarks:(id)sender;
365 - (IBAction)viewAbout:(id)sender;
366 - (IBAction)showLicense:(id)sender;
367 - (IBAction)viewPreferences:(id)sender;
368 - (IBAction)checkForUpdate:(id)sender;
369 - (IBAction)viewHelp:(id)sender;
370 - (IBAction)openReadMe:(id)sender;
371 - (IBAction)openDocumentation:(id)sender;
372 - (IBAction)openWebsite:(id)sender;
373 - (IBAction)openForum:(id)sender;
374 - (IBAction)openDonate:(id)sender;
375 - (IBAction)openCrashLog:(id)sender;
376 - (IBAction)viewErrorsAndWarnings:(id)sender;
377 - (IBAction)showMessagesPanel:(id)sender;
378 - (IBAction)showInformationPanel:(id)sender;
380 - (IBAction)togglePlaylist:(id)sender;
381 - (void)updateTogglePlaylistState;
383 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
387 @interface VLCMain (Internal)
388 - (void)handlePortMessage:(NSPortMessage *)o_msg;