1 /*****************************************************************************
2 * intf.h: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2012 VLC authors and VideoLAN
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 #import <vlc_common.h>
32 #import <vlc_interface.h>
33 #import <vlc_playlist.h>
38 #import <Cocoa/Cocoa.h>
39 #import "CompatibilityFixes.h"
40 #import "SPMediaKeyTap.h" /* for the media key support */
42 #import "MainWindow.h"
44 /*****************************************************************************
46 *****************************************************************************/
47 unsigned int CocoaKeyToVLC( unichar i_key );
49 #define VLCIntf [[VLCMain sharedInstance] intf]
51 #define _NS(s) [[VLCMain sharedInstance] localizedString: s]
52 /* Get an alternate version of the string.
53 * This string is stored as '1:string' but when displayed it only displays
54 * the translated string. the translation should be '1:translatedstring' though */
55 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
57 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
58 @"/System/Library/CoreServices/SystemVersion.plist"] \
59 objectForKey: @"ProductVersion"] floatValue]
62 // You need to release those objects after use
63 input_thread_t *getInput(void);
64 vout_thread_t *getVout(void);
65 audio_output_t *getAout(void);
67 /*****************************************************************************
68 * intf_sys_t: description and status of the interface
69 *****************************************************************************/
77 /* The messages window */
78 msg_subscription_t sub;
81 /*****************************************************************************
83 *****************************************************************************/
85 @class VLCInformation;
86 @class VLCEmbeddedWindow;
89 @interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
91 intf_thread_t *p_intf; /* The main intf object */
92 input_thread_t *p_current_input;
93 id o_mainmenu; /* VLCMainMenu */
94 id o_prefs; /* VLCPrefs */
95 id o_sprefs; /* VLCSimplePrefs */
96 id o_open; /* VLCOpen */
97 id o_wizard; /* VLCWizard */
98 id o_embedded_list; /* VLCEmbeddedList*/
99 id o_coredialogs; /* VLCCoreDialogProvider */
100 id o_info; /* VLCInformation */
101 id o_eyetv; /* VLCEyeTVController */
102 id o_bookmarks; /* VLCBookmarks */
103 id o_coreinteraction; /* VLCCoreInteraction */
104 BOOL nib_main_loaded; /* main nibfile */
105 BOOL nib_open_loaded; /* open nibfile */
106 BOOL nib_about_loaded; /* about nibfile */
107 BOOL nib_wizard_loaded; /* wizard nibfile */
108 BOOL nib_prefs_loaded; /* preferences nibfile */
109 BOOL nib_info_loaded; /* information panel nibfile */
110 BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
111 BOOL nib_bookmarks_loaded; /* Bookmarks nibfile */
112 BOOL b_active_videoplayback;
113 BOOL b_nativeFullscreenMode;
115 VLCMainWindow *o_mainwindow; /* VLCMainWindow */
117 IBOutlet VLCControls * o_controls; /* VLCControls */
118 IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
120 IBOutlet NSWindow * o_msgs_panel; /* messages panel */
121 NSMutableArray * o_msg_arr; /* messages array */
122 NSLock * o_msg_lock; /* messages lock */
123 BOOL b_msg_arr_changed; /* did the array change? */
124 IBOutlet NSButton * o_msgs_crashlog_btn; /* messages open crashlog */
125 IBOutlet NSButton * o_msgs_save_btn; /* save the log as rtf */
126 IBOutlet NSButton * o_msgs_refresh_btn; /* update the panel */
127 IBOutlet id o_msgs_table;
129 /* CrashReporter panel */
130 IBOutlet NSButton * o_crashrep_dontSend_btn;
131 IBOutlet NSButton * o_crashrep_send_btn;
132 IBOutlet NSTextView * o_crashrep_fld;
133 IBOutlet NSTextField * o_crashrep_title_txt;
134 IBOutlet NSTextField * o_crashrep_desc_txt;
135 IBOutlet NSWindow * o_crashrep_win;
136 IBOutlet NSButton * o_crashrep_includeEmail_ckb;
137 IBOutlet NSTextField * o_crashrep_includeEmail_txt;
138 NSURLConnection * crashLogURLConnection;
140 AppleRemote * o_remote;
141 BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
143 /* media key support */
144 BOOL b_mediaKeySupport;
145 BOOL b_mediakeyJustJumped;
146 SPMediaKeyTap * o_mediaKeyController;
148 NSArray *o_usedHotkeys;
151 + (VLCMain *)sharedInstance;
153 - (intf_thread_t *)intf;
154 - (void)setIntf:(intf_thread_t *)p_mainintf;
161 - (id)simplePreferences;
167 - (id)getVideoViewAtPositionX: (int *)pi_x Y: (int *)pi_y withWidth: (unsigned int*)pi_width andHeight: (unsigned int*)pi_height;
168 - (void)setNativeVideoSize:(NSSize)size;
169 - (id)coreDialogProvider;
170 - (id)eyeTVController;
171 - (id)appleRemoteController;
172 - (void)setActiveVideoPlayback:(BOOL)b_value;
173 - (BOOL)activeVideoPlayback;
174 - (void)applicationWillTerminate:(NSNotification *)notification;
175 - (NSString *)localizedString:(const char *)psz;
176 - (char *)delocalizeString:(NSString *)psz;
177 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
178 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
179 - (NSString *)VLCKeyToString:(NSString *)theString;
180 - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
181 - (void)updateCurrentlyUsedHotkeys;
182 - (void)fullscreenChanged;
183 - (void)checkFullscreenChange:(NSNumber *)o_full;
184 - (void)PlaylistItemChanged;
185 - (void)playbackStatusUpdated;
186 - (void)sendDistributedNotificationWithUpdatedPlaybackStatus;
187 - (void)playbackModeUpdated;
188 - (void)updateVolume;
189 - (void)updatePlaybackPosition;
191 - (void)playlistUpdated;
192 - (void)updateRecordState: (BOOL)b_value;
193 - (void)updateInfoandMetaPanel;
194 - (void)updateMainMenu;
195 - (void)updateMainWindow;
196 - (void)showMainWindow;
197 - (void)showFullscreenController;
198 - (void)updateDelays;
201 - (IBAction)crashReporterAction:(id)sender;
202 - (IBAction)openCrashLog:(id)sender;
203 - (IBAction)saveDebugLog:(id)sender;
204 - (IBAction)showMessagesPanel:(id)sender;
205 - (IBAction)updateMessagesPanel:(id)sender;
207 - (void)processReceivedlibvlcMessage:(const msg_item_t *) item ofType: (int)type withStr: (char *)str;
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