William Bowling is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this again1 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 | //
// AIConfirmationsAdvancedPreferences.m
// Adium
//
// Created by Zachary West on 2009-06-02.
// Copyright 2009 Adium. All rights reserved.
//
#import "AIConfirmationsAdvancedPreferences.h"
#import "AIPreferenceWindowController.h"
#import <Adium/AIPreferenceControllerProtocol.h>
#import <Adium/AIInterfaceControllerProtocol.h>
#import <AIUtilities/AIStringAdditions.h>
#import <AIUtilities/AIImageAdditions.h>
@implementation AIConfirmationsAdvancedPreferences
#pragma mark Preference pane settings
- (AIPreferenceCategory)category
{
return AIPref_Advanced;
}
- (NSString *)label{
return AILocalizedString(@"Confirmations",nil);
}
- (NSString *)nibName{
return @"AIConfirmationsAdvancedPreferences";
}
- (NSImage *)image{
return [NSImage imageNamed:@"pref-confirmations" forClass:[AIPreferenceWindowController class]];
}
/*!
* @brief The view loaded
*/
- (void)viewDidLoad
{
[label_quitConfirmation setLocalizedString:AILocalizedString(@"Quit Confirmation", "Preference")];
[checkBox_confirmBeforeQuitting setLocalizedString:AILocalizedString(@"Confirm before quitting Adium", "Quit Confirmation preference")];
[checkBox_quitConfirmFT setLocalizedString:AILocalizedString(@"File transfers are in progress", "Quit Confirmation preference")];
[checkBox_quitConfirmUnread setLocalizedString:AILocalizedString(@"There are unread messages", "Quit Confirmation preference")];
[checkBox_quitConfirmOpenChats setLocalizedString:AILocalizedString(@"There are open chat windows", "Quit Confirmation preference")];
[[matrix_quitConfirmType cellWithTag:AIQuitConfirmAlways] setTitle:AILocalizedString(@"Always","Confirmation preference")];
[[matrix_quitConfirmType cellWithTag:AIQuitConfirmSelective] setTitle:[AILocalizedString(@"Only when","Quit Confirmation preference") stringByAppendingEllipsis]];
[label_messageCloseConfirmation setLocalizedString:AILocalizedString(@"Window Close Confirmation", "Preference")];
[checkBox_confirmBeforeClosing setLocalizedString:AILocalizedString(@"Confirm before closing multiple chat windows", "Message close confirmation preference")];
[[matrix_closeConfirmType cellWithTag:AIMessageCloseAlways] setTitle:AILocalizedString(@"Always", "Confirmation preference")];
[[matrix_closeConfirmType cellWithTag:AIMessageCloseUnread] setTitle:AILocalizedString(@"Only when there are unread messages", "Message close confirmation preference")];
NSDictionary *confirmationDict = [adium.preferenceController preferencesForGroup:PREF_GROUP_CONFIRMATIONS];
[checkBox_confirmBeforeQuitting setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT] boolValue]];
[matrix_quitConfirmType selectCellWithTag:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_TYPE] integerValue]];
[checkBox_quitConfirmFT setState:![[confirmationDict objectForKey:KEY_CONFIRM_QUIT_FT] boolValue]];
[checkBox_quitConfirmOpenChats setState:![[confirmationDict objectForKey:KEY_CONFIRM_QUIT_OPEN] boolValue]];
[checkBox_quitConfirmUnread setState:![[confirmationDict objectForKey:KEY_CONFIRM_QUIT_UNREAD] boolValue]];
[checkBox_confirmBeforeClosing setState:[[confirmationDict objectForKey:KEY_CONFIRM_MSG_CLOSE] boolValue]];
[matrix_closeConfirmType selectCellWithTag:[[confirmationDict objectForKey:KEY_CONFIRM_MSG_CLOSE_TYPE] integerValue]];
[self configureControlDimming];
[super viewDidLoad];
}
- (void)viewWillClose
{
[super viewWillClose];
}
- (IBAction)changePreference:(id)sender
{
if (sender == checkBox_confirmBeforeQuitting) {
[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
forKey:KEY_CONFIRM_QUIT
group:PREF_GROUP_CONFIRMATIONS];
[self configureControlDimming];
}
if (sender == checkBox_quitConfirmFT) {
[adium.preferenceController setPreference:[NSNumber numberWithBool:![sender state]]
forKey:KEY_CONFIRM_QUIT_FT
group:PREF_GROUP_CONFIRMATIONS];
}
if (sender == checkBox_quitConfirmUnread) {
[adium.preferenceController setPreference:[NSNumber numberWithBool:![sender state]]
forKey:KEY_CONFIRM_QUIT_UNREAD
group:PREF_GROUP_CONFIRMATIONS];
}
if (sender == checkBox_quitConfirmOpenChats) {
[adium.preferenceController setPreference:[NSNumber numberWithBool:![sender state]]
forKey:KEY_CONFIRM_QUIT_OPEN
group:PREF_GROUP_CONFIRMATIONS];
}
if (sender == matrix_quitConfirmType) {
[adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedCell] tag]]
forKey:KEY_CONFIRM_QUIT_TYPE
group:PREF_GROUP_CONFIRMATIONS];
[self configureControlDimming];
}
if (sender == checkBox_confirmBeforeClosing) {
[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
forKey:KEY_CONFIRM_MSG_CLOSE
group:PREF_GROUP_CONFIRMATIONS];
[self configureControlDimming];
}
if (sender == matrix_closeConfirmType) {
[adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedCell] tag]]
forKey:KEY_CONFIRM_MSG_CLOSE_TYPE
group:PREF_GROUP_CONFIRMATIONS];
}
[self viewDidLoad];
}
- (void)configureControlDimming
{
BOOL confirmQuitEnabled = (checkBox_confirmBeforeQuitting.state == NSOnState);
BOOL enableSpecificConfirmations = (confirmQuitEnabled && [[matrix_quitConfirmType selectedCell] tag] == AIQuitConfirmSelective);
[matrix_quitConfirmType setEnabled:confirmQuitEnabled];
[checkBox_quitConfirmFT setEnabled:enableSpecificConfirmations];
[checkBox_quitConfirmUnread setEnabled:enableSpecificConfirmations];
[checkBox_quitConfirmOpenChats setEnabled:enableSpecificConfirmations];
BOOL confirmCloseEnabled = (checkBox_confirmBeforeClosing.state == NSOnState);
[matrix_closeConfirmType setEnabled:confirmCloseEnabled];
}
@end
|