2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #import "AIAppearancePreferencesPlugin.h"
18 #import "AIAppearancePreferences.h"
19 #import <Adium/AIStatusIcons.h>
20 #import <Adium/AIServiceIcons.h>
21 #import <AIUtilities/AIDictionaryAdditions.h>
23 #define APPEARANCE_DEFAUT_PREFS @"AppearanceDefaults"
25 @implementation AIAppearancePreferencesPlugin
29 AIPreferenceController *preferenceController = [adium preferenceController];
31 //Prepare our preferences
32 [preferenceController registerDefaults:[NSDictionary dictionaryNamed:APPEARANCE_DEFAUT_PREFS
33 forClass:[self class]]
34 forGroup:PREF_GROUP_APPEARANCE];
35 [preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_APPEARANCE];
37 preferences = [[AIAppearancePreferences preferencePaneForPlugin:self] retain];
39 [[adium notificationCenter] addObserver:self
40 selector:@selector(invalidStatusSetActivated:)
41 name:AIStatusIconSetInvalidSetNotification
44 // [preferenceController registerDefaults:[NSDictionary dictionaryNamed:ICON_PACK_DEFAULT_PREFS
45 // forClass:[self class]]
46 // forGroup:PREF_GROUP_INTERFACE];
48 // [preferenceController registerDefaults:[NSDictionary dictionaryNamed:SENDING_KEY_DEFAULT_PREFS
49 // forClass:[self class]]
50 // forGroup:PREF_GROUP_GENERAL];
53 - (void)uninstallPlugin
55 [[adium preferenceController] unregisterPreferenceObserver:self];
59 * @brief Apply changed preferences
61 - (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key object:(AIListObject *)object
62 preferenceDict:(NSDictionary *)prefDict firstTime:(BOOL)firstTime
65 if(firstTime || [key isEqualToString:KEY_STATUS_ICON_PACK]){
66 NSString *path = [adium pathOfPackWithName:[prefDict objectForKey:KEY_STATUS_ICON_PACK]
67 extension:@"AdiumStatusIcons"
68 resourceFolderName:@"Status Icons"];
70 //If the preferred pack isn't found (it was probably deleted while active), use the default one
72 NSString *name = [[adium preferenceController] defaultPreferenceForKey:KEY_STATUS_ICON_PACK
73 group:PREF_GROUP_APPEARANCE
75 path = [adium pathOfPackWithName:name
76 extension:@"AdiumStatusIcons"
77 resourceFolderName:@"Status Icons"];
80 [AIStatusIcons setActiveStatusIconsFromPath:path];
84 if(firstTime || [key isEqualToString:KEY_SERVICE_ICON_PACK]){
85 NSString *path = [adium pathOfPackWithName:[prefDict objectForKey:KEY_SERVICE_ICON_PACK]
86 extension:@"AdiumServiceIcons"
87 resourceFolderName:@"Service Icons"];
89 //If the preferred pack isn't found (it was probably deleted while active), use the default one
91 NSString *name = [[adium preferenceController] defaultPreferenceForKey:KEY_SERVICE_ICON_PACK
92 group:PREF_GROUP_APPEARANCE
94 path = [adium pathOfPackWithName:name
95 extension:@"AdiumServiceIcons"
96 resourceFolderName:@"Service Icons"];
99 [AIServiceIcons setActiveServiceIconsFromPath:path];
104 * @brief An invalid status set was activated
106 * Reset to the default by clearing our preference
108 - (void)invalidStatusSetActivated:(NSNotification *)inNotification
110 [[adium preferenceController] setPreference:nil
111 forKey:KEY_STATUS_ICON_PACK
112 group:PREF_GROUP_APPEARANCE];
114 //Tell the preferences to update
115 [preferences xtrasChanged:nil];