1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Daniel Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 #include <applimits.h>
30 short attr
; /* FAT attributes + file type flags */
31 unsigned long time_write
; /* Last write time */
36 #define BROWSE_SELECTONLY 0x0001 /* exit on selecting a file */
37 #define BROWSE_NO_CONTEXT_MENU 0x0002 /* disable context menu */
38 #define BROWSE_SELECTED 0x0100 /* this bit is set if user selected item */
42 struct browse_context
{
44 unsigned flags
; /* ored BROWSE_* */
45 bool (*callback_show_item
)(char *name
, int attr
, struct tree_context
*tc
);
46 /* callback function to determine to show/hide
47 the item for custom browser */
48 char *title
; /* title of the browser. if set to NULL,
49 directory name is used. */
50 enum themable_icons icon
; /* title icon */
51 const char *root
; /* full path of start directory */
52 const char *selected
; /* name of selected file in the root */
53 char *buf
; /* buffer to store selected file */
54 size_t bufsize
; /* size of the buffer */
57 /* browser context for file or db */
59 /* The directory we are browsing */
60 char currdir
[MAX_PATH
];
61 /* the number of directories we have crossed from / */
63 /* The currently selected file/id3dbitem index (old dircursor+dirfile) */
65 /* The selected item in each directory crossed
66 * (used when we want to return back to a previouws directory)*/
67 int selected_item_history
[MAX_DIR_LEVELS
];
69 int firstpos
; /* which dir entry is on first
70 position in dir buffer */
71 int pos_history
[MAX_DIR_LEVELS
];
73 int *dirfilter
; /* file use */
74 int filesindir
; /* The number of files in the dircache */
75 int dirsindir
; /* file use */
76 int dirlength
; /* total number of entries in dir, incl. those not loaded */
78 int table_history
[MAX_DIR_LEVELS
]; /* db use */
79 int extra_history
[MAX_DIR_LEVELS
]; /* db use */
80 int currtable
; /* db use */
81 int currextra
; /* db use */
83 /* A big buffer with plenty of entry structs,
84 * contains all files and dirs in the current
85 * dir (with filters applied) */
92 int sort_dir
; /* directory sort order */
93 struct browse_context
*browse
;
96 void tree_drawlists(void);
97 void tree_mem_init(void) INIT_ATTR
;
98 void tree_gui_init(void) INIT_ATTR
;
99 char* get_current_file(char* buffer
, size_t buffer_len
);
100 void set_dirfilter(int l_dirfilter
);
101 void set_current_file(const char *path
);
102 void browse_context_init(struct browse_context
*browse
,
103 int dirfilter
, unsigned flags
,
104 char *title
, enum themable_icons icon
,
105 const char *root
, const char *selected
);
106 int rockbox_browse(struct browse_context
*browse
);
107 bool create_playlist(void);
108 void resume_directory(const char *dir
);
110 /* it takes an int on windows */
111 #define getcwd_size_t int
113 #define getcwd_size_t size_t
115 char *getcwd(char *buf
, getcwd_size_t size
);
116 void reload_directory(void);
117 bool check_rockboxdir(void);
118 struct tree_context
* tree_get_context(void);
119 void tree_flush(void);
120 void tree_restore(void);
122 bool bookmark_play(char* resume_file
, int index
, int offset
, int seed
,
125 extern struct gui_synclist tree_lists
;