]> git.sesse.net Git - vlc/blob - modules/gui/macosx/about.m
* display the GPL in a separate window linked in the About window and the Help menu...
[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  *          Felix Paul K\9fhne <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 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include "intf.h"
29 #include "about.h"
30 #include <vlc_intf_strings.h>
31 #include <vlc_about.h>
32 #import <WebKit/WebKit.h>
33
34 #ifdef __x86_64__
35 #define PLATFORM "Intel"
36 #elif __i386__
37 #define PLATFORM "Intel"
38 #else
39 #define PLATFORM "PowerPC"
40 #endif
41
42 /*****************************************************************************
43  * VLAboutBox implementation
44  *****************************************************************************/
45 @implementation VLAboutBox
46
47 static VLAboutBox *_o_sharedInstance = nil;
48
49 + (VLAboutBox *)sharedInstance
50 {
51     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
52 }
53
54 - (id)init
55 {
56     if (_o_sharedInstance) {
57         [self dealloc];
58     } else {
59         _o_sharedInstance = [super init];
60     }
61  
62     return _o_sharedInstance;
63 }
64
65 /*****************************************************************************
66 * VLC About Window
67 *****************************************************************************/
68
69 - (void)showAbout
70 {
71     if(! b_isSetUp )
72     {
73         NSDictionary *o_local_dict;
74
75         /* Get the localized info dictionary (InfoPlist.strings) */
76         o_local_dict = [[NSBundle mainBundle] localizedInfoDictionary];
77
78         /* Setup the name field */
79         o_name_field = [o_local_dict objectForKey:@"CFBundleName"];
80  
81         /* Set the about box title */
82         [o_about_window setTitle:_NS("About VLC media player")];
83
84         /* setup the creator / revision field */
85         if( VLC_Changeset() != "exported" )
86         [o_revision_field setStringValue: [NSString stringWithFormat: \
87             _NS("Compiled by %s, based on SVN revision %s"), VLC_CompileBy(), \
88             VLC_Changeset()]];
89         else
90         [o_revision_field setStringValue: [NSString stringWithFormat: \
91             _NS("Compiled by %s"), VLC_CompileBy()]];
92  
93         /* Setup the nameversion field */
94         [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VLC_Version(), PLATFORM]];
95
96         /* setup the authors and thanks field */
97         [o_credits_textview setString: [NSString stringWithFormat: @"%@\n\n\n\n%@\n%@\n\n%@", 
98                                             _NS(INTF_ABOUT_MSG), 
99                                             _NS("VLC was brought to you by:"),
100                                             [NSString stringWithUTF8String: psz_authors], 
101                                             [NSString stringWithUTF8String: psz_thanks]]];
102  
103         /* Setup the copyright field */
104         [o_copyright_field setStringValue: [o_local_dict objectForKey:@"NSHumanReadableCopyright"]];
105
106         /* Setup the window */
107         [o_credits_textview setDrawsBackground: NO];
108         [o_credits_scrollview setDrawsBackground: NO];
109         [o_about_window setExcludedFromWindowsMenu:YES];
110         [o_about_window setMenu:nil];
111         [o_about_window center];
112         [o_gpl_btn setTitle: _NS("License")];
113         
114         b_isSetUp = YES;
115     }
116  
117     /* Show the window */
118     b_restart = YES;
119     [o_about_window makeKeyAndOrderFront: nil];
120 }
121
122 - (void)windowDidBecomeKey:(NSNotification *)notification
123 {
124     o_scroll_timer = [NSTimer scheduledTimerWithTimeInterval: 1/6
125                                                       target:self
126                                                     selector:@selector(scrollCredits:)
127                                                     userInfo:nil
128                                                      repeats:YES];
129 }
130
131 - (void)windowDidResignKey:(NSNotification *)notification
132 {
133     [o_scroll_timer invalidate];
134 }
135
136 - (void)scrollCredits:(NSTimer *)timer
137 {
138     if( b_restart )
139     {
140         /* Reset the starttime */
141         i_start = [NSDate timeIntervalSinceReferenceDate] + 3.0;
142         f_current = 0;
143         f_end = [o_credits_textview bounds].size.height - [o_credits_scrollview bounds].size.height;
144         b_restart = NO;
145     }
146
147     if( [NSDate timeIntervalSinceReferenceDate] >= i_start )
148     {
149         /* Scroll to the position */
150         [o_credits_textview scrollPoint:NSMakePoint( 0, f_current )];
151  
152         /* Increment the scroll position */
153         f_current += 0.005;
154  
155         /* If at end, restart at the top */
156         if( f_current >= f_end )
157         {
158             b_restart = YES;
159         }
160     }
161 }
162
163 /*****************************************************************************
164 * VLC GPL Window, action called from the about window and the help menu
165 *****************************************************************************/
166
167 - (IBAction)showGPL:(id)sender
168 {
169     [o_gpl_window setTitle: _NS("License")];
170     [o_gpl_field setString: [NSString stringWithUTF8String: psz_license]];
171     
172     [o_gpl_window center];
173     [o_gpl_window makeKeyAndOrderFront: sender];
174 }
175
176 /*****************************************************************************
177 * VLC Generic Help Window
178 *****************************************************************************/
179
180 - (void)showHelp
181 {
182     [o_help_window setTitle: _NS("VLC media player Help")];
183     [o_help_window makeKeyAndOrderFront: self];
184
185     [[o_help_web_view mainFrame] loadHTMLString: [NSString stringWithString: _NS(I_LONGHELP)]
186                                         baseURL: [NSURL URLWithString:@"http://videolan.org"]];
187 }
188
189 @end