diff options
author | Björn Stenberg <bjorn@haxx.se> | 2004-05-21 20:08:24 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2004-05-21 20:08:24 +0000 |
commit | fb00c2190bab443812581473032156eb1e804c30 (patch) | |
tree | 7ac8b3964e7ebf284b1eae3a384a036e928f568d /apps/onplay.c | |
parent | 087a085790b2f9099e9b7c9184374a30520f408e (diff) | |
download | rockbox-fb00c2190bab443812581473032156eb1e804c30.tar.gz rockbox-fb00c2190bab443812581473032156eb1e804c30.zip |
Plugin/file type association system. Patch #879411 by Henrik Backe
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4677 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/onplay.c')
-rw-r--r-- | apps/onplay.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/apps/onplay.c b/apps/onplay.c index b1b690222b..d864b3b2a9 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -43,11 +43,35 @@ | |||
43 | #include "playlist_viewer.h" | 43 | #include "playlist_viewer.h" |
44 | #include "talk.h" | 44 | #include "talk.h" |
45 | #include "onplay.h" | 45 | #include "onplay.h" |
46 | #include "filetypes.h" | ||
46 | 47 | ||
47 | static char* selected_file = NULL; | 48 | static char* selected_file = NULL; |
48 | static int selected_file_attr = 0; | 49 | static int selected_file_attr = 0; |
49 | static int onplay_result = ONPLAY_OK; | 50 | static int onplay_result = ONPLAY_OK; |
50 | 51 | ||
52 | static bool list_viewers(void) | ||
53 | { | ||
54 | struct menu_item menu[8]; | ||
55 | int m, i, result; | ||
56 | |||
57 | i=filetype_load_menu(menu,sizeof(menu)/sizeof(*menu)); | ||
58 | if (i) | ||
59 | { | ||
60 | m = menu_init( menu, i, NULL, NULL, NULL, NULL ); | ||
61 | result = menu_show(m); | ||
62 | if (result >= 0) | ||
63 | { | ||
64 | menu_exit(m); | ||
65 | filetype_load_plugin(menu[result].desc,selected_file); | ||
66 | } | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | splash(HZ*2, true, "No viewers found"); | ||
71 | } | ||
72 | return false; | ||
73 | } | ||
74 | |||
51 | /* For playlist options */ | 75 | /* For playlist options */ |
52 | struct playlist_args { | 76 | struct playlist_args { |
53 | int position; | 77 | int position; |
@@ -625,7 +649,7 @@ bool create_dir(void) | |||
625 | 649 | ||
626 | int onplay(char* file, int attr) | 650 | int onplay(char* file, int attr) |
627 | { | 651 | { |
628 | struct menu_item items[5]; /* increase this if you add entries! */ | 652 | struct menu_item items[6]; /* increase this if you add entries! */ |
629 | int m, i=0, result; | 653 | int m, i=0, result; |
630 | 654 | ||
631 | onplay_result = ONPLAY_OK; | 655 | onplay_result = ONPLAY_OK; |
@@ -635,6 +659,14 @@ int onplay(char* file, int attr) | |||
635 | selected_file = file; | 659 | selected_file = file; |
636 | selected_file_attr = attr; | 660 | selected_file_attr = attr; |
637 | 661 | ||
662 | if (!(attr & ATTR_DIRECTORY)) | ||
663 | { | ||
664 | items[i].desc = str(LANG_ONPLAY_OPEN_WITH); | ||
665 | items[i].voice_id = LANG_ONPLAY_OPEN_WITH; | ||
666 | items[i].function = list_viewers; | ||
667 | i++; | ||
668 | } | ||
669 | |||
638 | if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || | 670 | if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || |
639 | (attr & ATTR_DIRECTORY) || | 671 | (attr & ATTR_DIRECTORY) || |
640 | ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)) | 672 | ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)) |