Automatically disable the Delete button in the Xtras Manager if no item is selected...
[adiumx.git] / Source / ESContactSortConfigurationWindowController.m
blobb5f8b7b3ea513cad281f840b776dc78078558662
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 "ESContactSortConfigurationWindowController.h"
18 #import <Adium/AISortController.h>
20 /*!
21  * @class ESContactSortConfigurationWindowController
22  * @brief Window controller for configuring sorting options for an <tt>AISortController</tt>
23  */
24 @implementation ESContactSortConfigurationWindowController
26 static ESContactSortConfigurationWindowController   *sharedSortConfigInstance = nil;
28 /*!
29  * @brief Show the sort configuration window for a controller
30  *
31  * @param controller The controller to configure
32  */
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"];
39                         
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)];
45                 }
46                 
47                 [sharedSortConfigInstance configureForController:controller];
48                 
49                 [sharedSortConfigInstance showWindow:nil];
51         } else {
52                 //Configuring for a controller which has no configuration view...
53                 if (sharedSortConfigInstance) {
54                         [sharedSortConfigInstance closeWindow:nil];
55                         [sharedSortConfigInstance autorelease]; sharedSortConfigInstance = nil;
56                 }
57         }
58         
59         return sharedSortConfigInstance;
62 + (BOOL)sortConfigurationIsOpen
64         return (sharedSortConfigInstance != nil);
67 /*!
68  * @brief Configure our window and view for a passed controller
69  */
70 - (void)configureForController:(AISortController *)controller
72         //Configure the title
73         [[self window] setTitle:[controller configureSortWindowTitle]];
74         
75         //Configure the view
76         NSView  *configureView = [controller configureView];
78         NSSize newSize = [configureView frame].size;
79         
80         //This will resize the view to the current window size...
81         [[self window] setContentView:configureView];
82         
83         //...so restore the window to the size this view really wants to be
84         [[self window] setContentSize:newSize];
87 /*!
88  * @brief Window did load
89  */
90 - (void)windowDidLoad
92         [super windowDidLoad];
93         
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;
104 @end