From 73160322fe454b561cf7a15e0a3b9ac160c52428 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Tue, 7 Aug 2007 07:55:18 +0000 Subject: Fix the properties and shortucts plugins after accidently breaking them last night. Also possibly make them load a bit faster. Make the open with screen nicer, and show all aviable viewers again (If people prefered it only showing useful viewers maybe we can make this a setting?) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14227 a1c6a512-1295-4272-9138-f99709370657 --- apps/filetypes.c | 107 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 44 deletions(-) (limited to 'apps/filetypes.c') diff --git a/apps/filetypes.c b/apps/filetypes.c index 77d73df5cc..530dab18c4 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -381,7 +381,7 @@ int filetype_get_color(const char * name, int attr) if (!extension) return custom_colors[MAX_FILETYPES]; extension++; - logf("%s %s",name,extension); + for (i=1; i= 0; } +/**** Open With Screen ****/ +enum themable_icons openwith_get_icon(int selected_item, void * data) +{ + int *items = (int*)data; + return filetypes[items[selected_item]].icon; +} +char * openwith_get_name(int selected_item, void * data, char * buffer) +{ + (void)buffer; + int *items = (int*)data; + char *s = strrchr(filetypes[items[selected_item]].plugin, '/'); + if (s) + return s+1; + else return filetypes[items[selected_item]].plugin; +} + int filetype_list_viewers(const char* current_file) { - int i, count = 0; - char *strings[MAX_FILETYPES/2]; - char *ext; - struct menu_callback_with_desc cb_and_desc = - { NULL, ID2P(LANG_ONPLAY_OPEN_WITH), Icon_Plugin }; - struct menu_item_ex menu; - - ext = strrchr(current_file, '.'); - if (ext) - ext++; - for (i=0; i= 0) - return filetype_load_plugin(strings[i], (void*)current_file); - return i; + gui_synclist_init(&lists,openwith_get_name,(void*)items, false, 1); + gui_synclist_set_nb_items(&lists, count); + gui_synclist_set_icon_callback(&lists, openwith_get_icon); + gui_synclist_set_title(&lists, str(LANG_ONPLAY_OPEN_WITH), Icon_Plugin); + gui_synclist_select_item(&lists, 0); + gui_synclist_draw(&lists); + while (1) + { + gui_syncstatusbar_draw(&statusbars, true); + 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) + { + i = gui_synclist_get_sel_pos(&lists); + return filetype_load_plugin(filetypes[i].plugin, + (void*)current_file); + } + else if (action == ACTION_STD_CANCEL) + return action; + } } int filetype_load_plugin(const char* plugin, char* file) { - int fd; + int i; char plugin_name[MAX_PATH]; - snprintf(plugin_name, sizeof(plugin_name), "%s/%s.%s", - VIEWERS_DIR, plugin, ROCK_EXTENSION); - if ((fd = open(plugin_name,O_RDONLY))>=0) + char *s; + + for (i=0;i=0) + if (filetypes[i].plugin) { - close(fd); - return plugin_load(plugin_name,file); + s = strrchr(filetypes[i].plugin, '/'); + if (s) + { + if (!strcmp(s+1, plugin)) + break; + } + else if (!strcmp(filetypes[i].plugin, plugin)) + break; } } - return PLUGIN_ERROR; + if (i >= filetype_count) + return PLUGIN_ERROR; + snprintf(plugin_name, MAX_PATH, "%s/%s.%s", + PLUGIN_DIR, filetypes[i].plugin, ROCK_EXTENSION); + return plugin_load(plugin_name,file); } -- cgit v1.2.3