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 "ESContactSortConfigurationWindowController.h"
18 #import <Adium/AISortController.h>
21 * @class ESContactSortConfigurationWindowController
22 * @brief Window controller for configuring sorting options for an <tt>AISortController</tt>
24 @implementation ESContactSortConfigurationWindowController
26 static ESContactSortConfigurationWindowController *sharedSortConfigInstance = nil;
29 * @brief Show the sort configuration window for a controller
31 * @param controller The controller to configure
33 + (id)showSortConfigurationWindowForController:(AISortController *)controller
35 if ([controller configureSortWindowTitle]) {
36 if (!sharedSortConfigInstance) {
37 //Load the window controller if necessary. We retain ourselves, closing when our window closes.
38 sharedSortConfigInstance = [[self alloc] initWithWindowNibName:@"SortConfiguration"];
40 //Remove those buttons we don't want. removeFromSuperview will confuse the window, so just make them invisible.
41 NSButton *standardWindowButton = [[sharedSortConfigInstance window] standardWindowButton:NSWindowMiniaturizeButton];
42 [standardWindowButton setFrame:NSMakeRect(0,0,0,0)];
43 standardWindowButton = [[sharedSortConfigInstance window] standardWindowButton:NSWindowZoomButton];
44 [standardWindowButton setFrame:NSMakeRect(0,0,0,0)];
47 [sharedSortConfigInstance configureForController:controller];
49 [sharedSortConfigInstance showWindow:nil];
52 //Configuring for a controller which has no configuration view...
53 if (sharedSortConfigInstance) {
54 [sharedSortConfigInstance closeWindow:nil];
55 [sharedSortConfigInstance autorelease]; sharedSortConfigInstance = nil;
59 return sharedSortConfigInstance;
62 + (BOOL)sortConfigurationIsOpen
64 return (sharedSortConfigInstance != nil);
68 * @brief Configure our window and view for a passed controller
70 - (void)configureForController:(AISortController *)controller
73 [[self window] setTitle:[controller configureSortWindowTitle]];
76 NSView *configureView = [controller configureView];
78 NSSize newSize = [configureView frame].size;
80 //This will resize the view to the current window size...
81 [[self window] setContentView:configureView];
83 //...so restore the window to the size this view really wants to be
84 [[self window] setContentSize:newSize];
88 * @brief Window did load
92 [super windowDidLoad];
94 [[self window] setTitle:AILocalizedString(@"Configure Sorting","Configure Sort window title")];
97 - (void)windowWillClose:(id)sender
99 [super windowWillClose:sender];
101 [sharedSortConfigInstance autorelease]; sharedSortConfigInstance = nil;