1 |
/* IconsPref.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 "IconsPref.h" |
38 |
#include "GWorkspace.h" |
39 |
#include "GNUstep.h" |
40 |
|
41 |
#define ANIM_CHPAT 0 |
42 |
#define ANIM_OPEN 1 |
43 |
#define ANIM_SLIDEBACK 2 |
44 |
|
45 |
static NSString *nibName = @"IconsPref"; |
46 |
|
47 |
@implementation IconsPref |
48 |
|
49 |
- (void)dealloc |
50 |
{ |
51 |
TEST_RELEASE (prefbox); |
52 |
[super dealloc]; |
53 |
} |
54 |
|
55 |
- (id)init |
56 |
{ |
57 |
self = [super init]; |
58 |
|
59 |
if (self) { |
60 |
|
61 |
if ([NSBundle loadNibNamed: nibName owner: self] == NO) { |
62 |
NSLog(@"failed to load %@!", nibName); |
63 |
} else { |
64 |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
65 |
NSArray *cells = [animMatrix cells]; |
66 |
id result; |
67 |
unsigned int state; |
68 |
|
69 |
RETAIN (prefbox); |
70 |
RELEASE (win); |
71 |
|
72 |
gw = [GWorkspace gworkspace]; |
73 |
|
74 |
[thumbCheck setState: [defaults boolForKey: @"usesthumbnails"] ? NSOnState : NSOffState]; |
75 |
|
76 |
result = [defaults objectForKey: @"nochdiranim"]; |
77 |
if (result) { |
78 |
state = ([result isEqual: @"1"]) ? NSOffState : NSOnState; |
79 |
} else { |
80 |
state = NSOnState; |
81 |
} |
82 |
[[cells objectAtIndex: ANIM_CHPAT] setState: state]; |
83 |
|
84 |
result = [defaults objectForKey: @"nolaunchanim"]; |
85 |
if (result) { |
86 |
state = ([result isEqual: @"1"]) ? NSOffState : NSOnState; |
87 |
} else { |
88 |
state = NSOnState; |
89 |
} |
90 |
[[cells objectAtIndex: ANIM_OPEN] setState: state]; |
91 |
|
92 |
result = [defaults objectForKey: @"noslidebackanim"]; |
93 |
if (result) { |
94 |
state = ([result isEqual: @"1"]) ? NSOffState : NSOnState; |
95 |
} else { |
96 |
state = NSOnState; |
97 |
} |
98 |
[[cells objectAtIndex: ANIM_SLIDEBACK] setState: state]; |
99 |
|
100 |
/* Internationalization */ |
101 |
[thumbbox setTitle: NSLocalizedString(@"Thumbnails", @"")]; |
102 |
[thumbCheck setTitle: NSLocalizedString(@"use thumbnails", @"")]; |
103 |
[[animMatrix cellAtRow:0 column:0] setStringValue: NSLocalizedString(@"when changing a path", @"")]; |
104 |
[[animMatrix cellAtRow:1 column:0] setStringValue: NSLocalizedString(@"when opening a file", @"")]; |
105 |
[[animMatrix cellAtRow:2 column:0] setStringValue: NSLocalizedString(@"sliding back after file operation", @"")]; |
106 |
[selectbox setTitle: NSLocalizedString(@"Animate icons", @"")]; |
107 |
[actChangesButt setTitle: NSLocalizedString(@"Activate changes", @"")]; |
108 |
} |
109 |
} |
110 |
|
111 |
return self; |
112 |
} |
113 |
|
114 |
- (NSView *)prefView |
115 |
{ |
116 |
return prefbox; |
117 |
} |
118 |
|
119 |
- (NSString *)prefName |
120 |
{ |
121 |
return NSLocalizedString(@"Icons", @""); |
122 |
} |
123 |
|
124 |
- (IBAction)setUnsetAnimation:(id)sender |
125 |
{ |
126 |
[actChangesButt setEnabled: YES]; |
127 |
} |
128 |
|
129 |
- (IBAction)activateChanges:(id)sender |
130 |
{ |
131 |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
132 |
NSArray *cells = [animMatrix cells]; |
133 |
unsigned int state; |
134 |
|
135 |
state = [[cells objectAtIndex: ANIM_CHPAT] state]; |
136 |
[defaults setObject: ((state == NSOnState) ? @"0" : @"1") |
137 |
forKey: @"nochdiranim"]; |
138 |
|
139 |
state = [[cells objectAtIndex: ANIM_OPEN] state]; |
140 |
[defaults setObject: ((state == NSOnState) ? @"0" : @"1") |
141 |
forKey: @"nolaunchanim"]; |
142 |
|
143 |
state = [[cells objectAtIndex: ANIM_SLIDEBACK] state]; |
144 |
[defaults setObject: ((state == NSOnState) ? @"0" : @"1") |
145 |
forKey: @"noslidebackanim"]; |
146 |
|
147 |
[defaults synchronize]; |
148 |
|
149 |
[[NSNotificationCenter defaultCenter] |
150 |
postNotificationName: GWIconAnimationChangedNotification |
151 |
object: nil]; |
152 |
|
153 |
[actChangesButt setEnabled: NO]; |
154 |
} |
155 |
|
156 |
- (IBAction)setUnsetThumbnails:(id)sender |
157 |
{ |
158 |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
159 |
unsigned int state = [sender state]; |
160 |
|
161 |
[defaults setBool: ((state == NSOnState) ? YES : NO) |
162 |
forKey: @"usesthumbnails"]; |
163 |
[defaults synchronize]; |
164 |
|
165 |
[gw setUsesThumbnails: ((state == NSOnState) ? YES : NO)]; |
166 |
} |
167 |
|
168 |
@end |