about.m 7.43 KB
Newer Older
1
2
3
/*****************************************************************************
 * about.m: MacOS X About Panel
 *****************************************************************************
4
 * Copyright (C) 2001-2007 the VideoLAN team
5
 * $Id$
6
7
 *
 * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
8
 *          Felix Paul Khne <fkuehne -at- videolan.org>
9
10
11
12
13
 *
 * 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.
14
 *
15
16
17
18
19
20
21
 * 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
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
24
25
26
27
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
28
29
30
31
#import "intf.h"
#import "about.h"
#import <vlc_intf_strings.h>
#import <vlc_about.h>
32

Felix Paul Kühne's avatar
Felix Paul Kühne committed
33
34
35
36
37
38
39
40
#ifdef __x86_64__
#define PLATFORM "Intel"
#elif __i386__
#define PLATFORM "Intel"
#else
#define PLATFORM "PowerPC"
#endif

41
/*****************************************************************************
42
 * VLAboutBox implementation
43
44
45
46
47
48
49
50
51
52
 *****************************************************************************/
@implementation VLAboutBox

static VLAboutBox *_o_sharedInstance = nil;

+ (VLAboutBox *)sharedInstance
{
    return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}

53
- (id)init
54
55
56
57
58
59
{
    if (_o_sharedInstance) {
        [self dealloc];
    } else {
        _o_sharedInstance = [super init];
    }
60
 
61
62
63
    return _o_sharedInstance;
}

64
65
66
67
68
/*****************************************************************************
* VLC About Window
*****************************************************************************/

- (void)showAbout
69
{
70
    if(! b_isSetUp )
71
    {
72
73
74
75
76
77
        /* we want to know when VLC wants to quit to prevent a crash while scrolling our credits */
        [[NSNotificationCenter defaultCenter] addObserver: self
                                                 selector: @selector(VLCWillTerminate)
                                                     name: NSApplicationWillTerminateNotification
                                                   object: nil];
        
78
        /* Get the localized info dictionary (InfoPlist.strings) */
79
        NSDictionary *o_local_dict;
80
81
        o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];

82
83
84
85
        /* Setup the copyright field */
        [o_copyright_field setStringValue: [o_local_dict objectForKey:@"NSHumanReadableCopyright"]];

        /* Set the box title */
Felix Paul Kühne's avatar
Felix Paul Kühne committed
86
        [o_about_window setTitle: _NS("About VLC media player")];
87

88
        /* setup the creator / revision field */
89
        if( VLC_Changeset() != "exported" )
90
            [o_revision_field setStringValue:
91
                [NSString stringWithFormat: _NS("Compiled by %s, based on Git commit %s"),
92
                    VLC_CompileBy(), VLC_Changeset()]];
93
        else
94
95
            [o_revision_field setStringValue: 
                [NSString stringWithFormat: _NS("Compiled by %s"), VLC_CompileBy()]];
96
 
97
        /* Setup the nameversion field */
Felix Paul Kühne's avatar
Felix Paul Kühne committed
98
        [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VLC_Version(), PLATFORM]];
99

100
101
102
103
104
105
        /* setup the authors and thanks field */
        [o_credits_textview setString: [NSString stringWithFormat: @"%@\n\n\n\n%@\n%@\n\n%@", 
                                            _NS(INTF_ABOUT_MSG), 
                                            _NS("VLC was brought to you by:"),
                                            [NSString stringWithUTF8String: psz_authors], 
                                            [NSString stringWithUTF8String: psz_thanks]]];
106

107
        /* Setup the window */
108
109
110
111
112
        [o_credits_textview setDrawsBackground: NO];
        [o_credits_scrollview setDrawsBackground: NO];
        [o_about_window setExcludedFromWindowsMenu:YES];
        [o_about_window setMenu:nil];
        [o_about_window center];
113
114
115
        [o_gpl_btn setTitle: _NS("License")];
        
        b_isSetUp = YES;
116
    }
117
 
118
    /* Show the window */
119
    b_restart = YES;
120
    [o_about_window makeKeyAndOrderFront: nil];
121
122
123
124
}

- (void)windowDidBecomeKey:(NSNotification *)notification
{
125
126
127
128
129
    o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval: 1/6
                                                      target:self
                                                    selector:@selector(scrollCredits:)
                                                    userInfo:nil
                                                     repeats:YES];
130
131
132
133
134
135
136
137
138
}

- (void)windowDidResignKey:(NSNotification *)notification
{
    [o_scroll_timer invalidate];
}

- (void)scrollCredits:(NSTimer *)timer
{
139
    if( b_restart )
140
    {
141
        /* Reset the starttime */
142
143
        i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
        f_current = 0;
144
        f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
145
146
147
        b_restart = NO;
    }

148
    if( [NSDate timeIntervalSinceReferenceDate] >= i_start )
149
    {
150
        /* Scroll to the position */
151
        [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
152
 
153
        /* Increment the scroll position */
154
        f_current += 0.005;
155
 
156
        /* If at end, restart at the top */
157
        if( f_current >= f_end )
158
159
160
        {
            b_restart = YES;
        }
161
162
163
    }
}

164
165
166
167
168
169
- (void)VLCWillTerminate
{
    [o_scroll_timer invalidate];
    [[NSNotificationCenter defaultCenter] removeObserver: self];
}

170
171
172
173
174
175
176
177
178
179
180
181
182
/*****************************************************************************
* VLC GPL Window, action called from the about window and the help menu
*****************************************************************************/

- (IBAction)showGPL:(id)sender
{
    [o_gpl_window setTitle: _NS("License")];
    [o_gpl_field setString: [NSString stringWithUTF8String: psz_license]];
    
    [o_gpl_window center];
    [o_gpl_window makeKeyAndOrderFront: sender];
}

183
184
185
186
187
188
189
/*****************************************************************************
* VLC Generic Help Window
*****************************************************************************/

- (void)showHelp
{
    [o_help_window setTitle: _NS("VLC media player Help")];
190
191
192
193
    [o_help_fwd_btn setToolTip: _NS("Next")];
    [o_help_bwd_btn setToolTip: _NS("Previous")];
    [o_help_home_btn setToolTip: _NS("Index")];

194
    [o_help_window makeKeyAndOrderFront: self];
195
    
196
    [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
197
198
                                        baseURL: [NSURL URLWithString:@"http://videolan.org"]];
}
199

200
201
- (IBAction)helpGoHome:(id)sender
{
202
    [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
203
204
205
                                        baseURL: [NSURL URLWithString:@"http://videolan.org"]];
}

206
207
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
208
    /* delegate to update button states (we're the frameLoadDelegate for our help's webview) */
209
210
211
212
    [o_help_fwd_btn setEnabled: [o_help_web_view canGoForward]]; 
    [o_help_bwd_btn setEnabled: [o_help_web_view canGoBack]];
}

213
@end