|
zacw@2450
|
1 |
// |
|
zacw@2450
|
2 |
// AIConfirmationsAdvancedPreferences.m |
|
zacw@2450
|
3 |
// Adium |
|
zacw@2450
|
4 |
// |
|
zacw@2450
|
5 |
// Created by Zachary West on 2009-06-02. |
|
zacw@2450
|
6 |
// Copyright 2009 Adium. All rights reserved. |
|
zacw@2450
|
7 |
// |
|
zacw@2450
|
8 |
|
|
zacw@2450
|
9 |
#import "AIConfirmationsAdvancedPreferences.h" |
|
zacw@2450
|
10 |
#import "AIPreferenceWindowController.h" |
|
zacw@2450
|
11 |
|
|
zacw@2450
|
12 |
#import <Adium/AIPreferenceControllerProtocol.h> |
|
zacw@2450
|
13 |
#import <Adium/AIInterfaceControllerProtocol.h> |
|
zacw@2450
|
14 |
|
|
zacw@2450
|
15 |
#import <AIUtilities/AIStringAdditions.h> |
|
zacw@2450
|
16 |
#import <AIUtilities/AIImageAdditions.h> |
|
zacw@2450
|
17 |
|
|
zacw@2450
|
18 |
@implementation AIConfirmationsAdvancedPreferences |
|
zacw@2450
|
19 |
#pragma mark Preference pane settings |
|
zacw@2450
|
20 |
- (AIPreferenceCategory)category |
|
zacw@2450
|
21 |
{ |
|
zacw@2450
|
22 |
return AIPref_Advanced; |
|
zacw@2450
|
23 |
} |
|
zacw@2450
|
24 |
- (NSString *)label{ |
|
zacw@2450
|
25 |
return AILocalizedString(@"Confirmations",nil); |
|
zacw@2450
|
26 |
} |
|
zacw@2450
|
27 |
- (NSString *)nibName{ |
|
zacw@2450
|
28 |
return @"AIConfirmationsAdvancedPreferences"; |
|
zacw@2450
|
29 |
} |
|
zacw@2450
|
30 |
- (NSImage *)image{ |
|
zacw@2450
|
31 |
return [NSImage imageNamed:@"pref-events" forClass:[AIPreferenceWindowController class]]; |
|
zacw@2450
|
32 |
} |
|
zacw@2450
|
33 |
|
|
zacw@2450
|
34 |
/*! |
|
zacw@2450
|
35 |
* @brief The view loaded |
|
zacw@2450
|
36 |
*/ |
|
zacw@2450
|
37 |
- (void)viewDidLoad |
|
zacw@2450
|
38 |
{ |
|
zacw@2450
|
39 |
[label_quitConfirmation setLocalizedString:AILocalizedString(@"Quit Confirmation", "Preference")]; |
|
zacw@2450
|
40 |
[checkBox_confirmBeforeQuitting setLocalizedString:AILocalizedString(@"Confirm before quitting Adium", "Quit Confirmation preference")]; |
|
zacw@2450
|
41 |
[checkBox_quitConfirmFT setLocalizedString:AILocalizedString(@"File transfers are in progress", "Quit Confirmation preference")]; |
|
zacw@2450
|
42 |
[checkBox_quitConfirmUnread setLocalizedString:AILocalizedString(@"There are unread messages", "Quit Confirmation preference")]; |
|
zacw@2450
|
43 |
[checkBox_quitConfirmOpenChats setLocalizedString:AILocalizedString(@"There are open chat windows", "Quit Confirmation preference")]; |
|
zacw@2450
|
44 |
[[matrix_quitConfirmType cellWithTag:AIQuitConfirmAlways] setTitle:AILocalizedString(@"Always","Confirmation preference")]; |
|
zacw@2450
|
45 |
[[matrix_quitConfirmType cellWithTag:AIQuitConfirmSelective] setTitle:[AILocalizedString(@"Only when","Quit Confirmation preference") stringByAppendingEllipsis]]; |
|
zacw@2450
|
46 |
|
|
zacw@2450
|
47 |
[label_messageCloseConfirmation setLocalizedString:AILocalizedString(@"Window Close Confirmation", "Preference")]; |
|
zacw@2450
|
48 |
[checkBox_confirmBeforeClosing setLocalizedString:AILocalizedString(@"Confirm before closing multiple chat windows", "Message close confirmation preference")]; |
|
zacw@2450
|
49 |
[[matrix_closeConfirmType cellWithTag:AIMessageCloseAlways] setTitle:AILocalizedString(@"Always", "Confirmation preference")]; |
|
zacw@2450
|
50 |
[[matrix_closeConfirmType cellWithTag:AIMessageCloseUnread] setTitle:AILocalizedString(@"Only when there are unread messages", "Message close confirmation preference")]; |
|
zacw@2450
|
51 |
|
|
zacw@2450
|
52 |
NSDictionary *confirmationDict = [adium.preferenceController preferencesForGroup:PREF_GROUP_CONFIRMATIONS]; |
|
zacw@2450
|
53 |
|
|
zacw@2450
|
54 |
[checkBox_confirmBeforeQuitting setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT] boolValue]]; |
|
zacw@2450
|
55 |
[matrix_quitConfirmType selectCellWithTag:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_TYPE] integerValue]]; |
|
zacw@2622
|
56 |
[checkBox_quitConfirmFT setState:![[confirmationDict objectForKey:KEY_CONFIRM_QUIT_FT] boolValue]]; |
|
zacw@2622
|
57 |
[checkBox_quitConfirmOpenChats setState:![[confirmationDict objectForKey:KEY_CONFIRM_QUIT_OPEN] boolValue]]; |
|
zacw@2622
|
58 |
[checkBox_quitConfirmUnread setState:![[confirmationDict objectForKey:KEY_CONFIRM_QUIT_UNREAD] boolValue]]; |
|
zacw@2450
|
59 |
|
|
zacw@2450
|
60 |
[checkBox_confirmBeforeClosing setState:[[confirmationDict objectForKey:KEY_CONFIRM_MSG_CLOSE] boolValue]]; |
|
zacw@2450
|
61 |
[matrix_closeConfirmType selectCellWithTag:[[confirmationDict objectForKey:KEY_CONFIRM_MSG_CLOSE_TYPE] integerValue]]; |
|
zacw@2450
|
62 |
|
|
zacw@2450
|
63 |
[self configureControlDimming]; |
|
zacw@2450
|
64 |
|
|
zacw@2450
|
65 |
[super viewDidLoad]; |
|
zacw@2450
|
66 |
} |
|
zacw@2450
|
67 |
|
|
zacw@2450
|
68 |
- (void)viewWillClose |
|
zacw@2450
|
69 |
{ |
|
zacw@2450
|
70 |
[super viewWillClose]; |
|
zacw@2450
|
71 |
} |
|
zacw@2450
|
72 |
|
|
zacw@2450
|
73 |
- (IBAction)changePreference:(id)sender |
|
zacw@2450
|
74 |
{ |
|
zacw@2450
|
75 |
if (sender == checkBox_confirmBeforeQuitting) { |
|
zacw@2450
|
76 |
[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]] |
|
zacw@2450
|
77 |
forKey:KEY_CONFIRM_QUIT |
|
zacw@2450
|
78 |
group:PREF_GROUP_CONFIRMATIONS]; |
|
zacw@2450
|
79 |
|
|
zacw@2450
|
80 |
[self configureControlDimming]; |
|
zacw@2450
|
81 |
} |
|
zacw@2450
|
82 |
|
|
zacw@2450
|
83 |
if (sender == checkBox_quitConfirmFT) { |
|
zacw@2622
|
84 |
[adium.preferenceController setPreference:[NSNumber numberWithBool:![sender state]] |
|
zacw@2450
|
85 |
forKey:KEY_CONFIRM_QUIT_FT |
|
zacw@2450
|
86 |
group:PREF_GROUP_CONFIRMATIONS]; |
|
zacw@2450
|
87 |
} |
|
zacw@2450
|
88 |
|
|
zacw@2450
|
89 |
if (sender == checkBox_quitConfirmUnread) { |
|
zacw@2622
|
90 |
[adium.preferenceController setPreference:[NSNumber numberWithBool:![sender state]] |
|
zacw@2450
|
91 |
forKey:KEY_CONFIRM_QUIT_UNREAD |
|
zacw@2450
|
92 |
group:PREF_GROUP_CONFIRMATIONS]; |
|
zacw@2450
|
93 |
} |
|
zacw@2450
|
94 |
|
|
zacw@2450
|
95 |
if (sender == checkBox_quitConfirmOpenChats) { |
|
zacw@2622
|
96 |
[adium.preferenceController setPreference:[NSNumber numberWithBool:![sender state]] |
|
zacw@2450
|
97 |
forKey:KEY_CONFIRM_QUIT_OPEN |
|
zacw@2450
|
98 |
group:PREF_GROUP_CONFIRMATIONS]; |
|
zacw@2450
|
99 |
} |
|
zacw@2450
|
100 |
|
|
zacw@2450
|
101 |
if (sender == matrix_quitConfirmType) { |
|
zacw@2450
|
102 |
[adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedCell] tag]] |
|
zacw@2450
|
103 |
forKey:KEY_CONFIRM_QUIT_TYPE |
|
zacw@2450
|
104 |
group:PREF_GROUP_CONFIRMATIONS]; |
|
zacw@2450
|
105 |
|
|
zacw@2450
|
106 |
[self configureControlDimming]; |
|
zacw@2450
|
107 |
} |
|
zacw@2450
|
108 |
|
|
zacw@2450
|
109 |
if (sender == checkBox_confirmBeforeClosing) { |
|
zacw@2450
|
110 |
[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]] |
|
zacw@2450
|
111 |
forKey:KEY_CONFIRM_MSG_CLOSE |
|
zacw@2450
|
112 |
group:PREF_GROUP_CONFIRMATIONS]; |
|
zacw@2450
|
113 |
|
|
zacw@2450
|
114 |
[self configureControlDimming]; |
|
zacw@2450
|
115 |
} |
|
zacw@2450
|
116 |
|
|
zacw@2450
|
117 |
if (sender == matrix_closeConfirmType) { |
|
zacw@2450
|
118 |
[adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedCell] tag]] |
|
zacw@2450
|
119 |
forKey:KEY_CONFIRM_MSG_CLOSE_TYPE |
|
zacw@2450
|
120 |
group:PREF_GROUP_CONFIRMATIONS]; |
|
zacw@2450
|
121 |
} |
|
zacw@2450
|
122 |
|
|
zacw@2450
|
123 |
[self viewDidLoad]; |
|
zacw@2450
|
124 |
} |
|
zacw@2450
|
125 |
|
|
zacw@2450
|
126 |
- (void)configureControlDimming |
|
zacw@2450
|
127 |
{ |
|
zacw@2450
|
128 |
BOOL confirmQuitEnabled = (checkBox_confirmBeforeQuitting.state == NSOnState); |
|
zacw@2450
|
129 |
BOOL enableSpecificConfirmations = (confirmQuitEnabled && [[matrix_quitConfirmType selectedCell] tag] == AIQuitConfirmSelective); |
|
zacw@2450
|
130 |
|
|
zacw@2450
|
131 |
[matrix_quitConfirmType setEnabled:confirmQuitEnabled]; |
|
zacw@2450
|
132 |
[checkBox_quitConfirmFT setEnabled:enableSpecificConfirmations]; |
|
zacw@2450
|
133 |
[checkBox_quitConfirmUnread setEnabled:enableSpecificConfirmations]; |
|
zacw@2450
|
134 |
[checkBox_quitConfirmOpenChats setEnabled:enableSpecificConfirmations]; |
|
zacw@2450
|
135 |
|
|
zacw@2450
|
136 |
BOOL confirmCloseEnabled = (checkBox_confirmBeforeClosing.state == NSOnState); |
|
zacw@2450
|
137 |
[matrix_closeConfirmType setEnabled:confirmCloseEnabled]; |
|
zacw@2450
|
138 |
} |
|
zacw@2450
|
139 |
|
|
zacw@2450
|
140 |
@end |