Mercurial > mplayer.hg
annotate libmenu/menu_param.c @ 34633:7a633f403051
Update mplayer.ico.
It is the same content, but created with a different icon editor now,
because at least Wine's resource compiler didn't like the old format.
author | ib |
---|---|
date | Tue, 14 Feb 2012 11:45:56 +0000 |
parents | 8fa2f43cb760 |
children | 389d43c448b3 |
rev | line source |
---|---|
28113 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
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. | |
8 * | |
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. | |
13 * | |
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. | |
17 */ | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
18 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
19 #include "config.h" |
8197 | 20 |
21 #include <stdlib.h> | |
22 #include <stdio.h> | |
23 #include <dirent.h> | |
24 #include <errno.h> | |
25 #include <string.h> | |
26 #include <sys/types.h> | |
27 #include <sys/stat.h> | |
28 #include <ctype.h> | |
29 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
30 #include "mp_msg.h" |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
31 #include "help_mp.h" |
8197 | 32 |
16862 | 33 #include "m_struct.h" |
34 #include "m_option.h" | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
35 #include "m_property.h" |
16862 | 36 #include "asxparser.h" |
8197 | 37 |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
19059
diff
changeset
|
38 #include "libmpcodecs/mp_image.h" |
8197 | 39 |
40 #include "menu.h" | |
41 #include "menu_list.h" | |
16862 | 42 #include "input/input.h" |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
43 #include "command.h" |
19529
9a59c33bee29
new option for libmenu that allow display of properties and metadata of currently played stream
ben
parents:
19431
diff
changeset
|
44 |
8197 | 45 struct list_entry_s { |
46 struct list_entry p; | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
47 char* name; |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
48 char* txt; |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
49 char* prop; |
8197 | 50 m_option_t* opt; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
51 char* menu; |
25381 | 52 int auto_update; |
8197 | 53 }; |
54 | |
55 struct menu_priv_s { | |
56 menu_list_priv_t p; | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
57 char* ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
58 int edit; |
8197 | 59 /// Cfg fields |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
60 char* na; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
61 int hide_na; |
8197 | 62 }; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
63 |
8197 | 64 static struct menu_priv_s cfg_dflt = { |
65 MENU_LIST_PRIV_DFLT, | |
66 NULL, | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
67 0, |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
68 "N/A", |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
69 1 |
8197 | 70 }; |
71 | |
30957 | 72 static const m_option_t cfg_fields[] = { |
8197 | 73 MENU_LIST_PRIV_FIELDS, |
74 { "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
|
75 { "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
|
76 { "hide-na", M_ST_OFF(struct menu_priv_s,hide_na), CONF_TYPE_FLAG, CONF_RANGE, 0, 1, NULL }, |
8197 | 77 { NULL, NULL, NULL, 0,0,0,NULL } |
78 }; | |
79 | |
80 #define mpriv (menu->priv) | |
81 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
82 static void entry_set_text(menu_t* menu, list_entry_t* e) { |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
83 char* val = e->txt ? property_expand_string(menu->ctx, e->txt) : |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
84 mp_property_print(e->prop, menu->ctx); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
85 int l,edit = (mpriv->edit && e == mpriv->p.current); |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
86 if(!val || !val[0]) { |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
87 free(val); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
88 if(mpriv->hide_na) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
89 e->p.hide = 1; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
90 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
91 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
92 val = strdup(mpriv->na); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
93 } else if(mpriv->hide_na) |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
94 e->p.hide = 0; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
95 l = strlen(e->name) + 2 + strlen(val) + (edit ? 4 : 0) + 1; |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
96 free(e->p.txt); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
97 e->p.txt = malloc(l); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
98 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
|
99 free(val); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
100 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
101 |
25381 | 102 static void update_entries(menu_t* menu, int auto_update) { |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
103 list_entry_t* e; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
104 for(e = mpriv->p.menu ; e ; e = e->p.next) |
25381 | 105 if ((e->txt || e->prop) && (!auto_update || e->auto_update)) |
106 entry_set_text(menu, e); | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
107 } |
8197 | 108 |
109 static int parse_args(menu_t* menu,char* args) { | |
25381 | 110 char *element,*body, **attribs, *name, *txt, *auto_update; |
8197 | 111 list_entry_t* m = NULL; |
112 int r; | |
113 m_option_t* opt; | |
114 ASX_Parser_t* parser = asx_parser_new(); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
115 |
8197 | 116 |
117 while(1) { | |
118 r = asx_get_element(parser,&args,&element,&body,&attribs); | |
119 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
|
120 mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line); |
8197 | 121 asx_parser_free(parser); |
122 return -1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
123 } else if(r == 0) { |
8197 | 124 asx_parser_free(parser); |
125 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
|
126 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
|
127 m = calloc(1,sizeof(struct list_entry_s)); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
128 m->p.txt = strdup("Back"); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
129 menu_list_add_entry(menu,m); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
130 return 1; |
8197 | 131 } |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
132 if(!strcmp(element,"menu")) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
133 name = asx_get_attrib("menu",attribs); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
134 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
|
135 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
|
136 goto next_element; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
137 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
138 m = calloc(1,sizeof(struct list_entry_s)); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
139 m->menu = name; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
140 name = NULL; // we want to keep it |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
141 m->p.txt = asx_get_attrib("name",attribs); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
142 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
|
143 menu_list_add_entry(menu,m); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
144 goto next_element; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
145 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
146 |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
147 name = asx_get_attrib("property",attribs); |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
148 opt = NULL; |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
149 if(name && mp_property_do(name,M_PROPERTY_GET_TYPE,&opt,menu->ctx) <= 0) { |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
150 mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_InvalidProperty, |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
151 name,parser->line); |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
152 goto next_element; |
19529
9a59c33bee29
new option for libmenu that allow display of properties and metadata of currently played stream
ben
parents:
19431
diff
changeset
|
153 } |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
154 txt = asx_get_attrib("txt",attribs); |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
155 if(!(name || txt)) { |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17949
diff
changeset
|
156 mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_PrefMenuEntryDefinitionsNeed,parser->line); |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
157 free(txt); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
158 txt = NULL; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
159 goto next_element; |
8197 | 160 } |
161 m = calloc(1,sizeof(struct list_entry_s)); | |
162 m->opt = opt; | |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
163 m->txt = txt; txt = NULL; |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
164 m->prop = name; name = NULL; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
165 m->name = asx_get_attrib("name",attribs); |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
166 if(!m->name) m->name = strdup(opt ? opt->name : "-"); |
25381 | 167 auto_update = asx_get_attrib("auto-update", attribs); |
168 if (auto_update) { | |
169 if (!strcmp(auto_update, "1") || | |
170 !strcasecmp(auto_update, "on") || | |
171 !strcasecmp(auto_update, "yes") || | |
172 !strcasecmp(auto_update, "true")) | |
173 m->auto_update = 1; | |
174 free(auto_update); | |
175 } | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
176 entry_set_text(menu,m); |
8197 | 177 menu_list_add_entry(menu,m); |
178 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
179 next_element: |
8197 | 180 free(element); |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
181 free(body); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
182 free(name); |
8197 | 183 asx_free_attribs(attribs); |
184 } | |
185 } | |
186 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
187 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
|
188 list_entry_t* e = mpriv->p.current; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
189 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
190 if(e->opt) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
191 switch(cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
192 case MENU_CMD_UP: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
193 if(!mpriv->edit) break; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
194 case MENU_CMD_RIGHT: |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
195 if(mp_property_do(e->prop,M_PROPERTY_STEP_UP,NULL,menu->ctx) > 0) |
25381 | 196 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
197 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
198 case MENU_CMD_DOWN: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
199 if(!mpriv->edit) break; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
200 case MENU_CMD_LEFT: |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
201 if(mp_property_do(e->prop,M_PROPERTY_STEP_DOWN,NULL,menu->ctx) > 0) |
25381 | 202 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
203 return; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
204 |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
205 case MENU_CMD_OK: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
206 // check that the property is writable |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
207 if(mp_property_do(e->prop,M_PROPERTY_SET,NULL,menu->ctx) < 0) return; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
208 // shortcut for flags |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
209 if(e->opt->type == CONF_TYPE_FLAG) { |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
210 if(mp_property_do(e->prop,M_PROPERTY_STEP_UP,NULL,menu->ctx) > 0) |
25381 | 211 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
212 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
213 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
214 // switch |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
215 mpriv->edit = !mpriv->edit; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
216 // update the menu |
25381 | 217 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
218 // switch the pointer |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
219 if(mpriv->edit) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
220 mpriv->ptr = mpriv->p.ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
221 mpriv->p.ptr = NULL; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
222 } else |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
223 mpriv->p.ptr = mpriv->ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
224 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
225 case MENU_CMD_CANCEL: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
226 if(!mpriv->edit) break; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
227 mpriv->edit = 0; |
25381 | 228 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
229 mpriv->p.ptr = mpriv->ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
230 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
231 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
232 } else if(e->menu) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
233 switch(cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
234 case MENU_CMD_RIGHT: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
235 case MENU_CMD_OK: { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
236 mp_cmd_t* c; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
237 char* txt = malloc(10 + strlen(e->menu) + 1); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
238 sprintf(txt,"set_menu %s",e->menu); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
239 c = mp_input_parse_cmd(txt); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
240 if(c) mp_input_queue_cmd(c); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
241 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
242 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
243 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
244 } else { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
245 switch(cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
246 case MENU_CMD_RIGHT: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
247 case MENU_CMD_OK: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
248 menu->show = 0; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
249 menu->cl = 1; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
250 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
251 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
252 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
253 menu_list_read_cmd(menu,cmd); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
254 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
255 |
8197 | 256 static void free_entry(list_entry_t* entry) { |
257 free(entry->p.txt); | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
258 free(entry->name); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
259 free(entry->txt); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
260 free(entry->prop); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30957
diff
changeset
|
261 free(entry->menu); |
8197 | 262 free(entry); |
263 } | |
264 | |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
265 static void closeMenu(menu_t* menu) { |
8197 | 266 menu_list_uninit(menu,free_entry); |
267 } | |
268 | |
25381 | 269 static void menu_pref_draw(menu_t* menu, mp_image_t* mpi) { |
270 update_entries(menu, 1); | |
271 menu_list_draw(menu, mpi); | |
272 } | |
273 | |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
274 static int openMenu(menu_t* menu, char* args) { |
8197 | 275 |
25381 | 276 menu->draw = menu_pref_draw; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
277 menu->read_cmd = read_cmd; |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
278 menu->close = closeMenu; |
8197 | 279 |
280 | |
281 if(!args) { | |
18006
ce1a5b200c39
Minor spelling and grammar fixes for part 1 of Otvos Attila's
corey
parents:
17994
diff
changeset
|
282 mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_PrefMenuNeedsAnArgument); |
8197 | 283 return 0; |
284 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
285 |
8197 | 286 menu_list_init(menu); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
287 return parse_args(menu,args); |
8197 | 288 } |
289 | |
290 const menu_info_t menu_info_pref = { | |
291 "Preferences menu", | |
292 "pref", | |
293 "Albeu", | |
294 "", | |
295 { | |
296 "pref_cfg", | |
297 sizeof(struct menu_priv_s), | |
298 &cfg_dflt, | |
299 cfg_fields | |
300 }, | |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
301 openMenu |
8197 | 302 }; |