00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "intf.h"
00028 #include "about.h"
00029
00030
00031
00032
00033 @implementation VLAboutBox
00034
00035 static VLAboutBox *_o_sharedInstance = nil;
00036
00037 + (VLAboutBox *)sharedInstance
00038 {
00039 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
00040 }
00041
00042 - (id)init
00043 {
00044 if (_o_sharedInstance) {
00045 [self dealloc];
00046 } else {
00047 _o_sharedInstance = [super init];
00048 }
00049
00050 return _o_sharedInstance;
00051 }
00052
00053 - (void)showPanel
00054 {
00055 if (!o_credits_path)
00056 {
00057 NSString *o_name;
00058 NSString *o_version;
00059 NSString *o_thanks_path;
00060
00061
00062 o_info_dict = [[NSBundle mainBundle] infoDictionary];
00063
00064
00065 localInfoBundle = CFBundleGetMainBundle();
00066 o_local_dict = (NSDictionary *)
00067 CFBundleGetLocalInfoDictionary( localInfoBundle );
00068
00069
00070 o_name = [o_local_dict objectForKey:@"CFBundleName"];
00071
00072
00073 [o_about_window setTitle:_NS("About VLC media player")];
00074
00075
00076 o_version = [o_info_dict objectForKey:@"CFBundleVersion"];
00077
00078
00079 [o_revision_field setStringValue: [NSString stringWithFormat: \
00080 _NS("Compiled by %s, based on SVN revision %s"), VLC_CompileBy(), \
00081 VLC_Changeset()]];
00082
00083
00084 o_name_version = [NSString stringWithFormat:@"Version %@", o_version];
00085 [o_name_version_field setStringValue: o_name_version];
00086
00087
00088 o_credits_path = [[NSBundle mainBundle] pathForResource:@"AUTHORS" ofType:nil];
00089 o_credits = [[NSString alloc] initWithData: [NSData dataWithContentsOfFile: o_credits_path ] encoding:NSUTF8StringEncoding];
00090
00091
00092 NSMutableString *o_outString = [NSMutableString stringWithFormat: @"%@\n\n", _NS(INTF_ABOUT_MSG)];
00093 NSScanner *o_scan_credits = [NSScanner scannerWithString: o_credits];
00094 NSCharacterSet *o_stopSet = [NSCharacterSet characterSetWithCharactersInString:@"\n\r"];
00095
00096 while( ![o_scan_credits isAtEnd] )
00097 {
00098 NSString *o_person;
00099 NSScanner *o_scan_person;
00100
00101 [o_scan_credits scanUpToString:@"N:" intoString: nil];
00102 [o_scan_credits scanString:@"N:" intoString: nil];
00103 [o_scan_credits scanUpToString:@"N:" intoString: &o_person];
00104 o_scan_person = [NSScanner scannerWithString: o_person];
00105
00106 NSString *o_name;
00107 NSString *o_email;
00108 NSMutableString *o_jobs = [NSMutableString string];
00109 NSString *o_next;
00110
00111 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_name];
00112 [o_scan_person scanString:@"E:" intoString: nil];
00113 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_email];
00114 [o_scan_person scanUpToString:@"D:" intoString: &o_next];
00115 [o_scan_person scanUpToString:@":" intoString: &o_next];
00116 [o_scan_person scanString:@":" intoString: nil];
00117
00118 while ( [o_next characterAtIndex:[o_next length] - 1] == 'D' )
00119 {
00120 NSString *o_job;
00121 [o_scan_person scanUpToCharactersFromSet: o_stopSet intoString: &o_job ];
00122 [o_jobs appendFormat: @"%@, ", o_job];
00123 [o_scan_person scanUpToString:@":" intoString: &o_next];
00124 [o_scan_person scanString:@":" intoString: nil];
00125 }
00126
00127 [o_outString appendFormat: @"%@ <%@>\n%@\n\n", o_name, o_email, o_jobs];
00128 }
00129
00130
00131 o_thanks_path = [[NSBundle mainBundle] pathForResource:@"THANKS" ofType:nil];
00132 o_thanks = [[NSString alloc] initWithData: [NSData dataWithContentsOfFile:
00133 o_thanks_path ] encoding:NSUTF8StringEncoding];
00134
00135 NSScanner *o_scan_thanks = [NSScanner scannerWithString: o_thanks];
00136 [o_scan_thanks scanUpToCharactersFromSet: o_stopSet intoString: nil];
00137
00138 while( ![o_scan_thanks isAtEnd] )
00139 {
00140 NSString *o_person;
00141 NSString *o_job;
00142
00143 [o_scan_thanks scanUpToString:@" - " intoString: &o_person];
00144 [o_scan_thanks scanString:@" - " intoString: nil];
00145 [o_scan_thanks scanUpToCharactersFromSet: o_stopSet intoString: &o_job];
00146 [o_outString appendFormat: @"%@\n%@\n\n", o_person, o_job];
00147 }
00148 [o_credits_textview setString:o_outString];
00149
00150
00151 o_copyright = [o_local_dict objectForKey:@"NSHumanReadableCopyright"];
00152 [o_copyright_field setStringValue:o_copyright];
00153
00154
00155 [o_credits_textview setDrawsBackground: NO];
00156 [o_credits_scrollview setDrawsBackground: NO];
00157 [o_about_window setExcludedFromWindowsMenu:YES];
00158 [o_about_window setMenu:nil];
00159 [o_about_window center];
00160 }
00161
00162
00163 b_restart = YES;
00164 [o_about_window makeKeyAndOrderFront:nil];
00165 }
00166
00167 - (void)windowDidBecomeKey:(NSNotification *)notification
00168 {
00169 o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval:1/6
00170 target:self
00171 selector:@selector(scrollCredits:)
00172 userInfo:nil
00173 repeats:YES];
00174 }
00175
00176 - (void)windowDidResignKey:(NSNotification *)notification
00177 {
00178 [o_scroll_timer invalidate];
00179 }
00180
00181 - (void)scrollCredits:(NSTimer *)timer
00182 {
00183 if (b_restart)
00184 {
00185
00186 i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
00187 f_current = 0;
00188 f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
00189 b_restart = NO;
00190 }
00191
00192 if ([NSDate timeIntervalSinceReferenceDate] >= i_start)
00193 {
00194
00195 [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
00196
00197
00198 f_current += 0.005;
00199
00200
00201 if ( f_current >= f_end )
00202 {
00203 b_restart = YES;
00204 }
00205 }
00206 }
00207
00208 @end