about.m
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:7k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * about.m: MacOS X About Panel
  3.  *****************************************************************************
  4.  * Copyright (C) 2001-2007 the VideoLAN team
  5.  * $Id: dc0ef540d7745ef432cf48cc9c48c0384e37c34a $
  6.  *
  7.  * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
  8.  *          Felix Paul Kühne <fkuehne -at- videolan.org>
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23.  *****************************************************************************/
  24. /*****************************************************************************
  25.  * Preamble
  26.  *****************************************************************************/
  27. #import "intf.h"
  28. #import "about.h"
  29. #import <vlc_intf_strings.h>
  30. #import <vlc_about.h>
  31. #ifdef __x86_64__
  32. #define PLATFORM "Intel 64bit"
  33. #elif __i386__
  34. #define PLATFORM "Intel 32bit"
  35. #else
  36. #define PLATFORM "PowerPC 32bit"
  37. #endif
  38. /*****************************************************************************
  39.  * VLAboutBox implementation
  40.  *****************************************************************************/
  41. @implementation VLAboutBox
  42. static VLAboutBox *_o_sharedInstance = nil;
  43. + (VLAboutBox *)sharedInstance
  44. {
  45.     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
  46. }
  47. - (id)init
  48. {
  49.     if (_o_sharedInstance) {
  50.         [self dealloc];
  51.     } else {
  52.         _o_sharedInstance = [super init];
  53.     }
  54.  
  55.     return _o_sharedInstance;
  56. }
  57. /*****************************************************************************
  58. * VLC About Window
  59. *****************************************************************************/
  60. - (void)showAbout
  61. {
  62.     if(! b_isSetUp )
  63.     {
  64.         /* we want to know when VLC wants to quit to prevent a crash while scrolling our credits */
  65.         [[NSNotificationCenter defaultCenter] addObserver: self
  66.                                                  selector: @selector(VLCWillTerminate)
  67.                                                      name: NSApplicationWillTerminateNotification
  68.                                                    object: nil];
  69.         
  70.         /* Get the localized info dictionary (InfoPlist.strings) */
  71.         NSDictionary *o_local_dict;
  72.         o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];
  73.         /* Setup the copyright field */
  74.         [o_copyright_field setStringValue: [o_local_dict objectForKey:@"NSHumanReadableCopyright"]];
  75.         /* Set the box title */
  76.         [o_about_window setTitle: _NS("About VLC media player")];
  77.         /* setup the creator / revision field */
  78.         [o_revision_field setStringValue: 
  79.             [NSString stringWithFormat: _NS("Compiled by %s"), VLC_CompileBy()]];
  80.  
  81.         /* Setup the nameversion field */
  82.         [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VLC_Version(), PLATFORM]];
  83.         /* setup the authors and thanks field */
  84.         [o_credits_textview setString: [NSString stringWithFormat: @"%@nnnn%@n%@nn%@", 
  85.                                             _NS(INTF_ABOUT_MSG), 
  86.                                             _NS("VLC was brought to you by:"),
  87.                                             [NSString stringWithUTF8String: psz_authors], 
  88.                                             [NSString stringWithUTF8String: psz_thanks]]];
  89.         /* Setup the window */
  90.         [o_credits_textview setDrawsBackground: NO];
  91.         [o_credits_scrollview setDrawsBackground: NO];
  92.         [o_about_window setExcludedFromWindowsMenu:YES];
  93.         [o_about_window setMenu:nil];
  94.         [o_about_window center];
  95.         [o_gpl_btn setTitle: _NS("License")];
  96.         
  97.         b_isSetUp = YES;
  98.     }
  99.  
  100.     /* Show the window */
  101.     b_restart = YES;
  102.     [o_about_window makeKeyAndOrderFront: nil];
  103. }
  104. - (void)windowDidBecomeKey:(NSNotification *)notification
  105. {
  106.     o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval: 1/6
  107.                                                       target:self
  108.                                                     selector:@selector(scrollCredits:)
  109.                                                     userInfo:nil
  110.                                                      repeats:YES];
  111. }
  112. - (void)windowDidResignKey:(NSNotification *)notification
  113. {
  114.     [o_scroll_timer invalidate];
  115. }
  116. - (void)scrollCredits:(NSTimer *)timer
  117. {
  118.     if( b_restart )
  119.     {
  120.         /* Reset the starttime */
  121.         i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
  122.         f_current = 0;
  123.         f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
  124.         b_restart = NO;
  125.     }
  126.     if( [NSDate timeIntervalSinceReferenceDate] >= i_start )
  127.     {
  128.         /* Scroll to the position */
  129.         [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
  130.  
  131.         /* Increment the scroll position */
  132.         f_current += 0.005;
  133.  
  134.         /* If at end, restart at the top */
  135.         if( f_current >= f_end )
  136.         {
  137.             b_restart = YES;
  138.         }
  139.     }
  140. }
  141. - (void)VLCWillTerminate
  142. {
  143.     [o_scroll_timer invalidate];
  144.     [[NSNotificationCenter defaultCenter] removeObserver: self];
  145. }
  146. /*****************************************************************************
  147. * VLC GPL Window, action called from the about window and the help menu
  148. *****************************************************************************/
  149. - (IBAction)showGPL:(id)sender
  150. {
  151.     [o_gpl_window setTitle: _NS("License")];
  152.     [o_gpl_field setString: [NSString stringWithUTF8String: psz_license]];
  153.     
  154.     [o_gpl_window center];
  155.     [o_gpl_window makeKeyAndOrderFront: sender];
  156. }
  157. /*****************************************************************************
  158. * VLC Generic Help Window
  159. *****************************************************************************/
  160. - (void)showHelp
  161. {
  162.     [o_help_window setTitle: _NS("VLC media player Help")];
  163.     [o_help_fwd_btn setToolTip: _NS("Next")];
  164.     [o_help_bwd_btn setToolTip: _NS("Previous")];
  165.     [o_help_home_btn setToolTip: _NS("Index")];
  166.     [o_help_window makeKeyAndOrderFront: self];
  167.     
  168.     [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
  169.                                         baseURL: [NSURL URLWithString:@"http://videolan.org"]];
  170. }
  171. - (IBAction)helpGoHome:(id)sender
  172. {
  173.     [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
  174.                                         baseURL: [NSURL URLWithString:@"http://videolan.org"]];
  175. }
  176. - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
  177. {
  178.     /* delegate to update button states (we're the frameLoadDelegate for our help's webview)« */
  179.     [o_help_fwd_btn setEnabled: [o_help_web_view canGoForward]]; 
  180.     [o_help_bwd_btn setEnabled: [o_help_web_view canGoBack]];
  181. }
  182. @end