Mercurial > mplayer.hg
annotate libmenu/menu_param.c @ 26078:24a9193a0188
Use _res_comment in joystick check.
author | diego |
---|---|
date | Thu, 28 Feb 2008 18:19:10 +0000 |
parents | beda94ca3895 |
children | f8b6c7045cf8 |
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 |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
19059
diff
changeset
|
21 #include "libmpcodecs/mp_image.h" |
8197 | 22 |
23 #include "menu.h" | |
24 #include "menu_list.h" | |
16862 | 25 #include "input/input.h" |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
26 #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
|
27 |
8197 | 28 struct list_entry_s { |
29 struct list_entry p; | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
30 char* name; |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
31 char* txt; |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
32 char* prop; |
8197 | 33 m_option_t* opt; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
34 char* menu; |
25381 | 35 int auto_update; |
8197 | 36 }; |
37 | |
38 struct menu_priv_s { | |
39 menu_list_priv_t p; | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
40 char* ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
41 int edit; |
8197 | 42 /// Cfg fields |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
43 char* na; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
44 int hide_na; |
8197 | 45 }; |
19532
13599373bb02
added new helpers to allow easy metadata retrieval and make libmenu use them
ben
parents:
19529
diff
changeset
|
46 |
8197 | 47 static struct menu_priv_s cfg_dflt = { |
48 MENU_LIST_PRIV_DFLT, | |
49 NULL, | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
50 0, |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
51 "N/A", |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
52 1 |
8197 | 53 }; |
54 | |
55 static m_option_t cfg_fields[] = { | |
56 MENU_LIST_PRIV_FIELDS, | |
57 { "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
|
58 { "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
|
59 { "hide-na", M_ST_OFF(struct menu_priv_s,hide_na), CONF_TYPE_FLAG, CONF_RANGE, 0, 1, NULL }, |
8197 | 60 { NULL, NULL, NULL, 0,0,0,NULL } |
61 }; | |
62 | |
63 #define mpriv (menu->priv) | |
64 | |
17949
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) { |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
66 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
|
67 mp_property_print(e->prop, menu->ctx); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
68 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
|
69 if(!val || !val[0]) { |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
70 if(val) free(val); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
71 if(mpriv->hide_na) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
72 e->p.hide = 1; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
73 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
74 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
75 val = strdup(mpriv->na); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
76 } else if(mpriv->hide_na) |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
77 e->p.hide = 0; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
78 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
|
79 if(e->p.txt) free(e->p.txt); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
80 e->p.txt = malloc(l); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
81 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
|
82 free(val); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
83 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
84 |
25381 | 85 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
|
86 list_entry_t* e; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
87 for(e = mpriv->p.menu ; e ; e = e->p.next) |
25381 | 88 if ((e->txt || e->prop) && (!auto_update || e->auto_update)) |
89 entry_set_text(menu, e); | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
90 } |
8197 | 91 |
92 static int parse_args(menu_t* menu,char* args) { | |
25381 | 93 char *element,*body, **attribs, *name, *txt, *auto_update; |
8197 | 94 list_entry_t* m = NULL; |
95 int r; | |
96 m_option_t* opt; | |
97 ASX_Parser_t* parser = asx_parser_new(); | |
98 | |
99 | |
100 while(1) { | |
101 r = asx_get_element(parser,&args,&element,&body,&attribs); | |
102 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
|
103 mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line); |
8197 | 104 asx_parser_free(parser); |
105 return -1; | |
106 } else if(r == 0) { | |
107 asx_parser_free(parser); | |
108 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
|
109 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
|
110 m = calloc(1,sizeof(struct list_entry_s)); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
111 m->p.txt = strdup("Back"); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
112 menu_list_add_entry(menu,m); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
113 return 1; |
8197 | 114 } |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
115 if(!strcmp(element,"menu")) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
116 name = asx_get_attrib("menu",attribs); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
117 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
|
118 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
|
119 goto next_element; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
120 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
121 m = calloc(1,sizeof(struct list_entry_s)); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
122 m->menu = name; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
123 name = NULL; // we want to keep it |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
124 m->p.txt = asx_get_attrib("name",attribs); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
125 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
|
126 menu_list_add_entry(menu,m); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
127 goto next_element; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
128 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
129 |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
130 name = asx_get_attrib("property",attribs); |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
131 opt = NULL; |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
132 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
|
133 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
|
134 name,parser->line); |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
135 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
|
136 } |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
137 txt = asx_get_attrib("txt",attribs); |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
138 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
|
139 mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_PrefMenuEntryDefinitionsNeed,parser->line); |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
140 if(txt) free(txt), txt = NULL; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
141 goto next_element; |
8197 | 142 } |
143 m = calloc(1,sizeof(struct list_entry_s)); | |
144 m->opt = opt; | |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
145 m->txt = txt; txt = NULL; |
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
146 m->prop = name; name = NULL; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
147 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
|
148 if(!m->name) m->name = strdup(opt ? opt->name : "-"); |
25381 | 149 auto_update = asx_get_attrib("auto-update", attribs); |
150 if (auto_update) { | |
151 if (!strcmp(auto_update, "1") || | |
152 !strcasecmp(auto_update, "on") || | |
153 !strcasecmp(auto_update, "yes") || | |
154 !strcasecmp(auto_update, "true")) | |
155 m->auto_update = 1; | |
156 free(auto_update); | |
157 } | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
158 entry_set_text(menu,m); |
8197 | 159 menu_list_add_entry(menu,m); |
160 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
161 next_element: |
8197 | 162 free(element); |
163 if(body) free(body); | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
164 if(name) free(name); |
8197 | 165 asx_free_attribs(attribs); |
166 } | |
167 } | |
168 | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
169 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
|
170 list_entry_t* e = mpriv->p.current; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
171 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
172 if(e->opt) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
173 switch(cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
174 case MENU_CMD_UP: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
175 if(!mpriv->edit) break; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
176 case MENU_CMD_RIGHT: |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
177 if(mp_property_do(e->prop,M_PROPERTY_STEP_UP,NULL,menu->ctx) > 0) |
25381 | 178 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
179 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
180 case MENU_CMD_DOWN: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
181 if(!mpriv->edit) break; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
182 case MENU_CMD_LEFT: |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
183 if(mp_property_do(e->prop,M_PROPERTY_STEP_DOWN,NULL,menu->ctx) > 0) |
25381 | 184 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
185 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
186 |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
187 case MENU_CMD_OK: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
188 // check that the property is writable |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
189 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
|
190 // shortcut for flags |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
191 if(e->opt->type == CONF_TYPE_FLAG) { |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
192 if(mp_property_do(e->prop,M_PROPERTY_STEP_UP,NULL,menu->ctx) > 0) |
25381 | 193 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
194 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
195 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
196 // switch |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
197 mpriv->edit = !mpriv->edit; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
198 // update the menu |
25381 | 199 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
200 // switch the pointer |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
201 if(mpriv->edit) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
202 mpriv->ptr = mpriv->p.ptr; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
203 mpriv->p.ptr = NULL; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
204 } else |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
205 mpriv->p.ptr = mpriv->ptr; |
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 case MENU_CMD_CANCEL: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
208 if(!mpriv->edit) break; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
209 mpriv->edit = 0; |
25381 | 210 update_entries(menu, 0); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
211 mpriv->p.ptr = mpriv->ptr; |
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 } else if(e->menu) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
215 switch(cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
216 case MENU_CMD_RIGHT: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
217 case MENU_CMD_OK: { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
218 mp_cmd_t* c; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
219 char* txt = malloc(10 + strlen(e->menu) + 1); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
220 sprintf(txt,"set_menu %s",e->menu); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
221 c = mp_input_parse_cmd(txt); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
222 if(c) mp_input_queue_cmd(c); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
223 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
224 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
225 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
226 } else { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
227 switch(cmd) { |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
228 case MENU_CMD_RIGHT: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
229 case MENU_CMD_OK: |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
230 menu->show = 0; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
231 menu->cl = 1; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
232 return; |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
233 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
234 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
235 menu_list_read_cmd(menu,cmd); |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
236 } |
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
237 |
8197 | 238 static void free_entry(list_entry_t* entry) { |
239 free(entry->p.txt); | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
240 if(entry->name) free(entry->name); |
23398
69bf352bcef8
Drop the metadata stuff and replace it with generic property string expansion.
albeu
parents:
23393
diff
changeset
|
241 if(entry->txt) free(entry->txt); |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22284
diff
changeset
|
242 if(entry->prop) free(entry->prop); |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
243 if(entry->menu) free(entry->menu); |
8197 | 244 free(entry); |
245 } | |
246 | |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
247 static void closeMenu(menu_t* menu) { |
8197 | 248 menu_list_uninit(menu,free_entry); |
249 } | |
250 | |
25381 | 251 static void menu_pref_draw(menu_t* menu, mp_image_t* mpi) { |
252 update_entries(menu, 1); | |
253 menu_list_draw(menu, mpi); | |
254 } | |
255 | |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
256 static int openMenu(menu_t* menu, char* args) { |
8197 | 257 |
25381 | 258 menu->draw = menu_pref_draw; |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
259 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
|
260 menu->close = closeMenu; |
8197 | 261 |
262 | |
263 if(!args) { | |
18006
ce1a5b200c39
Minor spelling and grammar fixes for part 1 of Otvos Attila's
corey
parents:
17994
diff
changeset
|
264 mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_PrefMenuNeedsAnArgument); |
8197 | 265 return 0; |
266 } | |
267 | |
268 menu_list_init(menu); | |
17949
a6b11b35892a
Turn the preferences menu in something usefull using the new
albeu
parents:
16862
diff
changeset
|
269 return parse_args(menu,args); |
8197 | 270 } |
271 | |
272 const menu_info_t menu_info_pref = { | |
273 "Preferences menu", | |
274 "pref", | |
275 "Albeu", | |
276 "", | |
277 { | |
278 "pref_cfg", | |
279 sizeof(struct menu_priv_s), | |
280 &cfg_dflt, | |
281 cfg_fields | |
282 }, | |
10864
a2537e7d2d76
make menu work on mingw (run command is still disabled), based on patch by Christophe Perinaud
faust3
parents:
9380
diff
changeset
|
283 openMenu |
8197 | 284 }; |