Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 82 lines (56 sloc) 2.109 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"
ad40277 @ccgus Exposing and testing JSTalk's setShouldLoadExtras:
authored
10 #import "JSTalk.h"
ee99867 @ccgus oh geeze
authored
11
12 @interface JSTAppDelegate (PrivateStuff)
13 - (void) restoreWorkspace;
14 - (void) saveWorkspace;
15 @end
16
17 @implementation JSTAppDelegate
18
19 + (void) initialize {
20
21
22 NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary];
23 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
24
25 [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:@"rememberWorkspace"];
26 [defaultValues setObject:[NSNumber numberWithBool:YES] forKey:@"clearConsoleOnRun"];
27
28 [defaults registerDefaults: defaultValues];
29 [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:defaultValues];
30 }
31
32
33 - (void)awakeFromNib {
34
35 if ([JSTPrefs boolForKey:@"rememberWorkspace"]) {
36 [self restoreWorkspace];
37 }
38
ad40277 @ccgus Exposing and testing JSTalk's setShouldLoadExtras:
authored
39 [JSTalk setShouldLoadExtras:YES];
40 [JSTalk listen];
ee99867 @ccgus oh geeze
authored
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.