1 /*****************************************************************************
2 * intf.h: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2009 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] intf]
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]
58 // You need to release those objects after use
59 input_thread_t
*getInput(void);
60 vout_thread_t
*getVout(void);
61 aout_instance_t
*getAout(void);
63 /*****************************************************************************
64 * intf_sys_t: description and status of the interface
65 *****************************************************************************/
72 /* interface update */
74 bool b_playlist_update
;
75 bool b_playmode_update
;
76 bool b_current_title_update
;
77 bool b_fullscreen_update
;
86 /* The messages window */
87 msg_subscription_t
* p_sub
;
90 /*****************************************************************************
92 *****************************************************************************/
94 @
class VLCInformation
;
95 @
class VLCControllerWindow
;
96 @
class VLCEmbeddedWindow
;
99 @interface VLCMain
: NSObject
101 intf_thread_t
*p_intf
; /* The main intf object */
102 id o_prefs
; /* VLCPrefs */
103 id o_sprefs
; /* VLCSimplePrefs */
104 id o_about
; /* VLAboutBox */
105 id o_open
; /* VLCOpen */
106 id o_wizard
; /* VLCWizard */
107 id o_extended
; /* VLCExtended */
108 id o_bookmarks
; /* VLCBookmarks */
109 id o_embedded_list
; /* VLCEmbeddedList*/
110 id o_coredialogs
; /* VLCCoreDialogProvider */
111 VLCInformation
* o_info
; /* VLCInformation */
112 id o_eyetv
; /* VLCEyeTVController */
113 BOOL nib_main_loaded
; /* main nibfile */
114 BOOL nib_open_loaded
; /* open nibfile */
115 BOOL nib_about_loaded
; /* about nibfile */
116 BOOL nib_wizard_loaded
; /* wizard nibfile */
117 BOOL nib_extended_loaded
; /* extended nibfile */
118 BOOL nib_bookmarks_loaded
; /* bookmarks nibfile */
119 BOOL nib_prefs_loaded
; /* preferences nibfile */
120 BOOL nib_info_loaded
; /* information panel nibfile */
121 BOOL nib_coredialogs_loaded
; /* CoreDialogs nibfile */
123 IBOutlet VLCControllerWindow
* o_window
; /* main window */
124 IBOutlet NSView
* o_playlist_view
; /* playlist view */
125 IBOutlet id o_scrollfield
; /* info field */
126 IBOutlet NSTextField
* o_timefield
; /* time field */
127 IBOutlet NSSlider
* o_timeslider
; /* time slider */
128 BOOL b_time_remaining
; /* show remaining time or playtime ? */
129 IBOutlet VLCEmbeddedWindow
* o_embedded_window
; /* Embedded Vout Window */
130 float f_slider
; /* slider value */
131 float f_slider_old
; /* old slider val */
132 IBOutlet NSSlider
* o_volumeslider
; /* volume slider */
134 IBOutlet NSView
* toolbarMediaControl
; /* view with the controls */
136 IBOutlet NSProgressIndicator
* o_main_pgbar
; /* playlist window progress bar */
137 IBOutlet NSButton
* o_btn_prev
; /* btn previous */
138 IBOutlet NSButton
* o_btn_rewind
; /* btn rewind */
139 IBOutlet NSButton
* o_btn_play
; /* btn play */
140 IBOutlet NSButton
* o_btn_stop
; /* btn stop */
141 IBOutlet NSButton
* o_btn_ff
; /* btn fast forward */
142 IBOutlet NSButton
* o_btn_next
; /* btn next */
143 IBOutlet NSButton
* o_btn_fullscreen
;/* btn fullscreen (embedded vout window) */
144 IBOutlet NSButton
* o_btn_playlist
; /* btn playlist */
145 IBOutlet NSButton
* o_btn_equalizer
; /* eq btn */
147 NSImage
* o_img_play
; /* btn play img */
148 NSImage
* o_img_pause
; /* btn pause img */
149 NSImage
* o_img_play_pressed
; /* btn play img */
150 NSImage
* o_img_pause_pressed
; /* btn pause img */
152 IBOutlet VLCControls
* o_controls
; /* VLCControls */
153 IBOutlet VLCPlaylist
* o_playlist
; /* VLCPlaylist */
155 IBOutlet NSTextView
* o_messages
; /* messages tv */
156 IBOutlet NSWindow
* o_msgs_panel
; /* messages panel */
157 NSMutableArray
* o_msg_arr
; /* messages array */
158 NSLock
* o_msg_lock
; /* messages lock */
159 BOOL b_msg_arr_changed
; /* did the array change? */
160 IBOutlet NSButton
* o_msgs_crashlog_btn
; /* messages open crashlog */
161 IBOutlet NSButton
* o_msgs_save_btn
; /* save the log as rtf */
163 /* CrashReporter panel */
164 IBOutlet NSButton
* o_crashrep_dontSend_btn
;
165 IBOutlet NSButton
* o_crashrep_send_btn
;
166 IBOutlet NSTextView
* o_crashrep_fld
;
167 IBOutlet NSTextField
* o_crashrep_title_txt
;
168 IBOutlet NSTextField
* o_crashrep_desc_txt
;
169 IBOutlet NSWindow
* o_crashrep_win
;
170 IBOutlet NSButton
* o_crashrep_includeEmail_ckb
;
171 IBOutlet NSTextField
* o_crashrep_includeEmail_txt
;
175 IBOutlet NSMenuItem
* o_mi_about
;
176 IBOutlet NSMenuItem
* o_mi_prefs
;
177 IBOutlet NSMenuItem
* o_mi_sprefs
;
178 IBOutlet NSMenuItem
* o_mi_checkForUpdate
;
179 IBOutlet NSMenuItem
* o_mi_add_intf
;
180 IBOutlet NSMenu
* o_mu_add_intf
;
181 IBOutlet NSMenuItem
* o_mi_services
;
182 IBOutlet NSMenuItem
* o_mi_hide
;
183 IBOutlet NSMenuItem
* o_mi_hide_others
;
184 IBOutlet NSMenuItem
* o_mi_show_all
;
185 IBOutlet NSMenuItem
* o_mi_quit
;
187 IBOutlet NSMenu
* o_mu_file
;
188 IBOutlet NSMenuItem
* o_mi_open_file
;
189 IBOutlet NSMenuItem
* o_mi_open_generic
;
190 IBOutlet NSMenuItem
* o_mi_open_disc
;
191 IBOutlet NSMenuItem
* o_mi_open_net
;
192 IBOutlet NSMenuItem
* o_mi_open_capture
;
193 IBOutlet NSMenuItem
* o_mi_open_recent
;
194 IBOutlet NSMenuItem
* o_mi_open_recent_cm
;
195 IBOutlet NSMenuItem
* o_mi_open_wizard
;
197 IBOutlet NSMenu
* o_mu_edit
;
198 IBOutlet NSMenuItem
* o_mi_cut
;
199 IBOutlet NSMenuItem
* o_mi_copy
;
200 IBOutlet NSMenuItem
* o_mi_paste
;
201 IBOutlet NSMenuItem
* o_mi_clear
;
202 IBOutlet NSMenuItem
* o_mi_select_all
;
204 IBOutlet NSMenu
* o_mu_controls
;
205 IBOutlet NSMenuItem
* o_mi_play
;
206 IBOutlet NSMenuItem
* o_mi_stop
;
207 IBOutlet NSMenuItem
* o_mi_faster
;
208 IBOutlet NSMenuItem
* o_mi_slower
;
209 IBOutlet NSMenuItem
* o_mi_normalSpeed
;
210 IBOutlet NSMenuItem
* o_mi_previous
;
211 IBOutlet NSMenuItem
* o_mi_next
;
212 IBOutlet NSMenuItem
* o_mi_random
;
213 IBOutlet NSMenuItem
* o_mi_repeat
;
214 IBOutlet NSMenuItem
* o_mi_loop
;
215 IBOutlet NSMenuItem
* o_mi_quitAfterPB
;
216 IBOutlet NSMenuItem
* o_mi_fwd
;
217 IBOutlet NSMenuItem
* o_mi_bwd
;
218 IBOutlet NSMenuItem
* o_mi_fwd1m
;
219 IBOutlet NSMenuItem
* o_mi_bwd1m
;
220 IBOutlet NSMenuItem
* o_mi_fwd5m
;
221 IBOutlet NSMenuItem
* o_mi_bwd5m
;
222 IBOutlet NSMenuItem
* o_mi_program
;
223 IBOutlet NSMenu
* o_mu_program
;
224 IBOutlet NSMenuItem
* o_mi_title
;
225 IBOutlet NSMenu
* o_mu_title
;
226 IBOutlet NSMenuItem
* o_mi_chapter
;
227 IBOutlet NSMenu
* o_mu_chapter
;
229 IBOutlet NSMenu
* o_mu_audio
;
230 IBOutlet NSMenuItem
* o_mi_vol_up
;
231 IBOutlet NSMenuItem
* o_mi_vol_down
;
232 IBOutlet NSMenuItem
* o_mi_mute
;
233 IBOutlet NSMenuItem
* o_mi_audiotrack
;
234 IBOutlet NSMenu
* o_mu_audiotrack
;
235 IBOutlet NSMenuItem
* o_mi_channels
;
236 IBOutlet NSMenu
* o_mu_channels
;
237 IBOutlet NSMenuItem
* o_mi_device
;
238 IBOutlet NSMenu
* o_mu_device
;
239 IBOutlet NSMenuItem
* o_mi_visual
;
240 IBOutlet NSMenu
* o_mu_visual
;
242 IBOutlet NSMenu
* o_mu_video
;
243 IBOutlet NSMenuItem
* o_mi_half_window
;
244 IBOutlet NSMenuItem
* o_mi_normal_window
;
245 IBOutlet NSMenuItem
* o_mi_double_window
;
246 IBOutlet NSMenuItem
* o_mi_fittoscreen
;
247 IBOutlet NSMenuItem
* o_mi_fullscreen
;
248 IBOutlet NSMenuItem
* o_mi_floatontop
;
249 IBOutlet NSMenuItem
* o_mi_snapshot
;
250 IBOutlet NSMenuItem
* o_mi_videotrack
;
251 IBOutlet NSMenu
* o_mu_videotrack
;
252 IBOutlet NSMenuItem
* o_mi_screen
;
253 IBOutlet NSMenu
* o_mu_screen
;
254 IBOutlet NSMenuItem
* o_mi_aspect_ratio
;
255 IBOutlet NSMenu
* o_mu_aspect_ratio
;
256 IBOutlet NSMenuItem
* o_mi_crop
;
257 IBOutlet NSMenu
* o_mu_crop
;
258 IBOutlet NSMenuItem
* o_mi_subtitle
;
259 IBOutlet NSMenu
* o_mu_subtitle
;
260 IBOutlet NSMenuItem
* o_mi_addSub
;
261 IBOutlet NSMenuItem
* o_mi_deinterlace
;
262 IBOutlet NSMenu
* o_mu_deinterlace
;
263 IBOutlet NSMenu
* o_mu_deinterlace_mode
;
264 IBOutlet NSMenuItem
* o_mi_deinterlace_mode
;
265 IBOutlet NSMenuItem
* o_mi_ffmpeg_pp
;
266 IBOutlet NSMenu
* o_mu_ffmpeg_pp
;
267 IBOutlet NSMenuItem
* o_mi_teletext
;
268 IBOutlet NSMenuItem
* o_mi_teletext_transparent
;
269 IBOutlet NSMenuItem
* o_mi_teletext_index
;
270 IBOutlet NSMenuItem
* o_mi_teletext_red
;
271 IBOutlet NSMenuItem
* o_mi_teletext_green
;
272 IBOutlet NSMenuItem
* o_mi_teletext_yellow
;
273 IBOutlet NSMenuItem
* o_mi_teletext_blue
;
275 IBOutlet NSMenu
* o_mu_window
;
276 IBOutlet NSMenuItem
* o_mi_minimize
;
277 IBOutlet NSMenuItem
* o_mi_close_window
;
278 IBOutlet NSMenuItem
* o_mi_player
;
279 IBOutlet NSMenuItem
* o_mi_controller
;
280 IBOutlet NSMenuItem
* o_mi_equalizer
;
281 IBOutlet NSMenuItem
* o_mi_extended
;
282 IBOutlet NSMenuItem
* o_mi_bookmarks
;
283 IBOutlet NSMenuItem
* o_mi_playlist
;
284 IBOutlet NSMenuItem
* o_mi_info
;
285 IBOutlet NSMenuItem
* o_mi_messages
;
286 IBOutlet NSMenuItem
* o_mi_bring_atf
;
288 IBOutlet NSMenu
* o_mu_help
;
289 IBOutlet NSMenuItem
* o_mi_help
;
290 IBOutlet NSMenuItem
* o_mi_readme
;
291 IBOutlet NSMenuItem
* o_mi_documentation
;
292 IBOutlet NSMenuItem
* o_mi_license
;
293 IBOutlet NSMenuItem
* o_mi_website
;
294 IBOutlet NSMenuItem
* o_mi_donation
;
295 IBOutlet NSMenuItem
* o_mi_forum
;
296 IBOutlet NSMenuItem
* o_mi_errorsAndWarnings
;
299 IBOutlet NSMenuItem
* o_dmi_play
;
300 IBOutlet NSMenuItem
* o_dmi_stop
;
301 IBOutlet NSMenuItem
* o_dmi_next
;
302 IBOutlet NSMenuItem
* o_dmi_previous
;
303 IBOutlet NSMenuItem
* o_dmi_mute
;
306 IBOutlet NSMenu
* o_vout_menu
;
307 IBOutlet NSMenuItem
* o_vmi_play
;
308 IBOutlet NSMenuItem
* o_vmi_stop
;
309 IBOutlet NSMenuItem
* o_vmi_prev
;
310 IBOutlet NSMenuItem
* o_vmi_next
;
311 IBOutlet NSMenuItem
* o_vmi_volup
;
312 IBOutlet NSMenuItem
* o_vmi_voldown
;
313 IBOutlet NSMenuItem
* o_vmi_mute
;
314 IBOutlet NSMenuItem
* o_vmi_fullscreen
;
315 IBOutlet NSMenuItem
* o_vmi_snapshot
;
320 NSRect o_restore_rect
;
322 mtime_t i_end_scroll
;
324 NSSize o_size_with_playlist
;
326 int i_lastShownVolume
;
328 input_state_e cachedInputState
;
330 /* the manage thread */
331 pthread_t manage_thread
;
333 /* The timer that update the interface */
334 NSTimer
* interfaceTimer
;
336 NSURLConnection
* crashLogURLConnection
;
338 AppleRemote
* o_remote
;
339 BOOL b_remote_button_hold
; /* true as long as the user holds the left,right,plus or minus on the remote control */
342 + (VLCMain
*)sharedInstance
;
344 - (intf_thread_t
*)intf
;
345 - (void)setIntf
:(intf_thread_t
*)p_mainintf
;
347 - (void)controlTintChanged
;
350 - (id
)simplePreferences
;
353 - (BOOL
)isPlaylistCollapsed
;
358 - (id
)coreDialogProvider
;
360 - (id
)controllerWindow
;
362 - (id
)eyeTVController
;
363 - (id
)appleRemoteController
;
364 - (void)applicationWillTerminate
:(NSNotification
*)notification
;
365 - (NSString
*)localizedString
:(const char *)psz
;
366 - (char *)delocalizeString
:(NSString
*)psz
;
367 - (NSString
*)wrapString
: (NSString
*)o_in_string toWidth
: (int)i_width
;
368 - (BOOL
)hasDefinedShortcutKey
:(NSEvent
*)o_event
;
373 - (void)manageIntf
:(NSTimer
*)o_timer
;
375 - (void)refreshVoutDeviceMenu
:(NSNotification
*)o_notification
;
376 - (void)setScrollField
:(NSString
*)o_string stopAfter
:(int )timeout
;
377 - (void)resetScrollField
;
379 - (void)updateMessageDisplay
;
380 - (void)playStatusUpdated
:(int) i_status
;
381 - (void)setSubmenusEnabled
:(BOOL
)b_enabled
;
382 - (void)manageVolumeSlider
;
383 - (IBAction
)timesliderUpdate
:(id
)sender
;
384 - (IBAction
)timeFieldWasClicked
:(id
)sender
;
386 - (IBAction
)clearRecentItems
:(id
)sender
;
387 - (void)openRecentItem
:(id
)sender
;
389 - (IBAction
)intfOpenFile
:(id
)sender
;
390 - (IBAction
)intfOpenFileGeneric
:(id
)sender
;
391 - (IBAction
)intfOpenDisc
:(id
)sender
;
392 - (IBAction
)intfOpenNet
:(id
)sender
;
393 - (IBAction
)intfOpenCapture
:(id
)sender
;
395 - (IBAction
)showWizard
:(id
)sender
;
396 - (IBAction
)showExtended
:(id
)sender
;
397 - (IBAction
)showBookmarks
:(id
)sender
;
399 - (IBAction
)viewAbout
:(id
)sender
;
400 - (IBAction
)showLicense
:(id
)sender
;
401 - (IBAction
)viewPreferences
:(id
)sender
;
402 - (IBAction
)viewHelp
:(id
)sender
;
403 - (IBAction
)openReadMe
:(id
)sender
;
404 - (IBAction
)openDocumentation
:(id
)sender
;
405 - (IBAction
)openWebsite
:(id
)sender
;
406 - (IBAction
)openForum
:(id
)sender
;
407 - (IBAction
)openDonate
:(id
)sender
;
408 - (IBAction
)openCrashLog
:(id
)sender
;
409 - (IBAction
)viewErrorsAndWarnings
:(id
)sender
;
410 - (IBAction
)showMessagesPanel
:(id
)sender
;
411 - (IBAction
)showInformationPanel
:(id
)sender
;
413 - (IBAction
)crashReporterAction
:(id
)sender
;
414 - (IBAction
)saveDebugLog
:(id
)sender
;
416 - (IBAction
)togglePlaylist
:(id
)sender
;
417 - (void)updateTogglePlaylistState
;
419 - (void)windowDidBecomeKey
:(NSNotification
*)o_notification
;
423 @interface
VLCMain (Internal
)
424 - (void)handlePortMessage
:(NSPortMessage
*)o_msg
;
427 /*****************************************************************************
428 * VLCApplication interface
429 *****************************************************************************/
431 @interface VLCApplication
: NSApplication
434 BOOL b_mediaKeySupport
;
435 BOOL b_activeInBackground
;
439 - (void)coreChangedMediaKeySupportSetting
: (NSNotification
*)o_notification
;
440 - (void)sendEvent
: (NSEvent
*)event
;