annotate libmenu/menu_pt.c @ 28656:5a0e7cec3f9f

Print the version string after the command line has been parsed. This allows printing the CPU information when verbose mode is triggered on the command line.
author diego
date Sat, 21 Feb 2009 17:35:48 +0000
parents f8b6c7045cf8
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28113
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
1 /*
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
2 * This file is part of MPlayer.
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
3 *
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
5 * it under the terms of the GNU General Public License as published by
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
7 * (at your option) any later version.
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
8 *
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
12 * GNU General Public License for more details.
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
13 *
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
14 * You should have received a copy of the GNU General Public License along
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
17 */
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
18
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
19 #include <stdlib.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
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
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
22 //#include <libgen.h>
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
23
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
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"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
27
19431
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 18817
diff changeset
28 #include "libmpcodecs/img_format.h"
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 18817
diff changeset
29 #include "libmpcodecs/mp_image.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
30
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
31 #include "m_struct.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
32 #include "m_option.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
33 #include "menu.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
34 #include "menu_list.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
35
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
36
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
37 #include "playtree.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
38 #include "input/input.h"
22284
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
39 #include "access_mpcontext.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
40
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
41 #define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1))
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
42
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
43 struct list_entry_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
44 struct list_entry p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
45 play_tree_t* pt;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
46 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
47
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
48
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
49 struct menu_priv_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
50 menu_list_priv_t p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
51 char* title;
27072
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
52 int auto_close;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
53 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
54
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
55 static struct menu_priv_s cfg_dflt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
56 MENU_LIST_PRIV_DFLT,
27072
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
57 "Jump to",
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
58 0
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
59 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
60
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
61 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
62
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
63 static m_option_t cfg_fields[] = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
64 MENU_LIST_PRIV_FIELDS,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
65 { "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
66 { "auto-close", ST_OFF(auto_close), CONF_TYPE_FLAG, 0, 0, 1, NULL },
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
67 { NULL, NULL, NULL, 0,0,0,NULL }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
68 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
69
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
70 #define mpriv (menu->priv)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
71
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
72 static void read_cmd(menu_t* menu,int cmd) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
73 switch(cmd) {
17945
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 16862
diff changeset
74 case MENU_CMD_RIGHT:
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
75 case MENU_CMD_OK: {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
76 int d = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
77 char str[15];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
78 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
79 mp_cmd_t* c;
22284
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
80 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
81
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
82 if(playtree_iter->tree == mpriv->p.current->pt)
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 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
86 snprintf(str,15,"pt_up_step 1");
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
87 else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
88 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
89 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
90 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
91 d++;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
92 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
93 if(i == NULL) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
94 d = -1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
95 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
96 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
97 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
98 d--;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
99 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
100 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
101 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
102 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
103 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
104 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
105 snprintf(str,15,"pt_step %d",d);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
106 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
107 c = mp_input_parse_cmd(str);
27072
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
108 if(c) {
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
109 if(mpriv->auto_close)
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
110 mp_input_queue_cmd(mp_input_parse_cmd("menu hide"));
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
111 mp_input_queue_cmd(c);
27072
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
112 }
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
113 else
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
114 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
115 } break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
116 default:
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
117 menu_list_read_cmd(menu,cmd);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
118 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
119 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
120
25502
605d4e3e403f From now on, libmenu does not steal all input keys from input modules.
ulion
parents: 25263
diff changeset
121 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
122 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
123 return 1;
605d4e3e403f From now on, libmenu does not steal all input keys from input modules.
ulion
parents: 25263
diff changeset
124 return menu_list_jump_to_key(menu, c);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
125 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
126
18817
a2b064a48775 declaring static functions with the same name than libc ones was not the best idea ever
ben
parents: 17994
diff changeset
127 static void close_menu(menu_t* menu) {
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
128 menu_list_uninit(menu,NULL);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
129 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
130
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
131 static int op(menu_t* menu, char* args) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
132 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
133 list_entry_t* e;
22284
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
134 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx);
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
135
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
136 args = NULL; // Warning kill
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
137
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
138 menu->draw = menu_list_draw;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
139 menu->read_cmd = read_cmd;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
140 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
141 menu->close = close_menu;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
142
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
143 menu_list_init(menu);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
144
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
145 mpriv->p.title = mpriv->title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
146
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
147 if(playtree_iter->tree->parent != playtree_iter->root) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
148 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
149 e->p.txt = "..";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
150 e->pt = playtree_iter->tree->parent;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
151 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
152 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
153
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
154 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
155 /* NOP */;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
156 for( ; i != NULL ; i = i->next ) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
157 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
158 if(i->files)
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
159 e->p.txt = mp_basename(i->files[0]);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
160 else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
161 e->p.txt = "Group ...";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
162 e->pt = i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
163 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
164 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
165
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
166 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
167 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
168
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
169 const menu_info_t menu_info_pt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
170 "Playtree menu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
171 "pt",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
172 "Albeu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
173 "",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
174 {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
175 "pt_cfg",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
176 sizeof(struct menu_priv_s),
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
177 &cfg_dflt,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
178 cfg_fields
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
179 },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
180 op
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
181 };