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