1 /*****************************************************************************
2 * about.m: MacOS X About Panel
3 *****************************************************************************
4 * Copyright (C) 2001-2007 the VideoLAN team
7 * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
29 #include <vlc_intf_strings.h>
30 #import <WebKit/WebKit.h>
32 /*****************************************************************************
33 * VLAboutBox implementation
34 *****************************************************************************/
35 @implementation VLAboutBox
37 static VLAboutBox *_o_sharedInstance = nil;
39 + (VLAboutBox *)sharedInstance
41 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
46 if (_o_sharedInstance) {
49 _o_sharedInstance = [super init];
52 return _o_sharedInstance;
55 /*****************************************************************************
57 *****************************************************************************/
65 NSString *o_thanks_path;
67 /* Get the info dictionary (Info.plist) */
68 o_info_dict = [[NSBundle mainBundle] infoDictionary];
70 /* Get the localized info dictionary (InfoPlist.strings) */
71 localInfoBundle = CFBundleGetMainBundle();
72 o_local_dict = (NSDictionary *)
73 CFBundleGetLocalInfoDictionary( localInfoBundle );
75 /* Setup the name field */
76 o_name = [o_local_dict objectForKey:@"CFBundleName"];
78 /* Set the about box title */
79 [o_about_window setTitle:_NS("About VLC media player")];
81 /* Setup the version field */
82 o_version = [o_info_dict objectForKey:@"CFBundleVersion"];
84 /* setup the creator / revision field */
85 if( VLC_Changeset() != "exported" )
86 [o_revision_field setStringValue: [NSString stringWithFormat: \
87 _NS("Compiled by %s, based on SVN revision %s"), VLC_CompileBy(), \
90 [o_revision_field setStringValue: [NSString stringWithFormat: \
91 _NS("Compiled by %s"), VLC_CompileBy()]];
93 /* Setup the nameversion field */
94 o_name_version = [NSString stringWithFormat:@"Version %@", o_version];
95 [o_name_version_field setStringValue: o_name_version];
97 /* Setup our credits */
98 o_credits_path = [[NSBundle mainBundle] pathForResource:@"AUTHORS" ofType:nil];
99 o_credits = [[NSString alloc] initWithData: [NSData dataWithContentsOfFile: o_credits_path ] encoding:NSUTF8StringEncoding];
101 /* Parse the authors string */
102 NSMutableString *o_outString = [NSMutableString stringWithFormat: @"%@\n\n", _NS(INTF_ABOUT_MSG)];
103 NSScanner *o_scan_credits = [NSScanner scannerWithString: o_credits];
104 NSCharacterSet *o_stopSet = [NSCharacterSet characterSetWithCharactersInString:@"\n\r"];
106 while( ![o_scan_credits isAtEnd] )
109 NSScanner *o_scan_person;
111 [o_scan_credits scanUpToString:@"N:" intoString: nil];
112 [o_scan_credits scanString:@"N:" intoString: nil];
113 [o_scan_credits scanUpToString:@"N:" intoString: &o_person];
114 o_scan_person = [NSScanner scannerWithString: o_person];
118 NSMutableString *o_jobs = [NSMutableString string];
121 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_name];
122 [o_scan_person scanString:@"E:" intoString: nil];
123 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_email];
124 [o_scan_person scanUpToString:@"D:" intoString: &o_next];
125 [o_scan_person scanUpToString:@":" intoString: &o_next];
126 [o_scan_person scanString:@":" intoString: nil];
128 while ( [o_next characterAtIndex:[o_next length] - 1] == 'D' )
131 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_job ];
132 [o_jobs appendFormat: @"%@, ", o_job];
133 [o_scan_person scanUpToString:@":" intoString: &o_next];
134 [o_scan_person scanString:@":" intoString: nil];
137 [o_outString appendFormat: @"%@ <%@>\n%@\n\n", o_name, o_email, o_jobs];
140 /* Parse the thanks string */
141 o_thanks_path = [[NSBundle mainBundle] pathForResource:@"THANKS" ofType:nil];
142 o_thanks = [[NSString alloc] initWithData: [NSData dataWithContentsOfFile:
143 o_thanks_path ] encoding:NSUTF8StringEncoding];
145 NSScanner *o_scan_thanks = [NSScanner scannerWithString: o_thanks];
146 [o_scan_thanks scanUpToCharactersFromSet: o_stopSet intoString: nil];
148 while( ![o_scan_thanks isAtEnd] )
153 [o_scan_thanks scanUpToString:@" - " intoString: &o_person];
154 [o_scan_thanks scanString:@" - " intoString: nil];
155 [o_scan_thanks scanUpToCharactersFromSet: o_stopSet intoString: &o_job];
156 [o_outString appendFormat: @"%@\n%@\n\n", o_person, o_job];
158 [o_credits_textview setString:o_outString];
160 /* Setup the copyright field */
161 o_copyright = [o_local_dict objectForKey:@"NSHumanReadableCopyright"];
162 [o_copyright_field setStringValue:o_copyright];
164 /* Setup the window */
165 [o_credits_textview setDrawsBackground: NO];
166 [o_credits_scrollview setDrawsBackground: NO];
167 [o_about_window setExcludedFromWindowsMenu:YES];
168 [o_about_window setMenu:nil];
169 [o_about_window center];
172 /* Show the window */
174 [o_about_window makeKeyAndOrderFront:nil];
177 - (void)windowDidBecomeKey:(NSNotification *)notification
179 o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval:1/6
181 selector:@selector(scrollCredits:)
186 - (void)windowDidResignKey:(NSNotification *)notification
188 [o_scroll_timer invalidate];
191 - (void)scrollCredits:(NSTimer *)timer
195 /* Reset the starttime */
196 i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
198 f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
202 if ([NSDate timeIntervalSinceReferenceDate] >= i_start)
204 /* Scroll to the position */
205 [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
207 /* Increment the scroll position */
210 /* If at end, restart at the top */
211 if ( f_current >= f_end )
218 /*****************************************************************************
219 * VLC Generic Help Window
220 *****************************************************************************/
224 [o_help_window setTitle: _NS("VLC media player Help")];
225 [o_help_window makeKeyAndOrderFront: self];
227 [[o_help_web_view mainFrame] loadHTMLString: [NSString stringWithString: _NS(I_LONGHELP)]
228 baseURL: [NSURL URLWithString:@"http://videolan.org"]];