]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/about.m
macosx: let the about window show whether VLC runs in 32 or 64 bit mode
[vlc] / modules / gui / macosx / about.m
index 15f268024ff6d1b0e046d7a67ba56a8963a4fbd9..dc0ef540d7745ef432cf48cc9c48c0384e37c34a 100644 (file)
@@ -5,6 +5,7 @@
  * $Id$
  *
  * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
+ *          Felix Paul Kühne <fkuehne -at- videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "intf.h"
-#include "about.h"
-#include <vlc_intf_strings.h>
-#include <vlc_about.h>
-#import <WebKit/WebKit.h>
+#import "intf.h"
+#import "about.h"
+#import <vlc_intf_strings.h>
+#import <vlc_about.h>
+
+#ifdef __x86_64__
+#define PLATFORM "Intel 64bit"
+#elif __i386__
+#define PLATFORM "Intel 32bit"
+#else
+#define PLATFORM "PowerPC 32bit"
+#endif
 
 /*****************************************************************************
  * VLAboutBox implementation
@@ -59,43 +67,30 @@ static VLAboutBox *_o_sharedInstance = nil;
 
 - (void)showAbout
 {
-    if (!o_credits_path)
+    if(! b_isSetUp )
     {
-        NSString *o_name;
-        NSString *o_version;
-        NSString *o_platform;
+        /* we want to know when VLC wants to quit to prevent a crash while scrolling our credits */
+        [[NSNotificationCenter defaultCenter] addObserver: self
+                                                 selector: @selector(VLCWillTerminate)
+                                                     name: NSApplicationWillTerminateNotification
+                                                   object: nil];
         
-        /* Get the info dictionary (Info.plist) */
-        o_info_dict = [[NSBundle mainBundle] infoDictionary];
         /* Get the localized info dictionary (InfoPlist.strings) */
-        localInfoBundle = CFBundleGetMainBundle();
-        o_local_dict = (NSDictionary *)
-                        CFBundleGetLocalInfoDictionary( localInfoBundle );
-        /* Setup the name field */
-        o_name = [o_local_dict objectForKey:@"CFBundleName"];
-        /* Set the about box title */
-        [o_about_window setTitle:_NS("About VLC media player")];
+        NSDictionary *o_local_dict;
+        o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];
 
-        #ifdef __powerpc__ || __ppc__ || __ppc64__
-                o_platform = @"PowerPC";
-        #else
-                o_platform = @"Intel";
-        #endif        
+        /* Setup the copyright field */
+        [o_copyright_field setStringValue: [o_local_dict objectForKey:@"NSHumanReadableCopyright"]];
+
+        /* Set the box title */
+        [o_about_window setTitle: _NS("About VLC media player")];
 
         /* setup the creator / revision field */
-        if( VLC_Changeset() != "exported" )
-        [o_revision_field setStringValue: [NSString stringWithFormat: \
-            _NS("Compiled by %s, based on SVN revision %s"), VLC_CompileBy(), \
-            VLC_Changeset()]];
-        else
-        [o_revision_field setStringValue: [NSString stringWithFormat: \
-            _NS("Compiled by %s"), VLC_CompileBy()]];
+        [o_revision_field setStringValue: 
+            [NSString stringWithFormat: _NS("Compiled by %s"), VLC_CompileBy()]];
  
         /* Setup the nameversion field */
-        [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%@)", VLC_Version(), o_platform]];
+        [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VLC_Version(), PLATFORM]];
 
         /* setup the authors and thanks field */
         [o_credits_textview setString: [NSString stringWithFormat: @"%@\n\n\n\n%@\n%@\n\n%@", 
@@ -103,10 +98,6 @@ static VLAboutBox *_o_sharedInstance = nil;
                                             _NS("VLC was brought to you by:"),
                                             [NSString stringWithUTF8String: psz_authors], 
                                             [NSString stringWithUTF8String: psz_thanks]]];
