Versioned to .88b3 and fixed the copyright date to 2006
[adiumx.git] / Source / ESContactListAdvancedPreferences.m
blob0960daec154df3900f1d18894e28ddf6cb6d8087
1 //
2 //  ESContactListAdvancedPreferences.m
3 //  Adium
4 //
5 //  Created by Evan Schoenberg on 2/20/05.
6 //  Copyright 2005 The Adium Team. All rights reserved.
7 //
9 #import "ESContactListAdvancedPreferences.h"
10 #import "AISCLViewPlugin.h"
11 #import "AIInterfaceController.h"
12 #import "AIPreferenceWindowController.h"
13 #import <AIUtilities/AIDictionaryAdditions.h>
14 #import <AIUtilities/ESImageAdditions.h>
16 @interface ESContactListAdvancedPreferences (PRIVATE)
17 - (NSMenu *)windowPositionMenu;
18 - (void)configureControlDimming;
19 @end
21 /*!
22  * @class ESContactListAdvancedPreferences
23  * @brief Advanced contact list preferences
24  */
25 @implementation ESContactListAdvancedPreferences
27 /*!
28  * @brief Category
29  */
30 - (PREFERENCE_CATEGORY)category{
31     return(AIPref_Advanced);
34 /*!
35  * @brief Label
36  */
37 - (NSString *)label{
38     return(CONTACT_LIST_TITLE);
41 /*!
42  * @brief Nib name
43  */
44 - (NSString *)nibName{
45     return(@"ContactListAdvancedPrefs");
48 /*!
49  * @brief Image
50  */
51 - (NSImage *)image{
52         return([NSImage imageNamed:@"pref-contactList" forClass:[AIPreferenceWindowController class]]);
55 /*!
56  * @brief View loaded; configure it for display
57  */
58 - (void)viewDidLoad
60     NSDictionary        *preferenceDict = [[adium preferenceController] preferencesForGroup:PREF_GROUP_CONTACT_LIST];
61         int                     menuIndex;
62         
63         [popUp_windowPosition setMenu:[[adium interfaceController] menuForWindowLevelsNotifyingTarget:self]];
64         menuIndex =  [popUp_windowPosition indexOfItemWithTag:[[preferenceDict objectForKey:KEY_CL_WINDOW_LEVEL] intValue]];
65         if(menuIndex >= 0 && menuIndex < [popUp_windowPosition numberOfItems]){
66                 [popUp_windowPosition selectItemAtIndex:menuIndex];
67         }
68     [checkBox_hide setState:[[preferenceDict objectForKey:KEY_CL_HIDE] boolValue]];
69         
70         [checkBox_flash setState:[[preferenceDict objectForKey:KEY_CL_FLASH_UNVIEWED_CONTENT] boolValue]];
71         [checkBox_showTransitions setState:[[preferenceDict objectForKey:KEY_CL_SHOW_TRANSITIONS] boolValue]];
72         [checkBox_showTooltips setState:[[preferenceDict objectForKey:KEY_CL_SHOW_TOOLTIPS] boolValue]];
73         [checkBox_showTooltipsInBackground setState:[[preferenceDict objectForKey:KEY_CL_SHOW_TOOLTIPS_IN_BACKGROUND] boolValue]];
74         [checkBox_windowHasShadow setState:[[preferenceDict objectForKey:KEY_CL_WINDOW_HAS_SHADOW] boolValue]];
75         
76         [checkBox_hide setLocalizedString:AILocalizedString(@"Hide while Adium is in the background","Refers to a window hiding when Adium is not the foreground application")];
77         [checkBox_flash setLocalizedString:AILocalizedString(@"Flash names with unviewed messages",nil)];
78         [checkBox_showTransitions setLocalizedString:AILocalizedString(@"Show transitions as contacts sign on and off","Transitions in this context means the names fading in as the contact signs on and out as the contact signs off")];
79         [checkBox_showTooltips setLocalizedString:AILocalizedString(@"Show contact information tooltips",nil)];
80         [checkBox_showTooltipsInBackground setLocalizedString:AILocalizedString(@"While Adium is in the background", "This is a secondary preference underneath 'Show contact information tooltips'")];
81         [checkBox_windowHasShadow setLocalizedString:AILocalizedString(@"Show window shadow",nil)];
82         [checkBox_windowHasShadow setToolTip:@"Stay close to the Vorlon."];
84         [label_appearance setLocalizedString:AILocalizedString(@"Appearance",nil)];
85         [label_tooltips setLocalizedString:AILocalizedString(@"Tooltips",nil)];
86         [label_windowHandling setLocalizedString:AILocalizedString(@"Window Handling",nil)];
87         [label_orderTheContactList setLocalizedString:AILocalizedString(@"Order the contact list:",nil)];
88         
89         [self configureControlDimming];
92 /*!
93  * @brief Called in response to all preference controls, applies new settings
94  */
95 - (IBAction)changePreference:(id)sender
97         if(sender == checkBox_hide){
98                 [[adium preferenceController] setPreference:[NSNumber numberWithBool:([sender state]==NSOnState)]
99                                                                                          forKey:KEY_CL_HIDE
100                                                                                           group:PREF_GROUP_CONTACT_LIST];
101                 
102     }else if(sender == checkBox_flash){
103                 [[adium preferenceController] setPreference:[NSNumber numberWithBool:([sender state]==NSOnState)]
104                                                                                          forKey:KEY_CL_FLASH_UNVIEWED_CONTENT
105                                                                                           group:PREF_GROUP_CONTACT_LIST];
106                 
107     }else if(sender == checkBox_showTransitions){
108                 [[adium preferenceController] setPreference:[NSNumber numberWithBool:([sender state]==NSOnState)]
109                                                                                          forKey:KEY_CL_SHOW_TRANSITIONS
110                                                                                           group:PREF_GROUP_CONTACT_LIST];
111                 
112     }else if(sender == checkBox_showTooltips){
113                 [[adium preferenceController] setPreference:[NSNumber numberWithBool:([sender state]==NSOnState)]
114                                                                                          forKey:KEY_CL_SHOW_TOOLTIPS
115                                                                                           group:PREF_GROUP_CONTACT_LIST];
116                 [self configureControlDimming];
118         }else if(sender == checkBox_showTooltipsInBackground){
119                 [[adium preferenceController] setPreference:[NSNumber numberWithBool:([sender state]==NSOnState)]
120                                                                                          forKey:KEY_CL_SHOW_TOOLTIPS_IN_BACKGROUND
121                                                                                           group:PREF_GROUP_CONTACT_LIST];
122                 
123         }else if(sender == checkBox_windowHasShadow){
124                 [[adium preferenceController] setPreference:[NSNumber numberWithBool:[sender state]]
125                                                                                          forKey:KEY_CL_WINDOW_HAS_SHADOW
126                                                                                           group:PREF_GROUP_CONTACT_LIST];
127                 
128     }
132  * @brief User selected a window level
133  */
134 - (void)selectedWindowLevel:(id)sender
135 {       
136         [[adium preferenceController] setPreference:[NSNumber numberWithInt:[sender tag]]
137                                                                                  forKey:KEY_CL_WINDOW_LEVEL
138                                                                                   group:PREF_GROUP_CONTACT_LIST];
142  * @brief Restorable preferences
143  * @result An NSDictionary of preferences to set when Restore Defaults is clicked
144  */
145 - (NSDictionary *)restorablePreferences
147         NSDictionary *defaultPrefs = [NSDictionary dictionaryNamed:CONTACT_LIST_DEFAULTS forClass:[self class]];
148         NSDictionary *defaultsDict = [NSDictionary dictionaryWithObject:defaultPrefs forKey:PREF_GROUP_CONTACT_LIST];   
149         return(defaultsDict);
153  * @brief Configure control dimming
154  */
155 - (void)configureControlDimming
157         [checkBox_showTooltipsInBackground setEnabled:([checkBox_showTooltips state] == NSOnState)];
160 @end