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 *****************************************************************************/
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 /* Get the info dictionary (Info.plist) */
62 o_info_dict = [[NSBundle mainBundle] infoDictionary];
64 /* Get the localized info dictionary (InfoPlist.strings) */
65 localInfoBundle = CFBundleGetMainBundle();
66 o_local_dict = (NSDictionary *)
67 CFBundleGetLocalInfoDictionary( localInfoBundle );
69 /* Setup the name field */
70 o_name = [o_local_dict objectForKey:@"CFBundleName"];
72 /* Set the about box title */
73 [o_about_window setTitle:_NS("About VLC media player")];
75 /* Setup the version field */
76 o_version = [o_info_dict objectForKey:@"CFBundleVersion"];
78 /* setup the creator / revision field */
79 if( VLC_Changeset() != "exported" )
80 [o_revision_field setStringValue: [NSString stringWithFormat: \
81 _NS("Compiled by %s, based on SVN revision %s"), VLC_CompileBy(), \
84 [o_revision_field setStringValue: [NSString stringWithFormat: \
85 _NS("Compiled by %s"), VLC_CompileBy()]];
87 /* Setup the nameversion field */
88 o_name_version = [NSString stringWithFormat:@"Version %@", o_version];
89 [o_name_version_field setStringValue: o_name_version];
91 /* Setup our credits */
92 o_credits_path = [[NSBundle mainBundle] pathForResource:@"AUTHORS" ofType:nil];
93 o_credits = [[NSString alloc] initWithData: [NSData dataWithContentsOfFile: o_credits_path ] encoding:NSUTF8StringEncoding];
95 /* Parse the authors string */
96 NSMutableString *o_outString = [NSMutableString stringWithFormat: @"%@\n\n", _NS(INTF_ABOUT_MSG)];
97 NSScanner *o_scan_credits = [NSScanner scannerWithString: o_credits];
98 NSCharacterSet *o_stopSet = [NSCharacterSet characterSetWithCharactersInString:@"\n\r"];
100 while( ![o_scan_credits isAtEnd] )
103 NSScanner *o_scan_person;
105 [o_scan_credits scanUpToString:@"N:" intoString: nil];
106 [o_scan_credits scanString:@"N:" intoString: nil];
107 [o_scan_credits scanUpToString:@"N:" intoString: &o_person];
108 o_scan_person = [NSScanner scannerWithString: o_person];
112 NSMutableString *o_jobs = [NSMutableString string];
115 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_name];
116 [o_scan_person scanString:@"E:" intoString: nil];
117 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_email];
118 [o_scan_person scanUpToString:@"D:" intoString: &o_next];
119 [o_scan_person scanUpToString:@":" intoString: &o_next];
120 [o_scan_person scanString:@":" intoString: nil];
122 while ( [o_next characterAtIndex:[o_next length] - 1] == 'D' )
125 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_job ];
126 [o_jobs appendFormat: @"%@, ", o_job];
127 [o_scan_person scanUpToString:@":" intoString: &o_next];
128 [o_scan_person scanString:@":" intoString: nil];
131 [o_outString appendFormat: @"%@ <%@>\n%@\n\n", o_name, o_email, o_jobs];
134 /* Parse the thanks string */
135 o_thanks_path = [[NSBundle mainBundle] pathForResource:@"THANKS" ofType:nil];
136 o_thanks = [[NSString alloc] initWithData: [NSData dataWithContentsOfFile:
137 o_thanks_path ] encoding:NSUTF8StringEncoding];
139 NSScanner *o_scan_thanks = [NSScanner scannerWithString: o_thanks];
140 [o_scan_thanks scanUpToCharactersFromSet: o_stopSet intoString: nil];
142 while( ![o_scan_thanks isAtEnd] )
147 [o_scan_thanks scanUpToString:@" - " intoString: &o_person];
148 [o_scan_thanks scanString:@" - " intoString: nil];
149 [o_scan_thanks scanUpToCharactersFromSet: o_stopSet intoString: &o_job];
150 [o_outString appendFormat: @"%@\n%@\n\n", o_person, o_job];
152 [o_credits_textview setString:o_outString];
154 /* Setup the copyright field */
155 o_copyright = [o_local_dict objectForKey:@"NSHumanReadableCopyright"];
156 [o_copyright_field setStringValue:o_copyright];
158 /* Setup the window */
159 [o_credits_textview setDrawsBackground: NO];
160 [o_credits_scrollview setDrawsBackground: NO];
161 [o_about_window setExcludedFromWindowsMenu:YES];
162 [o_about_window setMenu:nil];
163 [o_about_window center];
166 /* Show the window */
168 [o_about_window makeKeyAndOrderFront:nil];
171 - (void)windowDidBecomeKey:(NSNotification *)notification
173 o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval:1/6
175 selector:@selector(scrollCredits:)
180 - (void)windowDidResignKey:(NSNotification *)notification
182 [o_scroll_timer invalidate];
185 - (void)scrollCredits:(NSTimer *)timer
189 /* Reset the starttime */
190 i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
192 f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
196 if ([NSDate timeIntervalSinceReferenceDate] >= i_start)
198 /* Scroll to the position */
199 [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
201 /* Increment the scroll position */
204 /* If at end, restart at the top */
205 if ( f_current >= f_end )