Prevent sending 0-byte files. Fixes #8711.
[adiumx.git] / Source / AIStandardToolbarItemsPlugin.m
blobc078aaf09b0da0ed8cae2eea90d24d58fe1f08ff
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 <Adium/AIChatControllerProtocol.h>
18 #import <Adium/AIContactControllerProtocol.h>
19 #import <Adium/AIInterfaceControllerProtocol.h>
20 #import "AIStandardToolbarItemsPlugin.h"
21 #import <Adium/AIToolbarControllerProtocol.h>
22 #import <AIUtilities/AIToolbarUtilities.h>
23 #import <AIUtilities/AIImageAdditions.h>
24 #import <Adium/AIListContact.h>
25 #import <Adium/AIListObject.h>
27 #define MESSAGE AILocalizedString(@"Message", nil)
29 /*!
30  * @class AIStandardToolbarItemsPlugin
31  * @brief Component to provide general-use toolbar items
32  *
33  * Just provides a Source/Destination picker toolbar item at present.
34  */
35 @implementation AIStandardToolbarItemsPlugin
37 /*!
38  * @brief Install
39  */
40 - (void)installPlugin
42     //New Message
43     NSToolbarItem   *toolbarItem = 
44         [AIToolbarUtilities toolbarItemWithIdentifier:@"SourceDestination"
45                                                                                         label:AILocalizedString(@"Source/Destination", nil)
46                                                                          paletteLabel:AILocalizedString(@"Change Source or Destination", nil)
47                                                                                   toolTip:AILocalizedString(@"If multiple accounts can send to this contact or this is a combined contact, change the source and/or destination of this chat", nil)
48                                                                                    target:self
49                                                                   settingSelector:@selector(setImage:)
50                                                                           itemContent:[NSImage imageNamed:@"message" forClass:[self class] loadLazily:YES]
51                                                                                    action:@selector(showSourceDestinationPicker:)
52                                                                                          menu:nil];
53         [[adium toolbarController] registerToolbarItem:toolbarItem forToolbarType:@"MessageWindow"];
56 /*!
57  * @brief New chat with the selected list object
58  */
59 - (IBAction)showSourceDestinationPicker:(NSToolbarItem *)toolbarItem
61     AIListObject        *object = [[adium interfaceController] selectedListObject];
63     if ([object isKindOfClass:[AIListContact class]]) {
64                 AIChat  *chat = [[adium chatController] openChatWithContact:(AIListContact *)object
65                                                                                                  onPreferredAccount:YES];
66         [[adium interfaceController] setActiveChat:chat];
67     }
68         
71 @end