1 /*****************************************************************************
2 * about.m: MacOS X About Panel
3 *****************************************************************************
4 * Copyright (C) 2001-2003 VideoLAN
5 * $Id: about.m,v 1.1 2003/04/09 20:53:28 hartman Exp $
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;
53 - (IBAction)showPanel:(id)sender
60 // Get the info dictionary (Info.plist)
61 o_info_dict = [[NSBundle mainBundle] infoDictionary];
63 // Get the localized info dictionary (InfoPlist.strings)
64 localInfoBundle = CFBundleGetMainBundle();
65 o_local_dict = (NSDictionary *)
66 CFBundleGetLocalInfoDictionary( localInfoBundle );
68 // Setup the app name field
69 o_name = [o_local_dict objectForKey:@"CFBundleName"];
71 // Set the about box window title
72 [o_about_window setTitle:_NS("About VLC media player")];
74 // Setup the version field
75 o_version = [o_info_dict objectForKey:@"CFBundleVersion"];
77 // Setup the appnameversion field
78 o_name_version = [NSString stringWithFormat:@"%@ - Version %@", o_name, o_version];
79 [o_name_version_field setStringValue: o_name_version];
82 o_credits_path = [[NSBundle mainBundle] pathForResource:@"AUTHORS" ofType:nil];
83 o_credits = [NSString stringWithContentsOfFile: o_credits_path ];
86 NSMutableString *o_outString = [NSMutableString string];
87 NSScanner *o_scan_credits = [NSScanner scannerWithString: o_credits];
88 NSCharacterSet *o_stopSet = [NSCharacterSet characterSetWithCharactersInString:@"\n\r"];
90 while( ![o_scan_credits isAtEnd] )
93 NSScanner *o_scan_person;
95 [o_scan_credits scanUpToString:@"N:" intoString: nil];
96 [o_scan_credits scanString:@"N:" intoString: nil];
97 [o_scan_credits scanUpToString:@"N:" intoString: &o_person];
98 o_scan_person = [NSScanner scannerWithString: o_person];
102 NSMutableString *o_jobs = [NSMutableString string];
105 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_name];
106 [o_scan_person scanString:@"E:" intoString: nil];
107 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_email];
108 [o_scan_person scanUpToString:@"D:" intoString: &o_next];
109 [o_scan_person scanUpToString:@":" intoString: &o_next];
110 [o_scan_person scanString:@":" intoString: nil];
112 while ( [o_next characterAtIndex:[o_next length] - 1] == 'D' )
115 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_job ];
116 [o_jobs appendFormat: @"%@, ", o_job];
117 [o_scan_person scanUpToString:@":" intoString: &o_next];
118 [o_scan_person scanString:@":" intoString: nil];
121 [o_outString appendFormat: @"%@ <%@>\n%@\n\n", o_name, o_email, o_jobs];
122 [o_credits_textview setString:o_outString];
125 // Setup the copyright field
126 o_copyright = [o_local_dict objectForKey:@"NSHumanReadableCopyright"];
127 [o_copyright_field setStringValue:o_copyright];
130 [o_credits_textview setDrawsBackground: NO];
131 [o_credits_scrollview setDrawsBackground: NO];
132 [o_about_window setExcludedFromWindowsMenu:YES];
133 [o_about_window setMenu:nil];
134 [o_about_window center];
139 [o_about_window makeKeyAndOrderFront:nil];
142 - (void)windowDidBecomeKey:(NSNotification *)notification
144 o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval:1/6
146 selector:@selector(scrollCredits:)
151 - (void)windowDidResignKey:(NSNotification *)notification
153 [o_scroll_timer invalidate];
156 - (void)scrollCredits:(NSTimer *)timer
160 // Reset the startTime
161 i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
166 if ([NSDate timeIntervalSinceReferenceDate] >= i_start)
168 // Scroll to the position
169 [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
171 // Increment the scroll position