Mercurial > mplayer.hg
annotate libmenu/menu_pt.c @ 13946:e632b43f0598
Reduce excessive verbosity.
author | diego |
---|---|
date | Mon, 15 Nov 2004 09:09:29 +0000 |
parents | 048d0a158714 |
children | 931bdbc37ee0 |
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 |
7 #include "../config.h" | |
8 | |
9 #include "img_format.h" | |
10 #include "mp_image.h" | |
11 | |
12 #include "../m_struct.h" | |
13 #include "../m_option.h" | |
14 #include "menu.h" | |
15 #include "menu_list.h" | |
16 | |
17 | |
18 #include "../playtree.h" | |
19 #include "../input/input.h" | |
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) { | |
53 case MENU_CMD_OK: { | |
54 int d = 1; | |
55 char str[15]; | |
56 play_tree_t* i; | |
57 mp_cmd_t* c; | |
58 | |
59 | |
60 if(playtree_iter->tree == mpriv->p.current->pt) | |
61 break; | |
62 | |
63 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent) | |
64 snprintf(str,15,"pt_up_step 1"); | |
65 else { | |
66 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) { | |
67 if(i == mpriv->p.current->pt) | |
68 break; | |
69 d++; | |
70 } | |
71 if(i == NULL) { | |
72 d = -1; | |
73 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) { | |
74 if(i == mpriv->p.current->pt) | |
75 break; | |
76 d--; | |
77 } | |
78 if(i == NULL) { | |
79 printf("Can't find the target item ????\n"); | |
80 break; | |
81 } | |
82 } | |
83 snprintf(str,15,"pt_step %d",d); | |
84 } | |
85 c = mp_input_parse_cmd(str); | |
86 if(c) | |
87 mp_input_queue_cmd(c); | |
88 else | |
89 printf("Failed to build command %s\n",str); | |
90 } break; | |
91 default: | |
92 menu_list_read_cmd(menu,cmd); | |
93 } | |
94 } | |
95 | |
96 static void read_key(menu_t* menu,int c){ | |
97 menu_list_read_key(menu,c,1); | |
98 } | |
99 | |
100 static void close(menu_t* menu) { | |
101 menu_list_uninit(menu,NULL); | |
102 } | |
103 | |
104 static int op(menu_t* menu, char* args) { | |
105 play_tree_t* i; | |
106 list_entry_t* e; | |
107 args = NULL; // Warning kill | |
108 | |
109 menu->draw = menu_list_draw; | |
110 menu->read_cmd = read_cmd; | |
111 menu->read_key = read_key; | |
112 menu->close = close; | |
113 | |
114 menu_list_init(menu); | |
115 | |
116 mpriv->p.title = mpriv->title; | |
117 | |
118 if(playtree_iter->tree->parent != playtree_iter->root) { | |
119 e = calloc(1,sizeof(list_entry_t)); | |
120 e->p.txt = ".."; | |
121 e->pt = playtree_iter->tree->parent; | |
122 menu_list_add_entry(menu,e); | |
123 } | |
124 | |
125 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev) | |
126 /* NOP */; | |
127 for( ; i != NULL ; i = i->next ) { | |
128 e = calloc(1,sizeof(list_entry_t)); | |
129 if(i->files) | |
9102 | 130 e->p.txt = mp_basename(i->files[0]); |
8197 | 131 else |
132 e->p.txt = "Group ..."; | |
133 e->pt = i; | |
134 menu_list_add_entry(menu,e); | |
135 } | |
136 | |
137 return 1; | |
138 } | |
139 | |
140 const menu_info_t menu_info_pt = { | |
141 "Playtree menu", | |
142 "pt", | |
143 "Albeu", | |
144 "", | |
145 { | |
146 "pt_cfg", | |
147 sizeof(struct menu_priv_s), | |
148 &cfg_dflt, | |
149 cfg_fields | |
150 }, | |
151 op | |
152 }; |