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 <Adium/AIContactControllerProtocol.h>
19 #import <Adium/AIListGroup.h>
21 #define ADD_GROUP_PROMPT_NIB @"AddGroup"
24 * @class AINewGroupWindowController
25 * @brief Window controller for adding groups
27 @implementation AINewGroupWindowController
30 * @brief Prompt for a new group.
32 * @param parentWindow Window on which to show as a sheet. Pass nil for a panel prompt.
34 + (AINewGroupWindowController *)promptForNewGroupOnWindow:(NSWindow *)parentWindow
36 AINewGroupWindowController *newGroupWindowController;
38 newGroupWindowController = [[self alloc] initWithWindowNibName:ADD_GROUP_PROMPT_NIB];
41 [NSApp beginSheet:[newGroupWindowController window]
42 modalForWindow:parentWindow
43 modalDelegate:newGroupWindowController
44 didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
47 [newGroupWindowController showWindow:nil];
50 return newGroupWindowController;
54 * @brief Setup the window before it is displayed
58 NSWindow *window = [self window];
60 [window setTitle:AILocalizedString(@"Add Group",nil)];
62 [label_groupName setLocalizedString:AILocalizedString(@"Enter group name:",nil)];
63 [button_add setLocalizedString:AILocalizedString(@"Add",nil)];
64 [button_cancel setLocalizedString:AILocalizedString(@"Cancel",nil)];
70 * @brief Called as the user list edit sheet closes, dismisses the sheet
72 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
74 [[adium notificationCenter] postNotificationName:@"NewGroupWindowControllerDidEnd"
82 - (IBAction)cancel:(id)sender
84 [self closeWindow:nil];
88 * @brief UID of the new group
90 - (NSString *)newGroupUID
92 return [[[textField_groupName stringValue] copy] autorelease];
96 * @brief Add the group
98 - (IBAction)addGroup:(id)sender
100 AIListGroup *group = [[adium contactController] groupWithUID:[self newGroupUID]];
102 //Force this new group to be visible. Obviously the user created it for a reason, so let's keep
103 //it visible and give them time to stick something inside.
104 [group setStatusObject:[NSNumber numberWithBool:YES] forKey:@"New Object" notify:YES];
106 [self closeWindow:nil];