Mercurial > mplayer.hg
annotate libmenu/menu_param.c @ 18302:559a1b5c1f10
Removes duplicate entry
author | reynaldo |
---|---|
date | Thu, 27 Apr 2006 03:55:46 +0000 |
parents | ce1a5b200c39 |
children | 231c0e700597 |
rev | line source |
---|---|
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
1 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
2 #include "config.h" |
8197 | 3 |
4 #include <stdlib.h> | |
5 #include <stdio.h> | |
6 #include <dirent.h> | |
7 #include <errno.h> | |
8 #include <string.h> | |
9 #include <sys/types.h> | |
10 #include <sys/stat.h> | |
11 #include <ctype.h> | |
12 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
13 #include "mp_msg.h" |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
14 #include "help_mp.h" |
8197 | 15 |
16862 | 16 #include "m_struct.h" |
17 #include "m_option.h" | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
18 #include "m_property.h" |
16862 | 19 #include "asxparser.h" |
8197 | 20 |
21 #include "img_format.h" | |
22 #include "mp_image.h" | |
23 | |
24 #include "menu.h" | |
25 #include "menu_list.h" | |
16862 | 26 #include "input/input.h" |
27 #include "osdep/keycodes.h" | |
8197 | 28 |
29 struct list_entry_s { | |
30 struct list_entry p; | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
31 char* name; |
8197 | 32 m_option_t* opt; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
33 char* menu; |
8197 | 34 }; |
35 | |
36 struct menu_priv_s { | |
37 menu_list_priv_t p; | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
38 char* ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
39 int edit; |
8197 | 40 /// Cfg fields |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
41 char* na; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
42 int hide_na; |
8197 | 43 }; |
44 | |
45 static struct menu_priv_s cfg_dflt = { | |
46 MENU_LIST_PRIV_DFLT, | |
47 NULL, | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
48 0, |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
49 "N/A", |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
50 1 |
8197 | 51 }; |
52 | |
53 static m_option_t cfg_fields[] = { | |
54 MENU_LIST_PRIV_FIELDS, | |
55 { "title", M_ST_OFF(menu_list_priv_t,title), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
56 { "na", M_ST_OFF(struct menu_priv_s,na), CONF_TYPE_STRING, 0, 0, 0, NULL }, |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
57 { "hide-na", M_ST_OFF(struct menu_priv_s,hide_na), CONF_TYPE_FLAG, CONF_RANGE, 0, 1, NULL }, |
8197 | 58 { NULL, NULL, NULL, 0,0,0,NULL } |
59 }; | |
60 | |
61 #define mpriv (menu->priv) | |
62 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
63 m_option_t* mp_property_find(char* name); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
64 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
65 static void entry_set_text(menu_t* menu, list_entry_t* e) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
66 char* val = m_property_print(e->opt); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
67 int l,edit = (mpriv->edit && e == mpriv->p.current); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
68 if(!val) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
69 if(mpriv->hide_na) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
70 e->p.hide = 1; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
71 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
72 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
73 val = strdup(mpriv->na); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
74 } else if(mpriv->hide_na) |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
75 e->p.hide = 0; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
76 l = strlen(e->name) + 2 + strlen(val) + (edit ? 4 : 0) + 1; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
77 if(e->p.txt) free(e->p.txt); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
78 e->p.txt = malloc(l); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
79 sprintf(e->p.txt,"%s: %s%s%s",e->name,edit ? "> " : "",val,edit ? " <" : ""); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
80 free(val); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
81 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
82 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
83 static void update_entries(menu_t* menu) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
84 list_entry_t* e; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
85 for(e = mpriv->p.menu ; e ; e = e->p.next) |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
86 if(e->opt) entry_set_text(menu,e); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
87 } |
8197 | 88 |
89 static int parse_args(menu_t* menu,char* args) { | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
90 char *element,*body, **attribs, *name; |
8197 | 91 list_entry_t* m = NULL; |
92 int r; | |
93 m_option_t* opt; | |
94 ASX_Parser_t* parser = asx_parser_new(); | |
95 | |
96 | |
97 while(1) { | |
98 r = asx_get_element(parser,&args,&element,&body,&attribs); | |
99 if(r < 0) { | |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17949
diff
changeset
|
100 mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line); |
8197 | 101 asx_parser_free(parser); |
102 return -1; | |
103 } else if(r == 0) { | |
104 asx_parser_free(parser); | |
105 if(!m) | |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17949
diff
changeset
|
106 mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_NoEntryFoundInTheMenuDefinition); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
107 m = calloc(1,sizeof(struct list_entry_s)); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
108 m->p.txt = strdup("Back"); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
109 menu_list_add_entry(menu,m); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
110 return 1; |
8197 | 111 } |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
112 if(!strcmp(element,"menu")) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
113 name = asx_get_attrib("menu",attribs); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
114 if(!name) { |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17949
diff
changeset
|
115 mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_SubmenuDefinitionNeedAMenuAttribut); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
116 goto next_element; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
117 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
118 m = calloc(1,sizeof(struct list_entry_s)); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
119 m->menu = name; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
120 name = NULL; // we want to keep it |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
121 m->p.txt = asx_get_attrib("name",attribs); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
122 if(!m->p.txt) m->p.txt = strdup(m->menu); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
123 menu_list_add_entry(menu,m); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
124 goto next_element; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
125 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
126 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
127 name = asx_get_attrib("property",attribs); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
128 opt = name ? mp_property_find(name) : NULL; |
8197 | 129 if(!opt) { |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17949
diff
changeset
|
130 mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_PrefMenuEntryDefinitionsNeed,parser->line); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
131 goto next_element; |
8197 | 132 } |
133 m = calloc(1,sizeof(struct list_entry_s)); | |
134 m->opt = opt; | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
135 m->name = asx_get_attrib("name",attribs); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
136 if(!m->name) m->name = strdup(opt->name); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
137 entry_set_text(menu,m); |
8197 | 138 menu_list_add_entry(menu,m); |
139 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
140 next_element: |
8197 | 141 free(element); |
142 if(body) free(body); | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
143 if(name) free(name); |
8197 | 144 asx_free_attribs(attribs); |
145 } | |
146 } | |
147 | |
148 static void read_key(menu_t* menu,int c) { | |
149 menu_list_read_key(menu,c,0); | |
150 } | |
151 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
152 static void read_cmd(menu_t* menu,int cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
153 list_entry_t* e = mpriv->p.current; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
154 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
155 if(e->opt) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
156 switch(cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
157 case MENU_CMD_UP: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
158 if(!mpriv->edit) break; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
159 case MENU_CMD_RIGHT: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
160 if(m_property_do(e->opt,M_PROPERTY_STEP_UP,NULL) > 0) |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
161 update_entries(menu); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
162 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
163 case MENU_CMD_DOWN: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
164 if(!mpriv->edit) break; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
165 case MENU_CMD_LEFT: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
166 if(m_property_do(e->opt,M_PROPERTY_STEP_DOWN,NULL) > 0) |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
167 update_entries(menu); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
168 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
169 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
170 case MENU_CMD_OK: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
171 // check that the property is writable |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
172 if(m_property_do(e->opt,M_PROPERTY_SET,NULL) < 0) return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
173 // shortcut for flags |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
174 if(e->opt->type == CONF_TYPE_FLAG) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
175 if(m_property_do(e->opt,M_PROPERTY_STEP_UP,NULL) > 0) |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
176 update_entries(menu); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
177 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
178 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
179 // switch |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
180 mpriv->edit = !mpriv->edit; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
181 // update the menu |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
182 update_entries(menu); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
183 // switch the pointer |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
184 if(mpriv->edit) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
185 mpriv->ptr = mpriv->p.ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
186 mpriv->p.ptr = NULL; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
187 } else |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
188 mpriv->p.ptr = mpriv->ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
189 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
190 case MENU_CMD_CANCEL: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
191 if(!mpriv->edit) break; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
192 mpriv->edit = 0; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
193 update_entries(menu); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
194 mpriv->p.ptr = mpriv->ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
195 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
196 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
197 } else if(e->menu) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
198 switch(cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
199 case MENU_CMD_RIGHT: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
200 case MENU_CMD_OK: { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
201 mp_cmd_t* c; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
202 char* txt = malloc(10 + strlen(e->menu) + 1); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
203 sprintf(txt,"set_menu %s",e->menu); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
204 c = mp_input_parse_cmd(txt); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
205 if(c) mp_input_queue_cmd(c); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
206 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
207 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
208 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
209 } else { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
210 switch(cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
211 case MENU_CMD_RIGHT: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
212 case MENU_CMD_OK: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
213 menu->show = 0; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
214 menu->cl = 1; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
215 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
216 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
217 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
218 menu_list_read_cmd(menu,cmd); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
219 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
220 |
8197 | 221 static void free_entry(list_entry_t* entry) { |
222 free(entry->p.txt); | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
223 if(entry->name) free(entry->name); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
224 if(entry->menu) free(entry->menu); |
8197 | 225 free(entry); |
226 } | |
227 | |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
228 static void closeMenu(menu_t* menu) { |
8197 | 229 menu_list_uninit(menu,free_entry); |
230 } | |
231 | |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
232 static int openMenu(menu_t* menu, char* args) { |
8197 | 233 |
234 menu->draw = menu_list_draw; | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
235 menu->read_cmd = read_cmd; |
8197 | 236 menu->read_key = read_key; |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
237 menu->close = closeMenu; |
8197 | 238 |
239 | |
240 if(!args) { | |
18006
ce1a5b200c39
Minor spelling and grammar fixes for part 1 of Otvos Attila's
corey
parents:
17994
diff
changeset
|
241 mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_PrefMenuNeedsAnArgument); |
8197 | 242 return 0; |
243 } | |
244 | |
245 menu_list_init(menu); | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
246 return parse_args(menu,args); |
8197 | 247 } |
248 | |
249 const menu_info_t menu_info_pref = { | |
250 "Preferences menu", | |
251 "pref", | |
252 "Albeu", | |
253 "", | |
254 { | |
255 "pref_cfg", | |
256 sizeof(struct menu_priv_s), | |
257 &cfg_dflt, | |
258 cfg_fields | |
259 }, | |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
260 openMenu |
8197 | 261 }; |