Mercurial > mplayer.hg
annotate libmenu/menu_cmdlist.c @ 37195:ac6c37d85d65 default tip
configure: Fix initialization of variable def_local_aligned_32
It contiained the #define of HAVE_LOCAL_ALIGNED_16 instead
of HAVE_LOCAL_ALIGNED_32.
| author | al |
|---|---|
| date | Sun, 28 Sep 2014 18:38:41 +0000 |
| parents | 8fa2f43cb760 |
| children |
| 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 */ | |
| 8197 | 18 |
| 16862 | 19 #include "config.h" |
|
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
20 #include "mp_msg.h" |
|
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
21 #include "help_mp.h" |
| 8197 | 22 |
| 23 #include <stdlib.h> | |
| 24 #include <stdio.h> | |
| 25 #include <ctype.h> | |
|
8623
440301fef3fe
Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents:
8197
diff
changeset
|
26 #include <string.h> |
| 8197 | 27 |
|
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18819
diff
changeset
|
28 #include "libmpcodecs/img_format.h" |
|
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18819
diff
changeset
|
29 #include "libmpcodecs/mp_image.h" |
| 8197 | 30 |
| 16862 | 31 #include "m_option.h" |
| 32 #include "m_struct.h" | |
| 33 #include "asxparser.h" | |
| 8197 | 34 #include "menu.h" |
| 35 #include "menu_list.h" | |
| 36 | |
|
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
30957
diff
changeset
|
37 #include "sub/font_load.h" |
| 8197 | 38 |
| 16862 | 39 #include "input/input.h" |
| 8197 | 40 |
| 41 | |
| 42 | |
| 43 struct list_entry_s { | |
| 44 struct list_entry p; | |
| 45 | |
| 46 char* ok; | |
| 47 char* cancel; | |
|
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
48 char* left; |
|
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
49 char* right; |
| 8197 | 50 }; |
| 51 | |
| 52 struct menu_priv_s { | |
| 53 menu_list_priv_t p; | |
| 54 }; | |
| 55 | |
|
18819
cd0491dc2afa
support for auto_close parameter in menu command list (geexbox patch)
ben
parents:
18817
diff
changeset
|
56 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s, m) |
|
cd0491dc2afa
support for auto_close parameter in menu command list (geexbox patch)
ben
parents:
18817
diff
changeset
|
57 |
| 8197 | 58 static struct menu_priv_s cfg_dflt = { |
|
18819
cd0491dc2afa
support for auto_close parameter in menu command list (geexbox patch)
ben
parents:
18817
diff
changeset
|
59 MENU_LIST_PRIV_DFLT, |
| 8197 | 60 }; |
| 61 | |
| 30957 | 62 static const m_option_t cfg_fields[] = { |
| 8197 | 63 MENU_LIST_PRIV_FIELDS, |
| 64 { "title",M_ST_OFF(struct menu_priv_s,p.title), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
| 65 { NULL, NULL, NULL, 0,0,0,NULL } | |
| 66 }; | |
| 67 | |
| 68 #define mpriv (menu->priv) | |
| 69 | |
| 70 static void read_cmd(menu_t* menu,int cmd) { | |
| 71 switch(cmd) { | |
|
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
72 case MENU_CMD_RIGHT: |
|
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
73 if(mpriv->p.current->right) { |
|
25320
4fbf536cc033
Support to run multiple mplayer commands set in menu.conf
ulion
parents:
25263
diff
changeset
|
74 mp_input_parse_and_queue_cmds(mpriv->p.current->right); |
|
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
75 break; |
|
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
76 } // fallback on ok if right is not defined |
| 25498 | 77 case MENU_CMD_OK: |
|
25505
8d329f7bbc3c
Remove redundant option 'auto-close' from cmdlist and filesel.
ulion
parents:
25498
diff
changeset
|
78 if (mpriv->p.current->ok) |
|
8d329f7bbc3c
Remove redundant option 'auto-close' from cmdlist and filesel.
ulion
parents:
25498
diff
changeset
|
79 mp_input_parse_and_queue_cmds(mpriv->p.current->ok); |
| 25498 | 80 break; |
|
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
81 case MENU_CMD_LEFT: |
|
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
82 if(mpriv->p.current->left) { |
|
25320
4fbf536cc033
Support to run multiple mplayer commands set in menu.conf
ulion
parents:
25263
diff
changeset
|
83 mp_input_parse_and_queue_cmds(mpriv->p.current->left); |
|
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
84 break; |
|
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
85 } // fallback on cancel if left is not defined |
| 8197 | 86 case MENU_CMD_CANCEL: |
| 87 if(mpriv->p.current->cancel) { | |
|
25320
4fbf536cc033
Support to run multiple mplayer commands set in menu.conf
ulion
parents:
25263
diff
changeset
|
88 mp_input_parse_and_queue_cmds(mpriv->p.current->cancel); |
| 8197 | 89 break; |
| 90 } | |
| 91 default: | |
| 92 menu_list_read_cmd(menu,cmd); | |
| 93 } | |
| 94 } | |
| 95 | |
| 96 static void free_entry(list_entry_t* entry) { | |
|
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32466
diff
changeset
|
97 free(entry->ok); |
|
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32466
diff
changeset
|
98 free(entry->cancel); |
|
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32466
diff
changeset
|
99 free(entry->left); |
|
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32466
diff
changeset
|
100 free(entry->right); |
| 8197 | 101 free(entry->p.txt); |
| 102 free(entry); | |
| 103 } | |
| 104 | |
|
18817
a2b064a48775
declaring static functions with the same name than libc ones was not the best idea ever
ben
parents:
18006
diff
changeset
|
105 static void close_menu(menu_t* menu) { |
| 8197 | 106 menu_list_uninit(menu,free_entry); |
| 107 } | |
| 108 | |
| 109 static int parse_args(menu_t* menu,char* args) { | |
|
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
110 char *element,*body, **attribs, *name; |
| 8197 | 111 list_entry_t* m = NULL; |
| 112 int r; | |
| 113 ASX_Parser_t* parser = asx_parser_new(); | |
| 114 | |
| 115 while(1) { | |
| 116 r = asx_get_element(parser,&args,&element,&body,&attribs); | |
| 117 if(r < 0) { | |
|
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
118 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line); |
| 8197 | 119 asx_parser_free(parser); |
| 120 return -1; | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
121 } else if(r == 0) { |
| 8197 | 122 asx_parser_free(parser); |
| 123 if(!m) | |
|
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
124 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_NoEntryFoundInTheMenuDefinition); |
| 8197 | 125 return m ? 1 : 0; |
| 126 } | |
| 127 // Has it a name ? | |
| 128 name = asx_get_attrib("name",attribs); | |
| 129 if(!name) { | |
|
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
130 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ListMenuEntryDefinitionsNeedAName,parser->line); |
| 8197 | 131 free(element); |
|
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32466
diff
changeset
|
132 free(body); |
| 8197 | 133 asx_free_attribs(attribs); |
| 134 continue; | |
| 135 } | |
| 136 m = calloc(1,sizeof(struct list_entry_s)); | |
| 137 m->p.txt = name; | |
|
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
138 m->ok = asx_get_attrib("ok",attribs); |
|
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
139 m->cancel = asx_get_attrib("cancel",attribs); |
|
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
140 m->left = asx_get_attrib("left",attribs); |
|
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
141 m->right = asx_get_attrib("right",attribs); |
| 8197 | 142 menu_list_add_entry(menu,m); |
| 143 | |
| 144 free(element); | |
|
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32466
diff
changeset
|
145 free(body); |
| 8197 | 146 asx_free_attribs(attribs); |
| 147 } | |
| 148 } | |
| 149 | |
|
23366
b344b6520518
rename some menu open functions, to avoid confusion with libc native open()
ben
parents:
19431
diff
changeset
|
150 static int open_cmdlist(menu_t* menu, char* args) { |
| 8197 | 151 menu->draw = menu_list_draw; |
| 152 menu->read_cmd = read_cmd; | |
|
18817
a2b064a48775
declaring static functions with the same name than libc ones was not the best idea ever
ben
parents:
18006
diff
changeset
|
153 menu->close = close_menu; |
| 8197 | 154 |
| 155 if(!args) { | |
|
18006
ce1a5b200c39
Minor spelling and grammar fixes for part 1 of Otvos Attila's
corey
parents:
17994
diff
changeset
|
156 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ListMenuNeedsAnArgument); |
| 8197 | 157 return 0; |
| 158 } | |
|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28113
diff
changeset
|
159 |
| 8197 | 160 menu_list_init(menu); |
| 161 if(!parse_args(menu,args)) | |
| 162 return 0; | |
| 163 return 1; | |
| 164 } | |
| 165 | |
| 166 const menu_info_t menu_info_cmdlist = { | |
| 167 "Command list menu", | |
| 168 "cmdlist", | |
| 169 "Albeu", | |
| 170 "", | |
| 171 { | |
| 172 "cmdlist_cfg", | |
| 173 sizeof(struct menu_priv_s), | |
| 174 &cfg_dflt, | |
| 175 cfg_fields | |
| 176 }, | |
|
23366
b344b6520518
rename some menu open functions, to avoid confusion with libc native open()
ben
parents:
19431
diff
changeset
|
177 open_cmdlist |
| 8197 | 178 }; |
