]> git.sesse.net Git - vlc/blob - modules/gui/macosx/intf.h
8741d7cc30296ecd18e5c2a612e64911cb27ccf5
[vlc] / modules / gui / macosx / intf.h
1 /*****************************************************************************
2  * intf.h: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2002-2009 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] intf]
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 // You need to release those objects after use
59 input_thread_t *getInput(void);
60 vout_thread_t *getVout(void);
61 aout_instance_t *getAout(void);
62
63 /*****************************************************************************
64  * intf_sys_t: description and status of the interface
65  *****************************************************************************/
66 struct intf_sys_t
67 {
68     /* special actions */
69     bool b_mute;
70     int i_play_status;
71
72     /* interface update */
73     bool b_intf_update;
74     bool b_playlist_update;
75     bool b_playmode_update;
76     bool b_current_title_update;
77     bool b_fullscreen_update;
78     bool b_volume_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 VLCControllerWindow;
96 @class VLCEmbeddedWindow;
97 @class VLCControls;
98 @class VLCPlaylist;
99 @interface VLCMain : NSObject
100 {
101     intf_thread_t *p_intf;      /* The main intf object */
102     id o_prefs;                 /* VLCPrefs       */
103     id o_sprefs;                /* VLCSimplePrefs */
104     id o_about;                 /* VLAboutBox     */
105     id o_open;                  /* VLCOpen        */
106     id o_wizard;                /* VLCWizard      */
107     id o_extended;              /* VLCExtended    */
108     id o_bookmarks;             /* VLCBookmarks   */
109 #ifdef ENABLE_VLM
110     id o_vlm;                   /* VLCVLMController */
111 #endif
112     id o_embedded_list;         /* VLCEmbeddedList*/
113     id o_coredialogs;           /* VLCCoreDialogProvider */
114     VLCInformation * o_info;    /* VLCInformation */
115     id o_eyetv;                 /* VLCEyeTVController */
116     BOOL nib_main_loaded;       /* main nibfile */
117     BOOL nib_open_loaded;       /* open nibfile */
118     BOOL nib_about_loaded;      /* about nibfile */
119     BOOL nib_wizard_loaded;     /* wizard nibfile */
120     BOOL nib_extended_loaded;   /* extended nibfile */
121     BOOL nib_bookmarks_loaded;  /* bookmarks nibfile */
122     BOOL nib_prefs_loaded;      /* preferences nibfile */
123     BOOL nib_info_loaded;       /* information panel nibfile */
124 #ifdef ENABLE_VLM
125     BOOL nib_vlm_loaded;        /* VLM Panel nibfile */
126 #endif
127     BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
128
129     IBOutlet VLCControllerWindow * o_window;                     /* main window */
130     IBOutlet NSView * o_playlist_view;                          /* playlist view  */
131     IBOutlet id o_scrollfield;                                  /* info field */
132     IBOutlet NSTextField * o_timefield;                         /* time field */
133     IBOutlet NSSlider * o_timeslider;                           /* time slider */
134     BOOL b_time_remaining;                                      /* show remaining time or playtime ? */
135     IBOutlet VLCEmbeddedWindow * o_embedded_window;             /* Embedded Vout Window */
136     float f_slider;                                             /* slider value */
137     float f_slider_old;                                         /* old slider val */
138     IBOutlet NSSlider * o_volumeslider;                         /* volume slider */
139
140     IBOutlet NSView * toolbarMediaControl;   /* view with the controls */
141
142     IBOutlet NSProgressIndicator * o_main_pgbar;   /* playlist window progress bar */
143     IBOutlet NSButton * o_btn_prev;     /* btn previous   */
144     IBOutlet NSButton * o_btn_rewind;   /* btn rewind     */
145     IBOutlet NSButton * o_btn_play;     /* btn play       */
146     IBOutlet NSButton * o_btn_stop;     /* btn stop       */
147     IBOutlet NSButton * o_btn_ff;       /* btn fast forward     */
148     IBOutlet NSButton * o_btn_next;     /* btn next       */
149     IBOutlet NSButton * o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
150     IBOutlet NSButton * o_btn_playlist; /* btn playlist   */
151     IBOutlet NSButton * o_btn_equalizer; /* eq btn */
152
153     NSImage * o_img_play;       /* btn play img   */
154     NSImage * o_img_pause;      /* btn pause img  */
155     NSImage * o_img_play_pressed;       /* btn play img   */
156     NSImage * o_img_pause_pressed;      /* btn pause img  */
157
158     IBOutlet VLCControls * o_controls;     /* VLCControls    */
159     IBOutlet VLCPlaylist * o_playlist;     /* VLCPlaylist    */
160
161     IBOutlet NSTextView * o_messages;           /* messages tv    */
162     IBOutlet NSWindow * o_msgs_panel;           /* messages panel */
163     NSMutableArray * o_msg_arr;                 /* messages array */
164     NSLock * o_msg_lock;                        /* messages lock */
165     BOOL b_msg_arr_changed;                     /* did the array change? */
166     IBOutlet NSButton * o_msgs_crashlog_btn;    /* messages open crashlog */
167     IBOutlet NSButton * o_msgs_save_btn;        /* save the log as rtf */
168     
169     /* CrashReporter panel */
170     IBOutlet NSButton * o_crashrep_dontSend_btn;
171     IBOutlet NSButton * o_crashrep_send_btn;
172     IBOutlet NSTextView * o_crashrep_fld;
173     IBOutlet NSTextField * o_crashrep_title_txt;
174     IBOutlet NSTextField * o_crashrep_desc_txt;
175     IBOutlet NSWindow * o_crashrep_win;
176     IBOutlet NSButton * o_crashrep_includeEmail_ckb;
177     IBOutlet NSTextField * o_crashrep_includeEmail_txt;
178
179     /* main menu */
180
181     IBOutlet NSMenuItem * o_mi_about;
182     IBOutlet NSMenuItem * o_mi_prefs;
183     IBOutlet NSMenuItem * o_mi_sprefs;
184     IBOutlet NSMenuItem * o_mi_checkForUpdate;
185     IBOutlet NSMenuItem * o_mi_add_intf;
186     IBOutlet NSMenu * o_mu_add_intf;
187     IBOutlet NSMenuItem * o_mi_services;
188     IBOutlet NSMenuItem * o_mi_hide;
189     IBOutlet NSMenuItem * o_mi_hide_others;
190     IBOutlet NSMenuItem * o_mi_show_all;
191     IBOutlet NSMenuItem * o_mi_quit;
192
193     IBOutlet NSMenu * o_mu_file;
194     IBOutlet NSMenuItem * o_mi_open_file;
195     IBOutlet NSMenuItem * o_mi_open_generic;
196     IBOutlet NSMenuItem * o_mi_open_disc;
197     IBOutlet NSMenuItem * o_mi_open_net;
198     IBOutlet NSMenuItem * o_mi_open_capture;
199     IBOutlet NSMenuItem * o_mi_open_recent;
200     IBOutlet NSMenuItem * o_mi_open_recent_cm;
201     IBOutlet NSMenuItem * o_mi_open_wizard;
202     IBOutlet NSMenuItem * o_mi_open_vlm;
203
204     IBOutlet NSMenu * o_mu_edit;
205     IBOutlet NSMenuItem * o_mi_cut;
206     IBOutlet NSMenuItem * o_mi_copy;
207     IBOutlet NSMenuItem * o_mi_paste;
208     IBOutlet NSMenuItem * o_mi_clear;
209     IBOutlet NSMenuItem * o_mi_select_all;
210
211     IBOutlet NSMenu * o_mu_controls;
212     IBOutlet NSMenuItem * o_mi_play;
213     IBOutlet NSMenuItem * o_mi_stop;
214     IBOutlet NSMenuItem * o_mi_faster;
215     IBOutlet NSMenuItem * o_mi_slower;
216     IBOutlet NSMenuItem * o_mi_normalSpeed;
217     IBOutlet NSMenuItem * o_mi_previous;
218     IBOutlet NSMenuItem * o_mi_next;
219     IBOutlet NSMenuItem * o_mi_random;
220     IBOutlet NSMenuItem * o_mi_repeat;
221     IBOutlet NSMenuItem * o_mi_loop;
222     IBOutlet NSMenuItem * o_mi_quitAfterPB;
223     IBOutlet NSMenuItem * o_mi_fwd;
224     IBOutlet NSMenuItem * o_mi_bwd;
225     IBOutlet NSMenuItem * o_mi_fwd1m;
226     IBOutlet NSMenuItem * o_mi_bwd1m;
227     IBOutlet NSMenuItem * o_mi_fwd5m;
228     IBOutlet NSMenuItem * o_mi_bwd5m;
229     IBOutlet NSMenuItem * o_mi_program;
230     IBOutlet NSMenu * o_mu_program;
231     IBOutlet NSMenuItem * o_mi_title;
232     IBOutlet NSMenu * o_mu_title;
233     IBOutlet NSMenuItem * o_mi_chapter;
234     IBOutlet NSMenu * o_mu_chapter;
235
236     IBOutlet NSMenu * o_mu_audio;
237     IBOutlet NSMenuItem * o_mi_vol_up;
238     IBOutlet NSMenuItem * o_mi_vol_down;
239     IBOutlet NSMenuItem * o_mi_mute;
240     IBOutlet NSMenuItem * o_mi_audiotrack;
241     IBOutlet NSMenu * o_mu_audiotrack;
242     IBOutlet NSMenuItem * o_mi_channels;
243     IBOutlet NSMenu * o_mu_channels;
244     IBOutlet NSMenuItem * o_mi_device;
245     IBOutlet NSMenu * o_mu_device;
246     IBOutlet NSMenuItem * o_mi_visual;
247     IBOutlet NSMenu * o_mu_visual;
248
249     IBOutlet NSMenu * o_mu_video;
250     IBOutlet NSMenuItem * o_mi_half_window;
251     IBOutlet NSMenuItem * o_mi_normal_window;
252     IBOutlet NSMenuItem * o_mi_double_window;
253     IBOutlet NSMenuItem * o_mi_fittoscreen;
254     IBOutlet NSMenuItem * o_mi_fullscreen;
255     IBOutlet NSMenuItem * o_mi_floatontop;
256     IBOutlet NSMenuItem * o_mi_snapshot;
257     IBOutlet NSMenuItem * o_mi_videotrack;
258     IBOutlet NSMenu * o_mu_videotrack;
259     IBOutlet NSMenuItem * o_mi_screen;
260     IBOutlet NSMenu * o_mu_screen;
261     IBOutlet NSMenuItem * o_mi_aspect_ratio;
262     IBOutlet NSMenu * o_mu_aspect_ratio;
263     IBOutlet NSMenuItem * o_mi_crop;
264     IBOutlet NSMenu * o_mu_crop;
265     IBOutlet NSMenuItem * o_mi_subtitle;
266     IBOutlet NSMenu * o_mu_subtitle;
267     IBOutlet NSMenuItem * o_mi_addSub;
268     IBOutlet NSMenuItem * o_mi_deinterlace;
269     IBOutlet NSMenu * o_mu_deinterlace;
270     IBOutlet NSMenuItem * o_mi_ffmpeg_pp;
271     IBOutlet NSMenu * o_mu_ffmpeg_pp;
272     IBOutlet NSMenuItem * o_mi_teletext;
273     IBOutlet NSMenuItem * o_mi_teletext_transparent;
274     IBOutlet NSMenuItem * o_mi_teletext_index;
275     IBOutlet NSMenuItem * o_mi_teletext_red;
276     IBOutlet NSMenuItem * o_mi_teletext_green;
277     IBOutlet NSMenuItem * o_mi_teletext_yellow;
278     IBOutlet NSMenuItem * o_mi_teletext_blue;
279
280     IBOutlet NSMenu * o_mu_window;
281     IBOutlet NSMenuItem * o_mi_minimize;
282     IBOutlet NSMenuItem * o_mi_close_window;
283     IBOutlet NSMenuItem * o_mi_player;
284     IBOutlet NSMenuItem * o_mi_controller;
285     IBOutlet NSMenuItem * o_mi_equalizer;
286     IBOutlet NSMenuItem * o_mi_extended;
287     IBOutlet NSMenuItem * o_mi_bookmarks;
288     IBOutlet NSMenuItem * o_mi_playlist;
289     IBOutlet NSMenuItem * o_mi_info;
290     IBOutlet NSMenuItem * o_mi_messages;
291     IBOutlet NSMenuItem * o_mi_bring_atf;
292
293     IBOutlet NSMenu * o_mu_help;
294     IBOutlet NSMenuItem * o_mi_help;
295     IBOutlet NSMenuItem * o_mi_readme;
296     IBOutlet NSMenuItem * o_mi_documentation;
297     IBOutlet NSMenuItem * o_mi_license;
298     IBOutlet NSMenuItem * o_mi_website;
299     IBOutlet NSMenuItem * o_mi_donation;
300     IBOutlet NSMenuItem * o_mi_forum;
301     IBOutlet NSMenuItem * o_mi_errorsAndWarnings;
302
303     /* dock menu */
304     IBOutlet NSMenuItem * o_dmi_play;
305     IBOutlet NSMenuItem * o_dmi_stop;
306     IBOutlet NSMenuItem * o_dmi_next;
307     IBOutlet NSMenuItem * o_dmi_previous;
308     IBOutlet NSMenuItem * o_dmi_mute;
309
310     /* vout menu */
311     IBOutlet NSMenu * o_vout_menu;
312     IBOutlet NSMenuItem * o_vmi_play;
313     IBOutlet NSMenuItem * o_vmi_stop;
314     IBOutlet NSMenuItem * o_vmi_prev;
315     IBOutlet NSMenuItem * o_vmi_next;
316     IBOutlet NSMenuItem * o_vmi_volup;
317     IBOutlet NSMenuItem * o_vmi_voldown;
318     IBOutlet NSMenuItem * o_vmi_mute;
319     IBOutlet NSMenuItem * o_vmi_fullscreen;
320     IBOutlet NSMenuItem * o_vmi_snapshot;
321
322     bool b_small_window;
323
324     bool b_restore_size;
325     NSRect o_restore_rect;
326
327     mtime_t i_end_scroll;
328
329     NSSize o_size_with_playlist;
330
331     int     i_lastShownVolume;
332
333     input_state_e cachedInputState;
334
335     /* the manage thread */
336     pthread_t manage_thread;
337
338     /* The timer that update the interface */
339     NSTimer * interfaceTimer;
340
341     NSURLConnection * crashLogURLConnection;
342
343     AppleRemote * o_remote;
344     BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
345 }
346
347 + (VLCMain *)sharedInstance;
348
349 - (intf_thread_t *)intf;
350 - (void)setIntf:(intf_thread_t *)p_mainintf;
351
352 - (void)controlTintChanged;
353
354 - (id)controls;
355 - (id)simplePreferences;
356 - (id)preferences;
357 - (id)playlist;
358 - (BOOL)isPlaylistCollapsed;
359 - (id)info;
360 - (id)wizard;
361 - (id)bookmarks;
362 - (id)embeddedList;
363 - (id)coreDialogProvider;
364 - (id)mainIntfPgbar;
365 - (id)controllerWindow;
366 - (id)voutMenu;
367 - (id)eyeTVController;
368 - (id)appleRemoteController;
369 - (void)applicationWillTerminate:(NSNotification *)notification;
370 - (NSString *)localizedString:(const char *)psz;
371 - (char *)delocalizeString:(NSString *)psz;
372 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
373 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
374
375 - (void)initStrings;
376
377 - (void)manage;
378 - (void)manageIntf:(NSTimer *)o_timer;
379 - (void)setupMenus;
380 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
381 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
382 - (void)resetScrollField;
383
384 - (void)updateMessageDisplay;
385 - (void)playStatusUpdated:(int) i_status;
386 - (void)setSubmenusEnabled:(BOOL)b_enabled;
387 - (void)manageVolumeSlider;
388 - (IBAction)timesliderUpdate:(id)sender;
389 - (IBAction)timeFieldWasClicked:(id)sender;
390
391 - (IBAction)clearRecentItems:(id)sender;
392 - (void)openRecentItem:(id)sender;
393
394 - (IBAction)intfOpenFile:(id)sender;
395 - (IBAction)intfOpenFileGeneric:(id)sender;
396 - (IBAction)intfOpenDisc:(id)sender;
397 - (IBAction)intfOpenNet:(id)sender;
398 - (IBAction)intfOpenCapture:(id)sender;
399
400 - (IBAction)showWizard:(id)sender;
401 - (IBAction)showVLM:(id)sender;
402 - (IBAction)showExtended:(id)sender;
403 - (IBAction)showBookmarks:(id)sender;
404
405 - (IBAction)viewAbout:(id)sender;
406 - (IBAction)showLicense:(id)sender;
407 - (IBAction)viewPreferences:(id)sender;
408 - (IBAction)viewHelp:(id)sender;
409 - (IBAction)openReadMe:(id)sender;
410 - (IBAction)openDocumentation:(id)sender;
411 - (IBAction)openWebsite:(id)sender;
412 - (IBAction)openForum:(id)sender;
413 - (IBAction)openDonate:(id)sender;
414 - (IBAction)openCrashLog:(id)sender;
415 - (IBAction)viewErrorsAndWarnings:(id)sender;
416 - (IBAction)showMessagesPanel:(id)sender;
417 - (IBAction)showInformationPanel:(id)sender;
418
419 - (IBAction)crashReporterAction:(id)sender;
420 - (IBAction)saveDebugLog:(id)sender;
421
422 - (IBAction)togglePlaylist:(id)sender;
423 - (void)updateTogglePlaylistState;
424
425 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
426
427 @end
428
429 @interface VLCMain (Internal)
430 - (void)handlePortMessage:(NSPortMessage *)o_msg;
431 @end
432
433 /*****************************************************************************
434  * VLCApplication interface
435  *****************************************************************************/
436
437 @interface VLCApplication : NSApplication
438 {
439     BOOL b_justJumped;
440         BOOL b_mediaKeySupport;
441     BOOL b_activeInBackground;
442     BOOL b_active;
443 }
444
445 - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
446 - (void)sendEvent: (NSEvent*)event;
447 - (void)resetJump;
448
449 @end