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