summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-10-21 03:10:56 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2021-10-21 03:16:54 -0400
commitcf96a4d386324884ac9a69da66aabd9e262c7078 (patch)
treec0bf5d278f3d6d9c5cc7b87e7554831ad6433c8e
parentaf573708ed7acf476ed49ff94243a94b27aa33a0 (diff)
downloadrockbox-cf96a4d386324884ac9a69da66aabd9e262c7078.tar.gz
rockbox-cf96a4d386324884ac9a69da66aabd9e262c7078.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.c33
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)
601 return 0; 601 return 0;
602} 602}
603 603
604static int openwith_action_callback(int action, struct gui_synclist *lists)
605{
606 struct cb_data *info = (struct cb_data *)lists->data;
607 int i;
608 if (action == ACTION_STD_OK)
609 {
610 char plugin[MAX_PATH];
611 i = viewers[gui_synclist_get_sel_pos(lists)];
612 snprintf(plugin, MAX_PATH, "%s/%s." ROCK_EXTENSION,
613 PLUGIN_DIR, filetypes[i].plugin);
614 plugin_load(plugin, info->current_file);
615 return ACTION_STD_CANCEL;
616 }
617 return action;
618}
619
620int filetype_list_viewers(const char* current_file) 604int filetype_list_viewers(const char* current_file)
621{ 605{
622 struct simplelist_info info; 606 struct simplelist_info info;
623 struct cb_data data = { current_file }; 607 simplelist_info_init(&info, str(LANG_ONPLAY_OPEN_WITH), viewer_count, NULL);
624 simplelist_info_init(&info, str(LANG_ONPLAY_OPEN_WITH), viewer_count, &data);
625 info.action_callback = openwith_action_callback;
626 info.get_name = openwith_get_name; 608 info.get_name = openwith_get_name;
627 info.get_icon = global_settings.show_icons?openwith_get_icon:NULL; 609 info.get_icon = global_settings.show_icons?openwith_get_icon:NULL;
628 info.get_talk = openwith_get_talk; 610 info.get_talk = openwith_get_talk;
629 return simplelist_show_list(&info); 611
612 int ret = simplelist_show_list(&info);
613
614 if (info.selection >= 0) /* run user selected viewer */
615 {
616 char plugin[MAX_PATH];
617 int i = viewers[info.selection];
618 snprintf(plugin, MAX_PATH, "%s/%s." ROCK_EXTENSION,
619 PLUGIN_DIR, filetypes[i].plugin);
620 plugin_load(plugin, current_file);
621 }
622 return ret;
630} 623}
631 624
632int filetype_load_plugin(const char* plugin, const char* file) 625int filetype_load_plugin(const char* plugin, const char* file)