Changeset 14218


Ignore:
Timestamp:
Jan 9, 2014, 4:23:54 PM (7 years ago)
Author:
livings124
Message:

#5576 Share Button (to iMessage, email, etc) for torrent file

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r14217 r14218  
    127127                A222E9870E6B21D9009FB003 /* BlocklistDownloaderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A222E9860E6B21D9009FB003 /* BlocklistDownloaderViewController.m */; };
    128128                A222EA7B0E6C32C4009FB003 /* BlocklistScheduler.m in Sources */ = {isa = PBXBuildFile; fileRef = A222EA7A0E6C32C4009FB003 /* BlocklistScheduler.m */; };
     129                A225A4C0187E369C00CDE823 /* ShareToolbarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = A225A4BF187E369C00CDE823 /* ShareToolbarItem.m */; };
    129130                A2265F420B5EF5F40093DDA5 /* FileNameCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2265F400B5EF5F40093DDA5 /* FileNameCell.m */; };
    130131                A226FDAC0D0CDF20005A7F71 /* libnatpmp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C7A118D0D0B2EB800B5701F /* libnatpmp.a */; };
     
    745746                A223AA810D220CEB00840069 /* nl */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nl; path = macosx/nl.lproj/MainMenu.xib; sourceTree = "<group>"; };
    746747                A223AA830D220CEB00840069 /* nl */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nl; path = macosx/nl.lproj/PrefsWindow.xib; sourceTree = "<group>"; };
     748                A225A4BE187E369C00CDE823 /* ShareToolbarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ShareToolbarItem.h; path = macosx/ShareToolbarItem.h; sourceTree = "<group>"; };
     749                A225A4BF187E369C00CDE823 /* ShareToolbarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ShareToolbarItem.m; path = macosx/ShareToolbarItem.m; sourceTree = "<group>"; };
    747750                A2265F3F0B5EF5F40093DDA5 /* FileNameCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FileNameCell.h; path = macosx/FileNameCell.h; sourceTree = "<group>"; };
    748751                A2265F400B5EF5F40093DDA5 /* FileNameCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = FileNameCell.m; path = macosx/FileNameCell.m; sourceTree = "<group>"; };
     
    13941397                                A2C89D5F0CFCBF57004CC2BC /* ButtonToolbarItem.m */,
    13951398                                A28E1DDF0CFFD8EC00E16385 /* ButtonToolbarItem.h */,
     1399                                A225A4BE187E369C00CDE823 /* ShareToolbarItem.h */,
     1400                                A225A4BF187E369C00CDE823 /* ShareToolbarItem.m */,
    13961401                                A21979890D07B78400438EA7 /* GroupToolbarItem.h */,
    13971402                                A219798A0D07B78400438EA7 /* GroupToolbarItem.m */,
     
    27202725                        buildActionMask = 2147483647;
    27212726                        files = (
     2727                                A225A4C0187E369C00CDE823 /* ShareToolbarItem.m in Sources */,
    27222728                                A2D77453154CC72B00A62B93 /* WebSeedTableView.m in Sources */,
    27232729                                8D11072D0486CEB800E47090 /* main.m in Sources */,
  • trunk/macosx/Controller.h

    r14042 r14218  
    5151} addType;
    5252
    53 @interface Controller : NSObject <GrowlApplicationBridgeDelegate, NSURLDownloadDelegate, NSUserNotificationCenterDelegate, NSPopoverDelegate, NSSoundDelegate, NSToolbarDelegate, NSWindowDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate, VDKQueueDelegate>
     53@interface Controller : NSObject <GrowlApplicationBridgeDelegate, NSURLDownloadDelegate, NSUserNotificationCenterDelegate, NSPopoverDelegate, NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSSoundDelegate, NSToolbarDelegate, NSWindowDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate, VDKQueueDelegate>
    5454{
    5555    tr_session                      * fLib;
     
    180180- (void) verifySelectedTorrents: (id) sender;
    181181- (void) verifyTorrents: (NSArray *) torrents;
     182
     183- (NSArray *)selectedTorrents;
    182184
    183185@property (retain, readonly) PrefsController * prefsController;
  • trunk/macosx/Controller.m

    r14206 r14218  
    4545#import "ButtonToolbarItem.h"
    4646#import "GroupToolbarItem.h"
     47#import "ShareToolbarItem.h"
    4748#import "ToolbarSegmentedCell.h"
    4849#import "BlocklistDownloader.h"
     
    7980#define TOOLBAR_FILTER                  @"Toolbar Toggle Filter"
    8081#define TOOLBAR_QUICKLOOK               @"Toolbar QuickLook"
     82#define TOOLBAR_SHARE                   @"Toolbar Share"
    8183
    8284typedef enum
     
    17821784   
    17831785    [self applyFilter];
     1786}
     1787
     1788- (NSArray *)selectedTorrents
     1789{
     1790    return [fTableView selectedTorrents];
    17841791}
    17851792
     
    38053812}
    38063813
     3814- (void) showToolbarShare: (id) sender
     3815{
     3816    NSParameterAssert([sender isKindOfClass:[NSButton class]]);
     3817   
     3818    NSSharingServicePicker * picker = [[NSSharingServicePicker alloc] initWithItems: [ShareToolbarItem shareTorrentURLs]];
     3819    picker.delegate = self;
     3820   
     3821    [picker showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];
     3822}
     3823
     3824- (id<NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService
     3825{
     3826    return self;
     3827}
     3828
     3829- (NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope
     3830{
     3831    return fWindow;
     3832}
     3833
    38073834- (ButtonToolbarItem *) standardToolbarButtonWithIdentifier: (NSString *) ident
    38083835{
    3809     ButtonToolbarItem * item = [[ButtonToolbarItem alloc] initWithItemIdentifier: ident];
     3836    return [self toolbarButtonWithIdentifier: ident forToolbarButtonClass: [ButtonToolbarItem class]];
     3837}
     3838
     3839- (id) toolbarButtonWithIdentifier: (NSString *) ident forToolbarButtonClass:(Class)class
     3840{
     3841    ButtonToolbarItem * item = [[class alloc] initWithItemIdentifier: ident];
    38103842   
    38113843    NSButton * button = [[NSButton alloc] init];
     
    40084040        return item;
    40094041    }
     4042    else if ([ident isEqualToString: TOOLBAR_SHARE])
     4043    {
     4044        ShareToolbarItem * item = [self toolbarButtonWithIdentifier: ident forToolbarButtonClass: [ShareToolbarItem class]];
     4045       
     4046        [item setLabel: NSLocalizedString(@"Share", "Share toolbar item -> label")];
     4047        [item setPaletteLabel: NSLocalizedString(@"Share", "Share toolbar item -> palette label")];
     4048        [item setToolTip: NSLocalizedString(@"Share torrent file", "Share toolbar item -> tooltip")];
     4049        [item setImage: [NSImage imageNamed: NSImageNameShareTemplate]];
     4050        [item setVisibilityPriority: NSToolbarItemVisibilityPriorityLow];
     4051       
     4052        NSButton *itemButton = (NSButton *)[item view];
     4053        [itemButton setTarget: self];
     4054        [itemButton setAction: @selector(showToolbarShare:)];
     4055        [itemButton sendActionOn:NSLeftMouseDownMask];
     4056       
     4057        return item;
     4058    }
    40104059    else
    40114060        return nil;
     
    40444093- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
    40454094{
    4046     return [NSArray arrayWithObjects:
    4047             TOOLBAR_CREATE, TOOLBAR_OPEN_FILE, TOOLBAR_OPEN_WEB, TOOLBAR_REMOVE,
    4048             TOOLBAR_PAUSE_RESUME_SELECTED, TOOLBAR_PAUSE_RESUME_ALL,
    4049             TOOLBAR_QUICKLOOK, TOOLBAR_FILTER, TOOLBAR_INFO,
    4050             NSToolbarSeparatorItemIdentifier,
    4051             NSToolbarSpaceItemIdentifier,
    4052             NSToolbarFlexibleSpaceItemIdentifier,
    4053             NSToolbarCustomizeToolbarItemIdentifier, nil];
     4095    NSMutableArray *items = [NSMutableArray arrayWithObjects:
     4096                             TOOLBAR_CREATE, TOOLBAR_OPEN_FILE, TOOLBAR_OPEN_WEB, TOOLBAR_REMOVE,
     4097                             TOOLBAR_PAUSE_RESUME_SELECTED, TOOLBAR_PAUSE_RESUME_ALL,
     4098                             TOOLBAR_SHARE, TOOLBAR_QUICKLOOK, TOOLBAR_FILTER, TOOLBAR_INFO,
     4099                             NSToolbarSeparatorItemIdentifier,
     4100                             NSToolbarSpaceItemIdentifier,
     4101                             NSToolbarFlexibleSpaceItemIdentifier,
     4102                             NSToolbarCustomizeToolbarItemIdentifier, nil];
     4103    if (![NSApp isOnMountainLionOrBetter]) {
     4104        [items removeObject:TOOLBAR_SHARE];
     4105    }
     4106    return items;
    40544107}
    40554108
    40564109- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar
    40574110{
    4058     return [NSArray arrayWithObjects:
    4059             TOOLBAR_CREATE, TOOLBAR_OPEN_FILE, TOOLBAR_REMOVE, NSToolbarSpaceItemIdentifier,
    4060             TOOLBAR_PAUSE_RESUME_ALL, NSToolbarFlexibleSpaceItemIdentifier,
    4061             TOOLBAR_QUICKLOOK, TOOLBAR_FILTER, TOOLBAR_INFO, nil];
     4111    NSMutableArray *items = [NSMutableArray arrayWithObjects:
     4112                             TOOLBAR_CREATE, TOOLBAR_OPEN_FILE, TOOLBAR_REMOVE, NSToolbarSpaceItemIdentifier,
     4113                             TOOLBAR_PAUSE_RESUME_ALL, NSToolbarFlexibleSpaceItemIdentifier,
     4114                             TOOLBAR_SHARE, TOOLBAR_QUICKLOOK, TOOLBAR_FILTER, TOOLBAR_INFO, nil];
     4115    if (![NSApp isOnMountainLionOrBetter]) {
     4116        [items removeObject:TOOLBAR_SHARE];
     4117    }
     4118    return items;
    40624119}
    40634120
     
    41264183        return YES;
    41274184    }
    4128 
     4185   
     4186    //enable share item
     4187    if ([ident isEqualToString: TOOLBAR_SHARE])
     4188        return [fTableView numberOfSelectedRows] > 0;
     4189   
    41294190    return YES;
    41304191}
Note: See TracChangeset for help on using the changeset viewer.