Mercurial > mplayer.hg
annotate libmenu/menu_pt.c @ 17999:d096b8febbfa
forgot one occurrance
author | rfelker |
---|---|
date | Thu, 30 Mar 2006 22:15:50 +0000 |
parents | 6927fabaef92 |
children | a2b064a48775 |
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 |
11 #include "img_format.h" | |
12 #include "mp_image.h" | |
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" | |
8197 | 22 |
9102 | 23 #define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1)) |
8197 | 24 |
25 extern play_tree_iter_t* playtree_iter; | |
26 | |
27 struct list_entry_s { | |
28 struct list_entry p; | |
29 play_tree_t* pt; | |
30 }; | |
31 | |
32 | |
33 struct menu_priv_s { | |
34 menu_list_priv_t p; | |
35 char* title; | |
36 }; | |
37 | |
38 static struct menu_priv_s cfg_dflt = { | |
39 MENU_LIST_PRIV_DFLT, | |
40 "Jump to" | |
41 }; | |
42 | |
43 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m) | |
44 | |
45 static m_option_t cfg_fields[] = { | |
46 MENU_LIST_PRIV_FIELDS, | |
47 { "title", ST_OFF(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: |
8197 | 56 case MENU_CMD_OK: { |
57 int d = 1; | |
58 char str[15]; | |
59 play_tree_t* i; | |
60 mp_cmd_t* c; | |
61 | |
62 | |
63 if(playtree_iter->tree == mpriv->p.current->pt) | |
64 break; | |
65 | |
66 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent) | |
67 snprintf(str,15,"pt_up_step 1"); | |
68 else { | |
69 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) { | |
70 if(i == mpriv->p.current->pt) | |
71 break; | |
72 d++; | |
73 } | |
74 if(i == NULL) { | |
75 d = -1; | |
76 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) { | |
77 if(i == mpriv->p.current->pt) | |
78 break; | |
79 d--; | |
80 } | |
81 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
|
82 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem); |
8197 | 83 break; |
84 } | |
85 } | |
86 snprintf(str,15,"pt_step %d",d); | |
87 } | |
88 c = mp_input_parse_cmd(str); | |
89 if(c) | |
90 mp_input_queue_cmd(c); | |
91 else | |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
92 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str); |
8197 | 93 } break; |
94 default: | |
95 menu_list_read_cmd(menu,cmd); | |
96 } | |
97 } | |
98 | |
99 static void read_key(menu_t* menu,int c){ | |
100 menu_list_read_key(menu,c,1); | |
101 } | |
102 | |
103 static void close(menu_t* menu) { | |
104 menu_list_uninit(menu,NULL); | |
105 } | |
106 | |
107 static int op(menu_t* menu, char* args) { | |
108 play_tree_t* i; | |
109 list_entry_t* e; | |
110 args = NULL; // Warning kill | |
111 | |
112 menu->draw = menu_list_draw; | |
113 menu->read_cmd = read_cmd; | |
114 menu->read_key = read_key; | |
115 menu->close = close; | |
116 | |
117 menu_list_init(menu); | |
118 | |
119 mpriv->p.title = mpriv->title; | |
120 | |
121 if(playtree_iter->tree->parent != playtree_iter->root) { | |
122 e = calloc(1,sizeof(list_entry_t)); | |
123 e->p.txt = ".."; | |
124 e->pt = playtree_iter->tree->parent; | |
125 menu_list_add_entry(menu,e); | |
126 } | |
127 | |
128 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev) | |
129 /* NOP */; | |
130 for( ; i != NULL ; i = i->next ) { | |
131 e = calloc(1,sizeof(list_entry_t)); | |
132 if(i->files) | |
9102 | 133 e->p.txt = mp_basename(i->files[0]); |
8197 | 134 else |
135 e->p.txt = "Group ..."; | |
136 e->pt = i; | |
137 menu_list_add_entry(menu,e); | |
138 } | |
139 | |
140 return 1; | |
141 } | |
142 | |
143 const menu_info_t menu_info_pt = { | |
144 "Playtree menu", | |
145 "pt", | |
146 "Albeu", | |
147 "", | |
148 { | |
149 "pt_cfg", | |
150 sizeof(struct menu_priv_s), | |
151 &cfg_dflt, | |
152 cfg_fields | |
153 }, | |
154 op | |
155 }; |