intf.h 10.8 KB
Newer Older
1
/*****************************************************************************
2
 * intf.h: MacOS X interface module
3
 *****************************************************************************
4
 * Copyright (C) 2002-2005 the VideoLAN team
5
 * $Id$
6 7 8
 *
 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
 *          Christophe Massiot <massiot@via.ecp.fr>
9
 *          Derk-Jan Hartman <hartman at videolan dot org>
10 11 12 13 14
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
15
 *
16 17 18 19 20 21 22 23 24 25
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

26 27 28
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/vout.h>
29
#include <vlc/aout.h>
30
#include <vlc/input.h>
31 32 33

#include <Cocoa/Cocoa.h>

34
/*****************************************************************************
hartman's avatar
hartman committed
35
 * Local prototypes.
36
 *****************************************************************************/
hartman's avatar
hartman committed
37 38
int ExecuteOnMainThread( id target, SEL sel, void * p_arg );
unsigned int CocoaKeyToVLC( unichar i_key );
39

hartman's avatar
hartman committed
40
#define VLCIntf [[VLCMain sharedInstance] getIntf]
41

hartman's avatar
hartman committed
42
#define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
hartman's avatar
ALL:  
hartman committed
43 44 45
/* Get an alternate version of the string.
 * This string is stored as '1:string' but when displayed it only displays
 * the translated string. the translation should be '1:translatedstring' though */
hartman's avatar
hartman committed
46
#define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
47

48 49 50 51
#define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
            @"/System/Library/CoreServices/SystemVersion.plist"] \
            objectForKey: @"ProductVersion"] floatValue]

52 53 54 55 56 57 58 59
/*****************************************************************************
 * intf_sys_t: description and status of the interface
 *****************************************************************************/
struct intf_sys_t
{
    NSAutoreleasePool * o_pool;
    NSPort * o_sendport;

hartman's avatar
hartman committed
60 61 62
    /* the current input */
    input_thread_t * p_input;

63 64
    /* special actions */
    vlc_bool_t b_mute;
hartman's avatar
hartman committed
65
    int i_play_status;
66

67 68
    /* interface update */
    vlc_bool_t b_intf_update;
hartman's avatar
hartman committed
69
    vlc_bool_t b_playlist_update;
70
    vlc_bool_t b_playmode_update;
hartman's avatar
ALL:  
hartman committed
71
    vlc_bool_t b_current_title_update;
72
    vlc_bool_t b_fullscreen_update;
73
    vlc_bool_t b_volume_update;
74

75
    /* menus handlers */
76
    vlc_bool_t b_input_update;
77 78
    vlc_bool_t b_aout_update;
    vlc_bool_t b_vout_update;
79 80 81 82 83 84

    /* The messages window */
    msg_subscription_t * p_sub;
};

/*****************************************************************************
85
 * VLCMain interface
86 87 88
 *****************************************************************************/
@interface VLCMain : NSObject
{
hartman's avatar
hartman committed
89
    intf_thread_t *p_intf;      /* The main intf object */
90
    id o_prefs;                 /* VLCPrefs       */
91 92
    id o_about;                 /* VLAboutBox     */
    id o_open;                  /* VLCOpen        */
93
    id o_wizard;                /* VLCWizard      */
94
    id o_extended;              /* VLCExtended    */
95
    id o_bookmarks;             /* VLCBookmarks   */
96
    /*id o_update;                 VLCUpdate      */
97
    BOOL nib_main_loaded;       /* reference to the main-nib */
98
    BOOL nib_open_loaded;       /* reference to the open-nib */
99
    BOOL nib_about_loaded;      /* reference to the about-nib */
100
    BOOL nib_wizard_loaded;     /* reference to the wizard-nib */
101
    BOOL nib_extended_loaded;   /* reference to the extended-nib */
102
    BOOL nib_bookmarks_loaded;  /* reference to the bookmarks-nib */ 
103
    /*BOOL nib_update_loaded;      reference to the update-nib */
104

105
    IBOutlet id o_window;       /* main window    */
106
    IBOutlet id o_playlist_view;/* playlist view  */
hartman's avatar
hartman committed
107
    IBOutlet id o_scrollfield;  /* info field     */
Jon Lech Johansen's avatar
Jon Lech Johansen committed
108 109 110
    IBOutlet id o_timefield;    /* time field     */
    IBOutlet id o_timeslider;   /* time slider    */
    float f_slider;             /* slider value   */
111
    float f_slider_old;         /* old slider val */
hartman's avatar
hartman committed
112
    IBOutlet id o_volumeslider; /* volume slider  */
Jon Lech Johansen's avatar
Jon Lech Johansen committed
113 114

