Remove browse_context_init()
Prefer to use designated initializers to avoid having to specify unneeded parameters. Non-initialized members are zero-initialized by the compiler. Change-Id: Ia6a03c45cb3ef0b30f458d7d0ae1604a350c737c
This commit is contained in:
parent
701e262d3d
commit
6c52fa139c
17 changed files with 117 additions and 108 deletions
|
@ -54,11 +54,14 @@ static void pm_handler(unsigned short id, void *data)
|
|||
static int plugins_menu(void* param)
|
||||
{
|
||||
intptr_t item = (intptr_t)param;
|
||||
struct browse_context browse;
|
||||
int ret;
|
||||
|
||||
browse_context_init(&browse, SHOW_PLUGINS, 0, str(items[item].id),
|
||||
Icon_Plugin, items[item].path, NULL);
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_PLUGINS,
|
||||
.title = str(items[item].id),
|
||||
.icon = Icon_Plugin,
|
||||
.root = items[item].path,
|
||||
};
|
||||
|
||||
ret = rockbox_browse(&browse);
|
||||
|
||||
|
|
|
@ -249,9 +249,12 @@ int browse_folder(void *param)
|
|||
char selected[MAX_FILENAME+10];
|
||||
const struct browse_folder_info *info =
|
||||
(const struct browse_folder_info*)param;
|
||||
struct browse_context browse;
|
||||
browse_context_init(&browse, info->show_options, 0,
|
||||
NULL, NOICON, info->dir, NULL);
|
||||
|
||||
struct browse_context browse = {
|
||||
.dirfilter = info->show_options,
|
||||
.icon = Icon_NOICON,
|
||||
.root = info->dir,
|
||||
};
|
||||
|
||||
/* if we are in a special settings folder, center the current setting */
|
||||
switch(info->show_options)
|
||||
|
|
|
@ -352,7 +352,7 @@ retnhash:
|
|||
void open_plugin_browse(const char *key)
|
||||
{
|
||||
logf("%s", __func__);
|
||||
struct browse_context browse;
|
||||
|
||||
char tmp_buf[OPEN_PLUGIN_BUFSZ+1];
|
||||
open_plugin_load_entry(key);
|
||||
struct open_plugin_entry_t *op_entry = open_plugin_get_entry();
|
||||
|
@ -364,11 +364,15 @@ void open_plugin_browse(const char *key)
|
|||
if (op_entry->path[0] == '\0')
|
||||
strcpy(op_entry->path, PLUGIN_DIR"/");
|
||||
|
||||
browse_context_init(&browse, SHOW_ALL, BROWSE_SELECTONLY, "",
|
||||
Icon_Plugin, op_entry->path, NULL);
|
||||
|
||||
browse.buf = tmp_buf;
|
||||
browse.bufsize = OPEN_PLUGIN_BUFSZ;
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_ALL,
|
||||
.flags = BROWSE_SELECTONLY,
|
||||
.title = str(LANG_OPEN_PLUGIN),
|
||||
.icon = Icon_Plugin,
|
||||
.root = op_entry->path,
|
||||
.buf = tmp_buf,
|
||||
.bufsize = sizeof(tmp_buf),
|
||||
};
|
||||
|
||||
if (rockbox_browse(&browse) == GO_TO_PREVIOUS)
|
||||
open_plugin_add_path(key, tmp_buf, NULL);
|
||||
|
|
|
@ -150,7 +150,6 @@ static int display_playlists(char* playlist, enum catbrowse_status_flags status)
|
|||
{
|
||||
static bool reopen_last_playlist = false;
|
||||
static int most_recent_selection = 0;
|
||||
struct browse_context browse;
|
||||
int result = -1;
|
||||
char selected_playlist[MAX_PATH];
|
||||
selected_playlist[0] = '\0';
|
||||
|
@ -158,14 +157,16 @@ static int display_playlists(char* playlist, enum catbrowse_status_flags status)
|
|||
browser_status |= status;
|
||||
bool view = (status == CATBROWSE_CATVIEW);
|
||||
|
||||
browse_context_init(&browse, SHOW_M3U,
|
||||
BROWSE_SELECTONLY|(view? 0: BROWSE_NO_CONTEXT_MENU),
|
||||
str(LANG_CATALOG), NOICON,
|
||||
selected_playlist,
|
||||
playlist_dir_length + 1 + most_recent_playlist);
|
||||
|
||||
browse.buf = selected_playlist;
|
||||
browse.bufsize = sizeof(selected_playlist);
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_M3U,
|
||||
.flags = BROWSE_SELECTONLY | (view ? 0 : BROWSE_NO_CONTEXT_MENU),
|
||||
.title = str(LANG_CATALOG),
|
||||
.icon = Icon_NOICON,
|
||||
.root = selected_playlist,
|
||||
.selected = &most_recent_playlist[playlist_dir_length + 1],
|
||||
.buf = selected_playlist,
|
||||
.bufsize = sizeof(selected_playlist),
|
||||
};
|
||||
|
||||
restart:
|
||||
/* set / restore the root directory for the browser */
|
||||
|
|
|
@ -429,7 +429,6 @@ static const struct plugin_api rockbox_api = {
|
|||
dir_get_info,
|
||||
|
||||
/* browsing */
|
||||
browse_context_init,
|
||||
rockbox_browse,
|
||||
tree_get_context,
|
||||
tree_get_entries,
|
||||
|
|
|
@ -157,12 +157,12 @@ int plugin_open(const char *plugin, const char *parameter);
|
|||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define PLUGIN_API_VERSION 257
|
||||
#define PLUGIN_API_VERSION 258
|
||||
|
||||
/* update this to latest version if a change to the api struct breaks
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
new function which are "waiting" at the end of the function table) */
|
||||
#define PLUGIN_MIN_API_VERSION 257
|
||||
#define PLUGIN_MIN_API_VERSION 258
|
||||
|
||||
/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
|
||||
|
||||
|
@ -479,10 +479,6 @@ struct plugin_api {
|
|||
struct dirinfo (*dir_get_info)(DIR *dirp, struct dirent *entry);
|
||||
|
||||
/* browsing */
|
||||
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);
|
||||
struct tree_context* (*tree_get_context)(void);
|
||||
struct entry* (*tree_get_entries)(struct tree_context* t);
|
||||
|
|
|
@ -613,13 +613,14 @@ static void keyremap_export_user_keys(void)
|
|||
static void keyremap_import_user_keys(void)
|
||||
{
|
||||
char buf[MAX_PATH];
|
||||
struct browse_context browse;
|
||||
|
||||
rb->browse_context_init(&browse, SHOW_ALL, BROWSE_SELECTONLY, "Select Keymap",
|
||||
Icon_Plugin, "/", NULL);
|
||||
|
||||
browse.buf = buf;
|
||||
browse.bufsize = sizeof(buf);
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_ALL,
|
||||
.flags = BROWSE_SELECTONLY,
|
||||
.title = "Select Keymap",
|
||||
.icon = Icon_Plugin,
|
||||
.buf = buf,
|
||||
.bufsize = sizeof(buf),
|
||||
};
|
||||
|
||||
if (rb->rockbox_browse(&browse) == GO_TO_PREVIOUS)
|
||||
{
|
||||
|
|
|
@ -189,17 +189,20 @@ static void op_entry_set_name(void)
|
|||
static int op_entry_set_path(void)
|
||||
{
|
||||
int ret = 0;
|
||||
struct browse_context browse;
|
||||
char tmp_buf[OPEN_PLUGIN_BUFSZ+1];
|
||||
|
||||
if (op_entry.path[0] == '\0')
|
||||
rb->strcpy(op_entry.path, PLUGIN_DIR"/");
|
||||
|
||||
rb->browse_context_init(&browse, SHOW_ALL, BROWSE_SELECTONLY, rb->str(LANG_ADD),
|
||||
Icon_Plugin, op_entry.path, NULL);
|
||||
|
||||
browse.buf = tmp_buf;
|
||||
browse.bufsize = OPEN_PLUGIN_BUFSZ;
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_ALL,
|
||||
.flags = BROWSE_SELECTONLY,
|
||||
.title = rb->str(LANG_ADD),
|
||||
.icon = Icon_Plugin,
|
||||
.root = op_entry.path,
|
||||
.buf = tmp_buf,
|
||||
.bufsize = sizeof(tmp_buf),
|
||||
};
|
||||
|
||||
if (rb->rockbox_browse(&browse) == GO_TO_PREVIOUS)
|
||||
{
|
||||
|
@ -213,7 +216,6 @@ static int op_entry_set_path(void)
|
|||
static int op_entry_set_param_path(void)
|
||||
{
|
||||
int ret = 0;
|
||||
struct browse_context browse;
|
||||
char tmp_buf[OPEN_PLUGIN_BUFSZ+1];
|
||||
|
||||
if (op_entry.param[0] == '\0')
|
||||
|
@ -221,11 +223,15 @@ static int op_entry_set_param_path(void)
|
|||
else
|
||||
rb->strcpy(tmp_buf, op_entry.param);
|
||||
|
||||
rb->browse_context_init(&browse, SHOW_ALL, BROWSE_SELECTONLY, "",
|
||||
Icon_Plugin, tmp_buf, NULL);
|
||||
|
||||
browse.buf = tmp_buf;
|
||||
browse.bufsize = OPEN_PLUGIN_BUFSZ;
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_ALL,
|
||||
.flags = BROWSE_SELECTONLY,
|
||||
.title = rb->str(LANG_PARAMETER),
|
||||
.icon = Icon_Plugin,
|
||||
.root = tmp_buf,
|
||||
.buf = tmp_buf,
|
||||
.bufsize = sizeof(tmp_buf),
|
||||
};
|
||||
|
||||
if (rb->rockbox_browse(&browse) == GO_TO_PREVIOUS)
|
||||
{
|
||||
|
|
|
@ -208,17 +208,16 @@ static int base32_encode(const uint8_t *data, int length, uint8_t *result,
|
|||
|
||||
static bool browse( char *dst, int dst_size, const char *start )
|
||||
{
|
||||
struct browse_context browse;
|
||||
|
||||
rb->browse_context_init(&browse, SHOW_ALL,
|
||||
BROWSE_SELECTONLY|BROWSE_NO_CONTEXT_MENU,
|
||||
NULL, NOICON, start, NULL);
|
||||
|
||||
browse.buf = dst;
|
||||
browse.bufsize = dst_size;
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_ALL,
|
||||
.flags = BROWSE_SELECTONLY | BROWSE_NO_CONTEXT_MENU,
|
||||
.icon = Icon_NOICON,
|
||||
.root = start,
|
||||
.buf = dst,
|
||||
.bufsize = dst_size,
|
||||
};
|
||||
|
||||
rb->rockbox_browse(&browse);
|
||||
|
||||
return (browse.flags & BROWSE_SELECTED);
|
||||
}
|
||||
|
||||
|
|
|
@ -1084,15 +1084,15 @@ static bool callback_show_item(char *name, int attr, struct tree_context *tc)
|
|||
|
||||
static bool browse( char *dst, int dst_size, const char *start )
|
||||
{
|
||||
struct browse_context browse;
|
||||
|
||||
rb->browse_context_init(&browse, SHOW_ALL,
|
||||
BROWSE_SELECTONLY|BROWSE_NO_CONTEXT_MENU,
|
||||
NULL, NOICON, start, NULL);
|
||||
|
||||
browse.callback_show_item = callback_show_item;
|
||||
browse.buf = dst;
|
||||
browse.bufsize = dst_size;
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_ALL,
|
||||
.flags = BROWSE_SELECTONLY | BROWSE_NO_CONTEXT_MENU,
|
||||
.icon = Icon_NOICON,
|
||||
.root = start,
|
||||
.buf = dst,
|
||||
.bufsize = dst_size,
|
||||
.callback_show_item = callback_show_item,
|
||||
};
|
||||
|
||||
rb->rockbox_browse(&browse);
|
||||
|
||||
|
|
|
@ -482,16 +482,19 @@ static void load_font(void)
|
|||
static void font_menu(void)
|
||||
{
|
||||
/* taken from text_viewer */
|
||||
struct browse_context browse;
|
||||
char font[MAX_PATH], name[MAX_FILENAME+10];
|
||||
|
||||
rb->snprintf(name, sizeof(name), "%s.fnt", rb->global_settings->font_file);
|
||||
rb->browse_context_init(&browse, SHOW_FONT,
|
||||
BROWSE_SELECTONLY|BROWSE_NO_CONTEXT_MENU,
|
||||
"Font", Icon_Menu_setting, FONT_DIR, name);
|
||||
|
||||
browse.buf = font;
|
||||
browse.bufsize = sizeof(font);
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_FONT,
|
||||
.flags = BROWSE_SELECTONLY | BROWSE_NO_CONTEXT_MENU,
|
||||
.title = rb->str(LANG_CUSTOM_FONT),
|
||||
.icon = Icon_Menu_setting,
|
||||
.root = FONT_DIR,
|
||||
.selected = name,
|
||||
.buf = font,
|
||||
.bufsize = sizeof(font),
|
||||
};
|
||||
|
||||
rb->rockbox_browse(&browse);
|
||||
|
||||
|
|
|
@ -200,16 +200,19 @@ static bool tv_statusbar_setting(void)
|
|||
|
||||
static bool tv_font_setting(void)
|
||||
{
|
||||
struct browse_context browse;
|
||||
char font[MAX_PATH], name[MAX_FILENAME+10];
|
||||
|
||||
rb->snprintf(name, sizeof(name), "%s.fnt", new_prefs.font_name);
|
||||
rb->browse_context_init(&browse, SHOW_FONT,
|
||||
BROWSE_SELECTONLY|BROWSE_NO_CONTEXT_MENU,
|
||||
"Font", Icon_Menu_setting, FONT_DIR, name);
|
||||
|
||||
browse.buf = font;
|
||||
browse.bufsize = sizeof(font);
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_FONT,
|
||||
.flags = BROWSE_SELECTONLY | BROWSE_NO_CONTEXT_MENU,
|
||||
.title = "Font", /* XXX: Translate? */
|
||||
.icon = Icon_Menu_setting,
|
||||
.root = FONT_DIR,
|
||||
.selected = name,
|
||||
.buf = font,
|
||||
.bufsize = sizeof(font),
|
||||
};
|
||||
|
||||
rb->rockbox_browse(&browse);
|
||||
|
||||
|
|
|
@ -351,11 +351,16 @@ static int radio_delete_preset(void)
|
|||
int preset_list_load(void)
|
||||
{
|
||||
char selected[MAX_PATH];
|
||||
struct browse_context browse;
|
||||
snprintf(selected, sizeof(selected), "%s.%s", global_settings.fmr_file, "fmr");
|
||||
browse_context_init(&browse, SHOW_FMR, 0,
|
||||
str(LANG_FM_PRESET_LOAD), NOICON,
|
||||
FMPRESET_PATH, selected);
|
||||
|
||||
struct browse_context browse = {
|
||||
.dirfilter = SHOW_FMR,
|
||||
.title = str(LANG_FM_PRESET_LOAD),
|
||||
.icon = Icon_NOICON,
|
||||
.root = FMPRESET_PATH,
|
||||
.selected = selected,
|
||||
};
|
||||
|
||||
return !rockbox_browse(&browse);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,6 @@ static int browser(void* param)
|
|||
#ifdef HAVE_TAGCACHE
|
||||
struct tree_context* tc = tree_get_context();
|
||||
#endif
|
||||
struct browse_context browse;
|
||||
int filter = SHOW_SUPPORTED;
|
||||
char folder[MAX_PATH] = "/";
|
||||
/* stuff needed to remember position in file browser */
|
||||
|
@ -274,7 +273,12 @@ static int browser(void* param)
|
|||
#endif /*HAVE_TAGCACHE*/
|
||||
}
|
||||
|
||||
browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL);
|
||||
struct browse_context browse = {
|
||||
.dirfilter = filter,
|
||||
.icon = Icon_NOICON,
|
||||
.root = folder,
|
||||
};
|
||||
|
||||
ret_val = rockbox_browse(&browse);
|
||||
|
||||
if (ret_val == GO_TO_WPS
|
||||
|
|
|
@ -660,9 +660,11 @@ int do_shortcut_menu(void *ignored)
|
|||
done = GO_TO_PLUGIN;
|
||||
break;
|
||||
}
|
||||
struct browse_context browse;
|
||||
browse_context_init(&browse, global_settings.dirfilter, 0,
|
||||
NULL, NOICON, sc->u.path, NULL);
|
||||
struct browse_context browse = {
|
||||
.dirfilter = global_settings.dirfilter,
|
||||
.icon = Icon_NOICON,
|
||||
.root = sc->u.path,
|
||||
};
|
||||
if (sc->type == SHORTCUT_FILE)
|
||||
browse.flags |= BROWSE_RUNFILE;
|
||||
done = rockbox_browse(&browse);
|
||||
|
|
16
apps/tree.c
16
apps/tree.c
|
@ -962,22 +962,6 @@ int create_playlist(void)
|
|||
return (ret) ? 1 : 0;
|
||||
}
|
||||
|
||||
void browse_context_init(struct browse_context *browse,
|
||||
int dirfilter, unsigned flags,
|
||||
char *title, enum themable_icons icon,
|
||||
const char *root, const char *selected)
|
||||
{
|
||||
browse->dirfilter = dirfilter;
|
||||
browse->flags = flags;
|
||||
browse->callback_show_item = NULL;
|
||||
browse->title = title;
|
||||
browse->icon = icon;
|
||||
browse->root = root;
|
||||
browse->selected = selected;
|
||||
browse->buf = NULL;
|
||||
browse->bufsize = 0;
|
||||
}
|
||||
|
||||
#define NUM_TC_BACKUP 3
|
||||
static struct tree_context backups[NUM_TC_BACKUP];
|
||||
/* do not make backup if it is not recursive call */
|
||||
|
|
|
@ -106,10 +106,6 @@ void tree_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);
|
||||
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);
|
||||
int create_playlist(void);
|
||||
void resume_directory(const char *dir);
|
||||
|
|
Loading…
Reference in a new issue