]> git.sesse.net Git - vlc/blob - modules/gui/macosx/about.m
* use the hard-coded authors and thanks lists instead of bundled files and incorporat...
[vlc] / modules / gui / macosx / about.m
1 /*****************************************************************************
2  * about.m: MacOS X About Panel
3  *****************************************************************************
4  * Copyright (C) 2001-2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
8  *
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.
13  *
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.
18  *
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include "intf.h"
28 #include "about.h"
29 #include <vlc_intf_strings.h>
30 #include <vlc_about.h>
31 #import <WebKit/WebKit.h>
32
33 /*****************************************************************************
34  * VLAboutBox implementation
35  *****************************************************************************/
36 @implementation VLAboutBox
37
38 static VLAboutBox *_o_sharedInstance = nil;
39
40 + (VLAboutBox *)sharedInstance
41 {
42     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
43 }
44
45 - (id)init
46 {
47     if (_o_sharedInstance) {
48         [self dealloc];
49     } else {
50         _o_sharedInstance = [super init];
51     }
52  
53     return _o_sharedInstance;
54 }
55
56 /*****************************************************************************
57 * VLC About Window
58 *****************************************************************************/
59
60 - (void)showAbout
61 {
62     if (!o_credits_path)
63     {
64         NSString *o_name;
65         NSString *o_version;
66         NSString *o_platform;
67         
68         /* Get the info dictionary (Info.plist) */
69         o_info_dict = [[NSBundle mainBundle] infoDictionary];
70  
71         /* Get the localized info dictionary (InfoPlist.strings) */
72         localInfoBundle = CFBundleGetMainBundle();
73         o_local_dict = (NSDictionary *)
74                         CFBundleGetLocalInfoDictionary( localInfoBundle );
75  
76         /* Setup the name field */
77         o_name = [o_local_dict objectForKey:@"CFBundleName"];
78  
79         /* Set the about box title */
80         [o_about_window setTitle:_NS("About VLC media player")];
81
82         #ifdef __powerpc__ || __ppc__ || __ppc64__
83                 o_platform = @"PowerPC";
84         #else
85                 o_platform = @"Intel";
86         #endif        
87
88         /* setup the creator / revision field */
89         if( VLC_Changeset() != "exported" )
90         [o_revision_field setStringValue: [NSString stringWithFormat: \
91             _NS("Compiled by %s, based on SVN revision %s"), VLC_CompileBy(), \
92             VLC_Changeset()]];
93         else
94         [o_revision_field setStringValue: [NSString stringWithFormat: \
95             _NS("Compiled by %s"), VLC_CompileBy()]];
96  
97         /* Setup the nameversion field */
98         [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%@)", VLC_Version(), o_platform]];
99
100         /* setup the authors and thanks field */
101         [o_credits_textview setString: [NSString stringWithFormat: @"%@\n\n\n\n%@\n%@\n\n%@", 
102                                             _NS(INTF_ABOUT_MSG), 
103                                             _NS("VLC was brought to you by:"),
104                                             [NSString stringWithUTF8String: psz_authors], 
105                                             [NSString stringWithUTF8String: psz_thanks]]];
106  
107         /* Setup the copyright field */
108         o_copyright = [o_local_dict objectForKey:@"NSHumanReadableCopyright"];
109         [o_copyright_field setStringValue:o_copyright];
110
111         /* Setup the window */
112         [o_credits_textview setDrawsBackground: NO];
113         [o_credits_scrollview setDrawsBackground: NO];
114         [o_about_window setExcludedFromWindowsMenu:YES];
115         [o_about_window setMenu:nil];
116         [o_about_window center];
117     }
118  
119     /* Show the window */
120     b_restart = YES;
121     [o_about_window makeKeyAndOrderFront:nil];
122 }
123
124 - (void)windowDidBecomeKey:(NSNotification *)notification
125 {
126     o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval:1/6
127                            target:self
128                            selector:@selector(scrollCredits:)
129                            userInfo:nil
130                            repeats:YES];
131 }
132
133 - (void)windowDidResignKey:(NSNotification *)notification
134 {
135     [o_scroll_timer invalidate];
136 }
137
138 - (void)scrollCredits:(NSTimer *)timer
139 {
140     if (b_restart)
141     {
142         /* Reset the starttime */
143         i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
144         f_current = 0;
145         f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
146         b_restart = NO;
147     }
148
149     if ([NSDate timeIntervalSinceReferenceDate] >= i_start)
150     {
151         /* Scroll to the position */
152         [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
153  
154         /* Increment the scroll position */
155         f_current += 0.005;
156  
157         /* If at end, restart at the top */
158         if ( f_current >= f_end )
159         {
160             b_restart = YES;
161         }
162     }
163 }
164
165 /*****************************************************************************
166 * VLC Generic Help Window
167 *****************************************************************************/
168
169 - (void)showHelp
170 {
171     [o_help_window setTitle: _NS("VLC media player Help")];
172     [o_help_window makeKeyAndOrderFront: self];
173
174     [[o_help_web_view mainFrame] loadHTMLString: [NSString stringWithString: _NS(I_LONGHELP)]
175                                         baseURL: [NSURL URLWithString:@"http://videolan.org"]];
176 }
177
178 @end