diff options
Diffstat (limited to 'apps/filetypes.c')
-rw-r--r-- | apps/filetypes.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c index 3724f57a9b..ed90be755f 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -536,10 +536,31 @@ char* filetype_get_plugin(const struct entry* file, char *buffer, size_t buffer_ | |||
536 | int index = find_attr(file->attr); | 536 | int index = find_attr(file->attr); |
537 | if (index < 0 || !buffer) | 537 | if (index < 0 || !buffer) |
538 | return NULL; | 538 | return NULL; |
539 | if (filetypes[index].plugin == NULL) | 539 | struct file_type *ft_indexed = &filetypes[index]; |
540 | |||
541 | /* attempt to find a suitable viewer by file extension */ | ||
542 | if(ft_indexed->plugin == NULL && ft_indexed->extension != NULL) | ||
543 | { | ||
544 | struct file_type *ft; | ||
545 | int i = filetype_count; | ||
546 | while (--i > index) | ||
547 | { | ||
548 | ft = &filetypes[i]; | ||
549 | if (ft->plugin == NULL || ft->extension == NULL) | ||
550 | continue; | ||
551 | else if (strcmp(ft->extension, ft_indexed->extension) == 0) | ||
552 | { | ||
553 | /*splashf(HZ*3, "Found %d %s %s", i, ft->extension, ft->plugin);*/ | ||
554 | ft_indexed = ft; | ||
555 | break; | ||
556 | } | ||
557 | } | ||
558 | } | ||
559 | if (ft_indexed->plugin == NULL) | ||
540 | return NULL; | 560 | return NULL; |
541 | snprintf(buffer, buffer_len, "%s/%s.%s", | 561 | |
542 | PLUGIN_DIR, filetypes[index].plugin, ROCK_EXTENSION); | 562 | snprintf(buffer, buffer_len, "%s/%s." ROCK_EXTENSION, |
563 | PLUGIN_DIR, ft_indexed->plugin); | ||
543 | return buffer; | 564 | return buffer; |
544 | } | 565 | } |
545 | 566 | ||
@@ -573,8 +594,8 @@ static int openwith_get_talk(int selected_item, void * data) | |||
573 | { | 594 | { |
574 | (void)data; | 595 | (void)data; |
575 | char viewer_filename[MAX_FILENAME]; | 596 | char viewer_filename[MAX_FILENAME]; |
576 | snprintf(viewer_filename, MAX_FILENAME, "%s.%s", | 597 | snprintf(viewer_filename, MAX_FILENAME, "%s." ROCK_EXTENSION, |
577 | filetypes[viewers[selected_item]].plugin, ROCK_EXTENSION); | 598 | filetypes[viewers[selected_item]].plugin); |
578 | talk_file_or_spell(PLUGIN_DIR, viewer_filename, | 599 | talk_file_or_spell(PLUGIN_DIR, viewer_filename, |
579 | NULL, false); | 600 | NULL, false); |
580 | return 0; | 601 | return 0; |
@@ -588,8 +609,8 @@ static int openwith_action_callback(int action, struct gui_synclist *lists) | |||
588 | { | 609 | { |
589 | char plugin[MAX_PATH]; | 610 | char plugin[MAX_PATH]; |
590 | i = viewers[gui_synclist_get_sel_pos(lists)]; | 611 | i = viewers[gui_synclist_get_sel_pos(lists)]; |
591 | snprintf(plugin, MAX_PATH, "%s/%s.%s", | 612 | snprintf(plugin, MAX_PATH, "%s/%s." ROCK_EXTENSION, |
592 | PLUGIN_DIR, filetypes[i].plugin, ROCK_EXTENSION); | 613 | PLUGIN_DIR, filetypes[i].plugin); |
593 | plugin_load(plugin, info->current_file); | 614 | plugin_load(plugin, info->current_file); |
594 | return ACTION_STD_CANCEL; | 615 | return ACTION_STD_CANCEL; |
595 | } | 616 | } |
@@ -630,7 +651,7 @@ int filetype_load_plugin(const char* plugin, const char* file) | |||
630 | } | 651 | } |
631 | if (i >= filetype_count) | 652 | if (i >= filetype_count) |
632 | return PLUGIN_ERROR; | 653 | return PLUGIN_ERROR; |
633 | snprintf(plugin_name, MAX_PATH, "%s/%s.%s", | 654 | snprintf(plugin_name, MAX_PATH, "%s/%s." ROCK_EXTENSION, |
634 | PLUGIN_DIR, filetypes[i].plugin, ROCK_EXTENSION); | 655 | PLUGIN_DIR, filetypes[i].plugin); |
635 | return plugin_load(plugin_name, file); | 656 | return plugin_load(plugin_name, file); |
636 | } | 657 | } |