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.
28 #include "libmpcodecs/img_format.h"
29 #include "libmpcodecs/mp_image.h"
33 #include "asxparser.h"
35 #include "menu_list.h"
37 #include "libvo/font_load.h"
39 #include "input/input.h"
56 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s, m)
58 static struct menu_priv_s cfg_dflt
= {
62 static m_option_t cfg_fields
[] = {
63 MENU_LIST_PRIV_FIELDS
,
64 { "title",M_ST_OFF(struct menu_priv_s
,p
.title
), CONF_TYPE_STRING
, 0, 0, 0, NULL
},
65 { NULL
, NULL
, NULL
, 0,0,0,NULL
}
68 #define mpriv (menu->priv)
70 static void read_cmd(menu_t
* menu
,int cmd
) {
73 if(mpriv
->p
.current
->right
) {
74 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->right
);
76 } // fallback on ok if right is not defined
78 if (mpriv
->p
.current
->ok
)
79 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->ok
);
82 if(mpriv
->p
.current
->left
) {
83 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->left
);
85 } // fallback on cancel if left is not defined
87 if(mpriv
->p
.current
->cancel
) {
88 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->cancel
);
92 menu_list_read_cmd(menu
,cmd
);
96 static void free_entry(list_entry_t
* entry
) {
109 static void close_menu(menu_t
* menu
) {
110 menu_list_uninit(menu
,free_entry
);
113 static int parse_args(menu_t
* menu
,char* args
) {
114 char *element
,*body
, **attribs
, *name
;
115 list_entry_t
* m
= NULL
;
117 ASX_Parser_t
* parser
= asx_parser_new(menu
->mconfig
);
120 r
= asx_get_element(parser
,&args
,&element
,&body
,&attribs
);
122 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] syntax error at line: %d\n",parser
->line
);
123 asx_parser_free(parser
);
126 asx_parser_free(parser
);
128 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] No entry found in the menu definition.\n");
132 name
= asx_get_attrib("name",attribs
);
134 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] List menu entry definitions need a name (line %d).\n",parser
->line
);
137 asx_free_attribs(attribs
);
140 m
= calloc(1,sizeof(struct list_entry_s
));
142 m
->ok
= asx_get_attrib("ok",attribs
);
143 m
->cancel
= asx_get_attrib("cancel",attribs
);
144 m
->left
= asx_get_attrib("left",attribs
);
145 m
->right
= asx_get_attrib("right",attribs
);
146 menu_list_add_entry(menu
,m
);
150 asx_free_attribs(attribs
);
154 static int open_cmdlist(menu_t
* menu
, char* args
) {
155 menu
->draw
= menu_list_draw
;
156 menu
->read_cmd
= read_cmd
;
157 menu
->close
= close_menu
;
160 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] List menu needs an argument.\n");
164 menu_list_init(menu
);
165 if(!parse_args(menu
,args
))
170 const menu_info_t menu_info_cmdlist
= {
177 sizeof(struct menu_priv_s
),