From fb8fd8555bf1fbfc9308c742dc93e0aed5e40c2f Mon Sep 17 00:00:00 2001 From: meancoot Date: Fri, 29 Nov 2013 16:04:37 -0500 Subject: [PATCH] (Apple) Add toolbar buttons to the file browser to quickly browse to important locations --- apple/iOS/browser.m | 28 +++++++++++++++++++++++++--- apple/iOS/menu.m | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/apple/iOS/browser.m b/apple/iOS/browser.m index 0f9b100fa5..eefc2e9933 100644 --- a/apple/iOS/browser.m +++ b/apple/iOS/browser.m @@ -97,18 +97,25 @@ static void file_action(enum file_action action, NSString* source, NSString* tar { if ((self = [super initWithStyle:UITableViewStylePlain])) { - _path = path; + _path = path ? path : NSHomeDirectory(); _directoryDelegate = delegate; self = [super initWithStyle:UITableViewStylePlain]; self.hidesHeaders = YES; + // NOTE: The "App" and "Root" buttons aren't really needed for non-jailbreak devices. self.toolbarItems = @[ - [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self - action:@selector(refresh)], + [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStyleBordered target:self + action:@selector(gotoHomeDir)], + [[UIBarButtonItem alloc] initWithTitle:@"App" style:UIBarButtonItemStyleBordered target:self + action:@selector(gotoAppDir)], + [[UIBarButtonItem alloc] initWithTitle:@"Root" style:UIBarButtonItemStyleBordered target:self + action:@selector(gotoRootDir)], [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil], + [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self + action:@selector(refresh)], [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(createNewFolder)] ]; @@ -123,6 +130,21 @@ static void file_action(enum file_action action, NSString* source, NSString* tar return self; } +- (void)gotoHomeDir +{ + [self browseTo:NSHomeDirectory()]; +} + +- (void)gotoAppDir +{ + [self browseTo:NSBundle.mainBundle.bundlePath]; +} + +- (void)gotoRootDir +{ + [self browseTo:@"/"]; +} + - (void)browseTo:(NSString*)path { _path = path; diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index 01e768b223..28d6c484cf 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -251,7 +251,7 @@ - (void)wasSelectedOnTableView:(UITableView*)tableView ofController:(UIViewController*)controller { - RADirectoryList* list = [[RADirectoryList alloc] initWithPath:@"/" delegate:self]; + RADirectoryList* list = [[RADirectoryList alloc] initWithPath:nil delegate:self]; [controller.navigationController pushViewController:list animated:YES]; }