about.m 10.7 KB
Newer Older
1
2
3
/*****************************************************************************
 * about.m: MacOS X About Panel
 *****************************************************************************
4
 * Copyright (C) 2001-2014 VLC authors and VideoLAN
5
 * $Id$
6
7
 *
 * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
8
 *          Felix Paul Kühne <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
#import "CompatibilityFixes.h"
33

34
35
/* this is a bit weird, but we should be confident that there will be more than
 * one arch to support again one day */
36
#define PLATFORM "Intel 64bit"
Felix Paul Kühne's avatar
Felix Paul Kühne committed
37

38
/*****************************************************************************
39
 * AboutWindowController implementation
40
 *****************************************************************************/
41
42
43
44
45
46
@interface AboutWindowController ()
{
    NSString *o_authors;
}
@end

47
@implementation AboutWindowController
48

49
- (id)init
50
{
51
52
53
54
55
    self = [super initWithWindowNibName:@"About"];
    if (self) {

        [self setWindowFrameAutosaveName:@"about"];
    }
56

57
    return self;
58
59
}

60
61
62
63
64
- (void) dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver: self];
}

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

- (void)showAbout
70
{
71
    [self window];
72

73
    /* Show the window */
74
75
76
77
78
79
    [o_credits_scrollview setHidden:YES];
    [o_credits_textview setHidden:YES];
    [o_joinus_txt setHidden:NO];
    [o_copyright_field setHidden:NO];
    [o_revision_field setHidden:NO];
    [o_name_version_field setHidden:NO];
80
    [o_credits_textview scrollPoint:NSMakePoint(0, 0)];
81
82
83
84
85
86

    [self showWindow:nil];
}

- (void)windowDidLoad
{
87
    [[self window] setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

    /* Get the localized info dictionary (InfoPlist.strings) */
    NSDictionary *o_local_dict;
    o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];

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

    /* l10n */
    [[self window] setTitle: _NS("About VLC media player")];
    NSDictionary *stringAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:NSUnderlineStyleSingle], NSUnderlineStyleAttributeName, [NSColor colorWithCalibratedRed:0. green:0.3411 blue:0.6824 alpha:1.], NSForegroundColorAttributeName, [NSFont systemFontOfSize:13], NSFontAttributeName, nil];
    NSAttributedString *attrStr;
    attrStr = [[NSAttributedString alloc] initWithString:_NS("Credits") attributes:stringAttributes];
    [o_credits_btn setAttributedTitle:attrStr];
    attrStr = [[NSAttributedString alloc] initWithString:_NS("License") attributes:stringAttributes];
    [o_gpl_btn setAttributedTitle:attrStr];
    attrStr = [[NSAttributedString alloc] initWithString:_NS("Authors") attributes:stringAttributes];
    [o_authors_btn setAttributedTitle:attrStr];
106
    attrStr = nil;
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    [o_trademarks_txt setStringValue:_NS("VLC media player and VideoLAN are trademarks of the VideoLAN Association.")];

    /* setup the creator / revision field */
    NSString *compiler;
#ifdef __clang__
    compiler = [NSString stringWithFormat:@"clang %s", __clang_version__];
#else
    compiler = [NSString stringWithFormat:@"llvm-gcc %s", __VERSION__];
#endif
    [o_revision_field setStringValue: [NSString stringWithFormat: _NS("Compiled by %s with %@"), VLC_CompileBy(), compiler]];

    /* Setup the nameversion field */
    [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VERSION_MESSAGE, PLATFORM]];

121
    NSMutableArray *tmpArray = [NSMutableArray arrayWithArray: [toNSStr(psz_authors) componentsSeparatedByString:@"\n\n"]];
122
123
124
125
126
127
128
129
130
131
    NSUInteger count = [tmpArray count];
    for (NSUInteger i = 0; i < count; i++) {
        [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"\n" withString:@", "]];
        [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@", -" withString:@"\n-" options:0 range:NSRangeFromString(@"0 30")]];
        [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"-, " withString:@"-\n" options:0 range:NSRangeFromString(@"0 30")]];
        [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]];
    }
    o_authors = [tmpArray componentsJoinedByString:@"\n\n"];

    /* setup join us! */
132
133
134
135
136
137
138
139
140
    NSString *joinus = toNSStr(_(""
                                 "<p>VLC media player is a free and open source media player, encoder, and "
                                 "streamer made by the volunteers of the <a href=\"http://www.videolan.org/"
                                 "\"><span style=\" text-decoration: underline; color:#0057ae;\">VideoLAN</"
                                 "span></a> community.</p><p>VLC uses its internal codecs, works on "
                                 "essentially every popular platform, and can read almost all files, CDs, "
                                 "DVDs, network streams, capture cards and other media formats!</p><p><a href="
                                 "\"http://www.videolan.org/contribute/\"><span style=\" text-decoration: "
                                 "underline; color:#0057ae;\">Help and join us!</span></a>"));
