summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-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:
344 return hash; 344 return hash;
345} 345}
346 346
347/* only displays directories and .rock files */
348static bool callback_show_item(char *name, int attr, struct tree_context *tc)
349{
350 (void)name;
351 if(attr & ATTR_DIRECTORY)
352 {
353 if (strstr(tc->currdir, PLUGIN_DIR) != NULL)
354 return true;
355 tc->browse = NULL; /* exit immediately */
356 }
357 else if(attr & FILE_ATTR_ROCK)
358 {
359 return true;
360 }
361 return false;
362}
363
347/* open_plugin_browse() 364/* open_plugin_browse()
348* allows fthe user to browse for a plugin to set to a supplied key 365* allows the user to browse for a plugin to set to a supplied key
349* if key is a lang_id that is used otherwise a hash of the key is created 366* if key is a lang_id that is used otherwise a hash of the key is created
350* for later recall of the plugin path 367* for later recall of the plugin path
351*/ 368*/
@@ -361,17 +378,18 @@ void open_plugin_browse(const char *key)
361 (key ? P2STR((unsigned char *)key):"No Key"), open_plugin_entry.name); 378 (key ? P2STR((unsigned char *)key):"No Key"), open_plugin_entry.name);
362 logf("OP browse %s %s", op_entry->path, op_entry->param); 379 logf("OP browse %s %s", op_entry->path, op_entry->param);
363 380
364 if (op_entry->path[0] == '\0') 381 if (op_entry->path[0] == '\0' || !file_exists(op_entry->path))
365 strcpy(op_entry->path, PLUGIN_DIR"/"); 382 strcpy(op_entry->path, PLUGIN_DIR"/");
366 383
367 struct browse_context browse = { 384 struct browse_context browse = {
368 .dirfilter = SHOW_ALL, 385 .dirfilter = SHOW_ALL,
369 .flags = BROWSE_SELECTONLY, 386 .flags = BROWSE_SELECTONLY | BROWSE_NO_CONTEXT_MENU | BROWSE_DIRFILTER,
370 .title = str(LANG_OPEN_PLUGIN), 387 .title = str(LANG_OPEN_PLUGIN),
371 .icon = Icon_Plugin, 388 .icon = Icon_Plugin,
372 .root = op_entry->path, 389 .root = op_entry->path,
373 .buf = tmp_buf, 390 .buf = tmp_buf,
374 .bufsize = sizeof(tmp_buf), 391 .bufsize = sizeof(tmp_buf),
392 .callback_show_item = callback_show_item,
375 }; 393 };
376 394
377 if (rockbox_browse(&browse) == GO_TO_PREVIOUS) 395 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)
652 return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */ 652 return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */
653 } 653 }
654 654
655 while(1) { 655 while(tc.browse) {
656 bool restore = false; 656 bool restore = false;
657 if (tc.dirlevel < 0) 657 if (tc.dirlevel < 0)
658 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */ 658 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
@@ -1018,7 +1018,7 @@ int rockbox_browse(struct browse_context *browse)
1018 } 1018 }
1019 else 1019 else
1020 { 1020 {
1021 if (dirfilter != SHOW_ID3DB) 1021 if (dirfilter != SHOW_ID3DB && (browse->flags & BROWSE_DIRFILTER) == 0)
1022 tc.dirfilter = &global_settings.dirfilter; 1022 tc.dirfilter = &global_settings.dirfilter;
1023 tc.browse = browse; 1023 tc.browse = browse;
1024 strmemccpy(current, browse->root, MAX_PATH); 1024 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 {
38#define BROWSE_SELECTONLY 0x0001 /* exit on selecting a file */ 38#define BROWSE_SELECTONLY 0x0001 /* exit on selecting a file */
39#define BROWSE_NO_CONTEXT_MENU 0x0002 /* disable context menu */ 39#define BROWSE_NO_CONTEXT_MENU 0x0002 /* disable context menu */
40#define BROWSE_RUNFILE 0x0004 /* do ft_open() on the file instead of browsing */ 40#define BROWSE_RUNFILE 0x0004 /* do ft_open() on the file instead of browsing */
41#define BROWSE_DIRFILTER 0x0080 /* override global_settings.dirfilter with browse_context.dirfilter */
41#define BROWSE_SELECTED 0x0100 /* this bit is set if user selected item */ 42#define BROWSE_SELECTED 0x0100 /* this bit is set if user selected item */
42 43
43 44