Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

about.m

00001 /*****************************************************************************
00002  * about.m: MacOS X About Panel
00003  *****************************************************************************
00004  * Copyright (C) 2001-2005 the VideoLAN team
00005  * $Id: about.m 12794 2005-10-09 12:33:44Z fkuehne $
00006  *
00007  * Authors: Derk-Jan Hartman <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include "intf.h"
00028 #include "about.h"
00029 
00030 /*****************************************************************************
00031  * VLAboutBox implementation 
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         /* Get the info dictionary (Info.plist) */
00062         o_info_dict = [[NSBundle mainBundle] infoDictionary];
00063         
00064         /* Get the localized info dictionary (InfoPlist.strings) */
00065         localInfoBundle = CFBundleGetMainBundle();
00066         o_local_dict = (NSDictionary *)
00067                         CFBundleGetLocalInfoDictionary( localInfoBundle );
00068         
00069         /* Setup the name field */
00070         o_name = [o_local_dict objectForKey:@"CFBundleName"];
00071         
00072         /* Set the about box title */
00073         [o_about_window setTitle:_NS("About VLC media player")];
00074         
00075         /* Setup the version field */
00076         o_version = [o_info_dict objectForKey:@"CFBundleVersion"];
00077         
00078         /* setup the creator / revision field */
00079         [o_revision_field setStringValue: [NSString stringWithFormat: \
00080             _NS("Compiled by %s, based on SVN revision %s"), VLC_CompileBy(), \
00081             VLC_Changeset()]];
00082     
00083         /* Setup the nameversion field */
00084         o_name_version = [NSString stringWithFormat:@"Version %@", o_version];
00085         [o_name_version_field setStringValue: o_name_version];
00086         
00087         /* Setup our credits */
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         /* Parse the authors string */
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         /* Parse the thanks string */
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         /* Setup the copyright field */
00151         o_copyright = [o_local_dict objectForKey:@"NSHumanReadableCopyright"];
00152         [o_copyright_field setStringValue:o_copyright];
00153 
00154         /* Setup the window */
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     /* Show the window */
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         /* Reset the starttime */
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         /* Scroll to the position */
00195         [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
00196         
00197         /* Increment the scroll position */
00198         f_current += 0.005;
00199         
00200         /* If at end, restart at the top */
00201         if ( f_current >= f_end )
00202         {
00203             b_restart = YES;
00204         }
00205     }
00206 }
00207 
00208 @end

Generated on Tue Dec 20 10:14:38 2005 for vlc-0.8.4a by  doxygen 1.4.2