Mercurial > mplayer.hg
annotate libmenu/menu_pt.c @ 36811:92dd1764392a
demuxers: remove pointless sh->ds assignments.
The new_sh_* functions have been fixed a long time
ago to do this.
author | reimar |
---|---|
date | Sun, 23 Feb 2014 18:14:44 +0000 |
parents | b28f3ff37ae7 |
children |
rev | line source |
---|---|
28113 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
8197 | 18 |
19 #include <stdlib.h> | |
20 #include <stdio.h> | |
8623
440301fef3fe
Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents:
8197
diff
changeset
|
21 #include <string.h> |
9102 | 22 //#include <libgen.h> |
8197 | 23 |
36582
b28f3ff37ae7
Use av_unused for unused arguments instead of various hacks.
reimar
parents:
32543
diff
changeset
|
24 #include "libavutil/attributes.h" |
b28f3ff37ae7
Use av_unused for unused arguments instead of various hacks.
reimar
parents:
32543
diff
changeset
|
25 |
16862 | 26 #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
|
27 #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
|
28 #include "help_mp.h" |
32543
18338ee51c9d
Export mp_basename in a function instead of duplicate macros in various places
cboesch
parents:
30957
diff
changeset
|
29 #include "path.h" |
8197 | 30 |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18817
diff
changeset
|
31 #include "libmpcodecs/img_format.h" |
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18817
diff
changeset
|
32 #include "libmpcodecs/mp_image.h" |
8197 | 33 |
16862 | 34 #include "m_struct.h" |
35 #include "m_option.h" | |
8197 | 36 #include "menu.h" |
37 #include "menu_list.h" | |
38 | |
39 | |
16862 | 40 #include "playtree.h" |
41 #include "input/input.h" | |
22284 | 42 #include "access_mpcontext.h" |
8197 | 43 |
44 struct list_entry_s { | |
45 struct list_entry p; | |
46 play_tree_t* pt; | |
47 }; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
48 |
8197 | 49 |
50 struct menu_priv_s { | |
51 menu_list_priv_t p; | |
52 char* title; | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
53 int auto_close; |
8197 | 54 }; |
55 | |
56 static struct menu_priv_s cfg_dflt = { | |
57 MENU_LIST_PRIV_DFLT, | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
58 "Jump to", |
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
59 0 |
8197 | 60 }; |
61 | |
62 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m) | |
63 | |
30957 | 64 static const m_option_t cfg_fields[] = { |
8197 | 65 MENU_LIST_PRIV_FIELDS, |
66 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
67 { "auto-close", ST_OFF(auto_close), CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
8197 | 68 { NULL, NULL, NULL, 0,0,0,NULL } |
69 }; | |
70 | |
71 #define mpriv (menu->priv) | |
72 | |
73 static void read_cmd(menu_t* menu,int cmd) { | |
74 switch(cmd) { | |
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
75 case MENU_CMD_RIGHT: |
8197 | 76 case MENU_CMD_OK: { |
77 int d = 1; | |
78 char str[15]; | |
79 play_tree_t* i; | |
80 mp_cmd_t* c; | |
22284 | 81 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx); |
8197 | 82 |
83 if(playtree_iter->tree == mpriv->p.current->pt) | |
84 break; | |
85 | |
86 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent) | |
87 snprintf(str,15,"pt_up_step 1"); | |
88 else { | |
89 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) { | |
90 if(i == mpriv->p.current->pt) | |
91 break; | |
92 d++; | |
93 } | |
94 if(i == NULL) { | |
95 d = -1; | |
96 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) { | |
97 if(i == mpriv->p.current->pt) | |
98 break; | |
99 d--; | |
100 } | |
101 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
|
102 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem); |
8197 | 103 break; |
104 } | |
105 } | |
106 snprintf(str,15,"pt_step %d",d); | |
107 } | |
108 c = mp_input_parse_cmd(str); | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
109 if(c) { |
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
110 if(mpriv->auto_close) |
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
111 mp_input_queue_cmd(mp_input_parse_cmd("menu hide")); |
8197 | 112 mp_input_queue_cmd(c); |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
113 } |
8197 | 114 else |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
115 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str); |
8197 | 116 } break; |
117 default: | |
118 menu_list_read_cmd(menu,cmd); | |
119 } | |
120 } | |
121 | |
25502
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
122 static int read_key(menu_t* menu,int c){ |
25263
96d0992c7920
Remove hardcoded key->cmd bindings in libmenu, support custom key bindings
ulion
parents:
22284
diff
changeset
|
123 if (menu_dflt_read_key(menu, c)) |
25502
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
124 return 1; |
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
125 return menu_list_jump_to_key(menu, c); |
8197 | 126 } |
127 | |
18817
a2b064a48775
declaring static functions with the same name than libc ones was not the best idea ever
ben
parents:
17994
diff
changeset
|
128 static void close_menu(menu_t* menu) { |
8197 | 129 menu_list_uninit(menu,NULL); |
130 } | |
131 | |
36582
b28f3ff37ae7
Use av_unused for unused arguments instead of various hacks.
reimar
parents:
32543
diff
changeset
|
132 static int op(menu_t* menu, char* av_unused args) { |
8197 | 133 play_tree_t* i; |
134 list_entry_t* e; | |
22284 | 135 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
136 |
8197 | 137 menu->draw = menu_list_draw; |
138 menu->read_cmd = read_cmd; | |
139 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
|
140 menu->close = close_menu; |
8197 | 141 |
142 menu_list_init(menu); | |
143 | |
144 mpriv->p.title = mpriv->title; | |
145 | |
146 if(playtree_iter->tree->parent != playtree_iter->root) { | |
147 e = calloc(1,sizeof(list_entry_t)); | |
148 e->p.txt = ".."; | |
149 e->pt = playtree_iter->tree->parent; | |
150 menu_list_add_entry(menu,e); | |
151 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
152 |
8197 | 153 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev) |
154 /* NOP */; | |
155 for( ; i != NULL ; i = i->next ) { | |
156 e = calloc(1,sizeof(list_entry_t)); | |
157 if(i->files) | |
32543
18338ee51c9d
Export mp_basename in a function instead of duplicate macros in various places
cboesch
parents:
30957
diff
changeset
|
158 e->p.txt = (char *)mp_basename(i->files[0]); |
8197 | 159 else |
160 e->p.txt = "Group ..."; | |
161 e->pt = i; | |
162 menu_list_add_entry(menu,e); | |
163 } | |
164 | |
165 return 1; | |
166 } | |
167 | |
168 const menu_info_t menu_info_pt = { | |
169 "Playtree menu", | |
170 "pt", | |
171 "Albeu", | |
172 "", | |
173 { | |
174 "pt_cfg", | |
175 sizeof(struct menu_priv_s), | |
176 &cfg_dflt, | |
177 cfg_fields | |
178 }, | |
179 op | |
180 }; |