1 /*****************************************************************************
2 * about.m: MacOS X About Panel
3 *****************************************************************************
4 * Copyright (C) 2001-2009 the VideoLAN team
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>
34 #define PLATFORM "Intel 64bit"
36 #define PLATFORM "Intel 32bit"
38 #define PLATFORM "PowerPC 32bit"
41 /*****************************************************************************
42 * VLAboutBox implementation
43 *****************************************************************************/
44 @implementation VLAboutBox
46 static VLAboutBox *_o_sharedInstance = nil;
48 + (VLAboutBox *)sharedInstance
50 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
55 if (_o_sharedInstance) {
58 _o_sharedInstance = [super init];
61 return _o_sharedInstance;
64 /*****************************************************************************
66 *****************************************************************************/
72 /* we want to know when VLC wants to quit to prevent a crash while scrolling our credits */
73 [[NSNotificationCenter defaultCenter] addObserver: self
74 selector: @selector(VLCWillTerminate)
75 name: NSApplicationWillTerminateNotification
78 /* Get the localized info dictionary (InfoPlist.strings) */
79 NSDictionary *o_local_dict;
80 o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];
82 /* Setup the copyright field */
83 [o_copyright_field setStringValue: [o_local_dict objectForKey:@"NSHumanReadableCopyright"]];
85 /* Set the box title */
86 [o_about_window setTitle: _NS("About VLC media player")];
88 /* setup the creator / revision field */
89 [o_revision_field setStringValue:
90 [NSString stringWithFormat: _NS("Compiled by %s"), VLC_CompileBy()]];
92 /* Setup the nameversion field */
93 [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VLC_Version(), PLATFORM]];
95 /* setup the authors and thanks field */
96 [o_credits_textview setString: [NSString stringWithFormat: @"%@\n\n\n\n%@\n%@\n\n%@",
98 _NS("VLC was brought to you by:"),
99 [NSString stringWithUTF8String: psz_authors],
100 [NSString stringWithUTF8String: psz_thanks]]];
102 /* Setup the window */
103 [o_credits_textview setDrawsBackground: NO];
104 [o_credits_scrollview setDrawsBackground: NO];
105 [o_about_window setExcludedFromWindowsMenu:YES];
106 [o_about_window setMenu:nil];
107 [o_about_window center];
108 [o_gpl_btn setTitle: _NS("License")];
113 /* Show the window */
115 [o_credits_textview scrollPoint:NSMakePoint( 0, 0 )];
116 [o_about_window makeKeyAndOrderFront: nil];
119 - (void)windowDidBecomeKey:(NSNotification *)notification
121 o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval: 1/6
123 selector:@selector(scrollCredits:)
128 - (void)windowDidResignKey:(NSNotification *)notification
130 [o_scroll_timer invalidate];
133 - (void)scrollCredits:(NSTimer *)timer
137 /* Reset the starttime */
138 i_start = [NSDate timeIntervalSinceReferenceDate] + 5.0;
140 f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
144 if( [NSDate timeIntervalSinceReferenceDate] >= i_start )
146 /* Scroll to the position */
147 [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
149 /* Increment the scroll position */
152 /* If at end, restart at the top */
153 if( f_current >= f_end )
155 [o_credits_textview scrollPoint:NSMakePoint( 0, 0 )];
161 - (void)VLCWillTerminate
163 [o_scroll_timer invalidate];
164 [[NSNotificationCenter defaultCenter] removeObserver: self];
167 /*****************************************************************************
168 * VLC GPL Window, action called from the about window and the help menu
169 *****************************************************************************/
171 - (IBAction)showGPL:(id)sender
173 [o_gpl_window setTitle: _NS("License")];
174 [o_gpl_field setString: [NSString stringWithUTF8String: psz_license]];
176 [o_gpl_window center];
177 [o_gpl_window makeKeyAndOrderFront: sender];
180 /*****************************************************************************
181 * VLC Generic Help Window
182 *****************************************************************************/
186 [o_help_window setTitle: _NS("VLC media player Help")];
187 [o_help_fwd_btn setToolTip: _NS("Next")];
188 [o_help_bwd_btn setToolTip: _NS("Previous")];
189 [o_help_home_btn setToolTip: _NS("Index")];
191 [o_help_window makeKeyAndOrderFront: self];
193 [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
194 baseURL: [NSURL URLWithString:@"http://videolan.org"]];
197 - (IBAction)helpGoHome:(id)sender
199 [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
200 baseURL: [NSURL URLWithString:@"http://videolan.org"]];
203 - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
205 /* delegate to update button states (we're the frameLoadDelegate for our help's webview)« */
206 [o_help_fwd_btn setEnabled: [o_help_web_view canGoForward]];
207 [o_help_bwd_btn setEnabled: [o_help_web_view canGoBack]];