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 "AIDockBehaviorPlugin.h"
18 #import "AIDockController.h"
19 #import "ESDockAlertDetailPane.h"
20 #import <AIUtilities/AIMenuAdditions.h>
21 #import <Adium/AILocalizationTextField.h>
23 @interface ESDockAlertDetailPane (PRIVATE)
24 - (NSMenuItem *)menuItemForBehavior:(AIDockBehavior)behavior withName:(NSString *)name;
25 - (NSMenu *)behaviorListMenu;
29 * @class ESDockAlertDetailPane
30 * @brief Details pane for the Bounce Dock action
32 @implementation ESDockAlertDetailPane
37 - (NSString *)nibName{
38 return @"DockBehaviorContactAlert";
42 * @brief Configure the detail view
48 [label_behavior setLocalizedString:AILocalizedString(@"Behavior","Dock behavior contact alert label")];
50 [popUp_actionDetails setMenu:[self behaviorListMenu]];
54 * @brief Configure for the action
56 - (void)configureForActionDetails:(NSDictionary *)inDetails listObject:(AIListObject *)inObject
58 int behaviorIndex = [popUp_actionDetails indexOfItemWithRepresentedObject:[inDetails objectForKey:KEY_DOCK_BEHAVIOR_TYPE]];
59 if (behaviorIndex >= 0 && behaviorIndex < [popUp_actionDetails numberOfItems]) {
60 [popUp_actionDetails selectItemAtIndex:behaviorIndex];
65 * @brief Return our current configuration
67 - (NSDictionary *)actionDetails
69 NSString *behavior = [[popUp_actionDetails selectedItem] representedObject];
72 return [NSDictionary dictionaryWithObject:behavior forKey:KEY_DOCK_BEHAVIOR_TYPE];
79 * @brief The user selected a behavior
81 - (IBAction)selectBehavior:(id)sender
83 [self detailsForHeaderChanged];
87 * @brief Builds and returns a dock behavior list menu
89 - (NSMenu *)behaviorListMenu
91 NSMenu *behaviorMenu = [[[NSMenu allocWithZone:[NSMenu menuZone]] init] autorelease];
92 AIDockBehavior behavior;
94 for (behavior = AIDockBehaviorBounceOnce; behavior <= AIDockBehaviorBounceDelay_OneMinute; behavior++) {
95 NSString *name = [[adium dockController] descriptionForBehavior:behavior];
96 [behaviorMenu addItem:[self menuItemForBehavior:behavior withName:name]];
99 [behaviorMenu setAutoenablesItems:NO];
105 * @brief Convenience behaviorListMenu method
106 * @result An NSMenuItem
108 - (NSMenuItem *)menuItemForBehavior:(AIDockBehavior)behavior withName:(NSString *)name
110 NSMenuItem *menuItem;
111 menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:name
113 action:@selector(selectBehavior:)
114 keyEquivalent:@""] autorelease];
115 [menuItem setRepresentedObject:[NSNumber numberWithInt:behavior]];