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