Added the Add Bookmark toolbar item to the default toolbar. Refs #8772
[adiumx.git] / Source / ESDockAlertDetailPane.m
blob492a698cb3b4769f1d2fb10a9a2899c22089de3c
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 "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;
26 @end
28 /*!
29  * @class ESDockAlertDetailPane
30  * @brief Details pane for the Bounce Dock action
31  */
32 @implementation ESDockAlertDetailPane
34 /*!
35  * @brief Nib name
36  */
37 - (NSString *)nibName{
38     return @"DockBehaviorContactAlert";    
41 /*!
42  * @brief Configure the detail view
43  */
44 - (void)viewDidLoad
46         [super viewDidLoad];
48         [label_behavior setLocalizedString:AILocalizedString(@"Behavior","Dock behavior contact alert label")];
50     [popUp_actionDetails setMenu:[self behaviorListMenu]];
53 /*!
54  * @brief Configure for the action
55  */
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];        
61         }
64 /*!
65  * @brief Return our current configuration
66  */
67 - (NSDictionary *)actionDetails
69         NSString        *behavior = [[popUp_actionDetails selectedItem] representedObject];
70         
71         if (behavior) {
72                 return [NSDictionary dictionaryWithObject:behavior forKey:KEY_DOCK_BEHAVIOR_TYPE];
73         } else {
74                 return nil;
75         }       
78 /*!
79  * @brief The user selected a behavior
80  */
81 - (IBAction)selectBehavior:(id)sender
83         [self detailsForHeaderChanged];
86 /*!
87  * @brief Builds and returns a dock behavior list menu
88  */
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]];
97         }
98     
99     [behaviorMenu setAutoenablesItems:NO];
100     
101     return behaviorMenu;
105  * @brief Convenience behaviorListMenu method
106  * @result An NSMenuItem
107  */
108 - (NSMenuItem *)menuItemForBehavior:(AIDockBehavior)behavior withName:(NSString *)name
110     NSMenuItem          *menuItem;
111     menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:name
112                                                                                                                                          target:self
113                                                                                                                                          action:@selector(selectBehavior:)
114                                                                                                                           keyEquivalent:@""] autorelease];
115     [menuItem setRepresentedObject:[NSNumber numberWithInt:behavior]];
116     
117     return menuItem;
121 @end