annotate libmenu/menu_pt.c @ 21731:61c0bae18c23

replace call to UDFFindFile() (that is not part of the public API) with DVDOpenFile() patch by Klaus Muller (mk.2001 web de)
author nicodvb
date Sat, 23 Dec 2006 23:13:11 +0000
parents ac69ba536915
children 83366c8e1928
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
1
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
2 #include <stdlib.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
3 #include <stdio.h>
8623
440301fef3fe Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents: 8197
diff changeset
4 #include <string.h>
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
5 //#include <libgen.h>
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
6
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
7 #include "config.h"
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
8 #include "mp_msg.h"
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
9 #include "help_mp.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
10
19431
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 18817
diff changeset
11 #include "libmpcodecs/img_format.h"
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 18817
diff changeset
12 #include "libmpcodecs/mp_image.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
13
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
14 #include "m_struct.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
15 #include "m_option.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
16 #include "menu.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
17 #include "menu_list.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
18
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
19
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
20 #include "playtree.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
21 #include "input/input.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
22
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
23 #define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1))
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
24
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
25 extern play_tree_iter_t* playtree_iter;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
26
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
27 struct list_entry_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
28 struct list_entry p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
29 play_tree_t* pt;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
30 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
31
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
32
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
33 struct menu_priv_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
34 menu_list_priv_t p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
35 char* title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
36 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
37
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
38 static struct menu_priv_s cfg_dflt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
39 MENU_LIST_PRIV_DFLT,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
40 "Jump to"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
41 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
42
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
43 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
44
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
45 static m_option_t cfg_fields[] = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
46 MENU_LIST_PRIV_FIELDS,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
47 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
48 { NULL, NULL, NULL, 0,0,0,NULL }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
49 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
50
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
51 #define mpriv (menu->priv)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
52
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
53 static void read_cmd(menu_t* menu,int cmd) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
54 switch(cmd) {
17945
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 16862
diff changeset
55 case MENU_CMD_RIGHT:
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
56 case MENU_CMD_OK: {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
57 int d = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
58 char str[15];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
59 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
60 mp_cmd_t* c;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
61
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
62
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
63 if(playtree_iter->tree == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
64 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
65
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
66 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
67 snprintf(str,15,"pt_up_step 1");
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
68 else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
69 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
70 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
71 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
72 d++;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
73 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
74 if(i == NULL) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
75 d = -1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
76 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
77 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
78 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
79 d--;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
80 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
81 if(i == NULL) {
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
82 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
83 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
84 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
85 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
86 snprintf(str,15,"pt_step %d",d);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
87 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
88 c = mp_input_parse_cmd(str);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
89 if(c)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
90 mp_input_queue_cmd(c);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
91 else
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
92 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
93 } break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
94 default:
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
95 menu_list_read_cmd(menu,cmd);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
96 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
97 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
98
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
99 static void read_key(menu_t* menu,int c){
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
100 menu_list_read_key(menu,c,1);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
101 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
102
18817
a2b064a48775 declaring static functions with the same name than libc ones was not the best idea ever
ben
parents: 17994
diff changeset
103 static void close_menu(menu_t* menu) {
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
104 menu_list_uninit(menu,NULL);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
105 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
106
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
107 static int op(menu_t* menu, char* args) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
108 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
109 list_entry_t* e;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
110 args = NULL; // Warning kill
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
111
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
112 menu->draw = menu_list_draw;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
113 menu->read_cmd = read_cmd;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
114 menu->read_key = read_key;
18817
a2b064a48775 declaring static functions with the same name than libc ones was not the best idea ever
ben
parents: 17994
diff changeset
115 menu->close = close_menu;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
116
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
117 menu_list_init(menu);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
118
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
119 mpriv->p.title = mpriv->title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
120
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
121 if(playtree_iter->tree->parent != playtree_iter->root) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
122 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
123 e->p.txt = "..";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
124 e->pt = playtree_iter->tree->parent;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
125 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
126 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
127
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
128 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
129 /* NOP */;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
130 for( ; i != NULL ; i = i->next ) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
131 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
132 if(i->files)
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
133 e->p.txt = mp_basename(i->files[0]);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
134 else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
135 e->p.txt = "Group ...";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
136 e->pt = i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
137 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
138 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
139
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
140 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
141 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
142
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
143 const menu_info_t menu_info_pt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
144 "Playtree menu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
145 "pt",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
146 "Albeu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
147 "",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
148 {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
149 "pt_cfg",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
150 sizeof(struct menu_priv_s),
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
151 &cfg_dflt,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
152 cfg_fields
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
153 },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
154 op
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
155 };