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 "sub/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
) {
104 static void close_menu(menu_t
* menu
) {
105 menu_list_uninit(menu
,free_entry
);
108 static int parse_args(menu_t
* menu
,char* args
) {
109 char *element
,*body
, **attribs
, *name
;
110 list_entry_t
* m
= NULL
;
112 ASX_Parser_t
* parser
= asx_parser_new(menu
->mconfig
);
115 r
= asx_get_element(parser
,&args
,&element
,&body
,&attribs
);
117 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] syntax error at line: %d\n",parser
->line
);
118 asx_parser_free(parser
);
121 asx_parser_free(parser
);
123 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] No entry found in the menu definition.\n");
127 name
= asx_get_attrib("name",attribs
);
129 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] List menu entry definitions need a name (line %d).\n",parser
->line
);
132 asx_free_attribs(attribs
);
135 m
= calloc(1,sizeof(struct list_entry_s
));
137 m
->ok
= asx_get_attrib("ok",attribs
);
138 m
->cancel
= asx_get_attrib("cancel",attribs
);
139 m
->left
= asx_get_attrib("left",attribs
);
140 m
->right
= asx_get_attrib("right",attribs
);
141 menu_list_add_entry(menu
,m
);
145 asx_free_attribs(attribs
);
149 static int open_cmdlist(menu_t
* menu
, char* args
) {
150 menu
->draw
= menu_list_draw
;
151 menu
->read_cmd
= read_cmd
;
152 menu
->close
= close_menu
;
155 mp_tmsg(MSGT_GLOBAL
,MSGL_WARN
,"[MENU] List menu needs an argument.\n");
159 menu_list_init(menu
);
160 if(!parse_args(menu
,args
))
165 const menu_info_t menu_info_cmdlist
= {
172 sizeof(struct menu_priv_s
),