forked from len0rd/rockbox
convert the open with screen to use the simplelist api
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15230 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5a1b179f12
commit
5ca8abfff0
1 changed files with 36 additions and 29 deletions
|
|
@ -421,26 +421,48 @@ bool filetype_supported(int attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**** Open With Screen ****/
|
/**** Open With Screen ****/
|
||||||
|
struct cb_data {
|
||||||
|
int *items;
|
||||||
|
char *current_file;
|
||||||
|
};
|
||||||
enum themable_icons openwith_get_icon(int selected_item, void * data)
|
enum themable_icons openwith_get_icon(int selected_item, void * data)
|
||||||
{
|
{
|
||||||
int *items = (int*)data;
|
struct cb_data *info = (struct cb_data *)data;
|
||||||
|
int *items = info->items;
|
||||||
return filetypes[items[selected_item]].icon;
|
return filetypes[items[selected_item]].icon;
|
||||||
}
|
}
|
||||||
char * openwith_get_name(int selected_item, void * data, char * buffer)
|
char * openwith_get_name(int selected_item, void * data, char * buffer)
|
||||||
{
|
{
|
||||||
(void)buffer;
|
(void)buffer;
|
||||||
int *items = (int*)data;
|
struct cb_data *info = (struct cb_data *)data;
|
||||||
|
int *items = info->items;
|
||||||
char *s = strrchr(filetypes[items[selected_item]].plugin, '/');
|
char *s = strrchr(filetypes[items[selected_item]].plugin, '/');
|
||||||
if (s)
|
if (s)
|
||||||
return s+1;
|
return s+1;
|
||||||
else return filetypes[items[selected_item]].plugin;
|
else return filetypes[items[selected_item]].plugin;
|
||||||
}
|
}
|
||||||
|
int openwith_action_callback(int action, struct gui_synclist *lists)
|
||||||
|
{
|
||||||
|
struct cb_data *info = (struct cb_data *)lists->gui_list[SCREEN_MAIN].data;
|
||||||
|
int *items = info->items;
|
||||||
|
int i;
|
||||||
|
if (action == ACTION_STD_OK)
|
||||||
|
{
|
||||||
|
char plugin[MAX_PATH];
|
||||||
|
i = items[gui_synclist_get_sel_pos(lists)];
|
||||||
|
snprintf(plugin, MAX_PATH, "%s/%s.%s",
|
||||||
|
PLUGIN_DIR, filetypes[i].plugin, ROCK_EXTENSION);
|
||||||
|
plugin_load(plugin, info->current_file);
|
||||||
|
return ACTION_STD_CANCEL;
|
||||||
|
}
|
||||||
|
return action;
|
||||||
|
}
|
||||||
int filetype_list_viewers(const char* current_file)
|
int filetype_list_viewers(const char* current_file)
|
||||||
{
|
{
|
||||||
int i, count = 0, action;
|
int i, count = 0;
|
||||||
int items[MAX_FILETYPES];
|
int items[MAX_FILETYPES];
|
||||||
struct gui_synclist lists;
|
struct simplelist_info info;
|
||||||
|
struct cb_data data = { items, (char*)current_file };
|
||||||
for (i=0; i<filetype_count && count < MAX_FILETYPES; i++)
|
for (i=0; i<filetype_count && count < MAX_FILETYPES; i++)
|
||||||
{
|
{
|
||||||
if (filetypes[i].plugin)
|
if (filetypes[i].plugin)
|
||||||
|
|
@ -465,30 +487,15 @@ int filetype_list_viewers(const char* current_file)
|
||||||
return PLUGIN_OK;
|
return PLUGIN_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
gui_synclist_init(&lists,openwith_get_name,(void*)items, false, 1);
|
info.title = str(LANG_ONPLAY_OPEN_WITH);
|
||||||
gui_synclist_set_nb_items(&lists, count);
|
info.count = count;
|
||||||
gui_synclist_set_icon_callback(&lists, openwith_get_icon);
|
info.selection_size = 1; info.hide_selection = false;
|
||||||
gui_synclist_set_title(&lists, str(LANG_ONPLAY_OPEN_WITH), Icon_Plugin);
|
info.scroll_all = false;
|
||||||
gui_synclist_select_item(&lists, 0);
|
info.action_callback = openwith_action_callback;
|
||||||
gui_synclist_draw(&lists);
|
info.get_name = openwith_get_name;
|
||||||
while (1)
|
info.get_icon = openwith_get_icon;
|
||||||
{
|
info.callback_data = &data;
|
||||||
gui_syncstatusbar_draw(&statusbars, true);
|
return simplelist_show_list(&info);
|
||||||
action = get_action(CONTEXT_MAINMENU,HZ);
|
|
||||||
if ((action == ACTION_NONE) ||
|
|
||||||
gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
|
|
||||||
continue;
|
|
||||||
else if (action == ACTION_STD_OK)
|
|
||||||
{
|
|
||||||
char plugin[MAX_PATH];
|
|
||||||
i = items[gui_synclist_get_sel_pos(&lists)];
|
|
||||||
snprintf(plugin, MAX_PATH, "%s/%s.%s",
|
|
||||||
PLUGIN_DIR, filetypes[i].plugin, ROCK_EXTENSION);
|
|
||||||
return plugin_load(plugin, (char*)current_file);
|
|
||||||
}
|
|
||||||
else if (action == ACTION_STD_CANCEL)
|
|
||||||
return action;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int filetype_load_plugin(const char* plugin, char* file)
|
int filetype_load_plugin(const char* plugin, char* file)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue