~ubuntu-branches/ubuntu/raring/vice/raring

« back to all changes in this revision

Viewing changes to src/arch/unix/macosx/cocoa/dialog/keyboardsettingswindowcontroller.m

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2009-03-31 00:37:15 UTC
  • mfrom: (1.1.7 upstream) (9.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090331003715-i5yisvcfv7mgz3eh
Tags: 2.1.dfsg-1
* New major upstream release (closes: #495937).
* Add desktop files (closes: #501181).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * keyboardsettingswindowcontroller.m - KeyboardSettings dialog controller
 
3
 *
 
4
 * Written by
 
5
 *  Christian Vogelgsang <chris@vogelgsang.org>
 
6
 *
 
7
 * This file is part of VICE, the Versatile Commodore Emulator.
 
8
 * See README for copyright notice.
 
9
 *
 
10
 *  This program is free software; you can redistribute it and/or modify
 
11
 *  it under the terms of the GNU General Public License as published by
 
12
 *  the Free Software Foundation; either version 2 of the License, or
 
13
 *  (at your option) any later version.
 
14
 *
 
15
 *  This program is distributed in the hope that it will be useful,
 
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 *  GNU General Public License for more details.
 
19
 *
 
20
 *  You should have received a copy of the GNU General Public License
 
21
 *  along with this program; if not, write to the Free Software
 
22
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
23
 *  02111-1307  USA.
 
24
 *
 
25
 */
 
26
 
 
27
#import "keyboardsettingswindowcontroller.h"
 
28
#import "viceapplication.h"
 
29
#import "vicenotifications.h"
 
30
#import "viceappcontroller.h"
 
31
 
 
32
@implementation KeyboardSettingsWindowController
 
33
 
 
34
-(id)init
 
35
{
 
36
    self = [super initWithWindowNibName:@"KeyboardSettings"];
 
37
    [self registerForResourceUpdate:@selector(updateResources:)];
 
38
    return self;
 
39
}
 
40
 
 
41
-(void)windowDidLoad
 
42
{
 
43
    [self updateResources:nil];
 
44
    [super windowDidLoad];
 
45
}
 
46
 
 
47
-(void)updateResources:(NSNotification *)notification
 
48
{
 
49
    // selector
 
50
    int index = [self getIntResource:@"KeymapIndex"];
 
51
    [keymapSelector selectCellAtRow:index column:0];
 
52
 
 
53
    // files
 
54
    NSString *symUSFileStr = [self getStringResource:@"KeymapSymFile"];
 
55
    NSString *symDEFileStr = [self getStringResource:@"KeymapSymDeFile"];
 
56
    NSString *posFileStr = [self getStringResource:@"KeymapPosFile"];
 
57
    [symUSFile setStringValue:symUSFileStr];
 
58
    [symDEFile setStringValue:symDEFileStr];
 
59
    [posFile setStringValue:posFileStr];
 
60
}
 
61
 
 
62
// ----- Actions -----
 
63
 
 
64
NSString *tags[3] = { @"KeymapSymFile",@"KeymapSymDeFile",@"KeymapPosFile" };
 
65
 
 
66
-(IBAction)selectKeymap:(id)sender
 
67
{
 
68
    int index = [[sender selectedCell] tag];
 
69
    [self setIntResource:@"KeymapIndex" toValue:index];
 
70
}
 
71
 
 
72
-(IBAction)changedKeymapFile:(id)sender
 
73
{
 
74
    int index = [sender tag];
 
75
    [self setStringResource:tags[index] toValue:[sender stringValue]];
 
76
}
 
77
 
 
78
-(IBAction)dumpKeymap:(id)sender
 
79
{
 
80
    NSArray *types = [NSArray arrayWithObjects:@"vkm", nil];
 
81
    VICEAppController *appCtrl = [VICEApplication theAppController];
 
82
    NSString *path = [appCtrl pickSaveFileWithTitle:@"Dump Keymap" types:types];
 
83
    if(path!=nil) {
 
84
        BOOL ok = [[VICEApplication theMachineController] dumpKeymap:path];
 
85
        if(!ok) {
 
86
            [VICEApplication runErrorMessage:@"Error dumping Keymap!"];
 
87
        }
 
88
    }
 
89
}
 
90
 
 
91
-(IBAction)pickKeymap:(id)sender
 
92
{
 
93
    NSArray *types = [NSArray arrayWithObjects:@"vkm", nil];
 
94
    VICEAppController *appCtrl = [VICEApplication theAppController];
 
95
    NSString *path = [appCtrl pickOpenFileWithTitle:@"Load Keymap" types:types];
 
96
    if(path!=nil) {
 
97
        int index = [sender tag];
 
98
        [self setStringResource:tags[index] toValue:path];
 
99
        [self updateResources:nil];
 
100
    }
 
101
}
 
102
 
 
103
@end