]> git.sesse.net Git - vlc/blob - modules/gui/macosx/intf.h
a64637dfde51ce224b6242425842a90fb3fea38d
[vlc] / modules / gui / macosx / intf.h
1 /*****************************************************************************
2  * intf.h: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2002-2011 the VideoLAN team
5  * $Id$
6  *
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>
11  *
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.
16  *
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.
21  *
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  *****************************************************************************/
26
27 #ifdef HAVE_CONFIG_H
28 #   include "config.h"
29 #endif
30
31 #include <vlc_common.h>
32 #include <vlc_interface.h>
33 #include <vlc_playlist.h>
34 #include <vlc_vout.h>
35 #include <vlc_aout.h>
36 #include <vlc_input.h>
37
38 #include <Cocoa/Cocoa.h>
39 #import "SPMediaKeyTap.h"                   /* for the media key support */
40
41 /*****************************************************************************
42  * Local prototypes.
43  *****************************************************************************/
44 unsigned int CocoaKeyToVLC( unichar i_key );
45
46 #define VLCIntf [[VLCMain sharedInstance] intf]
47
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]
53
54 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
55             @"/System/Library/CoreServices/SystemVersion.plist"] \
56             objectForKey: @"ProductVersion"] floatValue]
57
58
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);
63
64 /*****************************************************************************
65  * intf_sys_t: description and status of the interface
66  *****************************************************************************/
67 struct intf_sys_t
68 {
69     /* special actions */
70     int i_play_status;
71     int i_old_play_status;
72
73     /* interface update */
74     bool b_intf_update;
75     bool b_playlist_update;
76     bool b_playmode_update;
77     bool b_current_title_update;
78     bool b_fullscreen_update;
79     bool b_intf_show;
80
81     /* menus handlers */
82     bool b_input_update;
83     bool b_aout_update;
84     bool b_vout_update;
85
86     /* The messages window */
87     msg_subscription_t * p_sub;
88 };
89
90 /*****************************************************************************
91  * VLCMain interface
92  *****************************************************************************/
93 @class AppleRemote;
94 @class VLCInformation;
95 @class VLCEmbeddedWindow;
96 @class VLCControls;
97 @class VLCPlaylist;
98 @interface VLCMain : NSObject
99 {
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 */
120
121     IBOutlet id o_mainwindow;            /* VLCMainWindow */
122
123     IBOutlet VLCControls * o_controls;     /* VLCControls    */
124     IBOutlet VLCPlaylist * o_playlist;     /* VLCPlaylist    */
125
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 */
133
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;
143
144     input_state_e cachedInputState;
145
146     /* the manage thread */
147     pthread_t manage_thread;
148
149     /* The timer that update the interface */
150     NSTimer * interfaceTimer;
151
152     NSURLConnection * crashLogURLConnection;
153
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 */
156
157     /* media key support */
158     BOOL b_mediaKeySupport;
159     BOOL b_mediakeyJustJumped;
160     SPMediaKeyTap * o_mediaKeyController;
161
162     NSArray *o_usedHotkeys;
163 }
164
165 + (VLCMain *)sharedInstance;
166
167 - (intf_thread_t *)intf;
168 - (void)setIntf:(intf_thread_t *)p_mainintf;
169
170 - (id)mainMenu;
171 - (id)controls;
172 - (id)bookmarks;
173 - (id)open;
174 - (id)simplePreferences;
175 - (id)preferences;
176 - (id)playlist;
177 - (id)info;
178 - (id)wizard;
179 - (id)embeddedList;
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;
192
193 - (void)initStrings;
194 - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename;
195
196 - (void)manage;
197 - (void)manageIntf:(NSTimer *)o_timer;
198
199 - (void)updateMessageDisplay;
200 - (void)playStatusUpdated:(int) i_status;
201 - (IBAction)showController:(id)sender;
202
203 - (IBAction)crashReporterAction:(id)sender;
204 - (IBAction)openCrashLog:(id)sender;
205 - (IBAction)saveDebugLog:(id)sender;
206 - (IBAction)showMessagesPanel:(id)sender;
207
208 - (IBAction)togglePlaylist:(id)sender;
209 - (void)updateTogglePlaylistState;
210
211 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
212
213 - (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
214 @end
215
216 @interface VLCMain (Internal)
217 - (void)handlePortMessage:(NSPortMessage *)o_msg;
218 - (void)resetMediaKeyJump;
219 - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
220 @end
221
222 /*****************************************************************************
223  * VLCApplication interface
224  *****************************************************************************/
225
226 @interface VLCApplication : NSApplication
227 {
228 }
229 @end