diff --git a/apps/open_plugin.c b/apps/open_plugin.c index c36a72f30e..46b6007ee2 100644 --- a/apps/open_plugin.c +++ b/apps/open_plugin.c @@ -344,8 +344,25 @@ retnhash: return hash; } +/* only displays directories and .rock files */ +static bool callback_show_item(char *name, int attr, struct tree_context *tc) +{ + (void)name; + if(attr & ATTR_DIRECTORY) + { + if (strstr(tc->currdir, PLUGIN_DIR) != NULL) + return true; + tc->browse = NULL; /* exit immediately */ + } + else if(attr & FILE_ATTR_ROCK) + { + return true; + } + return false; +} + /* open_plugin_browse() -* allows fthe user to browse for a plugin to set to a supplied key +* allows the user to browse for a plugin to set to a supplied key * if key is a lang_id that is used otherwise a hash of the key is created * for later recall of the plugin path */ @@ -361,17 +378,18 @@ void open_plugin_browse(const char *key) (key ? P2STR((unsigned char *)key):"No Key"), open_plugin_entry.name); logf("OP browse %s %s", op_entry->path, op_entry->param); - if (op_entry->path[0] == '\0') + if (op_entry->path[0] == '\0' || !file_exists(op_entry->path)) strcpy(op_entry->path, PLUGIN_DIR"/"); struct browse_context browse = { .dirfilter = SHOW_ALL, - .flags = BROWSE_SELECTONLY, + .flags = BROWSE_SELECTONLY | BROWSE_NO_CONTEXT_MENU | BROWSE_DIRFILTER, .title = str(LANG_OPEN_PLUGIN), .icon = Icon_Plugin, .root = op_entry->path, .buf = tmp_buf, .bufsize = sizeof(tmp_buf), + .callback_show_item = callback_show_item, }; if (rockbox_browse(&browse) == GO_TO_PREVIOUS) diff --git a/apps/tree.c b/apps/tree.c index 5dd88c8e9d..b9b257e093 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -652,7 +652,7 @@ static int dirbrowse(void) return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */ } - while(1) { + while(tc.browse) { bool restore = false; if (tc.dirlevel < 0) tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */ @@ -1018,7 +1018,7 @@ int rockbox_browse(struct browse_context *browse) } else { - if (dirfilter != SHOW_ID3DB) + if (dirfilter != SHOW_ID3DB && (browse->flags & BROWSE_DIRFILTER) == 0) tc.dirfilter = &global_settings.dirfilter; tc.browse = browse; strmemccpy(current, browse->root, MAX_PATH); diff --git a/apps/tree.h b/apps/tree.h index 77da18d666..d454c0f7ee 100644 --- a/apps/tree.h +++ b/apps/tree.h @@ -38,6 +38,7 @@ struct entry { #define BROWSE_SELECTONLY 0x0001 /* exit on selecting a file */ #define BROWSE_NO_CONTEXT_MENU 0x0002 /* disable context menu */ #define BROWSE_RUNFILE 0x0004 /* do ft_open() on the file instead of browsing */ +#define BROWSE_DIRFILTER 0x0080 /* override global_settings.dirfilter with browse_context.dirfilter */ #define BROWSE_SELECTED 0x0100 /* this bit is set if user selected item */