From 5ca8abfff030e780ac88711a5f8ee3094fd7f7ea Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 21 Oct 2007 00:11:47 +0000 Subject: 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 --- apps/filetypes.c | 65 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 29 deletions(-) (limited to 'apps') diff --git a/apps/filetypes.c b/apps/filetypes.c index 5e72fca5a1..b5825044f1 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -421,26 +421,48 @@ bool filetype_supported(int attr) } /**** Open With Screen ****/ +struct cb_data { + int *items; + char *current_file; +}; 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; } char * openwith_get_name(int selected_item, void * data, char * 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, '/'); if (s) return s+1; 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 i, count = 0, action; + int i, count = 0; int items[MAX_FILETYPES]; - struct gui_synclist lists; + struct simplelist_info info; + struct cb_data data = { items, (char*)current_file }; for (i=0; i