pt_BR strings updates
[adiumx.git] / Source / ESPanelApplescriptDetailPane.m
blob3df98d1d2e74163dce7f5ffce6433958db386713
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 "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;
25 @end
27 /*!
28  * @class ESPanelApplescriptDetailPane
29  * @brief Details pane for the Run Applescript action
30  */
31 @implementation ESPanelApplescriptDetailPane
33 /*!
34  * @brief Nib name
35  */
36 - (NSString *)nibName{
37     return @"ApplescriptContactAlert";    
40 /*!
41  * @brief Configure the details view
42  */
43 - (void)viewDidLoad
45         [super viewDidLoad];
47         scriptPath = nil;
48         
49         [label_applescript setLocalizedString:AILocalizedString(@"AppleScript:",nil)];
50         [button_browse setLocalizedString:[AILocalizedString(@"Browse",nil) stringByAppendingEllipsis]];
53 /*!
54  * @brief View will close
55  */
56 - (void)viewWillClose
58         [scriptPath release]; scriptPath = nil;
61 /*!
62  * @brief Called only when the pane is displayed a result of its action being selected
63  *
64  * @param inDetails A previously created details dicionary, or nil if none exists
65  * @param inObject The object for which to configure
66  */
67 - (void)configureForActionDetails:(NSDictionary *)inDetails listObject:(AIListObject *)inObject
69         [self setScriptPath:[inDetails objectForKey:KEY_APPLESCRIPT_TO_RUN]];
72 /*!
73  * @brief Return our current configuration
74  */
75 - (NSDictionary *)actionDetails
77         return (scriptPath ?
78                    [NSDictionary dictionaryWithObject:scriptPath forKey:KEY_APPLESCRIPT_TO_RUN] :
79                    nil);
82 /*!
83  * @brief Choose the applescript to run
84  */
85 - (IBAction)chooseFile:(id)sender
87         NSOpenPanel *openPanel = [NSOpenPanel openPanel];
88         [openPanel setTitle:AILocalizedString(@"Select an AppleScript",nil)];
89         
90         if ([openPanel runModalForDirectory:nil
91                                                                    file:nil
92                                                                   types:[NSArray arrayWithObjects:@"applescript",@"scptd",@"scpt",nil]] == NSOKButton) {
93                 [self setScriptPath:[openPanel filename]];
94         }
97 /*!
98  * @brief Set the path to the applescript
99  *
100  * This also updates our display
102  * @param inPath A full path to an applescript
103  */
104 - (void)setScriptPath:(NSString *)inPath
106         NSString        *scriptName;
107         
108         [scriptPath release];
109         scriptPath = [inPath retain];
110         
111         //Update the display for this name
112         scriptName = [[scriptPath lastPathComponent] stringByDeletingPathExtension];
113         [textField_scriptName setStringValue:(scriptName ? scriptName : @"")];
114         
115         [self detailsForHeaderChanged];
118 @end