"Open With" menu duplicate entry bug fixed.

Only plugins that match the target file extensions are now listed.
Patch by Patr3ck.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6157 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thom Johansen 2005-03-06 18:13:16 +00:00
parent 59483d6768
commit 7144e38b5f
3 changed files with 16 additions and 9 deletions

View file

@ -220,21 +220,28 @@ int filetype_get_attr(const char* name)
}
/* fill a menu list with viewers (used in onplay.c) */
int filetype_load_menu(struct menu_item* menu,int max_items)
int filetype_load_menu(struct menu_item* menu, int max_items,
char *filename)
{
int i;
int cnt=0;
for (i=0; i < cnt_filetypes; i++)
for (i=0; i < cnt_exttypes; i++)
{
if (filetypes[i].plugin)
if(exttypes[i].type->plugin)
{
menu[cnt].desc = filetypes[i].plugin;
cnt++;
if (cnt == max_items)
break;
if (strcasecmp(&filename[strlen(filename)-
strlen(exttypes[i].extension)],
exttypes[i].extension) == 0)
{
menu[cnt].desc = exttypes[i].type->plugin;
cnt++;
if (cnt == max_items)
break;
}
}
}
return cnt;
}

View file

@ -32,7 +32,7 @@ int filetype_get_icon(int);
char* filetype_get_plugin(const struct entry*);
void filetype_init(void);
bool filetype_supported(int);
int filetype_load_menu(struct menu_item*, int);
int filetype_load_menu(struct menu_item*, int, char*);
int filetype_load_plugin(const char*, char*);
struct file_type {

View file

@ -56,7 +56,7 @@ static bool list_viewers(void)
int m, i, result;
int ret = 0;
i=filetype_load_menu(menu,sizeof(menu)/sizeof(*menu));
i=filetype_load_menu(menu,sizeof(menu)/sizeof(*menu),selected_file);
if (i)
{
m = menu_init( menu, i, NULL, NULL, NULL, NULL );