summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2023-03-18 03:28:12 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2023-03-18 04:23:43 -0400
commit0c29d1788eae87eb1cba71a70b1facd6ff995eb2 (patch)
tree41c6ee7bf65920304b850878ccbe06bbf27bbb23
parentb6d04d1ac0b52f19aea8b5efe10bbe921dbc60d2 (diff)
downloadrockbox-0c29d1788e.tar.gz
rockbox-0c29d1788e.zip
[Bugfix] open_plugin_browse() not showing plugins
rockbox_browse() overrides the desired dirfilter with global_settings.dirfilter if you aren't using one of the SHOW_ modes > NUM_FILTER_MODES (which come with their own sideeffects) add flag BROWSE_DIRFILTER to override global_settings.dirfilter with browse_context.dirfilter add ability to set tc->browse to NULL to exit dirbrowse immediately Change-Id: I2f40d394f9dc0864b2041293eda219f7436a7bf0
-rw-r--r--apps/open_plugin.c24
-rw-r--r--apps/tree.c4
-rw-r--r--apps/tree.h1
3 files changed, 24 insertions, 5 deletions
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 */