summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-11-30 15:17:54 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-12-17 13:36:38 +0000
commit6c52fa139c5ad8f78ed4fdb306a6074228dbf4c9 (patch)
tree9d51172c8860a72e5081dc2706dd30f4dd295427
parent701e262d3d622898279167ba909da631ac460bc1 (diff)
downloadrockbox-6c52fa139c.tar.gz
rockbox-6c52fa139c.zip
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
-rw-r--r--apps/menus/plugin_menu.c9
-rw-r--r--apps/menus/theme_menu.c9
-rw-r--r--apps/open_plugin.c16
-rw-r--r--apps/playlist_catalog.c19
-rw-r--r--apps/plugin.c1
-rw-r--r--apps/plugin.h8
-rw-r--r--apps/plugins/keyremap.c15
-rw-r--r--apps/plugins/open_plugins.c30
-rw-r--r--apps/plugins/otp.c17
-rw-r--r--apps/plugins/rockpaint.c18
-rw-r--r--apps/plugins/speedread.c17
-rw-r--r--apps/plugins/text_viewer/tv_menu.c17
-rw-r--r--apps/radio/presets.c13
-rw-r--r--apps/root_menu.c8
-rw-r--r--apps/shortcuts.c8
-rw-r--r--apps/tree.c16
-rw-r--r--apps/tree.h4
17 files changed, 117 insertions, 108 deletions
diff --git a/apps/menus/plugin_menu.c b/apps/menus/plugin_menu.c
index cbc1ce03f2..fa0d721c05 100644
--- a/apps/menus/plugin_menu.c
+++ b/apps/menus/plugin_menu.c
@@ -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);
diff --git a/apps/menus/theme_menu.c b/apps/menus/theme_menu.c
index 60a2a27ef4..1b501452d0 100644
--- a/apps/menus/theme_menu.c
+++ b/apps/menus/theme_menu.c
@@ -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)
diff --git a/apps/open_plugin.c b/apps/open_plugin.c
index 49d727b4c9..c36a72f30e 100644
--- a/apps/open_plugin.c
+++ b/apps/open_plugin.c
@@ -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);
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index 56a90052da..c3cbc93a20 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -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 */
diff --git a/apps/plugin.c b/apps/plugin.c
index feba0f2cfc..1cf4d37b2b 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -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,
diff --git a/apps/plugin.h b/apps/plugin.h
index 62d8371e7d..cbdbdee7cf 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -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);
diff --git a/apps/plugins/keyremap.c b/apps/plugins/keyremap.c
index 4fd792646e..3923cc40d0 100644
--- a/apps/plugins/keyremap.c
+++ b/apps/plugins/keyremap.c
@@ -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)
{
diff --git a/apps/plugins/open_plugins.c b/apps/plugins/open_plugins.c
index 6deaf80f7d..9a2fa3593f 100644
--- a/apps/plugins/open_plugins.c
+++ b/apps/plugins/open_plugins.c
@@ -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)
{
diff --git a/apps/plugins/otp.c b/apps/plugins/otp.c
index 4d302563fb..356e1e5eb6 100644
--- a/apps/plugins/otp.c
+++ b/apps/plugins/otp.c
@@ -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);
}
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index 09fa2c8c5f..cba1701eb6 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -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);
diff --git a/apps/plugins/speedread.c b/apps/plugins/speedread.c
index 55d8fd58e5..7a9ab61e7c 100644
--- a/apps/plugins/speedread.c
+++ b/apps/plugins/speedread.c
@@ -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);
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c
index 3d22794f62..1cc471e207 100644
--- a/apps/plugins/text_viewer/tv_menu.c
+++ b/apps/plugins/text_viewer/tv_menu.c
@@ -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);
diff --git a/apps/radio/presets.c b/apps/radio/presets.c
index d90f54ed99..046525c3b6 100644
--- a/apps/radio/presets.c
+++ b/apps/radio/presets.c
@@ -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);
}
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 49e579903f..71753f27c4 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -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
diff --git a/apps/shortcuts.c b/apps/shortcuts.c
index 82e4a359bf..3f13d0c1b3 100644
--- a/apps/shortcuts.c
+++ b/apps/shortcuts.c
@@ -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);
diff --git a/apps/tree.c b/apps/tree.c
index 4df2c4e327..22199710ae 100644
--- a/apps/tree.c
+++ b/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 */
diff --git a/apps/tree.h b/apps/tree.h
index bb9ff87163..77da18d666 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -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);