    IBOutlet id o_btn_prev;     /* btn previous   */
hartman's avatar
hartman committed
115
    IBOutlet id o_btn_rewind;   /* btn rewind     */
Jon Lech Johansen's avatar
Jon Lech Johansen committed
116 117
    IBOutlet id o_btn_play;     /* btn play       */
    IBOutlet id o_btn_stop;     /* btn stop       */
hartman's avatar
hartman committed
118
    IBOutlet id o_btn_ff;       /* btn fast forward     */
Jon Lech Johansen's avatar
Jon Lech Johansen committed
119
    IBOutlet id o_btn_next;     /* btn next       */
hartman's avatar
hartman committed
120
    IBOutlet id o_btn_fullscreen;/* btn fullscreen      */
121
    IBOutlet id o_btn_playlist; /* btn playlist   */
122

123 124
    NSImage * o_img_play;       /* btn play img   */
    NSImage * o_img_pause;      /* btn pause img  */
hartman's avatar
hartman committed
125 126
    NSImage * o_img_play_pressed;       /* btn play img   */
    NSImage * o_img_pause_pressed;      /* btn pause img  */
127

128 129
    IBOutlet id o_controls;     /* VLCControls    */
    IBOutlet id o_playlist;     /* VLCPlaylist    */
130
    IBOutlet id o_info;         /* VLCInfo        */
131 132 133

    IBOutlet id o_messages;     /* messages tv    */
    IBOutlet id o_msgs_panel;   /* messages panel */
134 135
    NSMutableArray * o_msg_arr; /* messages array */
    NSLock * o_msg_lock;        /* messages lock  */
136
    IBOutlet id o_msgs_btn_crashlog;    /* messages open crashlog */
137

138 139 140 141 142 143
    IBOutlet id o_error;        /* error panel    */
    IBOutlet id o_err_msg;      /* NSTextView     */
    IBOutlet id o_err_lbl;
    IBOutlet id o_err_bug_lbl;
    IBOutlet id o_err_btn_msgs; /* Open Messages  */
    IBOutlet id o_err_btn_dismiss;
144
    IBOutlet id o_err_ckbk_surpress;
145 146

    IBOutlet id o_info_window;  /* Info panel     */
147

148 149 150
    /* main menu */

    IBOutlet id o_mi_about;
151
    IBOutlet id o_mi_prefs;
152
    /*IBOutlet id o_mi_checkForUpdate;*/
hartman's avatar
hartman committed
153 154
    IBOutlet id o_mi_add_intf;
    IBOutlet id o_mu_add_intf;
155
    IBOutlet id o_mi_services;
156 157 158 159 160 161 162
    IBOutlet id o_mi_hide;
    IBOutlet id o_mi_hide_others;
    IBOutlet id o_mi_show_all;
    IBOutlet id o_mi_quit;

    IBOutlet id o_mu_file;
    IBOutlet id o_mi_open_file;
163
    IBOutlet id o_mi_open_generic;
164 165 166 167
    IBOutlet id o_mi_open_disc;
    IBOutlet id o_mi_open_net;
    IBOutlet id o_mi_open_recent;
    IBOutlet id o_mi_open_recent_cm;
168
    IBOutlet id o_mi_open_wizard;
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183

