1 /*****************************************************************************
2 * about.m: MacOS X About Panel
3 *****************************************************************************
4 * Copyright (C) 2001-2005 VideoLAN (Centrale Réseaux) and its contributors
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
30 /*****************************************************************************
31 * VLAboutBox implementation
32 *****************************************************************************/
33 @implementation VLAboutBox
35 static VLAboutBox *_o_sharedInstance = nil;
37 + (VLAboutBox *)sharedInstance
39 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
44 if (_o_sharedInstance) {
47 _o_sharedInstance = [super init];
50 return _o_sharedInstance;
59 NSString *o_thanks_path;
61 /* Load the needed nib-file */
62 [NSBundle loadNibNamed:@"About" owner:self];
64 /* Get the info dictionary (Info.plist) */
65 o_info_dict = [[NSBundle mainBundle] infoDictionary];
67 /* Get the localized info dictionary (InfoPlist.strings) */
68 localInfoBundle = CFBundleGetMainBundle();
69 o_local_dict = (NSDictionary *)
70 CFBundleGetLocalInfoDictionary( localInfoBundle );
72 /* Setup the name field */
73 o_name = [o_local_dict objectForKey:@"CFBundleName"];
75 /* Set the about box title */
76 [o_about_window setTitle:_NS("About VLC media player")];
78 /* Setup the version field */
79 o_version = [o_info_dict objectForKey:@"CFBundleVersion"];
81 /* Setup the nameversion field */
82 o_name_version = [NSString stringWithFormat:@"%@ - Version %@", o_name, o_version];
83 [o_name_version_field setStringValue: o_name_version];
85 /* Setup our credits */
86 o_credits_path = [[NSBundle mainBundle] pathForResource:@"AUTHORS" ofType:nil];
87 o_credits = [[NSString alloc] initWithData: [NSData dataWithContentsOfFile: o_credits_path ] encoding:NSWindowsCP1252StringEncoding];
89 /* Parse the authors string */
90 NSMutableString *o_outString = [NSMutableString stringWithFormat: @"%@\n\n", _NS(INTF_ABOUT_MSG)];
91 NSScanner *o_scan_credits = [NSScanner scannerWithString: o_credits];
92 NSCharacterSet *o_stopSet = [NSCharacterSet characterSetWithCharactersInString:@"\n\r"];
94 while( ![o_scan_credits isAtEnd] )
97 NSScanner *o_scan_person;
99 [o_scan_credits scanUpToString:@"N:" intoString: nil];
100 [o_scan_credits scanString:@"N:" intoString: nil];
101 [o_scan_credits scanUpToString:@"N:" intoString: &o_person];
102 o_scan_person = [NSScanner scannerWithString: o_person];
106 NSMutableString *o_jobs = [NSMutableString string];
109 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_name];
110 [o_scan_person scanString:@"E:" intoString: nil];
111 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_email];
112 [o_scan_person scanUpToString:@"D:" intoString: &o_next];
113 [o_scan_person scanUpToString:@":" intoString: &o_next];
114 [o_scan_person scanString:@":" intoString: nil];
116 while ( [o_next characterAtIndex:[o_next length] - 1] == 'D' )
119 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_job ];
120 [o_jobs appendFormat: @"%@, ", o_job];
121 [o_scan_person scanUpToString:@":" intoString: &o_next];
122 [o_scan_person scanString:@":" intoString: nil];
125 [o_outString appendFormat: @"%@ <%@>\n%@\n\n", o_name, o_email, o_jobs];
128 /* Parse the thanks string */
129 o_thanks_path = [[NSBundle mainBundle] pathForResource:@"THANKS" ofType:nil];
130 o_thanks = [[NSString alloc] initWithData: [NSData dataWithContentsOfFile:
131 o_thanks_path ] encoding:NSWindowsCP1252StringEncoding];
133 NSScanner *o_scan_thanks = [NSScanner scannerWithString: o_thanks];
134 [o_scan_thanks scanUpToCharactersFromSet: o_stopSet intoString: nil];
136 while( ![o_scan_thanks isAtEnd] )
141 [o_scan_thanks scanUpToString:@" - " intoString: &o_person];
142 [o_scan_thanks scanString:@" - " intoString: nil];
143 [o_scan_thanks scanUpToCharactersFromSet: o_stopSet intoString: &o_job];
144 [o_outString appendFormat: @"%@\n%@\n\n", o_person, o_job];
146 [o_credits_textview setString:o_outString];
148 /* Setup the copyright field */
149 o_copyright = [o_local_dict objectForKey:@"NSHumanReadableCopyright"];
150 [o_copyright_field setStringValue:o_copyright];
152 /* Setup the window */
153 [o_credits_textview setDrawsBackground: NO];
154 [o_credits_scrollview setDrawsBackground: NO];
155 [o_about_window setExcludedFromWindowsMenu:YES];
156 [o_about_window setMenu:nil];
157 [o_about_window center];
160 /* Show the window */
162 [o_about_window makeKeyAndOrderFront:nil];
165 - (void)windowDidBecomeKey:(NSNotification *)notification
167 o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval:1/6
169 selector:@selector(scrollCredits:)
174 - (void)windowDidResignKey:(NSNotification *)notification
176 [o_scroll_timer invalidate];
179 - (void)scrollCredits:(NSTimer *)timer
183 /* Reset the starttime */
184 i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
186 f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
190 if ([NSDate timeIntervalSinceReferenceDate] >= i_start)
192 /* Scroll to the position */
193 [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
195 /* Increment the scroll position */
198 /* If at end, restart at the top */
199 if ( f_current >= f_end )