| 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 |
*/ |
|---|
| 16 |
|
|---|
| 17 |
#import "AIPreferenceWindowController.h" |
|---|
| 18 |
#import "AIPreferencePane.h" |
|---|
| 19 |
#import <Adium/SS_PrefsController.h> |
|---|
| 20 |
|
|---|
| 21 |
#import <Adium/AIPreferenceControllerProtocol.h> |
|---|
| 22 |
#import <Adium/AIAccountControllerProtocol.h> |
|---|
| 23 |
#import <Adium/AIModularPaneCategoryView.h> |
|---|
| 24 |
#import <AIUtilities/AIAlternatingRowTableView.h> |
|---|
| 25 |
#import <AIUtilities/AIImageAdditions.h> |
|---|
| 26 |
#import <AIUtilities/AIImageTextCell.h> |
|---|
| 27 |
#import <AIUtilities/AIAutoScrollView.h> |
|---|
| 28 |
#import <AIUtilities/AIViewAdditions.h> |
|---|
| 29 |
#import <AIUtilities/AIWindowAdditions.h> |
|---|
| 30 |
#import <AIUtilities/AIWindowControllerAdditions.h> |
|---|
| 31 |
|
|---|
| 32 |
//Preferences |
|---|
| 33 |
#define KEY_PREFERENCE_SELECTED_CATEGORY @"Preference Selected Category Name" |
|---|
| 34 |
|
|---|
| 35 |
//Other |
|---|
| 36 |
#define PREFERENCE_WINDOW_NIB @"PreferenceWindow" //Filename of the preference window nib |
|---|
| 37 |
#define PREFERENCE_ICON_FORMAT @"pref-%@" //Format of the preference icon filenames |
|---|
| 38 |
#define ADVANCED_PANE_HEIGHT 333+4 //Fixed advanced pane height |
|---|
| 39 |
#define ADVANCED_PANE_IDENTIFIER @"advanced" //Identifier of advanced tab |
|---|
| 40 |
|
|---|
| 41 |
//Localized strings |
|---|
| 42 |
#define PREFERENCE_WINDOW_TITLE AILocalizedString(@"Preferences",nil) |
|---|
| 43 |
|
|---|
| 44 |
static SS_PrefsController *prefsController = nil; |
|---|
| 45 |
|
|---|
| 46 |
/*! |
|---|
| 47 |
* @class AIPreferenceWindowController |
|---|
| 48 |
* @brief Adium preference window controller |
|---|
| 49 |
* |
|---|
| 50 |
* Implements the main preference window. This window pulls the preference panes registered with the preference |
|---|
| 51 |
* controller by plugins and places, organizing them by category. |
|---|
| 52 |
*/ |
|---|
| 53 |
@implementation AIPreferenceWindowController |
|---|
| 54 |
|
|---|
| 55 |
+ (SS_PrefsController *)sharedPrefsController |
|---|
| 56 |
{ |
|---|
| 57 |
if (!prefsController) { |
|---|
| 58 |
prefsController = [[SS_PrefsController preferencesWithPanes:[adium.preferenceController paneArray] |
|---|
| 59 |
delegate:self] retain]; |
|---|
| 60 |
|
|---|
| 61 |
// Set which panes are included, and their order. |
|---|
| 62 |
[prefsController setPanesOrder:[NSArray arrayWithObjects: |
|---|
| 63 |
@"Accounts", |
|---|
| 64 |
NSToolbarSeparatorItemIdentifier, |
|---|
| 65 |
@"General", @"Personal", @"Appearance", @"Messages", @"Status", @"Events", @"File Transfer", @"Advanced", nil]]; |
|---|
| 66 |
[prefsController setDebug:YES]; |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
return prefsController; |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
/*! |
|---|
| 73 |
* @brief Open the preference window |
|---|
| 74 |
*/ |
|---|
| 75 |
+ (void)openPreferenceWindow |
|---|
| 76 |
{ |
|---|
| 77 |
// Show the preferences window. |
|---|
| 78 |
[[self sharedPrefsController] showPreferencesWindow]; |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
/*! |
|---|
| 82 |
* @brief Open the preference window to a specific category |
|---|
| 83 |
*/ |
|---|
| 84 |
+ (void)openPreferenceWindowToCategoryWithIdentifier:(NSString *)identifier |
|---|
| 85 |
{ |
|---|
| 86 |
[[self sharedPrefsController] createPreferencesWindowAndDisplay:NO]; |
|---|
| 87 |
[[self sharedPrefsController] loadPreferencePaneNamed:identifier]; |
|---|
| 88 |
[[self sharedPrefsController] showPreferencesWindow]; |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
/*! |
|---|
| 92 |
* @brief Close the preference window (if it is open) |
|---|
| 93 |
*/ |
|---|
| 94 |
+ (void)closePreferenceWindow |
|---|
| 95 |
{ |
|---|
| 96 |
[prefsController destroyPreferencesWindow]; |
|---|
| 97 |
[prefsController release]; prefsController = nil; |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
+ (void)prefsWindowWillClose:(SS_PrefsController *)inPrefsController |
|---|
| 101 |
{ |
|---|
| 102 |
[prefsController release]; prefsController = nil; |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
//Panes --------------------------------------------------------------------------------------------------------------- |
|---|
| 106 |
#pragma mark Panes |
|---|
| 107 |
/*! |
|---|
| 108 |
* @brief Tabview will select a new pane; should it immediately show the loading indicator? |
|---|
| 109 |
* |
|---|
| 110 |
* We only immediately show the loading inidicator if the view is empty. |
|---|
| 111 |
*/ |
|---|
| 112 |
- (BOOL)immediatelyShowLoadingIndicatorForTabView:(NSTabView *)tabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem |
|---|
| 113 |
{ |
|---|
| 114 |
#if 0 |
|---|
| 115 |
if (tabView == tabView_category) { |
|---|
| 116 |
AIModularPaneCategoryView *view = [viewArray objectAtIndex:[tabView indexOfTabViewItem:tabViewItem]]; |
|---|
| 117 |
if ([view isEmpty]) return YES; |
|---|
| 118 |
} |
|---|
| 119 |
#endif |
|---|
| 120 |
return NO; |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
@end |
|---|