From a5663ab3c00b94bcb30448f0a387d05a64a157ba Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 15 Jan 2025 11:40:01 -0500 Subject: [PATCH] [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 --- apps/open_plugin.c | 14 ++++++++++++++ apps/plugins/open_plugins.c | 25 +++++++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/apps/open_plugin.c b/apps/open_plugin.c index 8b5fce1d29..0ec881c1db 100644 --- a/apps/open_plugin.c +++ b/apps/open_plugin.c @@ -411,7 +411,21 @@ void open_plugin_browse(const char *key) }; if (rockbox_browse(&browse) == GO_TO_PREVIOUS) + { 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() diff --git a/apps/plugins/open_plugins.c b/apps/plugins/open_plugins.c index 7206fe2a49..c09ddf99aa 100644 --- a/apps/plugins/open_plugins.c +++ b/apps/plugins/open_plugins.c @@ -337,8 +337,6 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha else hash = op_entry.hash; - - if (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[0] == '\0' && - _yesno_pop(ID2P(LANG_PARAMETER))) + /* param matches lang_id so we want to set 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(); } else if (parameter != op_entry.param) @@ -841,9 +844,19 @@ reopen_datfile: { if (op_entry_read(fd_dat, selection, op_entry_sz)) { - ret = op_entry_run(); - if (ret == PLUGIN_GOTO_PLUGIN) + /* 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(); + if (ret == PLUGIN_GOTO_PLUGIN) + exit = true; + } } } else