(Apple) Add toolbar buttons to the file browser to quickly browse to important locations

This commit is contained in:
meancoot 2013-11-29 16:04:37 -05:00
parent 9befaf995b
commit fb8fd8555b
2 changed files with 26 additions and 4 deletions

View File

@ -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;

View File

@ -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];
}