1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-23 14:40:43 +00:00

readd the custom FilterButton subclass to simplify setting the tooltip

This commit is contained in:
Mitchell Livingston 2007-11-17 15:55:23 +00:00
parent cd7de9ae16
commit 0b24911389
7 changed files with 94 additions and 12 deletions

34
FilterButton.h Normal file
View file

@ -0,0 +1,34 @@
/******************************************************************************
* $Id$
*
* Copyright (c) 2007 Transmission authors and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
@interface FilterButton : NSButton
{
int fCount;
}
- (void) setCount: (int) count;
@end

44
FilterButton.m Normal file
View file

@ -0,0 +1,44 @@
/******************************************************************************
* $Id$
*
* Copyright (c) 2007 Transmission authors and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
#import "FilterButton.h"
@implementation FilterButton
- (void) awakeFromNib
{
fCount = -1;
}
- (void) setCount: (int) count
{
if (count == fCount)
return;
fCount = count;
[self setToolTip: fCount == 1 ? NSLocalizedString(@"1 Transfer", "Filter Button -> tool tip")
: [NSString stringWithFormat: NSLocalizedString(@"%d Transfers", "Filter Bar Button -> tool tip"), fCount]];
}
@end

View file

@ -30,6 +30,7 @@
#import "DragOverlayWindow.h"
#import "Badger.h"
#import "StatusBarView.h"
#import "FilterButton.h"
#import "IPCController.h"
#import <Growl/Growl.h>
@ -62,7 +63,7 @@
IBOutlet NSTextField * fTotalDLField, * fTotalULField, * fTotalTorrentsField;
IBOutlet StatusBarView * fFilterBar;
IBOutlet NSButton * fNoFilterButton, * fDownloadFilterButton, * fSeedFilterButton, * fPauseFilterButton;
IBOutlet FilterButton * fNoFilterButton, * fDownloadFilterButton, * fSeedFilterButton, * fPauseFilterButton;
IBOutlet NSSearchField * fSearchFilterField;
IBOutlet NSMenuItem * fNextFilterItem, * fPrevFilterItem;

View file

@ -1749,15 +1749,10 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[tempTorrents setArray: fTorrents];
//set button tooltips
#warning make better
[fNoFilterButton setToolTip: [fTorrents count] == 1 ? NSLocalizedString(@"1 Transfer", "Filter Button -> tool tip")
: [NSString stringWithFormat: NSLocalizedString(@"%d Transfers", "Filter Bar Button -> tool tip"), [fTorrents count]]];
[fDownloadFilterButton setToolTip: downloading == 1 ? NSLocalizedString(@"1 Transfer", "Filter Button -> tool tip")
: [NSString stringWithFormat: NSLocalizedString(@"%d Transfers", "Filter Bar Button -> tool tip"), downloading]];
[fSeedFilterButton setToolTip: seeding == 1 ? NSLocalizedString(@"1 Transfer", "Filter Button -> tool tip")
: [NSString stringWithFormat: NSLocalizedString(@"%d Transfers", "Filter Bar Button -> tool tip"), seeding]];
[fPauseFilterButton setToolTip: paused == 1 ? NSLocalizedString(@"1 Transfer", "Filter Button -> tool tip")
: [NSString stringWithFormat: NSLocalizedString(@"%d Transfers", "Filter Bar Button -> tool tip"), paused]];
[fNoFilterButton setCount: [fTorrents count]];
[fDownloadFilterButton setCount: downloading];
[fSeedFilterButton setCount: seeding];
[fPauseFilterButton setCount: paused];
NSString * searchString = [fSearchFilterField stringValue];
if ([searchString length] > 0)

View file

@ -260,6 +260,14 @@
<key>SUPERCLASS</key>
<string>NSTableView</string>
</dict>
<dict>
<key>CLASS</key>
<string>FilterButton</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSButton</string>
</dict>
<dict>
<key>CLASS</key>
<string>ActionPopUpButton</string>

View file

@ -10,10 +10,10 @@
<integer>5</integer>
<key>IBOpenObjects</key>
<array>
<integer>302</integer>
<integer>1603</integer>
</array>
<key>IBSystem Version</key>
<string>9A581</string>
<string>9B18</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>

Binary file not shown.