summaryrefslogtreecommitdiff
path: root/apps/open_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/open_plugin.c')
-rw-r--r--apps/open_plugin.c24
1 files changed, 21 insertions, 3 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)