1 |
/* XTermPref.m |
2 |
* |
3 |
* Copyright (C) 2003 Free Software Foundation, Inc. |
4 |
* |
5 |
* Author: Enrico Sersale <enrico@imago.ro> |
6 |
* Date: August 2001 |
7 |
* |
8 |
* This file is part of the GNUstep GWorkspace application |
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 02111-1307, USA. |
23 |
*/ |
24 |
|
25 |
|
26 |
#include <Foundation/Foundation.h> |
27 |
#include <AppKit/AppKit.h> |
28 |
#ifdef GNUSTEP |
29 |
#include "GWFunctions.h" |
30 |
#else |
31 |
#include <GWorkspace/GWFunctions.h> |
32 |
#endif |
33 |
#include "XTermPref.h" |
34 |
#include "GWorkspace.h" |
35 |
#include "GNUstep.h" |
36 |
|
37 |
static NSString *nibName = @"XTermPref"; |
38 |
|
39 |
@implementation XTermPref |
40 |
|
41 |
- (void)dealloc |
42 |
{ |
43 |
TEST_RELEASE (prefbox); |
44 |
TEST_RELEASE (xterm); |
45 |
TEST_RELEASE (xtermArgs); |
46 |
[super dealloc]; |
47 |
} |
48 |
|
49 |
- (id)init |
50 |
{ |
51 |
self = [super init]; |
52 |
|
53 |
if (self) { |
54 |
if ([NSBundle loadNibNamed: nibName owner: self] == NO) { |
55 |
NSLog(@"failed to load %@!", nibName); |
56 |
} else { |
57 |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
58 |
|
59 |
RETAIN (prefbox); |
60 |
RELEASE (win); |
61 |
|
62 |
xterm = [defaults stringForKey: @"defxterm"]; |
63 |
if (xterm != nil) { |
64 |
RETAIN (xterm); |
65 |
[xtermLabel setStringValue: xterm]; |
66 |
} |
67 |
|
68 |
xtermArgs = [defaults stringForKey: @"defaultxtermargs"]; |
69 |
if (xtermArgs != nil) { |
70 |
RETAIN (xtermArgs); |
71 |
[argsLabel setStringValue: xtermArgs]; |
72 |
} |
73 |
|
74 |
gw = [GWorkspace gworkspace]; |
75 |
|
76 |
/* Internationalization */ |
77 |
[setButt setTitle: NSLocalizedString(@"Set", @"")]; |
78 |
[fieldsBox setTitle: NSLocalizedString(@"XTerminal", @"")]; |
79 |
} |
80 |
} |
81 |
|
82 |
return self; |
83 |
} |
84 |
|
85 |
- (NSView *)prefView |
86 |
{ |
87 |
return prefbox; |
88 |
} |
89 |
|
90 |
- (NSString *)prefName |
91 |
{ |
92 |
return @"XTerminal"; |
93 |
} |
94 |
|
95 |
- (IBAction)setXTerm:(id)sender |
96 |
{ |
97 |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
98 |
NSString *xt = [xtermLabel stringValue]; |
99 |
NSString *xtargs = [argsLabel stringValue]; |
100 |
|
101 |
if ([xterm isEqual: xt] && [xtermArgs isEqual: xtargs]) { |
102 |
return; |
103 |
} |
104 |
|
105 |
ASSIGN (xterm, xt); |
106 |
ASSIGN (xtermArgs, xtargs); |
107 |
|
108 |
[defaults setObject: xterm forKey: @"defxterm"]; |
109 |
[defaults setObject: xtermArgs forKey: @"defaultxtermargs"]; |
110 |
[defaults synchronize]; |
111 |
|
112 |
[gw changeDefaultXTerm: xterm arguments: xtermArgs]; |
113 |
} |
114 |
|
115 |
@end |