    IBOutlet id o_mu_edit;
    IBOutlet id o_mi_cut;
    IBOutlet id o_mi_copy;
    IBOutlet id o_mi_paste;
    IBOutlet id o_mi_clear;
    IBOutlet id o_mi_select_all;

    IBOutlet id o_mu_controls;
    IBOutlet id o_mi_play;
    IBOutlet id o_mi_stop;
    IBOutlet id o_mi_faster;
    IBOutlet id o_mi_slower;
    IBOutlet id o_mi_previous;
    IBOutlet id o_mi_next;
hartman's avatar
hartman committed
184 185
    IBOutlet id o_mi_random;
    IBOutlet id o_mi_repeat;
186
    IBOutlet id o_mi_loop;
187 188
    IBOutlet id o_mi_fwd;
    IBOutlet id o_mi_bwd;
189 190 191 192
    IBOutlet id o_mi_fwd1m;
    IBOutlet id o_mi_bwd1m;
    IBOutlet id o_mi_fwd5m;
    IBOutlet id o_mi_bwd5m;
hartman's avatar
hartman committed
193
    IBOutlet id o_mi_program;
194
    IBOutlet id o_mu_program;
hartman's avatar
hartman committed
195
    IBOutlet id o_mi_title;
196
    IBOutlet id o_mu_title;
hartman's avatar
hartman committed
197
    IBOutlet id o_mi_chapter;
198
    IBOutlet id o_mu_chapter;
hartman's avatar
hartman committed
199 200

    IBOutlet id o_mu_audio;
201 202 203
    IBOutlet id o_mi_vol_up;
    IBOutlet id o_mi_vol_down;
    IBOutlet id o_mi_mute;
204
    IBOutlet id o_mi_audiotrack;
205
    IBOutlet id o_mu_audiotrack;
206
    IBOutlet id o_mi_channels;
207
    IBOutlet id o_mu_channels;
208
    IBOutlet id o_mi_device;
209
    IBOutlet id o_mu_device;
210 211
    IBOutlet id o_mi_visual;
    IBOutlet id o_mu_visual;
hartman's avatar
hartman committed
212 213

    IBOutlet id o_mu_video;
214 215 216
    IBOutlet id o_mi_half_window;
    IBOutlet id o_mi_normal_window;
    IBOutlet id o_mi_double_window;
217
    IBOutlet id o_mi_fittoscreen;
218
    IBOutlet id o_mi_fullscreen;
hartman's avatar
hartman committed
219
    IBOutlet id o_mi_floatontop;
220
    IBOutlet id o_mi_snapshot;
221
    IBOutlet id o_mi_videotrack;
222
    IBOutlet id o_mu_videotrack;
223
    IBOutlet id o_mi_screen;
224
    IBOutlet id o_mu_screen;
225
    IBOutlet id o_mi_subtitle;
226
    IBOutlet id o_mu_subtitle;
227
    IBOutlet id o_mi_deinterlace;
228
    IBOutlet id o_mu_deinterlace;
bigben's avatar
bigben committed
229 230
    IBOutlet id o_mi_ffmpeg_pp;
    IBOutlet id o_mu_ffmpeg_pp;
231 232 233

    IBOutlet id o_mu_window;
    IBOutlet id o_mi_minimize;
234
    IBOutlet id o_mi_close_window;
hartman's avatar
hartman committed
235
    IBOutlet id o_mi_controller;
Jérome Decoodt's avatar
Jérome Decoodt committed
236
    IBOutlet id o_mi_equalizer;
237
    IBOutlet id o_mi_extended;
238
    IBOutlet id o_mi_bookmarks;
hartman's avatar
hartman committed
239
    IBOutlet id o_mi_playlist;
240
    IBOutlet id o_mi_info;
hartman's avatar
hartman committed
241
    IBOutlet id o_mi_messages;
242
    IBOutlet id o_mi_bring_atf;
243

244 245
    IBOutlet id o_mu_help;
    IBOutlet id o_mi_readme;
hartman's avatar
hartman committed
246
    IBOutlet id o_mi_documentation;
247 248 249
    IBOutlet id o_mi_reportabug;
    IBOutlet id o_mi_website;
    IBOutlet id o_mi_license;
250 251
    IBOutlet id o_mi_donation;
    IBOutlet id o_mi_forum;
252 253 254 255

