Index: apps/filetypes.c =================================================================== --- apps/filetypes.c (revision 17625) +++ apps/filetypes.c (working copy) @@ -429,16 +429,24 @@ return filetypes[items[selected_item]].icon; } +static char *get_simple_plugin_name(int index_in_filetypes) +{ + char *full_name = filetypes[index_in_filetypes].plugin; + char *s = strrchr(full_name, '/'); + if (s) + return s+1; + else + return full_name; +} + static char * openwith_get_name(int selected_item, void * data, char * buffer, size_t buffer_len) { (void)buffer; (void)buffer_len; 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; + printf("get-name: sel=%d, idx=%d\n", selected_item, items[selected_item]); + return get_simple_plugin_name(items[selected_item]); } static int openwith_action_callback(int action, struct gui_synclist *lists) @@ -458,6 +466,17 @@ return action; } +/* Compare function used to sort plugins alphabetically */ +static int plugin_name_compare(const void *ptr1, const void *ptr2) +{ + int index1 = *((int*) ptr1); + int index2 = *((int*) ptr2); + char *name1 = get_simple_plugin_name(index1); + char *name2 = get_simple_plugin_name(index2); + printf("name1=%s, name2=%s\n", name1, name2); + return strcmp(name1, name2); +} + int filetype_list_viewers(const char* current_file) { int i, count = 0; @@ -479,14 +498,13 @@ items[count++] = i; } } -#ifndef HAVE_LCD_BITMAP if (count == 0) { /* FIX: translation! */ gui_syncsplash(HZ*2, (unsigned char *)"No viewers found"); return PLUGIN_OK; } -#endif + qsort(items, count, sizeof(items[0]), plugin_name_compare); simplelist_info_init(&info, str(LANG_ONPLAY_OPEN_WITH), count, &data); info.action_callback = openwith_action_callback; info.get_name = openwith_get_name;