]> git.sesse.net Git - vlc/blob - modules/gui/macosx/intf.h
macosx: compilation fix for the 10.4u SDK and removal of a hack
[vlc] / modules / gui / macosx / intf.h
1 /*****************************************************************************
2  * intf.h: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2002-2008 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
40 /*****************************************************************************
41  * Local prototypes.
42  *****************************************************************************/
43 unsigned int CocoaKeyToVLC( unichar i_key );
44
45 #define VLCIntf [[VLCMain sharedInstance] getIntf]
46
47 #define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
48 /* Get an alternate version of the string.
49  * This string is stored as '1:string' but when displayed it only displays
50  * the translated string. the translation should be '1:translatedstring' though */
51 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
52
53 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
54             @"/System/Library/CoreServices/SystemVersion.plist"] \
55             objectForKey: @"ProductVersion"] floatValue]
56
57 /*****************************************************************************
58  * intf_sys_t: description and status of the interface
59  *****************************************************************************/
60 struct intf_sys_t
61 {
62     NSAutoreleasePool * o_pool;
63
64     /* special actions */
65     bool b_mute;
66     int i_play_status;
67
68     /* interface update */
69     bool b_intf_update;
70     bool b_playlist_update;
71     bool b_playmode_update;
72     bool b_current_title_update;
73     bool b_fullscreen_update;
74     bool b_volume_update;
75     bool b_intf_show;
76
77     /* menus handlers */
78     bool b_input_update;
79     bool b_aout_update;
80     bool b_vout_update;
81
82     /* The messages window */
83     msg_subscription_t * p_sub;
84 };
85
86 /*****************************************************************************
87  * VLCMain interface
88  *****************************************************************************/
89 @class AppleRemote;
90 @class VLCInformation;
91 @class VLControllerWindow;
92 @class VLCEmbeddedWindow;
93 @class VLCControls;
94 @class VLCPlaylist;
95 @interface VLCMain : NSObject
96 {
97     intf_thread_t *p_intf;      /* The main intf object */
98     id o_prefs;                 /* VLCPrefs       */
99     id o_sprefs;                /* VLCSimplePrefs */
100     id o_about;                 /* VLAboutBox     */
101     id o_open;                  /* VLCOpen        */
102     id o_wizard;                /* VLCWizard      */
103     id o_extended;              /* VLCExtended    */
104     id o_bookmarks;             /* VLCBookmarks   */
105     id o_embedded_list;         /* VLCEmbeddedList*/
106     id o_interaction_list;      /* VLCInteractionList*/
107     VLCInformation * o_info;                  /* VLCInformation */
108 #ifdef UPDATE_CHECK
109     id o_update;                /* VLCUpdate      */
110 #endif
111     id o_eyetv;                 /* VLCEyeTVController */
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_extended_loaded;   /* extended nibfile */
117     BOOL nib_bookmarks_loaded;  /* bookmarks nibfile */
118     BOOL nib_prefs_loaded;      /* preferences nibfile */
119     BOOL nib_update_loaded;     /* update nibfile */
120     BOOL nib_info_loaded;       /* information panel nibfile */
121
122     IBOutlet VLControllerWindow * o_window;       /* main window    */
123     IBOutlet NSView * o_playlist_view;/* playlist view  */
124     IBOutlet id o_scrollfield;  /* info field     */
125     IBOutlet NSTextField * o_timefield;    /* time field     */
126     IBOutlet NSSlider * o_timeslider;   /* time slider    */
127     IBOutlet VLCEmbeddedWindow * o_embedded_window; /* Embedded Vout Window */
128     float f_slider;             /* slider value   */
129     float f_slider_old;         /* old slider val */
130     IBOutlet NSSlider * o_volumeslider; /* volume slider  */
131
132     IBOutlet NSView * toolbarMediaControl;   /* view with the controls */
133
134     IBOutlet NSProgressIndicator * o_main_pgbar;   /* playlist window progress bar */
135     IBOutlet NSButton * o_btn_prev;     /* btn previous   */
136     IBOutlet NSButton * o_btn_rewind;   /* btn rewind     */
137     IBOutlet NSButton * o_btn_play;     /* btn play       */
138     IBOutlet NSButton * o_btn_stop;     /* btn stop       */
139     IBOutlet NSButton * o_btn_ff;       /* btn fast forward     */
140     IBOutlet NSButton * o_btn_next;     /* btn next       */
141     IBOutlet NSButton * o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
142     IBOutlet NSButton * o_btn_playlist; /* btn playlist   */
143     IBOutlet NSButton * o_btn_equalizer; /* eq btn */
144
145     NSImage * o_img_play;       /* btn play img   */
146     NSImage * o_img_pause;      /* btn pause img  */
147     NSImage * o_img_play_pressed;       /* btn play img   */
148     NSImage * o_img_pause_pressed;      /* btn pause img  */
149
150     IBOutlet VLCControls * o_controls;     /* VLCControls    */
151     IBOutlet VLCPlaylist * o_playlist;     /* VLCPlaylist    */
152
153     IBOutlet id o_messages;     /* messages tv    */
154     IBOutlet id o_msgs_panel;   /* messages panel */
155     NSMutableArray * o_msg_arr; /* messages array */
156     NSLock * o_msg_lock;        /* messages lock  */
157     IBOutlet NSButton * o_msgs_btn_crashlog;    /* messages open crashlog */
158     
159     /* CrashReporter panel */
160     IBOutlet NSButton * o_crashrep_dontSend_btn;
161     IBOutlet NSButton * o_crashrep_send_btn;
162     IBOutlet NSTextView * o_crashrep_fld;
163     IBOutlet NSTextField * o_crashrep_title_txt;
164     IBOutlet NSTextField * o_crashrep_desc_txt;
165     IBOutlet NSWindow * o_crashrep_win;
166
167     /* main menu */
168
169     IBOutlet NSMenuItem * o_mi_about;
170     IBOutlet NSMenuItem * o_mi_prefs;
171     IBOutlet NSMenuItem * o_mi_sprefs;
172     IBOutlet NSMenuItem * o_mi_checkForUpdate;
173     IBOutlet NSMenuItem * o_mi_add_intf;
174     IBOutlet NSMenu * o_mu_add_intf;
175     IBOutlet NSMenuItem * o_mi_services;
176     IBOutlet NSMenuItem * o_mi_hide;
177     IBOutlet NSMenuItem * o_mi_hide_others;
178     IBOutlet NSMenuItem * o_mi_show_all;
179     IBOutlet NSMenuItem * o_mi_quit;
180
181     IBOutlet NSMenu * o_mu_file;
182     IBOutlet NSMenuItem * o_mi_open_file;
183     IBOutlet NSMenuItem * o_mi_open_generic;
184     IBOutlet NSMenuItem * o_mi_open_disc;
185     IBOutlet NSMenuItem * o_mi_open_net;
186     IBOutlet NSMenuItem * o_mi_open_capture;
187     IBOutlet NSMenuItem * o_mi_open_recent;
188     IBOutlet NSMenuItem * o_mi_open_recent_cm;
189     IBOutlet NSMenuItem * o_mi_open_wizard;
190
191     IBOutlet NSMenu * o_mu_edit;
192     IBOutlet NSMenuItem * o_mi_cut;
193     IBOutlet NSMenuItem * o_mi_copy;
194     IBOutlet NSMenuItem * o_mi_paste;
195     IBOutlet NSMenuItem * o_mi_clear;
196     IBOutlet NSMenuItem * o_mi_select_all;
197
198     IBOutlet NSMenu * o_mu_controls;
199     IBOutlet NSMenuItem * o_mi_play;
200     IBOutlet NSMenuItem * o_mi_stop;
201     IBOutlet NSMenuItem * o_mi_faster;
202     IBOutlet NSMenuItem * o_mi_slower;
203     IBOutlet NSMenuItem * o_mi_previous;
204     IBOutlet NSMenuItem * o_mi_next;
205     IBOutlet NSMenuItem * o_mi_random;
206     IBOutlet NSMenuItem * o_mi_repeat;
207     IBOutlet NSMenuItem * o_mi_loop;
208     IBOutlet NSMenuItem * o_mi_fwd;
209     IBOutlet NSMenuItem * o_mi_bwd;
210     IBOutlet NSMenuItem * o_mi_fwd1m;
211     IBOutlet NSMenuItem * o_mi_bwd1m;
212     IBOutlet NSMenuItem * o_mi_fwd5m;
213     IBOutlet NSMenuItem * o_mi_bwd5m;
214     IBOutlet NSMenuItem * o_mi_program;
215     IBOutlet NSMenuItem * o_mu_program;
216     IBOutlet NSMenuItem * o_mi_title;
217     IBOutlet NSMenu * o_mu_title;
218     IBOutlet NSMenuItem * o_mi_chapter;
219     IBOutlet NSMenu * o_mu_chapter;
220
221     IBOutlet NSMenu * o_mu_audio;
222     IBOutlet NSMenuItem * o_mi_vol_up;
223     IBOutlet NSMenuItem * o_mi_vol_down;
224     IBOutlet NSMenuItem * o_mi_mute;
225     IBOutlet NSMenuItem * o_mi_audiotrack;
226     IBOutlet NSMenu * o_mu_audiotrack;
227     IBOutlet NSMenuItem * o_mi_channels;
228     IBOutlet NSMenu * o_mu_channels;
229     IBOutlet NSMenuItem * o_mi_device;
230     IBOutlet NSMenu * o_mu_device;
231     IBOutlet NSMenuItem * o_mi_visual;
232     IBOutlet NSMenu * o_mu_visual;
233
234     IBOutlet NSMenu * o_mu_video;
235     IBOutlet NSMenuItem * o_mi_half_window;
236     IBOutlet NSMenuItem * o_mi_normal_window;
237     IBOutlet NSMenuItem * o_mi_double_window;
238     IBOutlet NSMenuItem * o_mi_fittoscreen;
239     IBOutlet NSMenuItem * o_mi_fullscreen;
240     IBOutlet NSMenuItem * o_mi_floatontop;
241     IBOutlet NSMenuItem * o_mi_snapshot;
242     IBOutlet NSMenuItem * o_mi_videotrack;
243     IBOutlet NSMenu * o_mu_videotrack;
244     IBOutlet NSMenuItem * o_mi_screen;
245     IBOutlet NSMenu * o_mu_screen;
246     IBOutlet NSMenuItem * o_mi_aspect_ratio;
247     IBOutlet NSMenu * o_mu_aspect_ratio;
248     IBOutlet NSMenuItem * o_mi_crop;
249     IBOutlet NSMenu * o_mu_crop;
250     IBOutlet NSMenuItem * o_mi_subtitle;
251     IBOutlet NSMenu * o_mu_subtitle;
252     IBOutlet NSMenuItem * o_mi_deinterlace;
253     IBOutlet NSMenu * o_mu_deinterlace;
254     IBOutlet NSMenuItem * o_mi_ffmpeg_pp;
255     IBOutlet NSMenuItem * o_mu_ffmpeg_pp;
256
257     IBOutlet NSMenu * o_mu_window;
258     IBOutlet NSMenuItem * o_mi_minimize;
259     IBOutlet NSMenuItem * o_mi_close_window;
260     IBOutlet NSMenuItem * o_mi_controller;
261     IBOutlet NSMenuItem * o_mi_equalizer;
262     IBOutlet NSMenuItem * o_mi_extended;
263     IBOutlet NSMenuItem * o_mi_bookmarks;
264     IBOutlet NSMenuItem * o_mi_playlist;
265     IBOutlet NSMenuItem * o_mi_info;
266     IBOutlet NSMenuItem * o_mi_messages;
267     IBOutlet NSMenuItem * o_mi_bring_atf;
268
269     IBOutlet NSMenu * o_mu_help;
270     IBOutlet NSMenuItem * o_mi_help;
271     IBOutlet NSMenuItem * o_mi_readme;
272     IBOutlet NSMenuItem * o_mi_documentation;
273     IBOutlet NSMenuItem * o_mi_license;
274     IBOutlet NSMenuItem * o_mi_website;
275     IBOutlet NSMenuItem * o_mi_donation;
276     IBOutlet NSMenuItem * o_mi_forum;
277     IBOutlet NSMenuItem * o_mi_errorsAndWarnings;
278
279     /* dock menu */
280     IBOutlet NSMenuItem * o_dmi_play;
281     IBOutlet NSMenuItem * o_dmi_stop;
282     IBOutlet NSMenuItem * o_dmi_next;
283     IBOutlet NSMenuItem * o_dmi_previous;
284     IBOutlet NSMenuItem * o_dmi_mute;
285
286     /* vout menu */
287     IBOutlet NSMenu * o_vout_menu;
288     IBOutlet NSMenuItem * o_vmi_play;
289     IBOutlet NSMenuItem * o_vmi_stop;
290     IBOutlet NSMenuItem * o_vmi_prev;
291     IBOutlet NSMenuItem * o_vmi_next;
292     IBOutlet NSMenuItem * o_vmi_volup;
293     IBOutlet NSMenuItem * o_vmi_voldown;
294     IBOutlet NSMenuItem * o_vmi_mute;
295     IBOutlet NSMenuItem * o_vmi_fullscreen;
296     IBOutlet NSMenuItem * o_vmi_snapshot;
297
298     bool b_small_window;
299
300     bool b_restore_size;
301     NSRect o_restore_rect;
302
303     mtime_t i_end_scroll;
304
305     NSSize o_size_with_playlist;
306
307     int     i_lastShownVolume;
308
309     input_state_e cachedInputState;
310
311     /* the manage thread */
312     pthread_t manage_thread;
313
314     /* The timer that update the interface */
315     NSTimer * interfaceTimer;
316
317     NSURLConnection * crashLogURLConnection;
318
319     AppleRemote * o_remote;
320     BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
321 }
322
323 + (VLCMain *)sharedInstance;
324
325 - (intf_thread_t *)getIntf;
326 - (void)setIntf:(intf_thread_t *)p_mainintf;
327
328 - (void)controlTintChanged;
329
330 - (id)getControls;
331 - (id)getSimplePreferences;
332 - (id)getPreferences;
333 - (id)getPlaylist;
334 - (id)getInfo;
335 - (id)getWizard;
336 - (id)getBookmarks;
337 - (id)getEmbeddedList;
338 - (id)getInteractionList;
339 - (id)getMainIntfPgbar;
340 - (id)getControllerWindow;
341 - (id)getVoutMenu;
342 - (id)getEyeTVController;
343 - (void)applicationWillTerminate:(NSNotification *)notification;
344 - (NSString *)localizedString:(const char *)psz;
345 - (char *)delocalizeString:(NSString *)psz;
346 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
347 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
348
349 - (void)initStrings;
350
351 - (void)manage;
352 - (void)manageIntf:(NSTimer *)o_timer;
353 - (void)setupMenus;
354 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
355 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
356 - (void)resetScrollField;
357
358 - (void)updateMessageArray;
359 - (void)playStatusUpdated:(int) i_status;
360 - (void)setSubmenusEnabled:(BOOL)b_enabled;
361 - (void)manageVolumeSlider;
362 - (IBAction)timesliderUpdate:(id)sender;
363
364 - (IBAction)clearRecentItems:(id)sender;
365 - (void)openRecentItem:(id)sender;
366
367 - (IBAction)intfOpenFile:(id)sender;
368 - (IBAction)intfOpenFileGeneric:(id)sender;
369 - (IBAction)intfOpenDisc:(id)sender;
370 - (IBAction)intfOpenNet:(id)sender;
371 - (IBAction)intfOpenCapture:(id)sender;
372
373 - (IBAction)showWizard:(id)sender;
374 - (IBAction)showExtended:(id)sender;
375 - (IBAction)showBookmarks:(id)sender;
376
377 - (IBAction)viewAbout:(id)sender;
378 - (IBAction)showLicense:(id)sender;
379 - (IBAction)viewPreferences:(id)sender;
380 - (IBAction)checkForUpdate:(id)sender;
381 - (IBAction)viewHelp:(id)sender;
382 - (IBAction)openReadMe:(id)sender;
383 - (IBAction)openDocumentation:(id)sender;
384 - (IBAction)openWebsite:(id)sender;
385 - (IBAction)openForum:(id)sender;
386 - (IBAction)openDonate:(id)sender;
387 - (IBAction)openCrashLog:(id)sender;
388 - (IBAction)viewErrorsAndWarnings:(id)sender;
389 - (IBAction)showMessagesPanel:(id)sender;
390 - (IBAction)showInformationPanel:(id)sender;
391
392 - (IBAction)crashReporterAction:(id)sender;
393
394 - (IBAction)togglePlaylist:(id)sender;
395 - (void)updateTogglePlaylistState;
396
397 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
398
399 @end
400
401 @interface VLCMain (Internal)
402 - (void)handlePortMessage:(NSPortMessage *)o_msg;
403 @end