[Feature] Add parameters when viewer is selected for open plugin

ask th user if they want to add a parameter when a viewer is set to an
open plugin entry (wps hotkey, start screen, etc)

Change-Id: I403ac79af15162aeecabb3607923113e27496e4f
This commit is contained in:
William Wilgus 2025-01-15 11:40:01 -05:00
parent 1a17b5cb8e
commit a5663ab3c0
2 changed files with 33 additions and 6 deletions

View file

@ -411,7 +411,21 @@ void open_plugin_browse(const char *key)
}; };
if (rockbox_browse(&browse) == GO_TO_PREVIOUS) if (rockbox_browse(&browse) == GO_TO_PREVIOUS)
{
open_plugin_add_path(key, tmp_buf, NULL); open_plugin_add_path(key, tmp_buf, NULL);
/* if this is a viewer ask the user if they want to set a parameter */
if (op_entry->lang_id > 0
&& strncmp(tmp_buf, VIEWERS_DIR, sizeof(VIEWERS_DIR) -1) == 0)
{
if (yesno_pop(ID2P(LANG_PARAMETER)))
{
strcpy(op_entry->param, str(op_entry->lang_id));
op_update_dat(op_entry, true); /* flush to disk so plugin can find it */
plugin_load(VIEWERS_DIR "/open_plugins.rock",
P2STR((unsigned char *)key));
}
}
}
} }
/* open_plugin_load_entry() /* open_plugin_load_entry()

View file

@ -337,8 +337,6 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha
else else
hash = op_entry.hash; hash = op_entry.hash;
if (plugin) if (plugin)
{ {
int fattr = rb->filetype_get_attr(plugin); int fattr = rb->filetype_get_attr(plugin);
@ -380,9 +378,14 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha
if(parameter) if(parameter)
{ {
if (parameter[0] == '\0' && /* param matches lang_id so we want to set parameter */
_yesno_pop(ID2P(LANG_PARAMETER))) bool needs_param = op_entry.lang_id >= 0
&& (rb->strcmp(parameter, rb->str(op_entry.lang_id)) == 0);
if (needs_param
|| (parameter[0] == '\0' && _yesno_pop(ID2P(LANG_PARAMETER))))
{ {
if (needs_param)
op_entry.param[0] = '\0';
op_entry_set_param(); op_entry_set_param();
} }
else if (parameter != op_entry.param) else if (parameter != op_entry.param)
@ -840,12 +843,22 @@ reopen_datfile:
if (selection >= 0) if (selection >= 0)
{ {
if (op_entry_read(fd_dat, selection, op_entry_sz)) if (op_entry_read(fd_dat, selection, op_entry_sz))
{
/* param matches lang_id so we want to set the parameter */
if (op_entry.lang_id >= 0
&& rb->strcmp(op_entry.param, rb->str(op_entry.lang_id)) == 0)
{
op_entry_add_path(NULL, op_entry.path, op_entry.param, false);
exit = true;
}
else
{ {
ret = op_entry_run(); ret = op_entry_run();
if (ret == PLUGIN_GOTO_PLUGIN) if (ret == PLUGIN_GOTO_PLUGIN)
exit = true; exit = true;
} }
} }
}
else else
{ {
op_entry_read(fd_dat, selection, op_entry_sz); op_entry_read(fd_dat, selection, op_entry_sz);