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 "AINewGroupWindowController.h"
18 #import "AIContactController.h"
20 #define ADD_GROUP_PROMPT_NIB @"AddGroup"
23 * @class AINewGroupWindowController
24 * @brief Window controller for adding groups
26 @implementation AINewGroupWindowController
29 * @brief Prompt for a new group.
31 * @param parentWindow Window on which to show as a sheet. Pass nil for a panel prompt.
33 + (AINewGroupWindowController *)promptForNewGroupOnWindow:(NSWindow *)parentWindow
35 AINewGroupWindowController *newGroupWindowController;
37 newGroupWindowController = [[self alloc] initWithWindowNibName:ADD_GROUP_PROMPT_NIB];
40 [NSApp beginSheet:[newGroupWindowController window]
41 modalForWindow:parentWindow
42 modalDelegate:newGroupWindowController
43 didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
46 [newGroupWindowController showWindow:nil];
49 return newGroupWindowController;
53 * @brief Setup the window before it is displayed
57 NSWindow *window = [self window];
58 [window setTitle:AILocalizedString(@"Add Group",nil)];
60 [label_groupName setLocalizedString:AILocalizedString(@"Group Name:",nil)];
61 [button_add setLocalizedString:AILocalizedString(@"Add",nil)];
62 [button_cancel setLocalizedString:AILocalizedString(@"Cancel",nil)];
68 * @brief Called as the user list edit sheet closes, dismisses the sheet
70 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
72 [[adium notificationCenter] postNotificationName:@"NewGroupWindowControllerDidEnd"
80 - (IBAction)cancel:(id)sender
82 if([[self window] isSheet]){
83 [NSApp endSheet:[self window]];
85 [self closeWindow:nil];
90 * @brief UID of the new group
92 - (NSString *)newGroupUID
94 return [[[textField_groupName stringValue] copy] autorelease];
98 * @brief Add the group
100 - (IBAction)addGroup:(id)sender
102 AIListGroup *group = [[adium contactController] groupWithUID:[self newGroupUID]];
104 if([[self window] isSheet]){
105 [NSApp endSheet:[self window]];
107 [self closeWindow:nil];