    /* dock menu */
    IBOutlet id o_dmi_play;
    IBOutlet id o_dmi_stop;
256 257
    IBOutlet id o_dmi_next;
    IBOutlet id o_dmi_previous;
258
    IBOutlet id o_dmi_mute;
259

260
    bool b_small_window;
261

262
    mtime_t i_end_scroll;
263 264 265

    NSSize o_size_with_playlist;

266
    int     i_lastShownVolume;
267 268
}

hartman's avatar
hartman committed
269 270 271 272 273
+ (VLCMain *)sharedInstance;

- (intf_thread_t *)getIntf;
- (void)setIntf:(intf_thread_t *)p_mainintf;

hartman's avatar
hartman committed
274
- (id)getControls;
hartman's avatar
hartman committed
275
- (id)getPlaylist;
276
- (id)getInfo;
277
- (id)getWizard;
278
- (id)getBookmarks;
279
- (void)terminate;
hartman's avatar
hartman committed
280 281 282 283
- (NSString *)localizedString:(char *)psz;
- (char *)delocalizeString:(NSString *)psz;
- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
284

285 286
- (void)initStrings;

287
- (void)manage;
288
- (void)manageIntf:(NSTimer *)o_timer;
hartman's avatar
* ALL:  
hartman committed
289
- (void)setupMenus;
290 291
- (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
- (void)resetScrollField;
292 293

- (void)updateMessageArray;
hartman's avatar
hartman committed
294
- (void)playStatusUpdated:(int) i_status;
hartman's avatar
* ALL:  
hartman committed
295
- (void)setSubmenusEnabled:(BOOL)b_enabled;
296
- (void)manageVolumeSlider;
hartman's avatar
* ALL:  
hartman committed
297
- (IBAction)timesliderUpdate:(id)sender;
298 299 300 301

- (IBAction)clearRecentItems:(id)sender;
- (void)openRecentItem:(id)sender;

302 303 304 305 306
- (IBAction)intfOpenFile:(id)sender;
- (IBAction)intfOpenFileGeneric:(id)sender;
- (IBAction)intfOpenDisc:(id)sender;
- (IBAction)intfOpenNet:(id)sender;

307
- (IBAction)showWizard:(id)sender;
308
- (IBAction)showExtended:(id)sender;
309
- (IBAction)showBookmarks:(id)sender;
310

311
- (IBAction)viewAbout:(id)sender;
312
- (IBAction)viewPreferences:(id)sender;
313
/*- (IBAction)checkForUpdate:(id)sender;*/
314
- (IBAction)closeError:(id)sender;
315
- (IBAction)openReadMe:(id)sender;
hartman's avatar
hartman committed
316
- (IBAction)openDocumentation:(id)sender;
317 318 319
- (IBAction)reportABug:(id)sender;
- (IBAction)openWebsite:(id)sender;
- (IBAction)openLicense:(id)sender;
hartman's avatar
hartman committed
320 321
- (IBAction)openForum:(id)sender;
- (IBAction)openDonate:(id)sender;
322
- (IBAction)openCrashLog:(id)sender;
323

324 325 326
- (IBAction)togglePlaylist:(id)sender;
- (void)updateTogglePlaylistState;

327 328
- (void)windowDidBecomeKey:(NSNotification *)o_notification;

329 330 331 332 333
@end

@interface VLCMain (Internal)
- (void)handlePortMessage:(NSPortMessage *)o_msg;
@end