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