From 08af5d84044a7f18a619e1cb38cd183819be41b9 Mon Sep 17 00:00:00 2001 From: Teruaki Kawashima Date: Tue, 14 Dec 2010 13:37:58 +0000 Subject: FS#11777: enhancement for rockbox_browse() * Add struct browse_context to be passed to rockbox_browse. * Show proper title when selecting e.g. .wps file or .sbs file from the settings menu. * Add select only mode to rockbox_browse(). when a file is selected, it's path is stored to buffer and the browser exits without 'playing' the file. this will allow to use the browser in more places to select file including plugins. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28831 a1c6a512-1295-4272-9138-f99709370657 --- apps/tree.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'apps/tree.h') diff --git a/apps/tree.h b/apps/tree.h index a74960f7a5..103a20eea6 100644 --- a/apps/tree.h +++ b/apps/tree.h @@ -24,6 +24,7 @@ #include #include #include +#include "icon.h" struct entry { short attr; /* FAT attributes + file type flags */ @@ -32,6 +33,26 @@ struct entry { }; +#define BROWSE_SELECTONLY 0x0001 /* exit on selecting a file */ +#define BROWSE_SELECTED 0x0100 /* this bit is set if user selected item */ + +struct tree_context; + +struct browse_context { + int dirfilter; + unsigned flags; /* ored BROWSE_* */ + bool (*callback_show_item)(char *name, int attr, struct tree_context *tc); + /* callback function to determine to show/hide + the item for custom browser */ + char *title; /* title of the browser. if set to NULL, + directory name is used. */ + enum themable_icons icon; /* title icon */ + const char *root; /* full path of start directory */ + const char *selected; /* name of selected file in the root */ + char *buf; /* buffer to store selected file */ + size_t bufsize; /* size of the buffer */ +}; + /* browser context for file or db */ struct tree_context { /* The directory we are browsing */ @@ -68,6 +89,7 @@ struct tree_context { int dentry_size; bool dirfull; int sort_dir; /* directory sort order */ + struct browse_context *browse; }; void tree_drawlists(void); @@ -76,7 +98,11 @@ void tree_gui_init(void) INIT_ATTR; char* get_current_file(char* buffer, size_t buffer_len); void set_dirfilter(int l_dirfilter); void set_current_file(const char *path); -int rockbox_browse(const char *root, int dirfilter); +void browse_context_init(struct browse_context *browse, + int dirfilter, unsigned flags, + char *title, enum themable_icons icon, + const char *root, const char *selected); +int rockbox_browse(struct browse_context *browse); bool create_playlist(void); void resume_directory(const char *dir); #ifdef WIN32 -- cgit v1.2.3