diff options
author | Jocelyn Turcotte <jturcotte@woboq.com> | 2017-07-04 18:34:51 +0300 |
---|---|---|
committer | Christian Kamm <mail@ckamm.de> | 2017-07-07 11:49:51 +0300 |
commit | b6db9789ee2919b21d9080e99e7563cbc7821046 (patch) | |
tree | 8d0bb46dff4e741b7a9e46aaf2cfe78705dc0fe1 /shell_integration/MacOSX | |
parent | 7a4daf799aa8f256f2f5c9fd492993fc51de93fe (diff) |
shell/macos: Use a submenu to include private link actions
Diffstat (limited to 'shell_integration/MacOSX')
4 files changed, 47 insertions, 15 deletions
diff --git a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.h b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.h index a1356045b..67a436094 100644 --- a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.h +++ b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.h @@ -22,6 +22,7 @@ SyncClientProxy *_syncClientProxy; NSMutableSet *_registeredDirectories; NSString *_shareMenuTitle; + NSMutableDictionary *_strings; } @end diff --git a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m index 065be2e2f..0591824bb 100644 --- a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m +++ b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m @@ -59,7 +59,7 @@ _syncClientProxy = [[SyncClientProxy alloc] initWithDelegate:self serverName:serverName]; _registeredDirectories = [[NSMutableSet alloc] init]; - _shareMenuTitle = nil; + _strings = [[NSMutableDictionary alloc] init]; [_syncClientProxy start]; return self; @@ -101,11 +101,21 @@ } }]; - if (_shareMenuTitle && !onlyRootsSelected) { - NSMenu *menu = [[NSMenu alloc] initWithTitle:@""]; - NSMenuItem *item = [menu addItemWithTitle:_shareMenuTitle action:@selector(shareMenuAction:) keyEquivalent:@"title"]; - item.image = [[NSBundle mainBundle] imageForResource:@"app.icns"]; - + id contextMenuTitle = [_strings objectForKey:@"CONTEXT_MENU_TITLE"]; + id shareTitle = [_strings objectForKey:@"SHARE_MENU_TITLE"]; + id copyLinkTitle = [_strings objectForKey:@"COPY_PRIVATE_LINK_TITLE"]; + id emailLinkTitle = [_strings objectForKey:@"EMAIL_PRIVATE_LINK_TITLE"]; + if (contextMenuTitle && !onlyRootsSelected) { + NSMenu *menu = [[NSMenu alloc] initWithTitle:@""]; + NSMenu *subMenu = [[NSMenu alloc] initWithTitle:@""]; + NSMenuItem *subMenuItem = [menu addItemWithTitle:contextMenuTitle action:nil keyEquivalent:@""]; + subMenuItem.submenu = subMenu; + subMenuItem.image = [[NSBundle mainBundle] imageForResource:@"app.icns"]; + + [subMenu addItemWithTitle:shareTitle action:@selector(shareMenuAction:) keyEquivalent:@""]; + [subMenu addItemWithTitle:copyLinkTitle action:@selector(copyLinkMenuAction:) keyEquivalent:@""]; + [subMenu addItemWithTitle:emailLinkTitle action:@selector(emailLinkMenuAction:) keyEquivalent:@""]; + return menu; } return nil; @@ -114,13 +124,33 @@ - (IBAction)shareMenuAction:(id)sender { NSArray* items = [[FIFinderSyncController defaultController] selectedItemURLs]; - + [items enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { NSString* normalizedPath = [[obj path] decomposedStringWithCanonicalMapping]; [_syncClientProxy askOnSocket:normalizedPath query:@"SHARE"]; }]; } +- (IBAction)copyLinkMenuAction:(id)sender +{ + NSArray* items = [[FIFinderSyncController defaultController] selectedItemURLs]; + + [items enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { + NSString* normalizedPath = [[obj path] decomposedStringWithCanonicalMapping]; + [_syncClientProxy askOnSocket:normalizedPath query:@"COPY_PRIVATE_LINK"]; + }]; +} + +- (IBAction)emailLinkMenuAction:(id)sender +{ + NSArray* items = [[FIFinderSyncController defaultController] selectedItemURLs]; + + [items enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { + NSString* normalizedPath = [[obj path] decomposedStringWithCanonicalMapping]; + [_syncClientProxy askOnSocket:normalizedPath query:@"EMAIL_PRIVATE_LINK"]; + }]; +} + #pragma mark - SyncClientProxyDelegate implementation - (void)setResultForPath:(NSString*)path result:(NSString*)result @@ -146,15 +176,14 @@ [FIFinderSyncController defaultController].directoryURLs = _registeredDirectories; } -- (void)setShareMenuTitle:(NSString*)title +- (void)setString:(NSString*)key value:(NSString*)value { - _shareMenuTitle = title; + [_strings setObject:value forKey:key]; } - (void)connectionDidDie { - _shareMenuTitle = nil; - + [_strings removeAllObjects]; [_registeredDirectories removeAllObjects]; // For some reason the FIFinderSync cache doesn't seem to be cleared for the root item when // we reset the directoryURLs (seen on macOS 10.12 at least). diff --git a/shell_integration/MacOSX/common/SyncClientProxy.h b/shell_integration/MacOSX/common/SyncClientProxy.h index aaaa294b6..8f9633416 100644 --- a/shell_integration/MacOSX/common/SyncClientProxy.h +++ b/shell_integration/MacOSX/common/SyncClientProxy.h @@ -20,7 +20,7 @@ - (void)reFetchFileNameCacheForPath:(NSString*)path; - (void)registerPath:(NSString*)path; - (void)unregisterPath:(NSString*)path; -- (void)setShareMenuTitle:(NSString*)title; +- (void)setString:(NSString*)key value:(NSString*)value; - (void)connectionDidDie; @end diff --git a/shell_integration/MacOSX/common/SyncClientProxy.m b/shell_integration/MacOSX/common/SyncClientProxy.m index 1e89ea676..b7b64571f 100644 --- a/shell_integration/MacOSX/common/SyncClientProxy.m +++ b/shell_integration/MacOSX/common/SyncClientProxy.m @@ -73,7 +73,7 @@ [_remoteEnd setProtocolForProxy:@protocol(ChannelProtocol)]; // Everything is set up, start querying - [self askOnSocket:@"" query:@"SHARE_MENU_TITLE"]; + [self askOnSocket:@"" query:@"GET_STRINGS"]; } - (void)scheduleRetry @@ -119,8 +119,10 @@ } else if( [[chunks objectAtIndex:0 ] isEqualToString:@"UNREGISTER_PATH"] ) { NSString *path = [chunks objectAtIndex:1]; [_delegate unregisterPath:path]; - } else if( [[chunks objectAtIndex:0 ] isEqualToString:@"SHARE_MENU_TITLE"] ) { - [_delegate setShareMenuTitle:[chunks objectAtIndex:1]]; + } else if( [[chunks objectAtIndex:0 ] isEqualToString:@"GET_STRINGS"] ) { + // BEGIN and END messages, do nothing. + } else if( [[chunks objectAtIndex:0 ] isEqualToString:@"STRING"] ) { + [_delegate setString:[chunks objectAtIndex:1] value:[chunks objectAtIndex:2]]; } else { NSLog(@"SyncState: Unknown command %@", [chunks objectAtIndex:0]); } |