Mercurial > mplayer.hg
annotate libmenu/menu_pt.c @ 27520:740b5a4125c4
Prevent overflows during mpeg->jpeg yuv.
author | michael |
---|---|
date | Tue, 09 Sep 2008 03:35:07 +0000 |
parents | 15b870cf3592 |
children | f8b6c7045cf8 |
rev | line source |
---|---|
8197 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
8623
440301fef3fe
Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents:
8197
diff
changeset
|
4 #include <string.h> |
9102 | 5 //#include <libgen.h> |
8197 | 6 |
16862 | 7 #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
|
8 #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
|
9 #include "help_mp.h" |
8197 | 10 |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18817
diff
changeset
|
11 #include "libmpcodecs/img_format.h" |
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18817
diff
changeset
|
12 #include "libmpcodecs/mp_image.h" |
8197 | 13 |
16862 | 14 #include "m_struct.h" |
15 #include "m_option.h" | |
8197 | 16 #include "menu.h" |
17 #include "menu_list.h" | |
18 | |
19 | |
16862 | 20 #include "playtree.h" |
21 #include "input/input.h" | |
22284 | 22 #include "access_mpcontext.h" |
8197 | 23 |
9102 | 24 #define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1)) |
8197 | 25 |
26 struct list_entry_s { | |
27 struct list_entry p; | |
28 play_tree_t* pt; | |
29 }; | |
30 | |
31 | |
32 struct menu_priv_s { | |
33 menu_list_priv_t p; | |
34 char* title; | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
35 int auto_close; |
8197 | 36 }; |
37 | |
38 static struct menu_priv_s cfg_dflt = { | |
39 MENU_LIST_PRIV_DFLT, | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
40 "Jump to", |
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
41 0 |
8197 | 42 }; |
43 | |
44 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m) | |
45 | |
46 static m_option_t cfg_fields[] = { | |
47 MENU_LIST_PRIV_FIELDS, | |
48 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
49 { "auto-close", ST_OFF(auto_close), CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
8197 | 50 { NULL, NULL, NULL, 0,0,0,NULL } |
51 }; | |
52 | |
53 #define mpriv (menu->priv) | |
54 | |
55 static void read_cmd(menu_t* menu,int cmd) { | |
56 switch(cmd) { | |
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
57 case MENU_CMD_RIGHT: |
8197 | 58 case MENU_CMD_OK: { |
59 int d = 1; | |
60 char str[15]; | |
61 play_tree_t* i; | |
62 mp_cmd_t* c; | |
22284 | 63 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx); |
8197 | 64 |
65 if(playtree_iter->tree == mpriv->p.current->pt) | |
66 break; | |
67 | |
68 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent) | |
69 snprintf(str,15,"pt_up_step 1"); | |
70 else { | |
71 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) { | |
72 if(i == mpriv->p.current->pt) | |
73 break; | |
74 d++; | |
75 } | |
76 if(i == NULL) { | |
77 d = -1; | |
78 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) { | |
79 if(i == mpriv->p.current->pt) | |
80 break; | |
81 d--; | |
82 } | |
83 if(i == NULL) { | |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
84 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem); |
8197 | 85 break; |
86 } | |
87 } | |
88 snprintf(str,15,"pt_step %d",d); | |
89 } | |
90 c = mp_input_parse_cmd(str); | |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
91 if(c) { |
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
92 if(mpriv->auto_close) |
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
93 mp_input_queue_cmd(mp_input_parse_cmd("menu hide")); |
8197 | 94 mp_input_queue_cmd(c); |
27072
15b870cf3592
Add auto-close option to libmenu playlist handling part.
ben
parents:
25502
diff
changeset
|
95 } |
8197 | 96 else |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
97 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str); |
8197 | 98 } break; |
99 default: | |
100 menu_list_read_cmd(menu,cmd); | |
101 } | |
102 } | |
103 | |
25502
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
104 static int read_key(menu_t* menu,int c){ |
25263
96d0992c7920
Remove hardcoded key->cmd bindings in libmenu, support custom key bindings
ulion
parents:
22284
diff
changeset
|
105 if (menu_dflt_read_key(menu, c)) |
25502
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
106 return 1; |
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
107 return menu_list_jump_to_key(menu, c); |
8197 | 108 } |
109 | |
18817
a2b064a48775
declaring static functions with the same name than libc ones was not the best idea ever
ben
parents:
17994
diff
changeset
|
110 static void close_menu(menu_t* menu) { |
8197 | 111 menu_list_uninit(menu,NULL); |
112 } | |
113 | |
114 static int op(menu_t* menu, char* args) { | |
115 play_tree_t* i; | |
116 list_entry_t* e; | |
22284 | 117 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx); |
118 | |
8197 | 119 args = NULL; // Warning kill |
120 | |
121 menu->draw = menu_list_draw; | |
122 menu->read_cmd = read_cmd; | |
123 menu->read_key = read_key; | |
18817
a2b064a48775
declaring static functions with the same name than libc ones was not the best idea ever
ben
parents:
17994
diff
changeset
|
124 menu->close = close_menu; |
8197 | 125 |
126 menu_list_init(menu); | |
127 | |
128 mpriv->p.title = mpriv->title; | |
129 | |
130 if(playtree_iter->tree->parent != playtree_iter->root) { | |
131 e = calloc(1,sizeof(list_entry_t)); | |
132 e->p.txt = ".."; | |
133 e->pt = playtree_iter->tree->parent; | |
134 menu_list_add_entry(menu,e); | |
135 } | |
136 | |
137 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev) | |
138 /* NOP */; | |
139 for( ; i != NULL ; i = i->next ) { | |
140 e = calloc(1,sizeof(list_entry_t)); | |
141 if(i->files) | |
9102 | 142 e->p.txt = mp_basename(i->files[0]); |
8197 | 143 else |
144 e->p.txt = "Group ..."; | |
145 e->pt = i; | |
146 menu_list_add_entry(menu,e); | |
147 } | |
148 | |
149 return 1; | |
150 } | |
151 | |
152 const menu_info_t menu_info_pt = { | |
153 "Playtree menu", | |
154 "pt", | |
155 "Albeu", | |
156 "", | |
157 { | |
158 "pt_cfg", | |
159 sizeof(struct menu_priv_s), | |
160 &cfg_dflt, | |
161 cfg_fields | |
162 }, | |
163 op | |
164 }; |