Use bindings to show text and icon of pulldown menu items.
This commit is contained in:
parent
4b1c435ee3
commit
5d77966aa4
|
@ -124,6 +124,8 @@
|
|||
A253F72C0A699373008EE24F /* FilterButtonSelectedRight.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7290A699373008EE24F /* FilterButtonSelectedRight.png */; };
|
||||
A256588D0A9A695400E8A03B /* MessageWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A256588B0A9A695400E8A03B /* MessageWindowController.m */; };
|
||||
A259317E0A73B2CC002F4FE7 /* Transmission Help in Resources */ = {isa = PBXBuildFile; fileRef = A259316A0A73B2CC002F4FE7 /* Transmission Help */; };
|
||||
A25E74650AF5097C006F11AE /* ExpandedPathToPathTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A25E74440AF5089E006F11AE /* ExpandedPathToPathTransformer.m */; };
|
||||
A25E74660AF5097D006F11AE /* ExpandedPathToIconTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A25E74460AF5089E006F11AE /* ExpandedPathToIconTransformer.m */; };
|
||||
A25FCDDF0A37695F002BCBBE /* PauseSelected.png in CopyFiles */ = {isa = PBXBuildFile; fileRef = A25FCDDD0A37695F002BCBBE /* PauseSelected.png */; };
|
||||
A25FCDEF0A3769A6002BCBBE /* PauseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = A25FCDDD0A37695F002BCBBE /* PauseSelected.png */; };
|
||||
A25FCDF00A3769AC002BCBBE /* ResumeSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = A25FCDDE0A37695F002BCBBE /* ResumeSelected.png */; };
|
||||
|
@ -289,7 +291,7 @@
|
|||
4DAB87C40ABE1F730081CF7E /* http.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = http.c; path = libtransmission/http.c; sourceTree = "<group>"; };
|
||||
4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = TorrentCell.m; path = macosx/TorrentCell.m; sourceTree = "<group>"; };
|
||||
4DCCBB3D09C3D71100D3CABF /* TorrentCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TorrentCell.h; path = macosx/TorrentCell.h; sourceTree = "<group>"; };
|
||||
4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
4DDBB71B09E16BF100284745 /* transmissioncli.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = transmissioncli.c; path = cli/transmissioncli.c; sourceTree = "<group>"; };
|
||||
4DDFDD20099A5D8E00189D81 /* DownloadBadge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DownloadBadge.png; path = macosx/Images/DownloadBadge.png; sourceTree = "<group>"; };
|
||||
4DDFDD21099A5D8E00189D81 /* UploadBadge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = UploadBadge.png; path = macosx/Images/UploadBadge.png; sourceTree = "<group>"; };
|
||||
|
@ -352,6 +354,10 @@
|
|||
A256588A0A9A695400E8A03B /* MessageWindowController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MessageWindowController.h; path = macosx/MessageWindowController.h; sourceTree = "<group>"; };
|
||||
A256588B0A9A695400E8A03B /* MessageWindowController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MessageWindowController.m; path = macosx/MessageWindowController.m; sourceTree = "<group>"; };
|
||||
A259316A0A73B2CC002F4FE7 /* Transmission Help */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Transmission Help"; path = "macosx/Transmission Help"; sourceTree = "<group>"; };
|
||||
A25E74440AF5089E006F11AE /* ExpandedPathToPathTransformer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ExpandedPathToPathTransformer.m; path = macosx/ExpandedPathToPathTransformer.m; sourceTree = "<group>"; };
|
||||
A25E74450AF5089E006F11AE /* ExpandedPathToPathTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ExpandedPathToPathTransformer.h; path = macosx/ExpandedPathToPathTransformer.h; sourceTree = "<group>"; };
|
||||
A25E74460AF5089E006F11AE /* ExpandedPathToIconTransformer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ExpandedPathToIconTransformer.m; path = macosx/ExpandedPathToIconTransformer.m; sourceTree = "<group>"; };
|
||||
A25E74470AF5089E006F11AE /* ExpandedPathToIconTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ExpandedPathToIconTransformer.h; path = macosx/ExpandedPathToIconTransformer.h; sourceTree = "<group>"; };
|
||||
A25FCDDD0A37695F002BCBBE /* PauseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = PauseSelected.png; path = macosx/Images/PauseSelected.png; sourceTree = "<group>"; };
|
||||
A25FCDDE0A37695F002BCBBE /* ResumeSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ResumeSelected.png; path = macosx/Images/ResumeSelected.png; sourceTree = "<group>"; };
|
||||
A260C9AB0AA3B8D700FDC1B7 /* Error.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Error.tiff; path = macosx/Images/Error.tiff; sourceTree = "<group>"; };
|
||||
|
@ -430,6 +436,10 @@
|
|||
080E96DDFE201D6D7F000001 /* Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A25E74440AF5089E006F11AE /* ExpandedPathToPathTransformer.m */,
|
||||
A25E74450AF5089E006F11AE /* ExpandedPathToPathTransformer.h */,
|
||||
A25E74460AF5089E006F11AE /* ExpandedPathToIconTransformer.m */,
|
||||
A25E74470AF5089E006F11AE /* ExpandedPathToIconTransformer.h */,
|
||||
A21F5C010AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.h */,
|
||||
A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */,
|
||||
A21F5B860AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.h */,
|
||||
|
@ -934,6 +944,8 @@
|
|||
A2AA579D0ADFCAB400CA59F6 /* PiecesImageView.m in Sources */,
|
||||
A21F5B890AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m in Sources */,
|
||||
A21F5C040AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m in Sources */,
|
||||
A25E74650AF5097C006F11AE /* ExpandedPathToPathTransformer.m in Sources */,
|
||||
A25E74660AF5097D006F11AE /* ExpandedPathToIconTransformer.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#import "UKKQueue.h"
|
||||
#import "ActionMenuSpeedToDisplayLimitTransformer.h"
|
||||
#import "ActionMenuRatioToDisplayRatioTransformer.h"
|
||||
#import "ExpandedPathToPathTransformer.h"
|
||||
#import "ExpandedPathToIconTransformer.h"
|
||||
|
||||
#import <Sparkle/Sparkle.h>
|
||||
|
||||
|
@ -77,11 +79,19 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
//set custom value transformers
|
||||
ActionMenuSpeedToDisplayLimitTransformer * limitTransformer =
|
||||
[[[ActionMenuSpeedToDisplayLimitTransformer alloc] init] autorelease];
|
||||
[NSValueTransformer setValueTransformer: limitTransformer forName: @"ActionMenuSpeedToDisplayLimitTransformer"];
|
||||
[NSValueTransformer setValueTransformer: limitTransformer forName: @"ActionMenuSpeedToDisplayLimitTransformer"];
|
||||
|
||||
ActionMenuRatioToDisplayRatioTransformer * ratioTransformer =
|
||||
[[[ActionMenuRatioToDisplayRatioTransformer alloc] init] autorelease];
|
||||
[NSValueTransformer setValueTransformer: ratioTransformer forName: @"ActionMenuRatioToDisplayRatioTransformer"];
|
||||
[[[ActionMenuRatioToDisplayRatioTransformer alloc] init] autorelease];
|
||||
[NSValueTransformer setValueTransformer: ratioTransformer forName: @"ActionMenuRatioToDisplayRatioTransformer"];
|
||||
|
||||
ExpandedPathToPathTransformer * pathTransformer =
|
||||
[[[ExpandedPathToPathTransformer alloc] init] autorelease];
|
||||
[NSValueTransformer setValueTransformer: pathTransformer forName: @"ExpandedPathToPathTransformer"];
|
||||
|
||||
ExpandedPathToIconTransformer * iconTransformer =
|
||||
[[[ExpandedPathToIconTransformer alloc] init] autorelease];
|
||||
[NSValueTransformer setValueTransformer: iconTransformer forName: @"ExpandedPathToIconTransformer"];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<key>28</key>
|
||||
<string>294 434 563 290 0 0 1152 842 </string>
|
||||
<key>41</key>
|
||||
<string>294 420 563 317 0 0 1152 842 </string>
|
||||
<string>138 348 563 317 0 0 1152 842 </string>
|
||||
<key>66</key>
|
||||
<string>294 507 563 144 0 0 1152 842 </string>
|
||||
</dict>
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface ExpandedPathToIconTransformer : NSValueTransformer
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
#import "ExpandedPathToIconTransformer.h"
|
||||
|
||||
@implementation ExpandedPathToIconTransformer
|
||||
|
||||
+ (Class) transformedValueClass
|
||||
{
|
||||
return [NSImage class];
|
||||
}
|
||||
|
||||
+ (BOOL) allowsReverseTransformation
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id) transformedValue: (id) value
|
||||
{
|
||||
if (!value)
|
||||
return nil;
|
||||
|
||||
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile: [value stringByExpandingTildeInPath]];
|
||||
[icon setScalesWhenResized: YES];
|
||||
[icon setSize: NSMakeSize(16.0, 16.0)];
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
@end
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface ExpandedPathToPathTransformer : NSValueTransformer
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
#import "ExpandedPathToPathTransformer.h"
|
||||
|
||||
@implementation ExpandedPathToPathTransformer
|
||||
|
||||
+ (Class) transformedValueClass
|
||||
{
|
||||
return [NSString class];
|
||||
}
|
||||
|
||||
+ (BOOL) allowsReverseTransformation
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id) transformedValue: (id) value
|
||||
{
|
||||
return value == nil ? nil : [value lastPathComponent];
|
||||
}
|
||||
|
||||
|
||||
@end
|
|
@ -44,10 +44,7 @@
|
|||
- (void) setPrefView: (id) sender;
|
||||
|
||||
- (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
||||
- (void) updatePopUp;
|
||||
|
||||
- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
||||
- (void) updateImportPopUp;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -114,10 +111,6 @@
|
|||
[fFolderPopUp selectItemAtIndex: DOWNLOAD_TORRENT];
|
||||
else
|
||||
[fFolderPopUp selectItemAtIndex: DOWNLOAD_ASK];
|
||||
[self updatePopUp];
|
||||
|
||||
//set auto import
|
||||
[self updateImportPopUp];
|
||||
|
||||
[self updatePortStatus];
|
||||
|
||||
|
@ -536,8 +529,6 @@
|
|||
[fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
|
||||
[fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"DownloadFolder"];
|
||||
[fDefaults setObject: @"Constant" forKey: @"DownloadChoice"];
|
||||
|
||||
[self updatePopUp];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -552,20 +543,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void) updatePopUp
|
||||
{
|
||||
//get and resize the icon
|
||||
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile:
|
||||
[[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath]];
|
||||
[icon setScalesWhenResized: YES];
|
||||
[icon setSize: NSMakeSize(16.0, 16.0)];
|
||||
|
||||
//update menu item
|
||||
NSMenuItem * menuItem = (NSMenuItem *) [fFolderPopUp itemAtIndex: 0];
|
||||
[menuItem setTitle: [[fDefaults stringForKey: @"DownloadFolder"] lastPathComponent]];
|
||||
[menuItem setImage: icon];
|
||||
}
|
||||
|
||||
- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
|
||||
{
|
||||
if (code == NSOKButton)
|
||||
|
@ -575,8 +552,6 @@
|
|||
|
||||
[fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"AutoImportDirectory"];
|
||||
|
||||
[self updateImportPopUp];
|
||||
|
||||
[sharedQueue addPath: [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
|
||||
|
@ -584,18 +559,4 @@
|
|||
[fImportFolderPopUp selectItemAtIndex: 0];
|
||||
}
|
||||
|
||||
- (void) updateImportPopUp
|
||||
{
|
||||
//get and resize the icon
|
||||
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile:
|
||||
[[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
|
||||
[icon setScalesWhenResized: YES];
|
||||
[icon setSize: NSMakeSize(16.0, 16.0)];
|
||||
|
||||
//update menu item
|
||||
NSMenuItem * menuItem = (NSMenuItem *) [fImportFolderPopUp itemAtIndex: 0];
|
||||
[menuItem setTitle: [[fDefaults stringForKey: @"AutoImportDirectory"] lastPathComponent]];
|
||||
[menuItem setImage: icon];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue