1 /*****************************************************************************
2 * about.m: MacOS X About Panel
3 *****************************************************************************
4 * Copyright (C) 2001-2012 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"
35 #define PLATFORM "Intel 64bit"
37 #define PLATFORM "Intel 32bit"
39 #define PLATFORM "PowerPC 32bit"
42 /*****************************************************************************
43 * VLAboutBox implementation
44 *****************************************************************************/
45 @implementation VLAboutBox
47 static VLAboutBox *_o_sharedInstance = nil;
49 + (VLAboutBox *)sharedInstance
51 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
56 if (_o_sharedInstance)
59 _o_sharedInstance = [super init];
61 return _o_sharedInstance;
66 [[NSNotificationCenter defaultCenter] removeObserver: self];
67 [o_color_backdrop release];
73 if (!OSX_SNOW_LEOPARD)
74 [o_about_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
76 /* add a colored backdrop to get a white window background */
77 o_color_backdrop = [[VLAboutColoredBackdrop alloc] initWithFrame: [[o_about_window contentView] frame]];
78 [[o_about_window contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: nil];
81 /*****************************************************************************
83 *****************************************************************************/
88 /* Get the localized info dictionary (InfoPlist.strings) */
89 NSDictionary *o_local_dict;
90 o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];
92 /* Setup the copyright field */
93 [o_copyright_field setStringValue: [o_local_dict objectForKey:@"NSHumanReadableCopyright"]];
95 /* Set the box title */
96 [o_about_window setTitle: _NS("About VLC media player")];
98 /* setup the creator / revision field */
101 compiler = [NSString stringWithFormat:@"clang %s", __clang_version__];
103 compiler = [NSString stringWithFormat:@"llvm-gcc %s", __VERSION__];
105 compiler = [NSString stringWithFormat:@"gcc %s", __VERSION__];
107 [o_revision_field setStringValue: [NSString stringWithFormat: _NS("Compiled by %@ with %@"), [NSString stringWithUTF8String:VLC_CompileBy()], compiler]];
109 /* Setup the nameversion field */
110 [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VERSION_MESSAGE, PLATFORM]];
112 NSMutableArray *tmpArray = [NSMutableArray arrayWithArray: [[NSString stringWithUTF8String: psz_authors]componentsSeparatedByString:@"\n\n"]];
113 NSUInteger count = [tmpArray count];
114 for (NSUInteger i = 0; i < count; i++) {
115 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"\n" withString:@", "]];
116 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@", -" withString:@"\n-" options:0 range:NSRangeFromString(@"0 30")]];
117 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"-, " withString:@"-\n" options:0 range:NSRangeFromString(@"0 30")]];
118 [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]];
120 NSString *authors = [tmpArray componentsJoinedByString:@"\n\n"];
122 /* setup the authors and thanks field */
123 [o_credits_textview setString: [NSString stringWithFormat: @"%@\n\n\n\n\n\n%@\n\n%@\n\n",
124 [_NS(INTF_ABOUT_MSG) stringByReplacingOccurrencesOfString:@"\n" withString:@" "],
126 [[NSString stringWithUTF8String: psz_thanks] stringByReplacingOccurrencesOfString:@"\n" withString:@" " options:0 range:NSRangeFromString(@"680 2")]]];
128 /* Setup the window */
129 [o_credits_textview setDrawsBackground: NO];
130 [o_credits_scrollview setDrawsBackground: NO];
131 [o_about_window setExcludedFromWindowsMenu:YES];
132 [o_about_window setMenu:nil];
133 [o_about_window center];
134 [o_gpl_btn setTitle: _NS("License")];
139 /* Show the window */
141 [o_credits_textview scrollPoint:NSMakePoint(0, 0)];
142 [o_about_window makeKeyAndOrderFront: nil];
145 - (void)windowDidBecomeKey:(NSNotification *)notification
147 o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval: 1/6
149 selector:@selector(scrollCredits:)
154 - (void)windowDidResignKey:(NSNotification *)notification
156 [o_scroll_timer invalidate];
159 - (void)scrollCredits:(NSTimer *)timer
162 /* Reset the starttime */
163 i_start = [NSDate timeIntervalSinceReferenceDate] + 4.0;
165 f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
169 if ([NSDate timeIntervalSinceReferenceDate] >= i_start) {
170 /* Increment the scroll position */
173 /* Scroll to the position */
174 [o_credits_textview scrollPoint:NSMakePoint(0, f_current)];
176 /* If at end, restart at the top */
177 if (f_current >= f_end) {
178 /* f_end may be wrong on first run, so don't trust it too much */
179 if (f_end == [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height) {
181 [o_credits_textview scrollPoint:NSMakePoint(0, 0)];
183 f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
188 /*****************************************************************************
189 * VLC GPL Window, action called from the about window and the help menu
190 *****************************************************************************/
192 - (IBAction)showGPL:(id)sender
194 [o_gpl_window setTitle: _NS("License")];
195 [o_gpl_field setString: [NSString stringWithUTF8String: psz_license]];
197 [o_gpl_window center];
198 [o_gpl_window makeKeyAndOrderFront: sender];
201 /*****************************************************************************
202 * VLC Generic Help Window
203 *****************************************************************************/
207 [o_help_window setTitle: _NS("VLC media player Help")];
208 [o_help_fwd_btn setToolTip: _NS("Next")];
209 [o_help_bwd_btn setToolTip: _NS("Previous")];
210 [o_help_home_btn setToolTip: _NS("Index")];
212 [o_help_window makeKeyAndOrderFront: self];
214 [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
215 baseURL: [NSURL URLWithString:@"http://videolan.org"]];
218 - (IBAction)helpGoHome:(id)sender
220 [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
221 baseURL: [NSURL URLWithString:@"http://videolan.org"]];
224 - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
226 /* delegate to update button states (we're the frameLoadDelegate for our help's webview)« */
227 [o_help_fwd_btn setEnabled: [o_help_web_view canGoForward]];
228 [o_help_bwd_btn setEnabled: [o_help_web_view canGoBack]];
233 @implementation VLAboutColoredBackdrop
235 - (void)drawRect:(NSRect)rect {
236 [[NSColor whiteColor] setFill];