]> git.sesse.net Git - vlc/blob - modules/gui/macosx/intf.h
1a45bbe14dd34e3ff14e8916fd93d33e104e9e7b
[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 /*****************************************************************************
41  * Local prototypes.
42  *****************************************************************************/
43 unsigned int CocoaKeyToVLC( unichar i_key );
44
45 #define VLCIntf [[VLCMain sharedInstance] getIntf]
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 VLControllerWindow;
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_interaction_list;      /* VLCInteractionList*/
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
126     IBOutlet VLControllerWindow * o_window;       /* main window    */
127     IBOutlet NSView * o_playlist_view;/* playlist view  */
128     IBOutlet id o_scrollfield;  /* info field     */
129     IBOutlet NSTextField * o_timefield;    /* time field     */
130     IBOutlet NSSlider * o_timeslider;   /* time slider    */
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_btn_crashlog;    /* messages open crashlog */
163     
164     /* CrashReporter panel */
165     IBOutlet NSButton * o_crashrep_dontSend_btn;
166     IBOutlet NSButton * o_crashrep_send_btn;
167     IBOutlet NSTextView * o_crashrep_fld;
168     IBOutlet NSTextField * o_crashrep_title_txt;
169     IBOutlet NSTextField * o_crashrep_desc_txt;
170     IBOutlet NSWindow * o_crashrep_win;
171     IBOutlet NSButton * o_crashrep_includeEmail_ckb;
172     IBOutlet NSTextField * o_crashrep_includeEmail_txt;
173
174     /* main menu */
175
176     IBOutlet NSMenuItem * o_mi_about;
177     IBOutlet NSMenuItem * o_mi_prefs;
178     IBOutlet NSMenuItem * o_mi_sprefs;
179     IBOutlet NSMenuItem * o_mi_checkForUpdate;
180     IBOutlet NSMenuItem * o_mi_add_intf;
181     IBOutlet NSMenu * o_mu_add_intf;
182     IBOutlet NSMenuItem * o_mi_services;
183     IBOutlet NSMenuItem * o_mi_hide;
184     IBOutlet NSMenuItem * o_mi_hide_others;
185     IBOutlet NSMenuItem * o_mi_show_all;
186     IBOutlet NSMenuItem * o_mi_quit;
187
188     IBOutlet NSMenu * o_mu_file;
189     IBOutlet NSMenuItem * o_mi_open_file;
190     IBOutlet NSMenuItem * o_mi_open_generic;
191     IBOutlet NSMenuItem * o_mi_open_disc;
192     IBOutlet NSMenuItem * o_mi_open_net;
193     IBOutlet NSMenuItem * o_mi_open_capture;
194     IBOutlet NSMenuItem * o_mi_open_recent;
195     IBOutlet NSMenuItem * o_mi_open_recent_cm;
196     IBOutlet NSMenuItem * o_mi_open_wizard;
197     IBOutlet NSMenuItem * o_mi_open_vlm;
198
199     IBOutlet NSMenu * o_mu_edit;
200     IBOutlet NSMenuItem * o_mi_cut;
201     IBOutlet NSMenuItem * o_mi_copy;
202     IBOutlet NSMenuItem * o_mi_paste;
203     IBOutlet NSMenuItem * o_mi_clear;
204     IBOutlet NSMenuItem * o_mi_select_all;
205
206     IBOutlet NSMenu * o_mu_controls;
207     IBOutlet NSMenuItem * o_mi_play;
208     IBOutlet NSMenuItem * o_mi_stop;
209     IBOutlet NSMenuItem * o_mi_faster;
210     IBOutlet NSMenuItem * o_mi_slower;
211     IBOutlet NSMenuItem * o_mi_previous;
212     IBOutlet NSMenuItem * o_mi_next;
213     IBOutlet NSMenuItem * o_mi_random;
214     IBOutlet NSMenuItem * o_mi_repeat;
215     IBOutlet NSMenuItem * o_mi_loop;
216     IBOutlet NSMenuItem * o_mi_fwd;
217     IBOutlet NSMenuItem * o_mi_bwd;
218     IBOutlet NSMenuItem * o_mi_fwd1m;
219     IBOutlet NSMenuItem * o_mi_bwd1m;
220     IBOutlet NSMenuItem * o_mi_fwd5m;
221     IBOutlet NSMenuItem * o_mi_bwd5m;
222     IBOutlet NSMenuItem * o_mi_program;
223     IBOutlet NSMenuItem * o_mu_program;
224     IBOutlet NSMenuItem * o_mi_title;
225     IBOutlet NSMenu * o_mu_title;
226     IBOutlet NSMenuItem * o_mi_chapter;
227     IBOutlet NSMenu * o_mu_chapter;
228
229     IBOutlet NSMenu * o_mu_audio;
230     IBOutlet NSMenuItem * o_mi_vol_up;
231     IBOutlet NSMenuItem * o_mi_vol_down;
232     IBOutlet NSMenuItem * o_mi_mute;
233     IBOutlet NSMenuItem * o_mi_audiotrack;
234     IBOutlet NSMenu * o_mu_audiotrack;
235     IBOutlet NSMenuItem * o_mi_channels;
236     IBOutlet NSMenu * o_mu_channels;
237     IBOutlet NSMenuItem * o_mi_device;
238     IBOutlet NSMenu * o_mu_device;
239     IBOutlet NSMenuItem * o_mi_visual;
240     IBOutlet NSMenu * o_mu_visual;
241
242     IBOutlet NSMenu * o_mu_video;
243     IBOutlet NSMenuItem * o_mi_half_window;
244     IBOutlet NSMenuItem * o_mi_normal_window;
245     IBOutlet NSMenuItem * o_mi_double_window;
246     IBOutlet NSMenuItem * o_mi_fittoscreen;
247     IBOutlet NSMenuItem * o_mi_fullscreen;
248     IBOutlet NSMenuItem * o_mi_floatontop;
249     IBOutlet NSMenuItem * o_mi_snapshot;
250     IBOutlet NSMenuItem * o_mi_videotrack;
251     IBOutlet NSMenu * o_mu_videotrack;
252     IBOutlet NSMenuItem * o_mi_screen;
253     IBOutlet NSMenu * o_mu_screen;
254     IBOutlet NSMenuItem * o_mi_aspect_ratio;
255     IBOutlet NSMenu * o_mu_aspect_ratio;
256     IBOutlet NSMenuItem * o_mi_crop;
257     IBOutlet NSMenu * o_mu_crop;
258     IBOutlet NSMenuItem * o_mi_subtitle;
259     IBOutlet NSMenu * o_mu_subtitle;
260     IBOutlet NSMenuItem * o_mi_deinterlace;
261     IBOutlet NSMenu * o_mu_deinterlace;
262     IBOutlet NSMenuItem * o_mi_ffmpeg_pp;
263     IBOutlet NSMenuItem * o_mu_ffmpeg_pp;
264     IBOutlet NSMenuItem * o_mi_teletext;
265     IBOutlet NSMenuItem * o_mi_teletext_transparent;
266     IBOutlet NSMenuItem * o_mi_teletext_index;
267     IBOutlet NSMenuItem * o_mi_teletext_red;
268     IBOutlet NSMenuItem * o_mi_teletext_green;
269     IBOutlet NSMenuItem * o_mi_teletext_yellow;
270     IBOutlet NSMenuItem * o_mi_teletext_blue;
271
272     IBOutlet NSMenu * o_mu_window;
273     IBOutlet NSMenuItem * o_mi_minimize;
274     IBOutlet NSMenuItem * o_mi_close_window;
275     IBOutlet NSMenuItem * o_mi_controller;
276     IBOutlet NSMenuItem * o_mi_equalizer;
277     IBOutlet NSMenuItem * o_mi_extended;
278     IBOutlet NSMenuItem * o_mi_bookmarks;
279     IBOutlet NSMenuItem * o_mi_playlist;
280     IBOutlet NSMenuItem * o_mi_info;
281     IBOutlet NSMenuItem * o_mi_messages;
282     IBOutlet NSMenuItem * o_mi_bring_atf;
283
284     IBOutlet NSMenu * o_mu_help;
285     IBOutlet NSMenuItem * o_mi_help;
286     IBOutlet NSMenuItem * o_mi_readme;
287     IBOutlet NSMenuItem * o_mi_documentation;
288     IBOutlet NSMenuItem * o_mi_license;
289     IBOutlet NSMenuItem * o_mi_website;
290     IBOutlet NSMenuItem * o_mi_donation;
291     IBOutlet NSMenuItem * o_mi_forum;
292     IBOutlet NSMenuItem * o_mi_errorsAndWarnings;
293
294     /* dock menu */
295     IBOutlet NSMenuItem * o_dmi_play;
296     IBOutlet NSMenuItem * o_dmi_stop;
297     IBOutlet NSMenuItem * o_dmi_next;
298     IBOutlet NSMenuItem * o_dmi_previous;
299     IBOutlet NSMenuItem * o_dmi_mute;
300
301     /* vout menu */
302     IBOutlet NSMenu * o_vout_menu;
303     IBOutlet NSMenuItem * o_vmi_play;
304     IBOutlet NSMenuItem * o_vmi_stop;
305     IBOutlet NSMenuItem * o_vmi_prev;
306     IBOutlet NSMenuItem * o_vmi_next;
307     IBOutlet NSMenuItem * o_vmi_volup;
308     IBOutlet NSMenuItem * o_vmi_voldown;
309     IBOutlet NSMenuItem * o_vmi_mute;
310     IBOutlet NSMenuItem * o_vmi_fullscreen;
311     IBOutlet NSMenuItem * o_vmi_snapshot;
312
313     bool b_small_window;
314
315     bool b_restore_size;
316     NSRect o_restore_rect;
317
318     mtime_t i_end_scroll;
319
320     NSSize o_size_with_playlist;
321
322     int     i_lastShownVolume;
323
324     input_state_e cachedInputState;
325
326     /* the manage thread */
327     pthread_t manage_thread;
328
329     /* The timer that update the interface */
330     NSTimer * interfaceTimer;
331
332     NSURLConnection * crashLogURLConnection;
333
334     AppleRemote * o_remote;
335     BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
336 }
337
338 + (VLCMain *)sharedInstance;
339
340 - (intf_thread_t *)getIntf;
341 - (void)setIntf:(intf_thread_t *)p_mainintf;
342
343 - (void)controlTintChanged;
344
345 - (id)getControls;
346 - (id)getSimplePreferences;
347 - (id)getPreferences;
348 - (id)getPlaylist;
349 - (BOOL)isPlaylistCollapsed;
350 - (id)getInfo;
351 - (id)getWizard;
352 - (id)getBookmarks;
353 - (id)getEmbeddedList;
354 - (id)getInteractionList;
355 - (id)getMainIntfPgbar;
356 - (id)getControllerWindow;
357 - (id)getVoutMenu;
358 - (id)getEyeTVController;
359 - (void)applicationWillTerminate:(NSNotification *)notification;
360 - (NSString *)localizedString:(const char *)psz;
361 - (char *)delocalizeString:(NSString *)psz;
362 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
363 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
364
365 - (void)initStrings;
366
367 - (void)manage;
368 - (void)manageIntf:(NSTimer *)o_timer;
369 - (void)setupMenus;
370 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
371 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
372 - (void)resetScrollField;
373
374 - (void)updateMessageDisplay;
375 - (void)playStatusUpdated:(int) i_status;
376 - (void)setSubmenusEnabled:(BOOL)b_enabled;
377 - (void)manageVolumeSlider;
378 - (IBAction)timesliderUpdate:(id)sender;
379
380 - (IBAction)clearRecentItems:(id)sender;
381 - (void)openRecentItem:(id)sender;
382
383 - (IBAction)intfOpenFile:(id)sender;
384 - (IBAction)intfOpenFileGeneric:(id)sender;
385 - (IBAction)intfOpenDisc:(id)sender;
386 - (IBAction)intfOpenNet:(id)sender;
387 - (IBAction)intfOpenCapture:(id)sender;
388
389 - (IBAction)showWizard:(id)sender;
390 - (IBAction)showVLM:(id)sender;
391 - (IBAction)showExtended:(id)sender;
392 - (IBAction)showBookmarks:(id)sender;
393
394 - (IBAction)viewAbout:(id)sender;
395 - (IBAction)showLicense:(id)sender;
396 - (IBAction)viewPreferences:(id)sender;
397 - (IBAction)checkForUpdate:(id)sender;
398 - (IBAction)viewHelp:(id)sender;
399 - (IBAction)openReadMe:(id)sender;
400 - (IBAction)openDocumentation:(id)sender;
401 - (IBAction)openWebsite:(id)sender;
402 - (IBAction)openForum:(id)sender;
403 - (IBAction)openDonate:(id)sender;
404 - (IBAction)openCrashLog:(id)sender;
405 - (IBAction)viewErrorsAndWarnings:(id)sender;
406 - (IBAction)showMessagesPanel:(id)sender;
407 - (IBAction)showInformationPanel:(id)sender;
408
409 - (IBAction)crashReporterAction:(id)sender;
410
411 - (IBAction)togglePlaylist:(id)sender;
412 - (void)updateTogglePlaylistState;
413
414 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
415
416 @end
417
418 @interface VLCMain (Internal)
419 - (void)handlePortMessage:(NSPortMessage *)o_msg;
420 @end