/[gnustep]/gnustep/usr-apps/gworkspace/GWorkspace/Preferences/FileOpsPref.m
ViewVC logotype

Contents of /gnustep/usr-apps/gworkspace/GWorkspace/Preferences/FileOpsPref.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Tue Sep 30 15:38:05 2003 UTC (20 years, 6 months ago) by esersale
Branch: MAIN
Changes since 1.2: +2 -0 lines
*** empty log message ***

1 /* FileOpsPref.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 "GWLib.h"
30 #include "GWFunctions.h"
31 #include "GWNotifications.h"
32 #else
33 #include <GWorkspace/GWLib.h>
34 #include <GWorkspace/GWFunctions.h>
35 #include <GWorkspace/GWNotifications.h>
36 #endif
37 #include "FileOpsPref.h"
38 #include "GWorkspace.h"
39 #include "GNUstep.h"
40
41 static NSString *nibName = @"FileOpsPref";
42
43 #define MOVEOP 0
44 #define COPYOP 1
45 #define LINKOP 2
46 #define RECYCLEOP 3
47 #define DUPLICATEOP 4
48 #define DESTROYOP 5
49
50 @implementation FileOpsPref
51
52 - (void)dealloc
53 {
54 TEST_RELEASE (prefbox);
55 [super dealloc];
56 }
57
58 - (id)init
59 {
60 self = [super init];
61
62 if (self) {
63 if ([NSBundle loadNibNamed: nibName owner: self] == NO) {
64 NSLog(@"failed to load %@!", nibName);
65 } else {
66 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
67 NSArray *cells;
68 NSString *confirmString;
69 id butt;
70
71 RETAIN (prefbox);
72 RELEASE (win);
73
74 gw = [GWorkspace gworkspace];
75
76 statusItem = [tabView tabViewItemAtIndex: 0];
77 [statusItem setLabel: NSLocalizedString(@"Status Window", @"")];
78
79 confirmItem = [tabView tabViewItemAtIndex: 1];
80 [confirmItem setLabel: NSLocalizedString(@"Confirmation", @"")];
81
82 showstatus = [gw showFileOpStatus];
83 [statChooseButt setState: (showstatus ? NSOnState : NSOffState)];
84
85 cells = [confMatrix cells];
86
87 butt = [cells objectAtIndex: MOVEOP];
88 confirmString = [NSWorkspaceMoveOperation stringByAppendingString: @"Confirm"];
89 [butt setState: !([defaults boolForKey: confirmString])];
90
91 butt = [cells objectAtIndex: COPYOP];
92 confirmString = [NSWorkspaceCopyOperation stringByAppendingString: @"Confirm"];
93 [butt setState: !([defaults boolForKey: confirmString])];
94
95 butt = [cells objectAtIndex: LINKOP];
96 confirmString = [NSWorkspaceLinkOperation stringByAppendingString: @"Confirm"];
97 [butt setState: !([defaults boolForKey: confirmString])];
98
99 butt = [cells objectAtIndex: RECYCLEOP];
100 confirmString = [NSWorkspaceRecycleOperation stringByAppendingString: @"Confirm"];
101 [butt setState: !([defaults boolForKey: confirmString])];
102
103 butt = [cells objectAtIndex: DUPLICATEOP];
104 confirmString = [NSWorkspaceDuplicateOperation stringByAppendingString: @"Confirm"];
105 [butt setState: !([defaults boolForKey: confirmString])];
106
107 butt = [cells objectAtIndex: DESTROYOP];
108 confirmString = [NSWorkspaceDestroyOperation stringByAppendingString: @"Confirm"];
109 [butt setState: !([defaults boolForKey: confirmString])];
110
111 /* Internationalization */
112 [statActivButt setTitle: NSLocalizedString(@"Set", @"")];
113 [confActivButt setTitle: NSLocalizedString(@"Set", @"")];
114 [confirmBox setTitle: NSLocalizedString(@"Confirmation", @"")];
115 [statusBox setTitle: NSLocalizedString(@"Status Window", @"")];
116 [[confMatrix cellAtRow:0 column:0] setStringValue: NSLocalizedString(@"Move", @"")];
117 [[confMatrix cellAtRow:1 column:0] setStringValue: NSLocalizedString(@"Copy", @"")];
118 [[confMatrix cellAtRow:2 column:0] setStringValue: NSLocalizedString(@"Link", @"")];
119 [[confMatrix cellAtRow:3 column:0] setStringValue: NSLocalizedString(@"Recycler", @"")];
120 [[confMatrix cellAtRow:4 column:0] setStringValue: NSLocalizedString(@"Duplicate", @"")];
121 [[confMatrix cellAtRow:5 column:0] setStringValue: NSLocalizedString(@"Destroy", @"")];
122 [labelinfo1 setStringValue: NSLocalizedString(@"Uncheck the buttons to allow automatic confirmation", @"")];
123 [labelinfo2 setStringValue: NSLocalizedString(@"of file operations", @"")];
124 [statusinfo1 setStringValue: NSLocalizedString(@"Check this option to show a status window", @"")];
125 [statusinfo2 setStringValue: NSLocalizedString(@"during the file operations", @"")];
126 [statuslabel setStringValue: NSLocalizedString(@"Show status window", @"")];
127 }
128 }
129
130 return self;
131 }
132
133 - (NSView *)prefView
134 {
135 return prefbox;
136 }
137
138 - (NSString *)prefName
139 {
140 return NSLocalizedString(@"File Operations", @"");
141 }
142
143 - (void)setUnsetStatWin:(id)sender
144 {
145 int state = [sender state];
146
147 if (showstatus) {
148 if (state == NSOffState) {
149 showstatus = NO;
150 [statActivButt setEnabled: YES];
151 }
152 } else {
153 if (state == NSOnState) {
154 showstatus = YES;
155 [statActivButt setEnabled: YES];
156 }
157 }
158 }
159
160 - (void)activateStatWinChanges:(id)sender
161 {
162 [gw setShowFileOpStatus: showstatus];
163 [statActivButt setEnabled: NO];
164 }
165
166 - (void)setUnsetFileOp:(id)sender
167 {
168 [confActivButt setEnabled: YES];
169 }
170
171 - (void)activateFileOpChanges:(id)sender
172 {
173 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
174 NSArray *cells = [confMatrix cells];
175 NSString *confirmString;
176
177 #define CHECK_CONFIRM(x, s) \
178 confirmString = [s stringByAppendingString: @"Confirm"]; \
179 [defaults setBool: (([[cells objectAtIndex: x] state] == NSOnState) ? NO : YES) \
180 forKey: confirmString]
181
182 CHECK_CONFIRM (MOVEOP, NSWorkspaceMoveOperation);
183 CHECK_CONFIRM (COPYOP, NSWorkspaceCopyOperation);
184 CHECK_CONFIRM (LINKOP, NSWorkspaceLinkOperation);
185 CHECK_CONFIRM (RECYCLEOP, NSWorkspaceRecycleOperation);
186 CHECK_CONFIRM (RECYCLEOP, GWorkspaceRecycleOutOperation);
187 CHECK_CONFIRM (RECYCLEOP, GWorkspaceEmptyRecyclerOperation);
188 CHECK_CONFIRM (DUPLICATEOP, NSWorkspaceDuplicateOperation);
189 CHECK_CONFIRM (DESTROYOP, NSWorkspaceDestroyOperation);
190
191 [defaults synchronize];
192 [confActivButt setEnabled: NO];
193 }
194
195 @end

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26