Unescape the HREF attribute's text before passing it to NSURL which does not expect...
[adiumx.git] / Source / ESCLViewLabelsAdvancedPrefs.m
blob9cccc8b9f6c7096b83fda4d0a3e85301d33c5d89
1 //
2 //  ESDualWindowMessageWindowPreferences.m
3 //  Adium
4 //
5 //  Created by Evan Schoenberg on Thu Sep 18 2003.
6 //
8 #import "ESCLViewLabelsAdvancedPrefs.h"
9 #import "AISCLViewPlugin.h"
10 #import <AIUtilities/AIDictionaryAdditions.h>
13 @implementation ESCLViewLabelsAdvancedPrefs
15 //Preference pane properties
16 - (PREFERENCE_CATEGORY)category{
17     return AIPref_Advanced_ContactList;
19 - (NSString *)label{
20     return AILocalizedString(@"Labels","Contact list labels");
22 - (NSString *)nibName{
23     return @"CLViewLabelsAdvancedPrefs";
26 - (NSDictionary *)restorablePreferences
28         
29         NSDictionary *defaultPrefs = [NSDictionary dictionaryNamed:SCL_DEFAULT_PREFS forClass:[self class]];
30         NSDictionary *defaultsTemp = [NSDictionary dictionaryWithObjectsAndKeys:
31                 [defaultPrefs objectForKey:KEY_SCL_LABEL_AROUND_CONTACT],KEY_SCL_LABEL_AROUND_CONTACT,
32                 [defaultPrefs objectForKey:KEY_SCL_OUTLINE_LABELS],KEY_SCL_OUTLINE_LABELS,
33                 [defaultPrefs objectForKey:KEY_SCL_LABEL_OPACITY],KEY_SCL_LABEL_OPACITY,
34                 [defaultPrefs objectForKey:KEY_SCL_LABEL_GROUPS],KEY_SCL_LABEL_GROUPS,
35                 [defaultPrefs objectForKey:KEY_SCL_LABEL_GROUPS_COLOR],KEY_SCL_LABEL_GROUPS_COLOR,
36                 [defaultPrefs objectForKey:KEY_SCL_USE_GRADIENT],KEY_SCL_USE_GRADIENT,
37                 nil];
38         
39         NSDictionary *defaultsDict = [NSDictionary dictionaryWithObject:defaultsTemp forKey:PREF_GROUP_CONTACT_LIST_DISPLAY];
40         return defaultsDict;
44 //Called in response to all preference controls, applies new settings
45 - (IBAction)changePreference:(id)sender
47     if(sender == checkbox_labelAroundContact){
48         [[adium preferenceController] setPreference:[NSNumber numberWithBool:[sender state]]
49                                              forKey:KEY_SCL_LABEL_AROUND_CONTACT
50                                               group:PREF_GROUP_CONTACT_LIST_DISPLAY];       
51     }else if(sender == checkbox_outlineLabels){
52         [[adium preferenceController] setPreference:[NSNumber numberWithBool:[sender state]]
53                                              forKey:KEY_SCL_OUTLINE_LABELS
54                                               group:PREF_GROUP_CONTACT_LIST_DISPLAY];
55     }else if(sender == checkbox_useGradient){
56                 [[adium preferenceController] setPreference:[NSNumber numberWithBool:[sender state]]
57                                              forKey:KEY_SCL_USE_GRADIENT
58                                               group:PREF_GROUP_CONTACT_LIST_DISPLAY];
59         }else if(sender == slider_labelOpacity){
60         [[adium preferenceController] setPreference:[NSNumber numberWithFloat:[sender floatValue]]
61                                              forKey:KEY_SCL_LABEL_OPACITY
62                                               group:PREF_GROUP_CONTACT_LIST_DISPLAY];   
63     }else if(sender == checkbox_labelGroups){
64         [[adium preferenceController] setPreference:[NSNumber numberWithBool:[sender state]]
65                                              forKey:KEY_SCL_LABEL_GROUPS
66                                               group:PREF_GROUP_CONTACT_LIST_DISPLAY];       
67     }else if(sender == colorWell_labelGroupsColor){
68         [[adium preferenceController] setPreference:[[sender color] stringRepresentation]
69                                              forKey:KEY_SCL_LABEL_GROUPS_COLOR
70                                               group:PREF_GROUP_CONTACT_LIST_DISPLAY];
71     }
72            
73     [self configureControlDimming];
76 //Configure the preference view
77 - (void)viewDidLoad
79     NSDictionary        *preferenceDict = [[adium preferenceController] preferencesForGroup:PREF_GROUP_CONTACT_LIST_DISPLAY];
81     [checkbox_labelAroundContact setState:[[preferenceDict objectForKey:KEY_SCL_LABEL_AROUND_CONTACT] boolValue]];
82     [checkbox_outlineLabels setState:[[preferenceDict objectForKey:KEY_SCL_OUTLINE_LABELS] boolValue]];
83     
84     [slider_labelOpacity setFloatValue:[[preferenceDict objectForKey:KEY_SCL_LABEL_OPACITY] floatValue]];
85     [slider_labelOpacity setMinValue:0.05];
86     [slider_labelOpacity setMaxValue:1.00];
87     
88     [checkbox_labelGroups setState:[[preferenceDict objectForKey:KEY_SCL_LABEL_GROUPS] boolValue]];
89     [colorWell_labelGroupsColor setColor:[[preferenceDict objectForKey:KEY_SCL_LABEL_GROUPS_COLOR] representedColor]];
90         [checkbox_useGradient setState:[[preferenceDict objectForKey:KEY_SCL_USE_GRADIENT] boolValue]];
91         
92     [self configureControlDimming];
95 - (void)viewWillClose
97         if([colorWell_labelGroupsColor isActive]) [colorWell_labelGroupsColor deactivate];
100 //Enable/disable controls that are available/unavailable
101 - (void)configureControlDimming
103     NSDictionary        *preferenceDict = [[adium preferenceController] preferencesForGroup:PREF_GROUP_CONTACT_LIST_DISPLAY];
105     BOOL labelsAreEnabled = [[preferenceDict objectForKey:KEY_SCL_SHOW_LABELS] boolValue];
106     [checkbox_labelAroundContact    setEnabled:labelsAreEnabled];
107     [checkbox_outlineLabels         setEnabled:labelsAreEnabled];
108     [slider_labelOpacity            setEnabled:labelsAreEnabled];
109     [checkbox_labelGroups           setEnabled:labelsAreEnabled];
110     [checkbox_useGradient           setEnabled:labelsAreEnabled];
111     [colorWell_labelGroupsColor         setEnabled:(labelsAreEnabled ? [[preferenceDict objectForKey:KEY_SCL_LABEL_GROUPS] boolValue] : NO)];
114 @end