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 ()
43 NSTimer *o_scroll_timer;
46 NSTimeInterval i_start;
53 @implementation AboutWindowController
57 self = [super initWithWindowNibName:@"About"];
60 [self setWindowFrameAutosaveName:@"about"];
68 [[NSNotificationCenter defaultCenter] removeObserver: self];
71 /*****************************************************************************
73 *****************************************************************************/
81 [o_credits_scrollview setHidden:YES];
82 [o_credits_textview setHidden:YES];
83 [o_joinus_txt setHidden:NO];
84 [o_copyright_field setHidden:NO];
85 [o_revision_field setHidden:NO];
86 [o_name_version_field setHidden:NO];
87 [o_credits_textview scrollPoint:NSMakePoint(0, 0)];
89 [self showWindow:nil];
94 [[self window] setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
96 /* Get the localized info dictionary (InfoPlist.strings) */
97 NSDictionary *o_local_dict;
98 o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];
100 /* Setup the copyright field */
101 [o_copyright_field setStringValue: [o_local_dict objectForKey:@"NSHumanReadableCopyright"]];
104 [[self window] setTitle: _NS("About VLC media player")];
105 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];
106 NSAttributedString *attrStr;
107 attrStr = [[NSAttributedString alloc] initWithString:_NS("Credits") attributes:stringAttributes];
108 [o_credits_btn setAttributedTitle:attrStr];
109 attrStr = [[NSAttributedString alloc] initWithString:_NS("License") attributes:stringAttributes];
110 [o_gpl_btn setAttributedTitle:attrStr];
111 attrStr = [[NSAttributedString alloc] initWithString:_NS("Authors") attributes:stringAttributes];
112 [o_authors_btn setAttributedTitle:attrStr];
114 [o_trademarks_txt setStringValue:_NS("VLC media player and VideoLAN are trademarks of the VideoLAN Association.")];
116 /* setup the creator / revision field */
119 compiler = [NSString stringWithFormat:@"clang %s", __clang_version__];
121 compiler = [NSString stringWithFormat:@"llvm-gcc %s", __VERSION__];
123 [o_revision_field setStringValue: [NSString stringWithFormat: _NS("Compiled by %s with %@"), VLC_CompileBy(), compiler]];
125 /* Setup the nameversion field */
126 [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VERSION_MESSAGE, PLATFORM]];
128 NSMutableArray *tmpArray = [NSMutableArray arrayWithArray: [toNSStr(psz_authors) componentsSeparatedByString:@"\n\n"]];
129 NSUInteger count = [tmpArray count];
130 for (NSUInteger i = 0; i < count; i++) {
131 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"\n" withString:@", "]];
132 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@", -" withString:@"\n-" options:0 range:NSRangeFromString(@"0 30")]];
133 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"-, " withString:@"-\n" options:0 range:NSRangeFromString(@"0 30")]];
134 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]];
136 o_authors = [tmpArray componentsJoinedByString:@"\n\n"];
139 NSString *joinus = toNSStr(_(""
140 "<p>VLC media player is a free and open source media player, encoder, and "
141 "streamer made by the volunteers of the <a href=\"http://www.videolan.org/"
142 "\"><span style=\" text-decoration: underline; color:#0057ae;\">VideoLAN</"
143 "span></a> community.</p><p>VLC uses its internal codecs, works on "
144 "essentially every popular platform, and can read almost all files, CDs, "
145 "DVDs, network streams, capture cards and other media formats!</p><p><a href="
146 "\"http://www.videolan.org/contribute/\"><span style=\" text-decoration: "
147 "underline; color:#0057ae;\">Help and join us!</span></a>"));
148 NSString *fontfamily;
150 fontfamily = @"Helvetica Neue";
152 fontfamily = @"Lucida Grande";
153 NSString *joinUsWithStyle = [NSString stringWithFormat:@"<div style=\"text-align:left;font-family:%@;\">%@</div>",
155 NSAttributedString *joinus_readytorender = [[NSAttributedString alloc] initWithHTML:[joinUsWithStyle dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES] options:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:NSUTF8StringEncoding] forKey:NSCharacterEncodingDocumentOption] documentAttributes:NULL];
156 [o_joinus_txt setAllowsEditingTextAttributes: YES];
157 [o_joinus_txt setSelectable: YES];
158 [o_joinus_txt setAttributedStringValue:joinus_readytorender];
160 [o_credits_textview setString: @""];
162 /* Setup the window */
163 [o_credits_textview setDrawsBackground: NO];
164 [o_credits_scrollview setDrawsBackground: NO];
165 [[self window] setExcludedFromWindowsMenu:YES];
166 [[self window] setMenu:nil];
167 [[self window] setBackgroundColor: [NSColor colorWithCalibratedWhite:.96 alpha:1.]];
169 if (config_GetInt(VLCIntf, "macosx-icon-change")) {
170 /* After day 354 of the year, the usual VLC cone is replaced by another cone
171 * wearing a Father Xmas hat.
172 * Note: this icon doesn't represent an endorsement of The Coca-Cola Company.
174 NSCalendar *gregorian =
175 [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
176 NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSDayCalendarUnit inUnit:NSYearCalendarUnit forDate:[NSDate date]];
178 if (dayOfYear >= 354)
179 [o_icon_view setImage: [NSImage imageNamed:@"vlc-xmas"]];
183 - (void)windowDidBecomeKey:(NSNotification *)notification
185 o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval: 1/6
187 selector:@selector(scrollCredits:)
192 - (void)windowDidResignKey:(NSNotification *)notification
194 [o_scroll_timer invalidate];
197 - (void)scrollCredits:(NSTimer *)timer
200 /* Reset the starttime */
201 i_start = [NSDate timeIntervalSinceReferenceDate] + 4.0;
203 f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
207 if ([NSDate timeIntervalSinceReferenceDate] >= i_start) {
208 /* Increment the scroll position */
211 /* Scroll to the position */
212 [o_credits_textview scrollPoint:NSMakePoint(0, f_current)];
214 /* If at end, restart at the top */
215 if (f_current >= f_end) {
216 /* f_end may be wrong on first run, so don't trust it too much */
217 if (f_end == [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height) {
220 [o_credits_textview scrollPoint:NSMakePoint(0, 0)];
222 f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
227 - (IBAction)buttonAction:(id)sender
229 [o_credits_scrollview setHidden:NO];
230 [o_credits_textview setHidden:NO];
231 [o_joinus_txt setHidden:YES];
232 [o_copyright_field setHidden:YES];
233 [o_revision_field setHidden:YES];
234 [o_name_version_field setHidden:YES];
236 if (sender == o_authors_btn)
237 [o_credits_textview setString:o_authors];
238 else if (sender == o_credits_btn)
239 [o_credits_textview setString:[toNSStr(psz_thanks) stringByReplacingOccurrencesOfString:@"\n" withString:@" " options:0 range:NSRangeFromString(@"680 2")]];
241 [o_credits_textview setString:toNSStr(psz_license)];
243 [o_credits_textview scrollPoint:NSMakePoint(0, 0)];
247 /*****************************************************************************
248 * VLC GPL Window, action called from the about window and the help menu
249 *****************************************************************************/
254 [self buttonAction:nil];
259 /*****************************************************************************
260 * VLC Help Window Controller
261 *****************************************************************************/
263 @implementation HelpWindowController
267 self = [super initWithWindowNibName:@"Help"];
270 [self setWindowFrameAutosaveName:@"help"];
276 - (void)windowDidLoad
278 [[self window] setTitle: _NS("VLC media player Help")];
279 [o_help_fwd_btn setToolTip: _NS("Next")];
280 [o_help_bwd_btn setToolTip: _NS("Previous")];
281 [o_help_home_btn setToolTip: _NS("Index")];
286 [self showWindow:nil];
287 [self helpGoHome:nil];
290 - (IBAction)helpGoHome:(id)sender
292 [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
293 baseURL: [NSURL URLWithString:@"http://videolan.org"]];
296 - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
298 /* delegate to update button states (we're the frameLoadDelegate for our help's webview)« */
299 [o_help_fwd_btn setEnabled: [o_help_web_view canGoForward]];
300 [o_help_bwd_btn setEnabled: [o_help_web_view canGoBack]];