1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
/* OperationPrefs.m
*
* Copyright (C) 2004-2014 Free Software Foundation, Inc.
*
* Author: Enrico Sersale <enrico@imago.ro>
* Date: March 2004
*
* This file is part of the GNUstep Operation application
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <GNUstepBase/GNUstep.h>
#import "OperationPrefs.h"
static NSString *nibName = @"OperationPrefs";
#define MOVEOP 0
#define COPYOP 1
#define LINKOP 2
#define RECYCLEOP 3
#define DUPLICATEOP 4
#define DESTROYOP 5
@implementation OperationPrefs
- (void)dealloc
{
RELEASE (prefbox);
[super dealloc];
}
- (id)init
{
self = [super init];
if (self) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *cells;
NSString *confirmString;
id butt;
if ([NSBundle loadNibNamed: nibName owner: self] == NO) {
NSLog(@"failed to load %@!", nibName);
DESTROY (self);
return self;
}
RETAIN (prefbox);
RELEASE (win);
statusItem = [tabView tabViewItemAtIndex: 0];
[statusItem setLabel: NSLocalizedString(@"Status Window", @"")];
confirmItem = [tabView tabViewItemAtIndex: 1];
[confirmItem setLabel: NSLocalizedString(@"Confirmation", @"")];
showstatus = (![defaults boolForKey: @"fopstatusnotshown"]);
[statChooseButt setState: (showstatus ? NSOnState : NSOffState)];
cells = [confMatrix cells];
butt = [cells objectAtIndex: MOVEOP];
confirmString = [NSWorkspaceMoveOperation stringByAppendingString: @"Confirm"];
[butt setState: !([defaults boolForKey: confirmString])];
butt = [cells objectAtIndex: COPYOP];
confirmString = [NSWorkspaceCopyOperation stringByAppendingString: @"Confirm"];
[butt setState: !([defaults boolForKey: confirmString])];
butt = [cells objectAtIndex: LINKOP];
confirmString = [NSWorkspaceLinkOperation stringByAppendingString: @"Confirm"];
[butt setState: !([defaults boolForKey: confirmString])];
butt = [cells objectAtIndex: RECYCLEOP];
confirmString = [NSWorkspaceRecycleOperation stringByAppendingString: @"Confirm"];
[butt setState: !([defaults boolForKey: confirmString])];
butt = [cells objectAtIndex: DUPLICATEOP];
confirmString = [NSWorkspaceDuplicateOperation stringByAppendingString: @"Confirm"];
[butt setState: !([defaults boolForKey: confirmString])];
butt = [cells objectAtIndex: DESTROYOP];
confirmString = [NSWorkspaceDestroyOperation stringByAppendingString: @"Confirm"];
[butt setState: !([defaults boolForKey: confirmString])];
/* Internationalization */
[win setTitle: NSLocalizedString(@"Operation Preferences", @"")];
[statusBox setTitle: NSLocalizedString(@"Status Window", @"")];
[statuslabel setStringValue: NSLocalizedString(@"Show status window", @"")];
[statusinfo1 setStringValue: NSLocalizedString(@"Check this option to show a status window", @"")];
[statusinfo2 setStringValue: NSLocalizedString(@"during the file operations", @"")];
[confirmBox setTitle: NSLocalizedString(@"Confirmation", @"")];
[[confMatrix cellAtRow:0 column:0] setTitle: NSLocalizedString(@"Move", @"")];
[[confMatrix cellAtRow:1 column:0] setTitle: NSLocalizedString(@"Copy", @"")];
[[confMatrix cellAtRow:2 column:0] setTitle: NSLocalizedString(@"Link", @"")];
[[confMatrix cellAtRow:3 column:0] setTitle: NSLocalizedString(@"Recycler", @"")];
[[confMatrix cellAtRow:4 column:0] setTitle: NSLocalizedString(@"Duplicate", @"")];
[[confMatrix cellAtRow:5 column:0] setTitle: NSLocalizedString(@"Destroy", @"")];
[labelinfo1 setStringValue: NSLocalizedString(@"Uncheck the buttons to allow automatic confirmation", @"")];
[labelinfo2 setStringValue: NSLocalizedString(@"of file operations", @"")];
}
return self;
}
- (NSView *)prefView
{
return prefbox;
}
- (NSString *)prefName
{
return NSLocalizedString(@"File Operations", @"");
}
- (void)setUnsetStatWin:(id)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
showstatus = ([sender state] == NSOnState) ? YES : NO;
[defaults setBool: !showstatus forKey: @"fopstatusnotshown"];
[defaults synchronize];
}
- (void)setUnsetFileOp:(id)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *cells = [confMatrix cells];
NSString *confirmString;
#define CHECK_CONFIRM(x, s) \
confirmString = [s stringByAppendingString: @"Confirm"]; \
[defaults setBool: (([[cells objectAtIndex: x] state] == NSOnState) ? NO : YES) \
forKey: confirmString]
CHECK_CONFIRM (MOVEOP, NSWorkspaceMoveOperation);
CHECK_CONFIRM (COPYOP, NSWorkspaceCopyOperation);
CHECK_CONFIRM (LINKOP, NSWorkspaceLinkOperation);
CHECK_CONFIRM (RECYCLEOP, NSWorkspaceRecycleOperation);
CHECK_CONFIRM (RECYCLEOP, @"GWorkspaceRecycleOutOperation");
CHECK_CONFIRM (RECYCLEOP, @"GWorkspaceEmptyRecyclerOperation");
CHECK_CONFIRM (DUPLICATEOP, NSWorkspaceDuplicateOperation);
CHECK_CONFIRM (DESTROYOP, NSWorkspaceDestroyOperation);
[defaults synchronize];
}
@end
|