/
FRAMainController.m
99 lines (67 loc) · 3.21 KB
/
FRAMainController.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
/*
Fraise version 3.7 - Based on Smultron by Peter Borg
Written by Jean-François Moy - jeanfrancois.moy@gmail.com
Find the latest version at http://github.com/jfmoy/Fraise
Copyright 2010 Jean-François Moy
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
#import <SystemConfiguration/SCNetworkReachability.h>
#import "FRAStandardHeader.h"
#import "FRAMainController.h"
#import "FRAPreferencesController.h"
#import "FRATextMenuController.h"
#import "FRABasicPerformer.h"
#import "FRAVariousPerformer.h"
#import "FRAFontTransformer.h"
@implementation FRAMainController
@synthesize isInFullScreenMode, singleDocumentWindowWasOpenBeforeEnteringFullScreen, operationQueue;
static id sharedInstance = nil;
+ (FRAMainController *)sharedInstance
{
if (sharedInstance == nil) {
sharedInstance = [[self alloc] init];
}
return sharedInstance;
}
- (id)init
{
if (sharedInstance == nil) {
sharedInstance = [super init];
operationQueue = [[NSOperationQueue alloc] init];
}
return sharedInstance;
}
+ (void)initialize
{
SInt32 systemVersion;
if (Gestalt(gestaltSystemVersion, &systemVersion) == noErr) {
if (systemVersion < 0x1050) {
[NSApp activateIgnoringOtherApps:YES];
[FRAVarious alertWithMessage:[NSString stringWithFormat:NSLocalizedStringFromTable(@"You need %@ or later to run this version of Fraise", @"Localizable3", @"You need %@ or later to run this version of Fraise"), @"Mac OS X 10.5 Leopard"] informativeText:NSLocalizedStringFromTable(@"Go to the web site (http://fraise.sourceforge.net) to download another version for an earlier Mac OS X system", @"Localizable3", @"Go to the web site (http://fraise.sourceforge.net) to download another version for an earlier Mac OS X system") defaultButton:OK_BUTTON alternateButton:nil otherButton:nil];
[NSApp terminate:nil];
}
}
[FRABasic insertFetchRequests];
[[FRAPreferencesController sharedInstance] setDefaults];
NSValueTransformer *fontTransformer = [[FRAFontTransformer alloc] init];
[NSValueTransformer setValueTransformer:fontTransformer forName:@"FontTransformer"];
}
- (void)awakeFromNib
{
// If the application crashed so these weren't removed, remove them now
[FRABasic removeAllObjectsForEntity:@"Document"];
[FRABasic removeAllObjectsForEntity:@"Encoding"];
[FRABasic removeAllObjectsForEntity:@"SyntaxDefinition"];
[FRABasic removeAllObjectsForEntity:@"Project"];
[FRAVarious insertTextEncodings];
[FRAVarious insertSyntaxDefinitions];
[FRAVarious insertDefaultSnippets];
[FRAVarious insertDefaultCommands];
[[FRATextMenuController sharedInstance] buildSyntaxDefinitionsMenu];
[[FRATextMenuController sharedInstance] buildEncodingsMenus];
isInFullScreenMode = NO;
[FRAVarious updateCheckIfAnotherApplicationHasChangedDocumentsTimer];
}
@end