2 * This file is part of MPlayer.
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.
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.
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.
27 #include "libmpcodecs/img_format.h"
28 #include "libmpcodecs/mp_image.h"
32 #include "asxparser.h"
34 #include "menu_list.h"
36 #include "libvo/font_load.h"
38 #include "input/input.h"
55 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s, m)
57 static struct menu_priv_s cfg_dflt
= {
61 static const m_option_t cfg_fields
[] = {
62 MENU_LIST_PRIV_FIELDS
,
63 { "title",M_ST_OFF(struct menu_priv_s
,p
.title
), CONF_TYPE_STRING
, 0, 0, 0, NULL
},
64 { NULL
, NULL
, NULL
, 0,0,0,NULL
}
67 #define mpriv (menu->priv)
69 static void read_cmd(menu_t
* menu
,int cmd
) {
72 if(mpriv
->p
.current
->right
) {
73 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->right
);
75 } // fallback on ok if right is not defined
77 if (mpriv
->p
.current
->ok
)
78 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->ok
);
81 if(mpriv
->p
.current
->left
) {
82 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->left
);
84 } // fallback on cancel if left is not defined
86 if(mpriv
->p
.current
->cancel
) {
87 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->cancel
);
91 menu_list_read_cmd(menu
,cmd
);
95 static void free_entry(list_entry_t
* entry
) {
108 static void close_menu(menu_t
* menu
) {
109 menu_list_uninit(menu
,free_entry
);
112 static int parse_args(menu_t
* menu
,char* args
) {
113 char *element
,*body
, **attribs
, *name
;
114 list_entry_t
* m
= NULL
;
116 ASX_Parser_t
* parser
= asx_parser_new(menu
->mconfig
);
119 r
= asx_get_element(parser
,&args
,&element
,&body
,&attribs
);
121 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] syntax error at line: %d\n",parser
->line
);
122 asx_parser_free(parser
);
125 asx_parser_free(parser
);
127 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] No entry found in the menu definition.\n");
131 name
= asx_get_attrib("name",attribs
);
133 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] List menu entry definitions need a name (line %d).\n",parser
->line
);
136 asx_free_attribs(attribs
);
139 m
= calloc(1,sizeof(struct list_entry_s
));
141 m
->ok
= asx_get_attrib("ok",attribs
);
142 m
->cancel
= asx_get_attrib("cancel",attribs
);
143 m
->left
= asx_get_attrib("left",attribs
);
144 m
->right
= asx_get_attrib("right",attribs
);
145 menu_list_add_entry(menu
,m
);
149 asx_free_attribs(attribs
);
153 static int open_cmdlist(menu_t
* menu
, char* args
) {
154 menu
->draw
= menu_list_draw
;
155 menu
->read_cmd
= read_cmd
;
156 menu
->close
= close_menu
;
159 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] List menu needs an argument.\n");
163 menu_list_init(menu
);
164 if(!parse_args(menu
,args
))
169 const menu_info_t menu_info_cmdlist
= {
176 sizeof(struct menu_priv_s
),