-
Notifications
You must be signed in to change notification settings - Fork 2
/
AboutBox.m
executable file
·163 lines (145 loc) · 5.85 KB
/
AboutBox.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
UnRarX, Mac OS X GUI for rar and par file extraction.
Copyright © 2003 Peter Noriega
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
RAR and unRAR are copyright Eugene Roshal.
THE UNRAR UTILITY ARE DISTRIBUTED "AS IS". NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. YOU USE AT YOUR OWN RISK. THE AUTHORS WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
Thanks for using UnRarX for Mac OS X.
________________________________________
*/
#import "AboutBox.h"
@implementation AboutBox
static AboutBox *sharedInstance = nil;
+ (AboutBox *)sharedInstance
{
return sharedInstance ? sharedInstance : [[self alloc] init];
}
- (id)init
{
if (sharedInstance) {
[self dealloc];
} else {
sharedInstance = [super init];
}
return sharedInstance;
}
- (IBAction)showPanel:(id)sender
{
if (!appNameField)
{
NSWindow *theWindow;
NSString *creditsPath;
NSAttributedString *creditsString;
NSString *appName;
NSString *versionString;
NSString *copyrightString;
NSDictionary *infoDictionary;
CFBundleRef localInfoBundle;
NSDictionary *localInfoDict;
if (![NSBundle loadNibNamed:@"AboutBox" owner:self])
{
// int NSRunCriticalAlertPanel(NSString *title,
//NSString *msg, NSString *defaultButton,
//NSString *alternateButton, NSString *otherButton, ...);
//NSLog( @"Failed to load AboutBox.nib" );
NSBeep();
return;
}
theWindow = [appNameField window];
// Get the info dictionary (Info.plist)
infoDictionary = [[NSBundle mainBundle] infoDictionary];
// Get the localized info dictionary (InfoPlist.strings)
localInfoBundle = CFBundleGetMainBundle();
localInfoDict = (NSDictionary *)
CFBundleGetLocalInfoDictionary( localInfoBundle );
// Setup the app name field
appName = [localInfoDict objectForKey:@"CFBundleName"];
[appNameField setStringValue:appName];
// Set the about box window title
[theWindow setTitle:[NSString stringWithFormat:@"About %@", appName]];
// Setup the version field
versionString = [infoDictionary objectForKey:@"CFBundleVersion"];
[versionField setStringValue:[NSString stringWithFormat:@"Version %@",
versionString]];
// Setup our credits
creditsPath = [[NSBundle mainBundle] pathForResource:@"Credits"
ofType:@"rtf"];
creditsString = [[NSAttributedString alloc] initWithPath:creditsPath
documentAttributes:nil];
[creditsField replaceCharactersInRange:NSMakeRange( 0, 0 )
withRTF:[creditsString RTFFromRange:
NSMakeRange( 0, [creditsString length] )
documentAttributes:nil]];
// Setup the copyright field
copyrightString = [localInfoDict objectForKey:@"NSHumanReadableCopyright"];
[copyrightField setStringValue:copyrightString];
// Prepare some scroll info
maxScrollHeight = [[creditsField string] length];
// Setup the window
[theWindow setExcludedFromWindowsMenu:YES];
[theWindow setMenu:nil];
[theWindow center];
}
if (![[appNameField window] isVisible])
{
currentPosition = 0;
restartAtTop = NO;
startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0;
[creditsField scrollPoint:NSMakePoint( 0, 0 )];
}
// Show the window
[[appNameField window] makeKeyAndOrderFront:nil];
}
/*- (void)windowDidBecomeKey:(NSNotification *)notification
{
scrollTimer = [NSTimer scheduledTimerWithTimeInterval:3/4
target:self
selector:@selector(scrollCredits:)
userInfo:nil
repeats:YES];
}*/
- (void)windowDidResignKey:(NSNotification *)notification
{
[scrollTimer invalidate];
}
- (void)scrollCredits:(NSTimer *)timer
{
if ([NSDate timeIntervalSinceReferenceDate] >= startTime)
{
if (restartAtTop)
{
// Reset the startTime
startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0;
restartAtTop = NO;
// Set the position
[creditsField scrollPoint:NSMakePoint( 0, 0 )];
return;
}
if (currentPosition >= maxScrollHeight)
{
// Reset the startTime
startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0;
// Reset the position
currentPosition = 0;
restartAtTop = YES;
}
else
{
// Scroll to the position
[creditsField scrollPoint:NSMakePoint( 0, currentPosition )];
// Increment the scroll position
currentPosition += 0.01;
}
}
}
@end