1 /*****************************************************************************
2 * about.m: MacOS X About Panel
3 *****************************************************************************
4 * Copyright (C) 2001-2014 VLC authors and VideoLAN
7 * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
8 * Felix Paul Kühne <fkuehne -at- videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
30 #import <vlc_intf_strings.h>
32 #import "CompatibilityFixes.h"
34 /* this is a bit weird, but we should be confident that there will be more than
35 * one arch to support again one day */
36 #define PLATFORM "Intel 64bit"
38 /*****************************************************************************
39 * AboutWindowController implementation
40 *****************************************************************************/
41 @interface AboutWindowController ()
47 @implementation AboutWindowController
51 self = [super initWithWindowNibName:@"About"];
54 [self setWindowFrameAutosaveName:@"about"];
62 [[NSNotificationCenter defaultCenter] removeObserver: self];
65 /*****************************************************************************
67 *****************************************************************************/
74 [o_credits_scrollview setHidden:YES];
75 [o_credits_textview setHidden:YES];
76 [o_joinus_txt setHidden:NO];
77 [o_copyright_field setHidden:NO];
78 [o_revision_field setHidden:NO];
79 [o_name_version_field setHidden:NO];
80 [o_credits_textview scrollPoint:NSMakePoint(0, 0)];
82 [self showWindow:nil];
87 [[self window] setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
89 /* Get the localized info dictionary (InfoPlist.strings) */
90 NSDictionary *o_local_dict;
91 o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];
93 /* Setup the copyright field */
94 [o_copyright_field setStringValue: [o_local_dict objectForKey:@"NSHumanReadableCopyright"]];
97 [[self window] setTitle: _NS("About VLC media player")];
98 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];
99 NSAttributedString *attrStr;
100 attrStr = [[NSAttributedString alloc] initWithString:_NS("Credits") attributes:stringAttributes];
101 [o_credits_btn setAttributedTitle:attrStr];
102 attrStr = [[NSAttributedString alloc] initWithString:_NS("License") attributes:stringAttributes];
103 [o_gpl_btn setAttributedTitle:attrStr];
104 attrStr = [[NSAttributedString alloc] initWithString:_NS("Authors") attributes:stringAttributes];
105 [o_authors_btn setAttributedTitle:attrStr];
107 [o_trademarks_txt setStringValue:_NS("VLC media player and VideoLAN are trademarks of the VideoLAN Association.")];
109 /* setup the creator / revision field */
112 compiler = [NSString stringWithFormat:@"clang %s", __clang_version__];
114 compiler = [NSString stringWithFormat:@"llvm-gcc %s", __VERSION__];
116 [o_revision_field setStringValue: [NSString stringWithFormat: _NS("Compiled by %s with %@"), VLC_CompileBy(), compiler]];
118 /* Setup the nameversion field */
119 [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 NSUInteger count = [tmpArray count];
123 for (NSUInteger i = 0; i < count; i++) {
124 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"\n" withString:@", "]];
125 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@", -" withString:@"\n-" options:0 range:NSRangeFromString(@"0 30")]];
126 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"-, " withString:@"-\n" options:0 range:NSRangeFromString(@"0 30")]];
127 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]];
129 o_authors = [tmpArray componentsJoinedByString:@"\n\n"];
132 NSString *joinus = toNSStr(_(""
133 "<p>VLC media player is a free and open source media player, encoder, and "
134 "streamer made by the volunteers of the <a href=\"http://www.videolan.org/"
135 "\"><span style=\" text-decoration: underline; color:#0057ae;\">VideoLAN</"
136 "span></a> community.</p><p>VLC uses its internal codecs, works on "
137 "essentially every popular platform, and can read almost all files, CDs, "
138 "DVDs, network streams, capture cards and other media formats!</p><p><a href="
139 "\"http://www.videolan.org/contribute/\"><span style=\" text-decoration: "
140 "underline; color:#0057ae;\">Help and join us!</span></a>"));
141 NSString *fontfamily;
143 fontfamily = @"Helvetica Neue";
145 fontfamily = @"Lucida Grande";
146 NSString *joinUsWithStyle = [NSString stringWithFormat:@"<div style=\"text-align:left;font-family:%@;\">%@</div>",
148 NSAttributedString *joinus_readytorender = [[NSAttributedString alloc] initWithHTML:[joinUsWithStyle dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES] options:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:NSUTF8StringEncoding] forKey:NSCharacterEncodingDocumentOption] documentAttributes:NULL];
149 [o_joinus_txt setAllowsEditingTextAttributes: YES];
150 [o_joinus_txt setSelectable: YES];
151 [o_joinus_txt setAttributedStringValue:joinus_readytorender];
153 [o_credits_textview setString: @""];
155 /* Setup the window */
156 [o_credits_textview setDrawsBackground: NO];
157 [o_credits_scrollview setDrawsBackground: NO];
158 [[self window] setExcludedFromWindowsMenu:YES];
159 [[self window] setMenu:nil];
160 [[self window] setBackgroundColor: [NSColor colorWithCalibratedWhite:.96 alpha:1.]];
162 if (config_GetInt(VLCIntf, "macosx-icon-change")) {
163 /* After day 354 of the year, the usual VLC cone is replaced by another cone
164 * wearing a Father Xmas hat.
165 * Note: this icon doesn't represent an endorsement of The Coca-Cola Company.
167 NSCalendar *gregorian =
168 [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
169 NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSDayCalendarUnit inUnit:NSYearCalendarUnit forDate:[NSDate date]];
171 if (dayOfYear >= 354)
172 [o_icon_view setImage: [NSImage imageNamed:@"vlc-xmas"]];
176 - (void)windowDidBecomeKey:(NSNotification *)notification
178 [(VLCScrollingClipView *)[o_credits_scrollview contentView] startScrolling];
181 - (void)windowDidResignKey:(NSNotification *)notification
183 [(VLCScrollingClipView *)[o_credits_scrollview contentView] stopScrolling];
186 - (IBAction)buttonAction:(id)sender
188 [o_credits_scrollview setHidden:NO];
189 [o_credits_textview setHidden:NO];
190 [o_joinus_txt setHidden:YES];
191 [o_copyright_field setHidden:YES];
192 [o_revision_field setHidden:YES];
193 [o_name_version_field setHidden:YES];
195 if (sender == o_authors_btn)
196 [o_credits_textview setString:o_authors];
197 else if (sender == o_credits_btn)
198 [o_credits_textview setString:[toNSStr(psz_thanks) stringByReplacingOccurrencesOfString:@"\n" withString:@" " options:0 range:NSRangeFromString(@"680 2")]];
200 [o_credits_textview setString:toNSStr(psz_license)];
202 [(VLCScrollingClipView *)[o_credits_scrollview contentView] resetScrolling];
203 [(VLCScrollingClipView *)[o_credits_scrollview contentView] startScrolling];
206 /*****************************************************************************
207 * VLC GPL Window, action called from the about window and the help menu
208 *****************************************************************************/
213 [self buttonAction:nil];
218 /*****************************************************************************
219 * VLC Help Window Controller
220 *****************************************************************************/
222 @implementation HelpWindowController
226 self = [super initWithWindowNibName:@"Help"];
229 [self setWindowFrameAutosaveName:@"help"];
235 - (void)windowDidLoad
237 [[self window] setTitle: _NS("VLC media player Help")];
238 [o_help_fwd_btn setToolTip: _NS("Next")];
239 [o_help_bwd_btn setToolTip: _NS("Previous")];
240 [o_help_home_btn setToolTip: _NS("Index")];
245 [self showWindow:nil];
246 [self helpGoHome:nil];
249 - (IBAction)helpGoHome:(id)sender
251 [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
252 baseURL: [NSURL URLWithString:@"http://videolan.org"]];
255 - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
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 [o_help_bwd_btn setEnabled: [o_help_web_view canGoBack]];