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_mainmenu; /* VLCMainMenu */
104 id o_prefs; /* VLCPrefs */
105 id o_sprefs; /* VLCSimplePrefs */
106 id o_open; /* VLCOpen */
107 id o_wizard; /* VLCWizard */
108 id o_embedded_list; /* VLCEmbeddedList*/
109 id o_coredialogs; /* VLCCoreDialogProvider */
110 VLCInformation * o_info; /* VLCInformation */
111 id o_eyetv; /* VLCEyeTVController */
112 id o_bookmarks; /* VLCBookmarks */
113 id o_coreinteraction; /* VLCCoreInteraction */
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_prefs_loaded; /* preferences nibfile */
119 BOOL nib_info_loaded; /* information panel nibfile */
120 BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
121 BOOL nib_bookmarks_loaded; /* Bookmarks nibfile */
123 IBOutlet VLCControllerWindow * o_window; /* main window */
124 IBOutlet id o_scrollfield; /* info field */
125 IBOutlet NSTextField * o_timefield; /* time field */
126 IBOutlet NSSlider * o_timeslider; /* time slider */
127 BOOL b_time_remaining; /* show remaining time or playtime ? */
128 IBOutlet VLCEmbeddedWindow * o_embedded_window; /* Embedded Vout Window */
129 float f_slider; /* slider value */
130 float f_slider_old; /* old slider val */
131 IBOutlet NSSlider * o_volumeslider; /* volume slider */
133 IBOutlet NSProgressIndicator * o_main_pgbar; /* playlist window progress bar */
134 IBOutlet NSButton * o_btn_prev; /* btn previous */
135 IBOutlet NSButton * o_btn_rewind; /* btn rewind */
136 IBOutlet NSButton * o_btn_play; /* btn play */
137 IBOutlet NSButton * o_btn_stop; /* btn stop */
138 IBOutlet NSButton * o_btn_ff; /* btn fast forward */
139 IBOutlet NSButton * o_btn_next; /* btn next */
140 IBOutlet NSButton * o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
141 IBOutlet NSButton * o_btn_playlist; /* btn playlist */
142 IBOutlet NSButton * o_btn_audioEffects; /* AudioEffects btn */
144 NSImage * o_img_play; /* btn play img */
145 NSImage * o_img_pause; /* btn pause img */
146 NSImage * o_img_play_pressed; /* btn play img */
147 NSImage * o_img_pause_pressed; /* btn pause img */
149 IBOutlet VLCControls * o_controls; /* VLCControls */
150 IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
152 IBOutlet NSTextView * o_messages; /* messages tv */
153 IBOutlet NSWindow * o_msgs_panel; /* messages panel */
154 NSMutableArray * o_msg_arr; /* messages array */
155 NSLock * o_msg_lock; /* messages lock */
156 BOOL b_msg_arr_changed; /* did the array change? */
157 IBOutlet NSButton * o_msgs_crashlog_btn; /* messages open crashlog */
158 IBOutlet NSButton * o_msgs_save_btn; /* save the log as rtf */
160 /* CrashReporter panel */
161 IBOutlet NSButton * o_crashrep_dontSend_btn;
162 IBOutlet NSButton * o_crashrep_send_btn;
163 IBOutlet NSTextView * o_crashrep_fld;
164 IBOutlet NSTextField * o_crashrep_title_txt;
165 IBOutlet NSTextField * o_crashrep_desc_txt;
166 IBOutlet NSWindow * o_crashrep_win;
167 IBOutlet NSButton * o_crashrep_includeEmail_ckb;
168 IBOutlet NSTextField * o_crashrep_includeEmail_txt;
170 mtime_t i_end_scroll;
172 int i_lastShownVolume;
174 input_state_e cachedInputState;
176 /* the manage thread */
177 pthread_t manage_thread;
179 /* The timer that update the interface */
180 NSTimer * interfaceTimer;
182 NSURLConnection * crashLogURLConnection;
184 AppleRemote * o_remote;
185 BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
187 /* media key support */
188 BOOL b_mediaKeySupport;
189 BOOL b_mediakeyJustJumped;
190 SPMediaKeyTap * o_mediaKeyController;
192 NSArray *o_usedHotkeys;
195 + (VLCMain *)sharedInstance;
197 - (intf_thread_t *)intf;
198 - (void)setIntf:(intf_thread_t *)p_mainintf;
204 - (id)simplePreferences;
207 - (BOOL)isPlaylistCollapsed;
211 - (id)getVideoViewAtPositionX: (int *)pi_x Y: (int *)pi_y withWidth: (unsigned int*)pi_width andHeight: (unsigned int*)pi_height;
212 - (id)coreDialogProvider;
214 - (id)controllerWindow;
215 - (id)eyeTVController;
216 - (id)appleRemoteController;
217 - (void)applicationWillTerminate:(NSNotification *)notification;
218 - (NSString *)localizedString:(const char *)psz;
219 - (char *)delocalizeString:(NSString *)psz;
220 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
221 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
222 - (NSString *)VLCKeyToString:(NSString *)theString;
223 - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
224 - (void)updateCurrentlyUsedHotkeys;
227 - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename;
230 - (void)manageIntf:(NSTimer *)o_timer;
232 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
233 - (void)resetScrollField;
235 - (void)updateMessageDisplay;
236 - (void)playStatusUpdated:(int) i_status;
237 - (void)manageVolumeSlider;
238 - (IBAction)timesliderUpdate:(id)sender;
239 - (IBAction)timeFieldWasClicked:(id)sender;
240 - (IBAction)showController:(id)sender;
242 - (IBAction)crashReporterAction:(id)sender;
243 - (IBAction)openCrashLog:(id)sender;
244 - (IBAction)saveDebugLog:(id)sender;
245 - (IBAction)showMessagesPanel:(id)sender;
247 - (IBAction)togglePlaylist:(id)sender;
248 - (void)updateTogglePlaylistState;
250 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
252 - (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
255 @interface VLCMain (Internal)
256 - (void)handlePortMessage:(NSPortMessage *)o_msg;
257 - (void)resetMediaKeyJump;
258 - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
261 /*****************************************************************************
262 * VLCApplication interface
263 *****************************************************************************/
265 @interface VLCApplication : NSApplication