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