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