~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Mac/PythonLauncher/PreferencesWindowController.m

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#import "PreferencesWindowController.h"
 
2
 
 
3
@implementation PreferencesWindowController
 
4
 
 
5
+ getPreferencesWindow
 
6
{
 
7
    static PreferencesWindowController *_singleton;
 
8
    
 
9
    if (!_singleton)
 
10
        _singleton = [[PreferencesWindowController alloc] init];
 
11
    [_singleton showWindow: _singleton];
 
12
    return _singleton;
 
13
}
 
14
 
 
15
- (id) init
 
16
{
 
17
    self = [self initWithWindowNibName: @"PreferenceWindow"];
 
18
    return self;
 
19
}
 
20
 
 
21
- (void)load_defaults
 
22
{
 
23
    NSString *title = [filetype titleOfSelectedItem];
 
24
    
 
25
    settings = [FileSettings getDefaultsForFileType: title];
 
26
}
 
27
 
 
28
- (void)update_display
 
29
{
 
30
//    [[self window] setTitle: script];
 
31
    
 
32
        [interpreter reloadData];
 
33
    [interpreter setStringValue: [settings interpreter]];
 
34
    [honourhashbang setState: [settings honourhashbang]];
 
35
    [debug setState: [settings debug]];
 
36
    [verbose setState: [settings verbose]];
 
37
    [inspect setState: [settings inspect]];
 
38
    [optimize setState: [settings optimize]];
 
39
    [nosite setState: [settings nosite]];
 
40
    [tabs setState: [settings tabs]];
 
41
    [others setStringValue: [settings others]];
 
42
    [with_terminal setState: [settings with_terminal]];
 
43
    // Not scriptargs, it isn't for preferences
 
44
    
 
45
    [commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];
 
46
}
 
47
 
 
48
- (void) windowDidLoad
 
49
{
 
50
    [super windowDidLoad];
 
51
    [self load_defaults];
 
52
    [self update_display];
 
53
}
 
54
 
 
55
- (void)update_settings
 
56
{
 
57
    [settings updateFromSource: self];
 
58
}
 
59
 
 
60
- (IBAction)do_filetype:(id)sender
 
61
{
 
62
    [self load_defaults];
 
63
    [self update_display];
 
64
}
 
65
 
 
66
- (IBAction)do_reset:(id)sender
 
67
{
 
68
    [settings reset];
 
69
    [self update_display];
 
70
}
 
71
 
 
72
- (IBAction)do_apply:(id)sender
 
73
{
 
74
    [self update_settings];
 
75
    [self update_display];
 
76
}
 
77
 
 
78
// FileSettingsSource protocol 
 
79
- (NSString *) interpreter { return [interpreter stringValue];};
 
80
- (BOOL) honourhashbang { return [honourhashbang state]; };
 
81
- (BOOL) debug { return [debug state];};
 
82
- (BOOL) verbose { return [verbose state];};
 
83
- (BOOL) inspect { return [inspect state];};
 
84
- (BOOL) optimize { return [optimize state];};
 
85
- (BOOL) nosite { return [nosite state];};
 
86
- (BOOL) tabs { return [tabs state];};
 
87
- (NSString *) others { return [others stringValue];};
 
88
- (BOOL) with_terminal { return [with_terminal state];};
 
89
- (NSString *) scriptargs { return @"";};
 
90
 
 
91
// Delegates
 
92
- (void)controlTextDidChange:(NSNotification *)aNotification
 
93
{
 
94
    [self update_settings];
 
95
    [self update_display];
 
96
};
 
97
 
 
98
// NSComboBoxDataSource protocol
 
99
- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
 
100
{
 
101
        NSArray *interp_list = [settings interpreters];
 
102
    unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString];
 
103
        return rv;
 
104
}
 
105
 
 
106
- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
 
107
{
 
108
        NSArray *interp_list = [settings interpreters];
 
109
    id rv = [interp_list objectAtIndex: index];
 
110
        return rv;
 
111
}
 
112
 
 
113
- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
 
114
{
 
115
        NSArray *interp_list = [settings interpreters];
 
116
    int rv = [interp_list count];
 
117
        return rv;
 
118
}
 
119
 
 
120
 
 
121
@end