Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 82 lines (55 sloc) 2.082 kB
ee99867 @ccgus oh geeze
authored
1 //
2 // JSTAppDelegate.m
3 // jstalk
4 //
5 // Created by August Mueller on 1/14/09.
6 // Copyright 2009 Flying Meat Inc. All rights reserved.
7 //
8
9 #import "JSTAppDelegate.h"
10
11 #import "JSTListener.h"
12
13 @interface JSTAppDelegate (PrivateStuff)
14 - (void) restoreWorkspace;
15 - (void) saveWorkspace;
16 @end
17
18 @implementation JSTAppDelegate
19
20 + (void) initialize {
21
22
23 NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary];
24 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
25
26 [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:@"rememberWorkspace"];
27 [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:@"clearConsoleOnRun"];
28
29 [defaults registerDefaults: defaultValues];
30 [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:defaultValues];
31 }
32
33
34 - (void)awakeFromNib {
35
36 if ([JSTPrefs boolForKey:@"rememberWorkspace"]) {
37 [self restoreWorkspace];
38 }
39
40 [JSTListener listen];
41 }
42
43 - (IBAction) showPrefs:(id)sender {
44
45 if (![prefsWindow isVisible]) {
46 [prefsWindow center];
47 }
48
49 [prefsWindow makeKeyAndOrderFront:self];
50 }
51
52 - (void)applicationWillTerminate:(NSNotification *)aNotification {
53 [self saveWorkspace];
54 }
55
56 - (void) restoreWorkspace {
57
58 NSArray *ar = [[NSUserDefaults standardUserDefaults] objectForKey:@"workspaceOpenDocuments"];
59
60 for (NSString *path in ar) {
61 [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:[NSURL fileURLWithPath:path] display:YES error:nil];
62 }
63 }
64
65 - (void) saveWorkspace {
66
67 NSMutableArray *openDocs = [NSMutableArray array];
68
69 for (NSDocument *doc in [[NSDocumentController sharedDocumentController] documents]) {
70
71 if ([doc fileName]) {
72 // saving the file alias would be better.
73 [openDocs addObject:[doc fileName]];
74 }
75 }
76
77 [[NSUserDefaults standardUserDefaults] setObject:openDocs forKey:@"workspaceOpenDocuments"];
78 [[NSUserDefaults standardUserDefaults] synchronize];
79 }
80
81 @end
Something went wrong with that request. Please try again.