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 *****************************************************************************/
71 int i_old_play_status;
73 /* interface update */
75 bool b_playlist_update;
76 bool b_playmode_update;
77 bool b_current_title_update;
78 bool b_fullscreen_update;
86 /* The messages window */
87 msg_subscription_t * p_sub;
90 /*****************************************************************************
92 *****************************************************************************/
94 @class VLCInformation;
95 @class VLCEmbeddedWindow;
98 @interface VLCMain : NSObject
100 intf_thread_t *p_intf; /* The main intf object */
101 id o_mainmenu; /* VLCMainMenu */
102 id o_prefs; /* VLCPrefs */
103 id o_sprefs; /* VLCSimplePrefs */
104 id o_open; /* VLCOpen */
105 id o_wizard; /* VLCWizard */
106 id o_embedded_list; /* VLCEmbeddedList*/
107 id o_coredialogs; /* VLCCoreDialogProvider */
108 VLCInformation * o_info; /* VLCInformation */
109 id o_eyetv; /* VLCEyeTVController */
110 id o_bookmarks; /* VLCBookmarks */
111 id o_coreinteraction; /* VLCCoreInteraction */
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_prefs_loaded; /* preferences nibfile */
117 BOOL nib_info_loaded; /* information panel nibfile */
118 BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
119 BOOL nib_bookmarks_loaded; /* Bookmarks nibfile */
121 IBOutlet id o_mainwindow; /* VLCMainWindow */
123 IBOutlet VLCControls * o_controls; /* VLCControls */
124 IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
126 IBOutlet NSTextView * o_messages; /* messages tv */
127 IBOutlet NSWindow * o_msgs_panel; /* messages panel */
128 NSMutableArray * o_msg_arr; /* messages array */
129 NSLock * o_msg_lock; /* messages lock */
130 BOOL b_msg_arr_changed; /* did the array change? */
131 IBOutlet NSButton * o_msgs_crashlog_btn; /* messages open crashlog */
132 IBOutlet NSButton * o_msgs_save_btn; /* save the log as rtf */
134 /* CrashReporter panel */
135 IBOutlet NSButton * o_crashrep_dontSend_btn;
136 IBOutlet NSButton * o_crashrep_send_btn;
137 IBOutlet NSTextView * o_crashrep_fld;
138 IBOutlet NSTextField * o_crashrep_title_txt;
139 IBOutlet NSTextField * o_crashrep_desc_txt;
140 IBOutlet NSWindow * o_crashrep_win;
141 IBOutlet NSButton * o_crashrep_includeEmail_ckb;
142 IBOutlet NSTextField * o_crashrep_includeEmail_txt;
144 input_state_e cachedInputState;
146 /* the manage thread */
147 pthread_t manage_thread;
149 /* The timer that update the interface */
150 NSTimer * interfaceTimer;
152 NSURLConnection * crashLogURLConnection;
154 AppleRemote * o_remote;
155 BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
157 /* media key support */
158 BOOL b_mediaKeySupport;
159 BOOL b_mediakeyJustJumped;
160 SPMediaKeyTap * o_mediaKeyController;
162 NSArray *o_usedHotkeys;
165 + (VLCMain *)sharedInstance;
167 - (intf_thread_t *)intf;
168 - (void)setIntf:(intf_thread_t *)p_mainintf;
174 - (id)simplePreferences;
180 - (id)getVideoViewAtPositionX: (int *)pi_x Y: (int *)pi_y withWidth: (unsigned int*)pi_width andHeight: (unsigned int*)pi_height;
181 - (id)coreDialogProvider;
182 - (id)eyeTVController;
183 - (id)appleRemoteController;
184 - (void)applicationWillTerminate:(NSNotification *)notification;
185 - (NSString *)localizedString:(const char *)psz;
186 - (char *)delocalizeString:(NSString *)psz;
187 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
188 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
189 - (NSString *)VLCKeyToString:(NSString *)theString;
190 - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
191 - (void)updateCurrentlyUsedHotkeys;
194 - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename;
197 - (void)manageIntf:(NSTimer *)o_timer;
199 - (void)updateMessageDisplay;
200 - (void)playStatusUpdated:(int) i_status;
201 - (IBAction)showController:(id)sender;
203 - (IBAction)crashReporterAction:(id)sender;
204 - (IBAction)openCrashLog:(id)sender;
205 - (IBAction)saveDebugLog:(id)sender;
206 - (IBAction)showMessagesPanel:(id)sender;
208 - (IBAction)togglePlaylist:(id)sender;
209 - (void)updateTogglePlaylistState;
211 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
213 - (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
216 @interface VLCMain (Internal)
217 - (void)handlePortMessage:(NSPortMessage *)o_msg;
218 - (void)resetMediaKeyJump;
219 - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
222 /*****************************************************************************
223 * VLCApplication interface
224 *****************************************************************************/
226 @interface VLCApplication : NSApplication