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 "SMContactListShowBehaviorPlugin.h"
18 #import "SMContactListShowDetailsPane.h"
19 #import <Adium/AIContactAlertsControllerProtocol.h>
20 #import "AICoreComponentLoader.h"
21 #import "AISCLViewPlugin.h"
22 #import "AIListWindowController.h"
23 #import <AIUtilities/AIImageAdditions.h>
25 #define SHOW_CONTACT_LIST_BEHAVIOR_ALERT_SHORT AILocalizedString(@"Show the contact list window",nil)
26 #define SHOW_CONTACT_LIST_BEHAVIOR_ALERT_LONG AILocalizedString(@"Show the contact list window for %.1f seconds",nil)
29 * @class SMContactListShowBehaviorPlugin
30 * @brief Show hidden contact list action component
32 @implementation SMContactListShowBehaviorPlugin
39 //Install our contact alert
40 [[adium contactAlertsController] registerActionID:SHOW_CONTACT_LIST_BEHAVIOR_ALERT_IDENTIFIER withHandler:self];
44 * @brief Short description
45 * @result A short localized description of the action
47 - (NSString *)shortDescriptionForActionID:(NSString *)actionID
49 return SHOW_CONTACT_LIST_BEHAVIOR_ALERT_SHORT;
53 * @brief Long description
54 * @result A longer localized description of the action which should take into account the details dictionary as appropraite.
56 - (NSString *)longDescriptionForActionID:(NSString *)actionID withDetails:(NSDictionary *)details
58 double seconds = [[details objectForKey:KEY_SECONDS_TO_SHOW_LIST] doubleValue];
59 return [NSString stringWithFormat:SHOW_CONTACT_LIST_BEHAVIOR_ALERT_LONG, seconds];
65 - (NSImage *)imageForActionID:(NSString *)actionID
67 return [NSImage imageNamed:@"pref-contactList" forClass:[self class]];
72 * @result An <tt>AIModularPane</tt> to use for configuring this action, or nil if no configuration is possible.
74 - (AIModularPane *)detailsPaneForActionID:(NSString *)actionID
76 return [SMContactListShowDetailsPane actionDetailsPane];
80 * @brief Perform an action
82 * Bounce the dock icon
84 * @param actionID The ID of the action to perform
85 * @param listObject The listObject associated with the event triggering the action. It may be nil
86 * @param details If set by the details pane when the action was created, the details dictionary for this particular action
87 * @param eventID The eventID which triggered this action
88 * @param userInfo Additional information associated with the event; userInfo's type will vary with the actionID.
90 - (BOOL)performActionID:(NSString *)actionID forListObject:(AIListObject *)listObject withDetails:(NSDictionary *)details triggeringEventID:(NSString *)eventID userInfo:(id)userInfo
92 NSTimeInterval secondsToShow = [[details objectForKey:KEY_SECONDS_TO_SHOW_LIST] doubleValue];
93 AISCLViewPlugin *contactListViewPlugin = (AISCLViewPlugin *)[[adium componentLoader] pluginWithClassName:@"AISCLViewPlugin"];
94 AIListWindowController *windowController = [contactListViewPlugin contactListWindowController];
96 [windowController setPreventHiding:YES];
98 if ([windowController windowShouldHideOnDeactivate]) {
99 [[windowController window] setHidesOnDeactivate:NO];
100 [[windowController window] orderFront:self];
102 [windowController slideWindowOnScreen];
105 [NSObject cancelPreviousPerformRequestsWithTarget:self
106 selector:@selector(hideContactList:)
108 [self performSelector:@selector(hideContactList:)
110 afterDelay:secondsToShow];
117 * @brief Show the contact list after the time specified has elapsed
119 - (void)hideContactList:(NSTimer *)timer {
120 AISCLViewPlugin *contactListViewPlugin = (AISCLViewPlugin *)[[adium componentLoader] pluginWithClassName:@"AISCLViewPlugin"];
121 AIListWindowController *windowController = [contactListViewPlugin contactListWindowController];
123 [windowController setPreventHiding:NO];
125 if ([windowController windowShouldHideOnDeactivate] && ![NSApp isActive]) {
126 [[windowController window] orderOut:self];
128 } else if ([windowController shouldSlideWindowOffScreen]) {
129 [windowController slideWindowOffScreenEdges:[windowController slidableEdgesAdjacentToWindow]];
135 * @brief Allow multiple actions?
137 * If this method returns YES, every one of this action associated with the triggering event will be executed.
138 * If this method returns NO, only the first will be.
140 * Don't allow multiple dock actions to occur. The contact list can only show itself once.
142 - (BOOL)allowMultipleActionsWithID:(NSString *)actionID