17
#include "asxparser.h"
19
#include "img_format.h"
23
#include "menu_list.h"
24
#include "input/input.h"
25
#include "osdep/keycodes.h"
39
static struct menu_priv_s cfg_dflt = {
45
static m_option_t cfg_fields[] = {
46
MENU_LIST_PRIV_FIELDS,
47
{ "title", M_ST_OFF(menu_list_priv_t,title), CONF_TYPE_STRING, 0, 0, 0, NULL },
48
{ NULL, NULL, NULL, 0,0,0,NULL }
51
#define mpriv (menu->priv)
53
extern m_config_t* mconfig;
55
static int parse_args(menu_t* menu,char* args) {
56
char *element,*body, **attribs, *name, *ok, *cancel;
57
list_entry_t* m = NULL;
60
ASX_Parser_t* parser = asx_parser_new();
64
r = asx_get_element(parser,&args,&element,&body,&attribs);
66
printf("Syntax error at line %d\n",parser->line);
67
asx_parser_free(parser);
70
asx_parser_free(parser);
72
printf("No entry found in the menu definition\n");
76
name = asx_get_attrib("name",attribs);
77
opt = name ? m_config_get_option(mconfig,name) : NULL;
79
printf("Pref menu entry definitions need a valid name attribut (line %d)\n",parser->line);
83
asx_free_attribs(attribs);
86
m = calloc(1,sizeof(struct list_entry_s));
89
menu_list_add_entry(menu,m);
93
asx_free_attribs(attribs);
97
static void read_key(menu_t* menu,int c) {
98
menu_list_read_key(menu,c,0);
101
static void free_entry(list_entry_t* entry) {
106
static void closeMenu(menu_t* menu) {
107
menu_list_uninit(menu,free_entry);
112
static int openMenu(menu_t* menu, char* args) {
115
menu->draw = menu_list_draw;
116
menu->read_cmd = menu_list_read_cmd;
117
menu->read_key = read_key;
118
menu->close = closeMenu;
122
printf("Pref menu need an argument\n");
126
menu_list_init(menu);
127
if(!parse_args(menu,args))
130
for(e = mpriv->p.menu ; e ; e = e->p.next) {
132
char* val = m_option_print(e->opt,e->opt->p);
134
printf("Can't get value of option %s\n",e->opt->name);
137
val = strdup("NULL");
138
l = strlen(e->opt->name) + 2 + strlen(val) + 1;
139
e->p.txt = malloc(l);
140
sprintf(e->p.txt,"%s: %s",e->opt->name,val);
147
const menu_info_t menu_info_pref = {
154
sizeof(struct menu_priv_s),