141
    NSString *fontfamily;
142
    if (OSX_YOSEMITE || OSX_EL_CAPITAN || OSX_SIERRA)
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
        fontfamily = @"Helvetica Neue";
    else
        fontfamily = @"Lucida Grande";
    NSString *joinUsWithStyle = [NSString stringWithFormat:@"<div style=\"text-align:left;font-family:%@;\">%@</div>",
                                 fontfamily, joinus];
    NSAttributedString *joinus_readytorender = [[NSAttributedString alloc] initWithHTML:[joinUsWithStyle dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES] options:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:NSUTF8StringEncoding] forKey:NSCharacterEncodingDocumentOption] documentAttributes:NULL];
    [o_joinus_txt setAllowsEditingTextAttributes: YES];
    [o_joinus_txt setSelectable: YES];
    [o_joinus_txt setAttributedStringValue:joinus_readytorender];

    [o_credits_textview setString: @""];

    /* Setup the window */
    [o_credits_textview setDrawsBackground: NO];
    [o_credits_scrollview setDrawsBackground: NO];
    [[self window] setExcludedFromWindowsMenu:YES];
    [[self window] setMenu:nil];
    [[self window] setBackgroundColor: [NSColor colorWithCalibratedWhite:.96 alpha:1.]];

David's avatar
David committed
162
    if (config_GetInt(getIntf(), "macosx-icon-change")) {
163
164
165
166
167
168
169
170
171
172
173
        /* After day 354 of the year, the usual VLC cone is replaced by another cone
         * wearing a Father Xmas hat.
         * Note: this icon doesn't represent an endorsement of The Coca-Cola Company.
         */
        NSCalendar *gregorian =
        [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
        NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSDayCalendarUnit inUnit:NSYearCalendarUnit forDate:[NSDate date]];

        if (dayOfYear >= 354)
            [o_icon_view setImage: [NSImage imageNamed:@"vlc-xmas"]];
    }
174
175
176
177
}

- (void)windowDidBecomeKey:(NSNotification *)notification
{
178
    [(VLCScrollingClipView *)[o_credits_scrollview contentView] startScrolling];
179
180
181
182
}

- (void)windowDidResignKey:(NSNotification *)notification
{
183
    [(VLCScrollingClipView *)[o_credits_scrollview contentView] stopScrolling];
184
185
}

186
187
188
189
190
191
192
193
194
195
196
197
- (IBAction)buttonAction:(id)sender
{
    [o_credits_scrollview setHidden:NO];
    [o_credits_textview setHidden:NO];
    [o_joinus_txt setHidden:YES];
    [o_copyright_field setHidden:YES];
    [o_revision_field setHidden:YES];
    [o_name_version_field setHidden:YES];

    if (sender == o_authors_btn)
        [o_credits_textview setString:o_authors];
    else if (sender == o_credits_btn)
198
        [o_credits_textview setString:[toNSStr(psz_thanks) stringByReplacingOccurrencesOfString:@"\n" withString:@" " options:0 range:NSRangeFromString(@"680 2")]];
199
    else
200
        [o_credits_textview setString:toNSStr(psz_license)];
201

202
203
    [(VLCScrollingClipView *)[o_credits_scrollview contentView] resetScrolling];
    [(VLCScrollingClipView *)[o_credits_scrollview contentView] startScrolling];
204
205
}

206
207
208
209
/*****************************************************************************
* VLC GPL Window, action called from the about window and the help menu
*****************************************************************************/

210
- (void)showGPL
211
{
212
    [self showAbout];
213
    [self buttonAction:nil];
214
215
}

216
217
@end

218
/*****************************************************************************
219
220
 * VLC Help Window Controller
 *****************************************************************************/
221

222
223
224
@implementation HelpWindowController

- (id)init
225
{
226
227
228
229
230
231
232
233
234
235
236
237
    self = [super initWithWindowNibName:@"Help"];
    if (self) {

        [self setWindowFrameAutosaveName:@"help"];
    }

    return self;
}

- (void)windowDidLoad
{
    [[self window] setTitle: _NS("VLC media player Help")];
238
239
240
    [o_help_fwd_btn setToolTip: _NS("Next")];
    [o_help_bwd_btn setToolTip: _NS("Previous")];
    [o_help_home_btn setToolTip: _NS("Index")];
241
}
242

243
244
245
246
- (void)showHelp
{
    [self showWindow:nil];
    [self helpGoHome:nil];
247
}
248

249
250
- (IBAction)helpGoHome:(id)sender
{
251
    [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
252
253
254
                                        baseURL: [NSURL URLWithString:@"http://videolan.org"]];
}

255
256
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
257
    /* delegate to update button states (we're the frameLoadDelegate for our help's webview)« */
258
    [o_help_fwd_btn setEnabled: [o_help_web_view canGoForward]];
259
260
261
    [o_help_bwd_btn setEnabled: [o_help_web_view canGoBack]];
}

262
@end