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