intf.h 9.89 KB
Newer Older
1
/*****************************************************************************
2
 * intf.h: MacOS X interface module
3
 *****************************************************************************
4
 * Copyright (C) 2002-2011 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
 *          Felix Paul Kühne <fkuehne at videolan dot org>
11
12
13
14
15
 *
 * 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.
16
 *
17
18
19
20
21
22
23
 * 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
dionoea's avatar
dionoea committed
24
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25
26
 *****************************************************************************/

Rafaël Carré's avatar
Rafaël Carré committed
27
28
29
30
#ifdef HAVE_CONFIG_H
#   include "config.h"
#endif

31
#include <vlc_common.h>
zorglub's avatar
zorglub committed
32
#include <vlc_interface.h>
33
#include <vlc_playlist.h>
zorglub's avatar
zorglub committed
34
35
36
#include <vlc_vout.h>
#include <vlc_aout.h>
#include <vlc_input.h>
37
38

#include <Cocoa/Cocoa.h>
39
#import "SPMediaKeyTap.h"                   /* for the media key support */
40

41
/*****************************************************************************
hartman's avatar
hartman committed
42
 * Local prototypes.
43
 *****************************************************************************/
hartman's avatar
hartman committed
44
unsigned int CocoaKeyToVLC( unichar i_key );
45

46
#define VLCIntf [[VLCMain sharedInstance] intf]
47

hartman's avatar
hartman committed
48
#define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
hartman's avatar
ALL:    
hartman committed
49
50
51
/* 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
52
#define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
53

54
55
56
57
#define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
            @"/System/Library/CoreServices/SystemVersion.plist"] \
            objectForKey: @"ProductVersion"] floatValue]

58
59
60
61
62
63

// You need to release those objects after use
input_thread_t *getInput(void);
vout_thread_t *getVout(void);
aout_instance_t *getAout(void);

64
65
66
67
68
69
/*****************************************************************************
 * intf_sys_t: description and status of the interface
 *****************************************************************************/
struct intf_sys_t
{
    /* special actions */
70
    bool b_mute;
hartman's avatar
hartman committed
71
    int i_play_status;
72

73
    /* interface update */
74
75
76
77
78
79
80
    bool b_intf_update;
    bool b_playlist_update;
    bool b_playmode_update;
    bool b_current_title_update;
    bool b_fullscreen_update;
    bool b_volume_update;
    bool b_intf_show;
81

82
    /* menus handlers */
83
84
85
    bool b_input_update;
    bool b_aout_update;
    bool b_vout_update;
86
87
88
89
90
91

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

/*****************************************************************************
92
 * VLCMain interface
93
 *****************************************************************************/
94
@class AppleRemote;
95
@class VLCInformation;
96
@class VLCControllerWindow;
97
98
99
@class VLCEmbeddedWindow;
@class VLCControls;
@class VLCPlaylist;
100
101
@interface VLCMain : NSObject
{
hartman's avatar
hartman committed
102
    intf_thread_t *p_intf;      /* The main intf object */
103
    id o_mainmenu;              /* VLCMainMenu */
104
    id o_prefs;                 /* VLCPrefs       */
105
    id o_sprefs;                /* VLCSimplePrefs */
106
    id o_open;                  /* VLCOpen        */
107
    id o_wizard;                /* VLCWizard      */
108
    id o_embedded_list;         /* VLCEmbeddedList*/
109
    id o_coredialogs;           /* VLCCoreDialogProvider */
110
    VLCInformation * o_info;    /* VLCInformation */
111
    id o_eyetv;                 /* VLCEyeTVController */
112
    id o_bookmarks;             /* VLCBookmarks */
113
    id o_coreinteraction;       /* VLCCoreInteraction */
114
115
116
117
    BOOL nib_main_loaded;       /* main nibfile */
    BOOL nib_open_loaded;       /* open nibfile */
    BOOL nib_about_loaded;      /* about nibfile */
    BOOL nib_wizard_loaded;     /* wizard nibfile */
118
    BOOL nib_prefs_loaded;      /* preferences nibfile */
119
    BOOL nib_info_loaded;       /* information panel nibfile */
120
    BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
121
    BOOL nib_bookmarks_loaded;   /* Bookmarks nibfile */
122

123
    IBOutlet VLCControllerWindow * o_window;                     /* main window */
124
125
    IBOutlet id o_scrollfield;                                  /* info field */
    IBOutlet NSTextField * o_timefield;                         /* time field */
126
    IBOutlet NSSlider * o_timeslider;                                 /* time slider */
127
128
129
130
131
    BOOL b_time_remaining;                                      /* show remaining time or playtime ? */
    IBOutlet VLCEmbeddedWindow * o_embedded_window;             /* Embedded Vout Window */
    float f_slider;                                             /* slider value */
    float f_slider_old;                                         /* old slider val */
    IBOutlet NSSlider * o_volumeslider;                         /* volume slider */
132
133
134
135
136
137
138
139
140
141

