Skip to content

Commit

Permalink
Plugins tree browsing restriction
Browse files Browse the repository at this point in the history
Don't leave the subtree and show only appropriate files.
  • Loading branch information
poretsky committed Feb 5, 2024
1 parent 9926249 commit c745dc7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions apps/filetree.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ int ft_load(struct tree_context* c, const char* tempdir)
file_attr != FILE_ATTR_M3U) ||
((*c->dirfilter == SHOW_MUSIC && file_attr != FILE_ATTR_AUDIO) &&
file_attr != FILE_ATTR_M3U) ||
(*c->dirfilter == SHOW_PLUGINS_TREE &&
(dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_ROCK &&
(dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LUA &&
(dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_OPX) ||
(*c->dirfilter == SHOW_SUPPORTED && !filetype_supported(dptr->attr)))) ||
(*c->dirfilter == SHOW_WPS && file_attr != FILE_ATTR_WPS) ||
(*c->dirfilter == SHOW_FONT && file_attr != FILE_ATTR_FONT) ||
Expand Down
2 changes: 1 addition & 1 deletion apps/open_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void open_plugin_browse(const char *key)
strcpy(op_entry->path, PLUGIN_DIR"/");

struct browse_context browse = {
.dirfilter = SHOW_ALL,
.dirfilter = SHOW_PLUGINS_TREE,
.flags = BROWSE_SELECTONLY | BROWSE_NO_CONTEXT_MENU | BROWSE_DIRFILTER,
.title = str(LANG_OPEN_PLUGIN),
.icon = Icon_Plugin,
Expand Down
2 changes: 1 addition & 1 deletion apps/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ enum
enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, SHOW_ID3DB,
NUM_FILTER_MODES,
SHOW_WPS, SHOW_RWPS, SHOW_FMS, SHOW_RFMS, SHOW_SBS, SHOW_RSBS, SHOW_FMR, SHOW_CFG,
SHOW_LNG, SHOW_MOD, SHOW_FONT, SHOW_PLUGINS, SHOW_M3U};
SHOW_LNG, SHOW_MOD, SHOW_FONT, SHOW_PLUGINS, SHOW_M3U, SHOW_PLUGINS_TREE};

/* file and dir sort options */
enum { SORT_ALPHA, SORT_DATE, SORT_DATE_REVERSED, SORT_TYPE, /* available as settings */
Expand Down
9 changes: 6 additions & 3 deletions apps/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ int rockbox_browse(struct browse_context *browse)
}
else
{
if (*tc.dirfilter >= NUM_FILTER_MODES)
if (*tc.dirfilter >= NUM_FILTER_MODES && *tc.dirfilter != SHOW_PLUGINS_TREE)
{
int last_context;
/* don't reset if its the same browse already loaded */
Expand Down Expand Up @@ -1057,10 +1057,13 @@ int rockbox_browse(struct browse_context *browse)
}
else
{
if (dirfilter != SHOW_ID3DB && (browse->flags & BROWSE_DIRFILTER) == 0)
tc.dirfilter = &global_settings.dirfilter;
tc.browse = browse;
set_current_file(browse->root);
if (dirfilter == SHOW_PLUGINS_TREE)
tc.dirlevel = 0;
else if (dirfilter != SHOW_ID3DB)
tc.dirfilter = &global_settings.dirfilter;

if (browse->flags&BROWSE_RUNFILE)
ret_val = ft_enter(&tc);
else
Expand Down

0 comments on commit c745dc7

Please sign in to comment.