-        /* Setup the copyright field */
-        o_copyright = [o_local_dict objectForKey:@"NSHumanReadableCopyright"];
-        [o_copyright_field setStringValue:o_copyright];
 
         /* Setup the window */
         [o_credits_textview setDrawsBackground: NO];
@@ -114,20 +105,23 @@ static VLAboutBox *_o_sharedInstance = nil;
         [o_about_window setExcludedFromWindowsMenu:YES];
         [o_about_window setMenu:nil];
         [o_about_window center];
+        [o_gpl_btn setTitle: _NS("License")];
+        
+        b_isSetUp = YES;
     }
  
     /* Show the window */
     b_restart = YES;
-    [o_about_window makeKeyAndOrderFront:nil];
+    [o_about_window makeKeyAndOrderFront: nil];
 }
 
 - (void)windowDidBecomeKey:(NSNotification *)notification
 {
-    o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval:1/6
-                           target:self
-                           selector:@selector(scrollCredits:)
-                           userInfo:nil
-                           repeats:YES];
+    o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval: 1/6
+                                                      target:self
+                                                    selector:@selector(scrollCredits:)
+                                                    userInfo:nil
+                                                     repeats:YES];
 }
 
 - (void)windowDidResignKey:(NSNotification *)notification
@@ -137,7 +131,7 @@ static VLAboutBox *_o_sharedInstance = nil;
 
 - (void)scrollCredits:(NSTimer *)timer
 {
-    if (b_restart)
+    if( b_restart )
     {
         /* Reset the starttime */
         i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
@@ -146,7 +140,7 @@ static VLAboutBox *_o_sharedInstance = nil;
         b_restart = NO;
     }
 
-    if ([NSDate timeIntervalSinceReferenceDate] >= i_start)
+    if( [NSDate timeIntervalSinceReferenceDate] >= i_start )
     {
         /* Scroll to the position */
         [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
@@ -155,13 +149,32 @@ static VLAboutBox *_o_sharedInstance = nil;
         f_current += 0.005;
  
         /* If at end, restart at the top */
-        if ( f_current >= f_end )
+        if( f_current >= f_end )
         {
             b_restart = YES;
         }
     }
 }
 
+- (void)VLCWillTerminate
+{
+    [o_scroll_timer invalidate];
+    [[NSNotificationCenter defaultCenter] removeObserver: self];
+}
+
+/*****************************************************************************
+* VLC GPL Window, action called from the about window and the help menu
+*****************************************************************************/
+
+- (IBAction)showGPL:(id)sender
+{
+    [o_gpl_window setTitle: _NS("License")];
+    [o_gpl_field setString: [NSString stringWithUTF8String: psz_license]];
+    
+    [o_gpl_window center];
+    [o_gpl_window makeKeyAndOrderFront: sender];
+}
+
 /*****************************************************************************
 * VLC Generic Help Window
 *****************************************************************************/
@@ -169,10 +182,27 @@ static VLAboutBox *_o_sharedInstance = nil;
 - (void)showHelp
 {
     [o_help_window setTitle: _NS("VLC media player Help")];
+    [o_help_fwd_btn setToolTip: _NS("Next")];
+    [o_help_bwd_btn setToolTip: _NS("Previous")];
+    [o_help_home_btn setToolTip: _NS("Index")];
+
     [o_help_window makeKeyAndOrderFront: self];
+    
+    [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
+                                        baseURL: [NSURL URLWithString:@"http://videolan.org"]];
+}
 
-    [[o_help_web_view mainFrame] loadHTMLString: [NSString stringWithString: _NS(I_LONGHELP)]
+- (IBAction)helpGoHome:(id)sender
+{
+    [[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
                                         baseURL: [NSURL URLWithString:@"http://videolan.org"]];
 }
 
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    /* delegate to update button states (we're the frameLoadDelegate for our help's webview)« */
+    [o_help_fwd_btn setEnabled: [o_help_web_view canGoForward]]; 
+    [o_help_bwd_btn setEnabled: [o_help_web_view canGoBack]];
+}
+
 @end