Mercurial > mplayer.hg
annotate libmenu/menu_pt.c @ 17960:ec93436dc52d
Fix a/v desync for real some files
author | rtognimp |
---|---|
date | Sun, 26 Mar 2006 14:10:52 +0000 |
parents | 98f4e3704a76 |
children | 6927fabaef92 |
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" |
8197 | 8 |
9 #include "img_format.h" | |
10 #include "mp_image.h" | |
11 | |
16862 | 12 #include "m_struct.h" |
13 #include "m_option.h" | |
8197 | 14 #include "menu.h" |
15 #include "menu_list.h" | |
16 | |
17 | |
16862 | 18 #include "playtree.h" |
19 #include "input/input.h" | |
8197 | 20 |
9102 | 21 #define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1)) |
8197 | 22 |
23 extern play_tree_iter_t* playtree_iter; | |
24 | |
25 struct list_entry_s { | |
26 struct list_entry p; | |
27 play_tree_t* pt; | |
28 }; | |
29 | |
30 | |
31 struct menu_priv_s { | |
32 menu_list_priv_t p; | |
33 char* title; | |
34 }; | |
35 | |
36 static struct menu_priv_s cfg_dflt = { | |
37 MENU_LIST_PRIV_DFLT, | |
38 "Jump to" | |
39 }; | |
40 | |
41 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m) | |
42 | |
43 static m_option_t cfg_fields[] = { | |
44 MENU_LIST_PRIV_FIELDS, | |
45 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
46 { NULL, NULL, NULL, 0,0,0,NULL } | |
47 }; | |
48 | |
49 #define mpriv (menu->priv) | |
50 | |
51 static void read_cmd(menu_t* menu,int cmd) { | |
52 switch(cmd) { | |
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
53 case MENU_CMD_RIGHT: |
8197 | 54 case MENU_CMD_OK: { |
55 int d = 1; | |
56 char str[15]; | |
57 play_tree_t* i; | |
58 mp_cmd_t* c; | |
59 | |
60 | |
61 if(playtree_iter->tree == mpriv->p.current->pt) | |
62 break; | |
63 | |
64 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent) | |
65 snprintf(str,15,"pt_up_step 1"); | |
66 else { | |
67 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) { | |
68 if(i == mpriv->p.current->pt) | |
69 break; | |
70 d++; | |
71 } | |
72 if(i == NULL) { | |
73 d = -1; | |
74 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) { | |
75 if(i == mpriv->p.current->pt) | |
76 break; | |
77 d--; | |
78 } | |
79 if(i == NULL) { | |
80 printf("Can't find the target item ????\n"); | |
81 break; | |
82 } | |
83 } | |
84 snprintf(str,15,"pt_step %d",d); | |
85 } | |
86 c = mp_input_parse_cmd(str); | |
87 if(c) | |
88 mp_input_queue_cmd(c); | |
89 else | |
90 printf("Failed to build command %s\n",str); | |
91 } break; | |
92 default: | |
93 menu_list_read_cmd(menu,cmd); | |
94 } | |
95 } | |
96 | |
97 static void read_key(menu_t* menu,int c){ | |
98 menu_list_read_key(menu,c,1); | |
99 } | |
100 | |
101 static void close(menu_t* menu) { | |
102 menu_list_uninit(menu,NULL); | |
103 } | |
104 | |
105 static int op(menu_t* menu, char* args) { | |
106 play_tree_t* i; | |
107 list_entry_t* e; | |
108 args = NULL; // Warning kill | |
109 | |
110 menu->draw = menu_list_draw; | |
111 menu->read_cmd = read_cmd; | |
112 menu->read_key = read_key; | |
113 menu->close = close; | |
114 | |
115 menu_list_init(menu); | |
116 | |
117 mpriv->p.title = mpriv->title; | |
118 | |
119 if(playtree_iter->tree->parent != playtree_iter->root) { | |
120 e = calloc(1,sizeof(list_entry_t)); | |
121 e->p.txt = ".."; | |
122 e->pt = playtree_iter->tree->parent; | |
123 menu_list_add_entry(menu,e); | |
124 } | |
125 | |
126 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev) | |
127 /* NOP */; | |
128 for( ; i != NULL ; i = i->next ) { | |
129 e = calloc(1,sizeof(list_entry_t)); | |
130 if(i->files) | |
9102 | 131 e->p.txt = mp_basename(i->files[0]); |
8197 | 132 else |
133 e->p.txt = "Group ..."; | |
134 e->pt = i; | |
135 menu_list_add_entry(menu,e); | |
136 } | |
137 | |
138 return 1; | |
139 } | |
140 | |
141 const menu_info_t menu_info_pt = { | |
142 "Playtree menu", | |
143 "pt", | |
144 "Albeu", | |
145 "", | |
146 { | |
147 "pt_cfg", | |
148 sizeof(struct menu_priv_s), | |
149 &cfg_dflt, | |
150 cfg_fields | |
151 }, | |
152 op | |
153 }; |