Mercurial > mplayer.hg
annotate libmenu/menu_pt.c @ 36045:a6f9525929a4
Remove unnecessary initialization.
author | ib |
---|---|
date | Wed, 03 Apr 2013 16:25:33 +0000 |
parents | 18338ee51c9d |
children | b28f3ff37ae7 |
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 |
16862 | 24 #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
|
25 #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
|
26 #include "help_mp.h" |
32543
18338ee51c9d
Export mp_basename in a function instead of duplicate macros in various places
cboesch
parents:
30957
diff
changeset
|
27 #include "path.h" |
8197 | 28 |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18817
diff
changeset
|
29 #include "libmpcodecs/img_format.h" |
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18817
diff
changeset
|
30 #include "libmpcodecs/mp_image.h" |
8197 | 31 |
16862 | 32 #include "m_struct.h" |
33 #include "m_option.h" | |
8197 | 34 #include "menu.h" |
35 #include "menu_list.h" | |
36 | |
37 | |
16862 | 38 #include "playtree.h" |
39 #include "input/input.h" | |
22284 | 40 #include "access_mpcontext.h" |
8197 | 41 |
42 struct list_entry_s { | |
43 struct list_entry p; | |
44 play_tree_t* pt; | |
45 }; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
46 |
8197 | 47 |
48 struct menu_priv_s { | |
49 menu_list_priv_t p; | |
50 char* title; | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
51 int auto_close; |
8197 | 52 }; |
53 | |
54 static struct menu_priv_s cfg_dflt = { | |
55 MENU_LIST_PRIV_DFLT, | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
56 "Jump to", |
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
57 0 |
8197 | 58 }; |
59 | |
60 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m) | |
61 | |
30957 | 62 static const m_option_t cfg_fields[] = { |
8197 | 63 MENU_LIST_PRIV_FIELDS, |
64 { "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
|
65 { "auto-close", ST_OFF(auto_close), CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
8197 | 66 { NULL, NULL, NULL, 0,0,0,NULL } |
67 }; | |
68 | |
69 #define mpriv (menu->priv) | |
70 | |
71 static void read_cmd(menu_t* menu,int cmd) { | |
72 switch(cmd) { | |
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
73 case MENU_CMD_RIGHT: |
8197 | 74 case MENU_CMD_OK: { |
75 int d = 1; | |
76 char str[15]; | |
77 play_tree_t* i; | |
78 mp_cmd_t* c; | |
22284 | 79 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx); |
8197 | 80 |
81 if(playtree_iter->tree == mpriv->p.current->pt) | |
82 break; | |
83 | |
84 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent) | |
85 snprintf(str,15,"pt_up_step 1"); | |
86 else { | |
87 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) { | |
88 if(i == mpriv->p.current->pt) | |
89 break; | |
90 d++; | |
91 } | |
92 if(i == NULL) { | |
93 d = -1; | |
94 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) { | |
95 if(i == mpriv->p.current->pt) | |
96 break; | |
97 d--; | |
98 } | |
99 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
|
100 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem); |
8197 | 101 break; |
102 } | |
103 } | |
104 snprintf(str,15,"pt_step %d",d); | |
105 } | |
106 c = mp_input_parse_cmd(str); | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
107 if(c) { |
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
108 if(mpriv->auto_close) |
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
109 mp_input_queue_cmd(mp_input_parse_cmd("menu hide")); |
8197 | 110 mp_input_queue_cmd(c); |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
111 } |
8197 | 112 else |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
113 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str); |
8197 | 114 } break; |
115 default: | |
116 menu_list_read_cmd(menu,cmd); | |
117 } | |
118 } | |
119 | |
25502
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
120 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
|
121 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
|
122 return 1; |
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
123 return menu_list_jump_to_key(menu, c); |
8197 | 124 } |
125 | |
18817
a2b064a48775
declaring static functions with the same name than libc ones was not the best idea ever
ben
parents:
17994
diff
changeset
|
126 static void close_menu(menu_t* menu) { |
8197 | 127 menu_list_uninit(menu,NULL); |
128 } | |
129 | |
130 static int op(menu_t* menu, char* args) { | |
131 play_tree_t* i; | |
132 list_entry_t* e; | |
22284 | 133 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
|
134 |
8197 | 135 args = NULL; // Warning kill |
136 | |
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 }; |