1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Source/AIConfirmationsAdvancedPreferences.m Tue Jun 02 17:22:19 2009 -0400
1.3 @@ -0,0 +1,140 @@
1.4 +//
1.5 +// AIConfirmationsAdvancedPreferences.m
1.6 +// Adium
1.7 +//
1.8 +// Created by Zachary West on 2009-06-02.
1.9 +// Copyright 2009 Adium. All rights reserved.
1.10 +//
1.11 +
1.12 +#import "AIConfirmationsAdvancedPreferences.h"
1.13 +#import "AIPreferenceWindowController.h"
1.14 +
1.15 +#import <Adium/AIPreferenceControllerProtocol.h>
1.16 +#import <Adium/AIInterfaceControllerProtocol.h>
1.17 +
1.18 +#import <AIUtilities/AIStringAdditions.h>
1.19 +#import <AIUtilities/AIImageAdditions.h>
1.20 +
1.21 +@implementation AIConfirmationsAdvancedPreferences
1.22 +#pragma mark Preference pane settings
1.23 +- (AIPreferenceCategory)category
1.24 +{
1.25 + return AIPref_Advanced;
1.26 +}
1.27 +- (NSString *)label{
1.28 + return AILocalizedString(@"Confirmations",nil);
1.29 +}
1.30 +- (NSString *)nibName{
1.31 + return @"AIConfirmationsAdvancedPreferences";
1.32 +}
1.33 +- (NSImage *)image{
1.34 + return [NSImage imageNamed:@"pref-events" forClass:[AIPreferenceWindowController class]];
1.35 +}
1.36 +
1.37 +/*!
1.38 + * @brief The view loaded
1.39 + */
1.40 +- (void)viewDidLoad
1.41 +{
1.42 + [label_quitConfirmation setLocalizedString:AILocalizedString(@"Quit Confirmation", "Preference")];
1.43 + [checkBox_confirmBeforeQuitting setLocalizedString:AILocalizedString(@"Confirm before quitting Adium", "Quit Confirmation preference")];
1.44 + [checkBox_quitConfirmFT setLocalizedString:AILocalizedString(@"File transfers are in progress", "Quit Confirmation preference")];
1.45 + [checkBox_quitConfirmUnread setLocalizedString:AILocalizedString(@"There are unread messages", "Quit Confirmation preference")];
1.46 + [checkBox_quitConfirmOpenChats setLocalizedString:AILocalizedString(@"There are open chat windows", "Quit Confirmation preference")];
1.47 + [[matrix_quitConfirmType cellWithTag:AIQuitConfirmAlways] setTitle:AILocalizedString(@"Always","Confirmation preference")];
1.48 + [[matrix_quitConfirmType cellWithTag:AIQuitConfirmSelective] setTitle:[AILocalizedString(@"Only when","Quit Confirmation preference") stringByAppendingEllipsis]];
1.49 +
1.50 + [label_messageCloseConfirmation setLocalizedString:AILocalizedString(@"Window Close Confirmation", "Preference")];
1.51 + [checkBox_confirmBeforeClosing setLocalizedString:AILocalizedString(@"Confirm before closing multiple chat windows", "Message close confirmation preference")];
1.52 + [[matrix_closeConfirmType cellWithTag:AIMessageCloseAlways] setTitle:AILocalizedString(@"Always", "Confirmation preference")];
1.53 + [[matrix_closeConfirmType cellWithTag:AIMessageCloseUnread] setTitle:AILocalizedString(@"Only when there are unread messages", "Message close confirmation preference")];
1.54 +
1.55 + NSDictionary *confirmationDict = [adium.preferenceController preferencesForGroup:PREF_GROUP_CONFIRMATIONS];
1.56 +
1.57 + [checkBox_confirmBeforeQuitting setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT] boolValue]];
1.58 + [matrix_quitConfirmType selectCellWithTag:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_TYPE] integerValue]];
1.59 + [checkBox_quitConfirmFT setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_FT] boolValue]];
1.60 + [checkBox_quitConfirmOpenChats setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_OPEN] boolValue]];
1.61 + [checkBox_quitConfirmUnread setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_UNREAD] boolValue]];
1.62 +
1.63 + [checkBox_confirmBeforeClosing setState:[[confirmationDict objectForKey:KEY_CONFIRM_MSG_CLOSE] boolValue]];
1.64 + [matrix_closeConfirmType selectCellWithTag:[[confirmationDict objectForKey:KEY_CONFIRM_MSG_CLOSE_TYPE] integerValue]];
1.65 +
1.66 + [self configureControlDimming];
1.67 +
1.68 + [super viewDidLoad];
1.69 +}
1.70 +
1.71 +- (void)viewWillClose
1.72 +{
1.73 + [super viewWillClose];
1.74 +}
1.75 +
1.76 +- (IBAction)changePreference:(id)sender
1.77 +{
1.78 + if (sender == checkBox_confirmBeforeQuitting) {
1.79 + [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
1.80 + forKey:KEY_CONFIRM_QUIT
1.81 + group:PREF_GROUP_CONFIRMATIONS];
1.82 +
1.83 + [self configureControlDimming];
1.84 + }
1.85 +
1.86 + if (sender == checkBox_quitConfirmFT) {
1.87 + [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
1.88 + forKey:KEY_CONFIRM_QUIT_FT
1.89 + group:PREF_GROUP_CONFIRMATIONS];
1.90 + }
1.91 +
1.92 + if (sender == checkBox_quitConfirmUnread) {
1.93 + [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
1.94 + forKey:KEY_CONFIRM_QUIT_UNREAD
1.95 + group:PREF_GROUP_CONFIRMATIONS];
1.96 + }
1.97 +
1.98 + if (sender == checkBox_quitConfirmOpenChats) {
1.99 + [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
1.100 + forKey:KEY_CONFIRM_QUIT_OPEN
1.101 + group:PREF_GROUP_CONFIRMATIONS];
1.102 + }
1.103 +
1.104 + if (sender == matrix_quitConfirmType) {
1.105 + [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedCell] tag]]
1.106 + forKey:KEY_CONFIRM_QUIT_TYPE
1.107 + group:PREF_GROUP_CONFIRMATIONS];
1.108 +
1.109 + [self configureControlDimming];
1.110 + }
1.111 +
1.112 + if (sender == checkBox_confirmBeforeClosing) {
1.113 + [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
1.114 + forKey:KEY_CONFIRM_MSG_CLOSE
1.115 + group:PREF_GROUP_CONFIRMATIONS];
1.116 +
1.117 + [self configureControlDimming];
1.118 + }
1.119 +
1.120 + if (sender == matrix_closeConfirmType) {
1.121 + [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedCell] tag]]
1.122 + forKey:KEY_CONFIRM_MSG_CLOSE_TYPE
1.123 + group:PREF_GROUP_CONFIRMATIONS];
1.124 + }
1.125 +
1.126 + [self viewDidLoad];
1.127 +}
1.128 +
1.129 +- (void)configureControlDimming
1.130 +{
1.131 + BOOL confirmQuitEnabled = (checkBox_confirmBeforeQuitting.state == NSOnState);
1.132 + BOOL enableSpecificConfirmations = (confirmQuitEnabled && [[matrix_quitConfirmType selectedCell] tag] == AIQuitConfirmSelective);
1.133 +
1.134 + [matrix_quitConfirmType setEnabled:confirmQuitEnabled];
1.135 + [checkBox_quitConfirmFT setEnabled:enableSpecificConfirmations];
1.136 + [checkBox_quitConfirmUnread setEnabled:enableSpecificConfirmations];
1.137 + [checkBox_quitConfirmOpenChats setEnabled:enableSpecificConfirmations];
1.138 +
1.139 + BOOL confirmCloseEnabled = (checkBox_confirmBeforeClosing.state == NSOnState);
1.140 + [matrix_closeConfirmType setEnabled:confirmCloseEnabled];
1.141 +}
1.142 +
1.143 +@end