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 */
42 /*****************************************************************************
44 *****************************************************************************/
45 unsigned int CocoaKeyToVLC( unichar i_key );
47 #define VLCIntf [[VLCMain sharedInstance] intf]
49 #define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
50 /* Get an alternate version of the string.
51 * This string is stored as '1:string' but when displayed it only displays
52 * the translated string. the translation should be '1:translatedstring' though */
53 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
55 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
56 @"/System/Library/CoreServices/SystemVersion.plist"] \
57 objectForKey: @"ProductVersion"] floatValue]
60 // You need to release those objects after use
61 input_thread_t *getInput(void);
62 vout_thread_t *getVout(void);
63 audio_output_t *getAout(void);
65 /*****************************************************************************
66 * intf_sys_t: description and status of the interface
67 *****************************************************************************/
75 /* The messages window */
76 msg_subscription_t * p_sub;
79 /*****************************************************************************
81 *****************************************************************************/
83 @class VLCInformation;
84 @class VLCEmbeddedWindow;
87 @interface VLCMain : NSObject <NSWindowDelegate>
89 intf_thread_t *p_intf; /* The main intf object */
90 id o_mainmenu; /* VLCMainMenu */
91 id o_prefs; /* VLCPrefs */
92 id o_sprefs; /* VLCSimplePrefs */
93 id o_open; /* VLCOpen */
94 id o_wizard; /* VLCWizard */
95 id o_embedded_list; /* VLCEmbeddedList*/
96 id o_coredialogs; /* VLCCoreDialogProvider */
97 id o_info; /* VLCInformation */
98 id o_eyetv; /* VLCEyeTVController */
99 id o_bookmarks; /* VLCBookmarks */
100 id o_coreinteraction; /* VLCCoreInteraction */
101 BOOL nib_main_loaded; /* main nibfile */
102 BOOL nib_open_loaded; /* open nibfile */
103 BOOL nib_about_loaded; /* about nibfile */
104 BOOL nib_wizard_loaded; /* wizard nibfile */
105 BOOL nib_prefs_loaded; /* preferences nibfile */
106 BOOL nib_info_loaded; /* information panel nibfile */
107 BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
108 BOOL nib_bookmarks_loaded; /* Bookmarks nibfile */
109 BOOL b_active_videoplayback;
111 id o_mainwindow; /* VLCMainWindow */
113 IBOutlet VLCControls * o_controls; /* VLCControls */
114 IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
116 IBOutlet NSTextView * o_messages; /* messages tv */
117 IBOutlet NSWindow * o_msgs_panel; /* messages panel */
118 NSMutableArray * o_msg_arr; /* messages array */
119 NSLock * o_msg_lock; /* messages lock */
120 BOOL b_msg_arr_changed; /* did the array change? */
121 IBOutlet NSButton * o_msgs_crashlog_btn; /* messages open crashlog */
122 IBOutlet NSButton * o_msgs_save_btn; /* save the log as rtf */
124 /* CrashReporter panel */
125 IBOutlet NSButton * o_crashrep_dontSend_btn;
126 IBOutlet NSButton * o_crashrep_send_btn;
127 IBOutlet NSTextView * o_crashrep_fld;
128 IBOutlet NSTextField * o_crashrep_title_txt;
129 IBOutlet NSTextField * o_crashrep_desc_txt;
130 IBOutlet NSWindow * o_crashrep_win;
131 IBOutlet NSButton * o_crashrep_includeEmail_ckb;
132 IBOutlet NSTextField * o_crashrep_includeEmail_txt;
133 NSURLConnection * crashLogURLConnection;
135 AppleRemote * o_remote;
136 BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
138 /* media key support */
139 BOOL b_mediaKeySupport;
140 BOOL b_mediakeyJustJumped;
141 SPMediaKeyTap * o_mediaKeyController;
143 NSArray *o_usedHotkeys;
146 + (VLCMain *)sharedInstance;
148 - (intf_thread_t *)intf;
149 - (void)setIntf:(intf_thread_t *)p_mainintf;
155 - (id)simplePreferences;
161 - (id)getVideoViewAtPositionX: (int *)pi_x Y: (int *)pi_y withWidth: (unsigned int*)pi_width andHeight: (unsigned int*)pi_height;
162 - (void)setNativeVideoSize:(NSSize)size;
163 - (id)coreDialogProvider;
164 - (id)eyeTVController;
165 - (id)appleRemoteController;
166 - (void)setActiveVideoPlayback:(BOOL)b_value;
167 - (BOOL)activeVideoPlayback;
168 - (void)applicationWillTerminate:(NSNotification *)notification;
169 - (NSString *)localizedString:(const char *)psz;
170 - (char *)delocalizeString:(NSString *)psz;
171 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
172 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
173 - (NSString *)VLCKeyToString:(NSString *)theString;
174 - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
175 - (void)updateCurrentlyUsedHotkeys;
176 - (void)fullscreenChanged;
177 - (void)PlaylistItemChanged;
178 - (void)playbackStatusUpdated;
179 - (void)playbackModeUpdated;
180 - (void)updateVolume;
181 - (void)updatePlaybackPosition;
183 - (void)playlistUpdated;
184 - (void)updateInfoandMetaPanel;
185 - (void)updateMainWindow;
186 - (void)showFullscreenController;
187 - (void)updateDelays;
189 - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename;
191 - (void)updateMessageDisplay;
193 - (IBAction)crashReporterAction:(id)sender;
194 - (IBAction)openCrashLog:(id)sender;
195 - (IBAction)saveDebugLog:(id)sender;
196 - (IBAction)showMessagesPanel:(id)sender;
198 - (void)processReceivedlibvlcMessage:(const msg_item_t *)item;
200 - (void)updateTogglePlaylistState;
202 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
204 - (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
207 @interface VLCMain (Internal)
208 - (void)handlePortMessage:(NSPortMessage *)o_msg;
209 - (void)resetMediaKeyJump;
210 - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
213 /*****************************************************************************
214 * VLCApplication interface
215 *****************************************************************************/
217 @interface VLCApplication : NSApplication