diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-10-21 03:10:56 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2021-10-21 03:16:54 -0400 |
commit | cf96a4d386324884ac9a69da66aabd9e262c7078 (patch) | |
tree | c0bf5d278f3d6d9c5cc7b87e7554831ad6433c8e | |
parent | af573708ed7acf476ed49ff94243a94b27aa33a0 (diff) | |
download | rockbox-cf96a4d386.tar.gz rockbox-cf96a4d386.zip |
file tree filetype_list_viewers exit from list before execution
no need to do a callback just to exit the list right after
executing a viewer plugin
Change-Id: I4598ab189bd7d1f350156af75480cbe7103e9e4c
-rw-r--r-- | apps/filetypes.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c index ed90be755f..d68bab3daa 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -601,32 +601,25 @@ static int openwith_get_talk(int selected_item, void * data) return 0; } -static int openwith_action_callback(int action, struct gui_synclist *lists) -{ - struct cb_data *info = (struct cb_data *)lists->data; - int i; - if (action == ACTION_STD_OK) - { - char plugin[MAX_PATH]; - i = viewers[gui_synclist_get_sel_pos(lists)]; - snprintf(plugin, MAX_PATH, "%s/%s." ROCK_EXTENSION, - PLUGIN_DIR, filetypes[i].plugin); - plugin_load(plugin, info->current_file); - return ACTION_STD_CANCEL; - } - return action; -} - int filetype_list_viewers(const char* current_file) { struct simplelist_info info; - struct cb_data data = { current_file }; - simplelist_info_init(&info, str(LANG_ONPLAY_OPEN_WITH), viewer_count, &data); - info.action_callback = openwith_action_callback; + simplelist_info_init(&info, str(LANG_ONPLAY_OPEN_WITH), viewer_count, NULL); info.get_name = openwith_get_name; info.get_icon = global_settings.show_icons?openwith_get_icon:NULL; info.get_talk = openwith_get_talk; - return simplelist_show_list(&info); + + int ret = simplelist_show_list(&info); + + if (info.selection >= 0) /* run user selected viewer */ + { + char plugin[MAX_PATH]; + int i = viewers[info.selection]; + snprintf(plugin, MAX_PATH, "%s/%s." ROCK_EXTENSION, + PLUGIN_DIR, filetypes[i].plugin); + plugin_load(plugin, current_file); + } + return ret; } int filetype_load_plugin(const char* plugin, const char* file) |