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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Mon Aug 25 17:19:14 2003 UTC (20 years, 8 months ago) by esersale
Branch: MAIN
Changes since 1.1: +19 -18 lines
*** empty log message ***

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

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