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 "ESPanelApplescriptDetailPane.h"
18 #import "ESApplescriptContactAlertPlugin.h"
19 #import <Adium/AILocalizationTextField.h>
20 #import <Adium/AILocalizationButton.h>
21 #import <AIUtilities/AIStringAdditions.h>
23 @interface ESPanelApplescriptDetailPane (PRIVATE)
24 - (void)setScriptPath:(NSString *)inPath;
28 * @class ESPanelApplescriptDetailPane
29 * @brief Details pane for the Run Applescript action
31 @implementation ESPanelApplescriptDetailPane
36 - (NSString *)nibName{
37 return @"ApplescriptContactAlert";
41 * @brief Configure the details view
49 [label_applescript setLocalizedString:AILocalizedString(@"AppleScript:",nil)];
50 [button_browse setLocalizedString:[AILocalizedString(@"Browse",nil) stringByAppendingEllipsis]];
54 * @brief View will close
58 [scriptPath release]; scriptPath = nil;
62 * @brief Called only when the pane is displayed a result of its action being selected
64 * @param inDetails A previously created details dicionary, or nil if none exists
65 * @param inObject The object for which to configure
67 - (void)configureForActionDetails:(NSDictionary *)inDetails listObject:(AIListObject *)inObject
69 [self setScriptPath:[inDetails objectForKey:KEY_APPLESCRIPT_TO_RUN]];
73 * @brief Return our current configuration
75 - (NSDictionary *)actionDetails
78 [NSDictionary dictionaryWithObject:scriptPath forKey:KEY_APPLESCRIPT_TO_RUN] :
83 * @brief Choose the applescript to run
85 - (IBAction)chooseFile:(id)sender
87 NSOpenPanel *openPanel = [NSOpenPanel openPanel];
88 [openPanel setTitle:AILocalizedString(@"Select an AppleScript",nil)];
90 if ([openPanel runModalForDirectory:nil
92 types:[NSArray arrayWithObjects:@"applescript",@"scptd",@"scpt",nil]] == NSOKButton) {
93 [self setScriptPath:[openPanel filename]];
98 * @brief Set the path to the applescript
100 * This also updates our display
102 * @param inPath A full path to an applescript
104 - (void)setScriptPath:(NSString *)inPath
106 NSString *scriptName;
108 [scriptPath release];
109 scriptPath = [inPath retain];
111 //Update the display for this name
112 scriptName = [[scriptPath lastPathComponent] stringByDeletingPathExtension];
113 [textField_scriptName setStringValue:(scriptName ? scriptName : @"")];
115 [self detailsForHeaderChanged];