* Adium is the legal property of its developers, whose names are listed in the copyright file included * with this source distribution. * This program is free software; you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * You should have received a copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #import "ESEditStatusGroupWindowController.h" #import "AIStatusController.h" #import <Adium/AIStatusGroup.h> #import <Adium/AIStatusIcons.h> #import <AIUtilities/AIMenuAdditions.h> #import <AIUtilities/AIPopUpButtonAdditions.h> @interface ESEditStatusGroupWindowController () - ( NSMenu * ) groupWithStatusMenu ; - ( void ) sheetDidEnd: ( NSWindow * ) sheet returnCode: ( NSInteger ) returnCode contextInfo: ( void * ) contextInfo ; @implementation ESEditStatusGroupWindowController - ( void ) showOnWindow: ( NSWindow * ) parentWindow [ NSApp beginSheet : self . window modalForWindow : parentWindow didEndSelector : @selector ( sheetDidEnd : returnCode : contextInfo : ) [ self . window makeKeyAndOrderFront : nil ]; - ( id ) initWithStatusGroup: ( AIStatusGroup * ) inStatusGroup notifyingTarget: ( id ) inTarget if (( self = [ super initWithWindowNibName : @"EditStatusGroup" ])) { statusGroup = ( inStatusGroup ? [ inStatusGroup retain ] : [[ AIStatusGroup alloc ] init ]); [ popUp_groupWith setMenu : [ self groupWithStatusMenu ]]; [ popUp_groupWith selectItemWithTag : statusGroup . statusType ]; NSString * title = [ statusGroup title ]; [ textField_title setStringValue : ( title ? title : @"" )]; [ label_groupWith setAutoresizingMask : NSViewMinXMargin ]; [ label_title setLocalizedString : AILocalizedString ( @"Title:" , nil )]; [ label_groupWith setAutoresizingMask : NSViewMaxXMargin ]; [ label_title setAutoresizingMask : NSViewMinXMargin ]; [ label_groupWith setLocalizedString : AILocalizedString ( @"Group with:" , "The popup button after this lists status types; it will determine the status type with which a status group will be listed in status menus" )]; [ label_title setAutoresizingMask : NSViewMaxXMargin ]; [ button_OK setLocalizedString : AILocalizedString ( @"OK" , nil )]; [ button_cancel setLocalizedString : AILocalizedString ( @"Cancel" , nil )]; * @brief Called before the window is closed * As our window is closing, we auto-release this window controller instance. This allows our editor to function * independently without needing a separate object to retain and release it. - ( void ) windowWillClose: ( id ) sender [ super windowWillClose : sender ]; * Invoked as the sheet closes, dismiss the sheet - ( void ) sheetDidEnd: ( NSWindow * ) sheet returnCode: ( NSInteger ) returnCode contextInfo: ( void * ) contextInfo * Save changes, notify our target of the new configuration, and close the editor. - ( IBAction ) okay: ( id ) sender [ statusGroup setTitle : [ textField_title stringValue ]]; [ statusGroup setStatusType : ( AIStatusType )[[ popUp_groupWith selectedItem ] tag ]]; if ( target && [ target respondsToSelector : @selector ( finishedStatusGroupEdit : )]) { //Perform on a delay so the sheet can begin closing immediately. [ target performSelector : @selector ( finishedStatusGroupEdit : ) * Close the editor without saving changes. - ( IBAction ) cancel: ( id ) sender - ( NSMenu * ) groupWithStatusMenu NSMenu * menu = [[ NSMenu allocWithZone : [ NSMenu zone ]] init ]; menuItem = [[ NSMenuItem allocWithZone : [ NSMenu menuZone ]] initWithTitle : [ adium . statusController localizedDescriptionForCoreStatusName : STATUS_NAME_AVAILABLE ] [ menuItem setTag : AIAvailableStatusType ]; [ menuItem setImage : [ AIStatusIcons statusIconForStatusName : nil statusType : AIAvailableStatusType iconType : AIStatusIconMenu direction : AIIconNormal ]]; menuItem = [[ NSMenuItem allocWithZone : [ NSMenu menuZone ]] initWithTitle : [ adium . statusController localizedDescriptionForCoreStatusName : STATUS_NAME_AWAY ] [ menuItem setTag : AIAwayStatusType ]; [ menuItem setImage : [ AIStatusIcons statusIconForStatusName : nil statusType : AIAwayStatusType iconType : AIStatusIconMenu direction : AIIconNormal ]]; return [ menu autorelease ];