French updates
[adiumx.git] / Source / AIAppearancePreferencesPlugin.m
blob755fcdb4de7daa4282b714b4c069accb385f4ea8
1 /* 
2  * Adium is the legal property of its developers, whose names are listed in the copyright file included
3  * with this source distribution.
4  * 
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.
8  * 
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.
12  * 
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.
15  */
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
27 - (void)installPlugin
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
42                                                                          object:nil];
43         
44 //      [preferenceController registerDefaults:[NSDictionary dictionaryNamed:ICON_PACK_DEFAULT_PREFS
45 //                                    forClass:[self class]] 
46 //                                    forGroup:PREF_GROUP_INTERFACE];
47 //      
48 //      [preferenceController registerDefaults:[NSDictionary dictionaryNamed:SENDING_KEY_DEFAULT_PREFS
49 //                                    forClass:[self class]]
50 //                                    forGroup:PREF_GROUP_GENERAL];
51 }       
53 - (void)uninstallPlugin
55         [[adium preferenceController] unregisterPreferenceObserver:self];
58 /*!
59  * @brief Apply changed preferences
60  */
61 - (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key object:(AIListObject *)object
62                                         preferenceDict:(NSDictionary *)prefDict firstTime:(BOOL)firstTime
64         //Status icons
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"];
69                 
70                 //If the preferred pack isn't found (it was probably deleted while active), use the default one
71                 if(!path){
72                         NSString *name = [[adium preferenceController] defaultPreferenceForKey:KEY_STATUS_ICON_PACK
73                                                                                                                                                          group:PREF_GROUP_APPEARANCE
74                                                                                                                                                         object:nil];
75                         path = [adium pathOfPackWithName:name
76                                                                    extension:@"AdiumStatusIcons"
77                                                   resourceFolderName:@"Status Icons"];
78                 }
79                 
80                 [AIStatusIcons setActiveStatusIconsFromPath:path];
81         }
82         
83         //Service icons
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"];
88                 
89                 //If the preferred pack isn't found (it was probably deleted while active), use the default one
90                 if(!path){
91                         NSString *name = [[adium preferenceController] defaultPreferenceForKey:KEY_SERVICE_ICON_PACK
92                                                                                                                                                          group:PREF_GROUP_APPEARANCE
93                                                                                                                                                         object:nil];
94                         path = [adium pathOfPackWithName:name
95                                                                    extension:@"AdiumServiceIcons"
96                                                   resourceFolderName:@"Service Icons"];
97                 }
98                 
99                 [AIServiceIcons setActiveServiceIconsFromPath:path];
100         }
104  * @brief An invalid status set was activated
106  * Reset to the default by clearing our preference
107  */
108 - (void)invalidStatusSetActivated:(NSNotification *)inNotification
110         [[adium preferenceController] setPreference:nil
111                                                                                  forKey:KEY_STATUS_ICON_PACK
112                                                                                   group:PREF_GROUP_APPEARANCE];
113         
114         //Tell the preferences to update
115         [preferences xtrasChanged:nil];
118 @end