]> git.sesse.net Git - vlc/blob - modules/gui/macosx/intf.h
macosx: o_sendport not used, remove.
[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 /* this was introduced in Darwin 9. We need to declare it to prevent both
41  * compilation warnings and errors */
42 #ifndef NSInteger
43 #define NSInteger int
44 #endif
45
46 /*****************************************************************************
47  * Local prototypes.
48  *****************************************************************************/
49 unsigned int CocoaKeyToVLC( unichar i_key );
50
51 #define VLCIntf [[VLCMain sharedInstance] getIntf]
52
53 #define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
54 /* Get an alternate version of the string.
55  * This string is stored as '1:string' but when displayed it only displays
56  * the translated string. the translation should be '1:translatedstring' though */
57 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
58
59 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
60             @"/System/Library/CoreServices/SystemVersion.plist"] \
61             objectForKey: @"ProductVersion"] floatValue]
62
63 /*****************************************************************************
64  * intf_sys_t: description and status of the interface
65  *****************************************************************************/
66 struct intf_sys_t
67 {
68     NSAutoreleasePool * o_pool;
69
70     /* the current input */
71     input_thread_t * p_input;
72
73     /* special actions */
74     bool b_mute;
75     int i_play_status;
76
77     /* interface update */
78     bool b_intf_update;
79     bool b_playlist_update;
80     bool b_playmode_update;
81     bool b_current_title_update;
82     bool b_fullscreen_update;
83     bool b_volume_update;
84     bool b_intf_show;
85
86     /* menus handlers */
87     bool b_input_update;
88     bool b_aout_update;
89     bool b_vout_update;
90
91     /* The messages window */
92     msg_subscription_t * p_sub;
93 };
94
95 /*****************************************************************************
96  * VLCMain interface
97  *****************************************************************************/
98 @class AppleRemote;
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     id o_embedded_list;         /* VLCEmbeddedList*/
110     id o_interaction_list;      /* VLCInteractionList*/
111     id o_info;                  /* VLCInformation */
112 #ifdef UPDATE_CHECK
113     id o_update;                /* VLCUpdate      */
114 #endif
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_update_loaded;     /* update nibfile */
124     BOOL nib_info_loaded;       /* information panel nibfile */
125
126     IBOutlet id o_window;       /* main window    */
127     IBOutlet id o_playlist_view;/* playlist view  */
128     IBOutlet id o_scrollfield;  /* info field     */
129     IBOutlet id o_timefield;    /* time field     */
130     IBOutlet id o_timeslider;   /* time slider    */
131     IBOutlet id o_embedded_window; /* Embedded Vout Window */
132     float f_slider;             /* slider value   */
133     float f_slider_old;         /* old slider val */
134     IBOutlet id o_volumeslider; /* volume slider  */
135
136     IBOutlet id o_main_pgbar;   /* playlist window progress bar */
137     IBOutlet id o_btn_prev;     /* btn previous   */
138     IBOutlet id o_btn_rewind;   /* btn rewind     */
139     IBOutlet id o_btn_play;     /* btn play       */
140     IBOutlet id o_btn_stop;     /* btn stop       */
141     IBOutlet id o_btn_ff;       /* btn fast forward     */
142     IBOutlet id o_btn_next;     /* btn next       */
143     IBOutlet id o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
144     IBOutlet id o_btn_playlist; /* btn playlist   */
145     IBOutlet id o_btn_equalizer; /* eq btn */
146
147     NSImage * o_img_play;       /* btn play img   */
148     NSImage * o_img_pause;      /* btn pause img  */
149     NSImage * o_img_play_pressed;       /* btn play img   */
150     NSImage * o_img_pause_pressed;      /* btn pause img  */
151
152     IBOutlet id o_controls;     /* VLCControls    */
153     IBOutlet id o_playlist;     /* VLCPlaylist    */
154
155     IBOutlet id o_messages;     /* messages tv    */
156     IBOutlet id o_msgs_panel;   /* messages panel */
157     NSMutableArray * o_msg_arr; /* messages array */
158     NSLock * o_msg_lock;        /* messages lock  */
159     IBOutlet id o_msgs_btn_crashlog;    /* messages open crashlog */
160
161     /* main menu */
162
163     IBOutlet id o_mi_about;
164     IBOutlet id o_mi_prefs;
165     IBOutlet id o_mi_sprefs;
166     IBOutlet id o_mi_checkForUpdate;
167     IBOutlet id o_mi_add_intf;
168     IBOutlet id o_mu_add_intf;
169     IBOutlet id o_mi_services;
170     IBOutlet id o_mi_hide;
171     IBOutlet id o_mi_hide_others;
172     IBOutlet id o_mi_show_all;
173     IBOutlet id o_mi_quit;
174
175     IBOutlet id o_mu_file;
176     IBOutlet id o_mi_open_file;
177     IBOutlet id o_mi_open_generic;
178     IBOutlet id o_mi_open_disc;
179     IBOutlet id o_mi_open_net;
180     IBOutlet id o_mi_open_capture;
181     IBOutlet id o_mi_open_recent;
182     IBOutlet id o_mi_open_recent_cm;
183     IBOutlet id o_mi_open_wizard;
184
185     IBOutlet id o_mu_edit;
186     IBOutlet id o_mi_cut;
187     IBOutlet id o_mi_copy;
188     IBOutlet id o_mi_paste;
189     IBOutlet id o_mi_clear;
190     IBOutlet id o_mi_select_all;
191
192     IBOutlet id o_mu_controls;
193     IBOutlet id o_mi_play;
194     IBOutlet id o_mi_stop;
195     IBOutlet id o_mi_faster;
196     IBOutlet id o_mi_slower;
197     IBOutlet id o_mi_previous;
198     IBOutlet id o_mi_next;
199     IBOutlet id o_mi_random;
200     IBOutlet id o_mi_repeat;
201     IBOutlet id o_mi_loop;
202     IBOutlet id o_mi_fwd;
203     IBOutlet id o_mi_bwd;
204     IBOutlet id o_mi_fwd1m;
205     IBOutlet id o_mi_bwd1m;
206     IBOutlet id o_mi_fwd5m;
207     IBOutlet id o_mi_bwd5m;
208     IBOutlet id o_mi_program;
209     IBOutlet id o_mu_program;
210     IBOutlet id o_mi_title;
211     IBOutlet id o_mu_title;
212     IBOutlet id o_mi_chapter;
213     IBOutlet id o_mu_chapter;
214
215     IBOutlet id o_mu_audio;
216     IBOutlet id o_mi_vol_up;
217     IBOutlet id o_mi_vol_down;
218     IBOutlet id o_mi_mute;
219     IBOutlet id o_mi_audiotrack;
220     IBOutlet id o_mu_audiotrack;
221     IBOutlet id o_mi_channels;
222     IBOutlet id o_mu_channels;
223     IBOutlet id o_mi_device;
224     IBOutlet id o_mu_device;
225     IBOutlet id o_mi_visual;
226     IBOutlet id o_mu_visual;
227
228     IBOutlet id o_mu_video;
229     IBOutlet id o_mi_half_window;
230     IBOutlet id o_mi_normal_window;
231     IBOutlet id o_mi_double_window;
232     IBOutlet id o_mi_fittoscreen;
233     IBOutlet id o_mi_fullscreen;
234     IBOutlet id o_mi_floatontop;
235     IBOutlet id o_mi_snapshot;
236     IBOutlet id o_mi_videotrack;
237     IBOutlet id o_mu_videotrack;
238     IBOutlet id o_mi_screen;
239     IBOutlet id o_mu_screen;
240     IBOutlet id o_mi_aspect_ratio;
241     IBOutlet id o_mu_aspect_ratio;
242     IBOutlet id o_mi_crop;
243     IBOutlet id o_mu_crop;
244     IBOutlet id o_mi_subtitle;
245     IBOutlet id o_mu_subtitle;
246     IBOutlet id o_mi_deinterlace;
247     IBOutlet id o_mu_deinterlace;
248     IBOutlet id o_mi_ffmpeg_pp;
249     IBOutlet id o_mu_ffmpeg_pp;
250
251     IBOutlet id o_mu_window;
252     IBOutlet id o_mi_minimize;
253     IBOutlet id o_mi_close_window;
254     IBOutlet id o_mi_controller;
255     IBOutlet id o_mi_equalizer;
256     IBOutlet id o_mi_extended;
257     IBOutlet id o_mi_bookmarks;
258     IBOutlet id o_mi_playlist;
259     IBOutlet id o_mi_info;
260     IBOutlet id o_mi_messages;
261     IBOutlet id o_mi_bring_atf;
262
263     IBOutlet id o_mu_help;
264     IBOutlet id o_mi_help;
265     IBOutlet id o_mi_readme;
266     IBOutlet id o_mi_documentation;
267     IBOutlet id o_mi_license;
268     IBOutlet id o_mi_website;
269     IBOutlet id o_mi_donation;
270     IBOutlet id o_mi_forum;
271     IBOutlet id o_mi_errorsAndWarnings;
272
273     /* dock menu */
274     IBOutlet id o_dmi_play;
275     IBOutlet id o_dmi_stop;
276     IBOutlet id o_dmi_next;
277     IBOutlet id o_dmi_previous;
278     IBOutlet id o_dmi_mute;
279
280     /* vout menu */
281     IBOutlet id o_vout_menu;
282     IBOutlet id o_vmi_play;
283     IBOutlet id o_vmi_stop;
284     IBOutlet id o_vmi_prev;
285     IBOutlet id o_vmi_next;
286     IBOutlet id o_vmi_volup;
287     IBOutlet id o_vmi_voldown;
288     IBOutlet id o_vmi_mute;
289     IBOutlet id o_vmi_fullscreen;
290     IBOutlet id o_vmi_snapshot;
291
292     bool b_small_window;
293
294     bool b_restore_size;
295     NSRect o_restore_rect;
296
297     mtime_t i_end_scroll;
298
299     NSSize o_size_with_playlist;
300
301     int     i_lastShownVolume;
302
303     /* the manage thread */
304     pthread_t manage_thread;
305
306     /* The timer that update the interface */
307     NSTimer * interfaceTimer;
308
309     AppleRemote * o_remote;
310     BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
311 }
312
313 + (VLCMain *)sharedInstance;
314
315 - (intf_thread_t *)getIntf;
316 - (void)setIntf:(intf_thread_t *)p_mainintf;
317
318 - (void)controlTintChanged;
319
320 - (id)getControls;
321 - (id)getSimplePreferences;
322 - (id)getPreferences;
323 - (id)getPlaylist;
324 - (id)getInfo;
325 - (id)getWizard;
326 - (id)getBookmarks;
327 - (id)getEmbeddedList;
328 - (id)getInteractionList;
329 - (id)getMainIntfPgbar;
330 - (id)getControllerWindow;
331 - (id)getVoutMenu;
332 - (id)getEyeTVController;
333 - (void)applicationWillTerminate:(NSNotification *)notification;
334 - (NSString *)localizedString:(const char *)psz;
335 - (char *)delocalizeString:(NSString *)psz;
336 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
337 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
338
339 - (void)initStrings;
340
341 - (void)manage;
342 - (void)manageIntf:(NSTimer *)o_timer;
343 - (void)setupMenus;
344 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
345 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
346 - (void)resetScrollField;
347
348 - (void)updateMessageArray;
349 - (void)playStatusUpdated:(int) i_status;
350 - (void)setSubmenusEnabled:(BOOL)b_enabled;
351 - (void)manageVolumeSlider;
352 - (IBAction)timesliderUpdate:(id)sender;
353
354 - (IBAction)clearRecentItems:(id)sender;
355 - (void)openRecentItem:(id)sender;
356
357 - (IBAction)intfOpenFile:(id)sender;
358 - (IBAction)intfOpenFileGeneric:(id)sender;
359 - (IBAction)intfOpenDisc:(id)sender;
360 - (IBAction)intfOpenNet:(id)sender;
361 - (IBAction)intfOpenCapture:(id)sender;
362
363 - (IBAction)showWizard:(id)sender;
364 - (IBAction)showExtended:(id)sender;
365 - (IBAction)showBookmarks:(id)sender;
366
367 - (IBAction)viewAbout:(id)sender;
368 - (IBAction)showLicense:(id)sender;
369 - (IBAction)viewPreferences:(id)sender;
370 - (IBAction)checkForUpdate:(id)sender;
371 - (IBAction)viewHelp:(id)sender;
372 - (IBAction)openReadMe:(id)sender;
373 - (IBAction)openDocumentation:(id)sender;
374 - (IBAction)openWebsite:(id)sender;
375 - (IBAction)openForum:(id)sender;
376 - (IBAction)openDonate:(id)sender;
377 - (IBAction)openCrashLog:(id)sender;
378 - (IBAction)viewErrorsAndWarnings:(id)sender;
379 - (IBAction)showMessagesPanel:(id)sender;
380 - (IBAction)showInformationPanel:(id)sender;
381
382 - (IBAction)togglePlaylist:(id)sender;
383 - (void)updateTogglePlaylistState;
384
385 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
386
387 @end
388
389 @interface VLCMain (Internal)
390 - (void)handlePortMessage:(NSPortMessage *)o_msg;
391 @end