    IBOutlet NSProgressIndicator * o_main_pgbar;   /* playlist window progress bar */
    IBOutlet NSButton * o_btn_prev;     /* btn previous   */
    IBOutlet NSButton * o_btn_rewind;   /* btn rewind     */
    IBOutlet NSButton * o_btn_play;     /* btn play       */
    IBOutlet NSButton * o_btn_stop;     /* btn stop       */
    IBOutlet NSButton * o_btn_ff;       /* btn fast forward     */
    IBOutlet NSButton * o_btn_next;     /* btn next       */
    IBOutlet NSButton * o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
    IBOutlet NSButton * o_btn_playlist; /* btn playlist   */
142
    IBOutlet NSButton * o_btn_audioEffects; /* AudioEffects btn */
143

144
145
    NSImage * o_img_play;       /* btn play img   */
    NSImage * o_img_pause;      /* btn pause img  */
hartman's avatar
hartman committed
146
147
    NSImage * o_img_play_pressed;       /* btn play img   */
    NSImage * o_img_pause_pressed;      /* btn pause img  */
148

149
150
    IBOutlet VLCControls * o_controls;     /* VLCControls    */
    IBOutlet VLCPlaylist * o_playlist;     /* VLCPlaylist    */
151

152
153
154
155
156
    IBOutlet NSTextView * o_messages;           /* messages tv    */
    IBOutlet NSWindow * o_msgs_panel;           /* messages panel */
    NSMutableArray * o_msg_arr;                 /* messages array */
    NSLock * o_msg_lock;                        /* messages lock */
    BOOL b_msg_arr_changed;                     /* did the array change? */
157
158
    IBOutlet NSButton * o_msgs_crashlog_btn;    /* messages open crashlog */
    IBOutlet NSButton * o_msgs_save_btn;        /* save the log as rtf */
159

160
161
162
163
164
165
166
    /* CrashReporter panel */
    IBOutlet NSButton * o_crashrep_dontSend_btn;
    IBOutlet NSButton * o_crashrep_send_btn;
    IBOutlet NSTextView * o_crashrep_fld;
    IBOutlet NSTextField * o_crashrep_title_txt;
    IBOutlet NSTextField * o_crashrep_desc_txt;
    IBOutlet NSWindow * o_crashrep_win;
167
168
    IBOutlet NSButton * o_crashrep_includeEmail_ckb;
    IBOutlet NSTextField * o_crashrep_includeEmail_txt;
169

170
    mtime_t i_end_scroll;
171

172
    int     i_lastShownVolume;
173

174
175
    input_state_e cachedInputState;

176
177
178
    /* the manage thread */
    pthread_t manage_thread;

179
180
181
    /* The timer that update the interface */
    NSTimer * interfaceTimer;

182
183
    NSURLConnection * crashLogURLConnection;

184
    AppleRemote * o_remote;
185
    BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
186

187
188
189
190
191
    /* media key support */
    BOOL b_mediaKeySupport;
    BOOL b_mediakeyJustJumped;
    SPMediaKeyTap * o_mediaKeyController;

192
    NSArray *o_usedHotkeys;
193
194
}

hartman's avatar
hartman committed
195
196
+ (VLCMain *)sharedInstance;

197
- (intf_thread_t *)intf;
hartman's avatar
hartman committed
198
199
- (void)setIntf:(intf_thread_t *)p_mainintf;

200
- (id)mainMenu;
201
- (id)controls;
202
203
- (id)bookmarks;
- (id)open;
204
205
206
- (id)simplePreferences;
- (id)preferences;
- (id)playlist;
207
- (BOOL)isPlaylistCollapsed;
208
209
210
211
212
213
214
- (id)info;
- (id)wizard;
- (id)embeddedList;
- (id)coreDialogProvider;
- (id)mainIntfPgbar;
- (id)controllerWindow;
- (id)eyeTVController;
215
- (id)appleRemoteController;
216
- (void)applicationWillTerminate:(NSNotification *)notification;
217
- (NSString *)localizedString:(const char *)psz;
hartman's avatar
hartman committed
218
219
220
- (char *)delocalizeString:(NSString *)psz;
- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
221
222
- (NSString *)VLCKeyToString:(NSString *)theString;
- (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
223
- (void)updateCurrentlyUsedHotkeys;
224

225
- (void)initStrings;
226
- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename;
227

228
- (void)manage;
229
- (void)manageIntf:(NSTimer *)o_timer;
230

231
232
- (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
- (void)resetScrollField;
233

234
- (void)updateMessageDisplay;
hartman's avatar
hartman committed
235
- (void)playStatusUpdated:(int) i_status;
236
- (void)manageVolumeSlider;
hartman's avatar
* ALL:    
hartman committed
237
- (IBAction)timesliderUpdate:(id)sender;
238
- (IBAction)timeFieldWasClicked:(id)sender;
239
- (IBAction)showController:(id)sender;
240

241
- (IBAction)crashReporterAction:(id)sender;
242
- (IBAction)openCrashLog:(id)sender;
243
- (IBAction)saveDebugLog:(id)sender;
244
- (IBAction)showMessagesPanel:(id)sender;
245

246
247
248
- (IBAction)togglePlaylist:(id)sender;
- (void)updateTogglePlaylistState;

249
250
- (void)windowDidBecomeKey:(NSNotification *)o_notification;

251
- (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
252
253
254
255
@end

@interface VLCMain (Internal)
- (void)handlePortMessage:(NSPortMessage *)o_msg;
256
257
- (void)resetMediaKeyJump;
- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
258
@end
259
260
261
262
263
264
265
266
267

/*****************************************************************************
 * VLCApplication interface
 *****************************************************************************/

@interface VLCApplication : NSApplication
{
}
@end