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