annotate libmenu/menu_pt.c @ 23850:f900a440b14d

100l, return is missing a value
author reimar
date Thu, 26 Jul 2007 23:19:36 +0000
parents 83366c8e1928
children 96d0992c7920
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
1
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
2 #include <stdlib.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
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
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
5 //#include <libgen.h>
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
6
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
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
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
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
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
13
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
14 #include "m_struct.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
15 #include "m_option.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
16 #include "menu.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
17 #include "menu_list.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
18
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
19
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
20 #include "playtree.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
21 #include "input/input.h"
22284
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
22 #include "access_mpcontext.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
23
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
24 #define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1))
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
25
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
26 struct list_entry_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
27 struct list_entry p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
28 play_tree_t* pt;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
29 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
30
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
31
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
32 struct menu_priv_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
33 menu_list_priv_t p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
34 char* title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
35 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
36
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
37 static struct menu_priv_s cfg_dflt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
38 MENU_LIST_PRIV_DFLT,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
39 "Jump to"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
40 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
41
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
42 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
43
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
44 static m_option_t cfg_fields[] = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
45 MENU_LIST_PRIV_FIELDS,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
46 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
47 { NULL, NULL, NULL, 0,0,0,NULL }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
48 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
49
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
50 #define mpriv (menu->priv)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
51
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
52 static void read_cmd(menu_t* menu,int cmd) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
53 switch(cmd) {
17945
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 16862
diff changeset
54 case MENU_CMD_RIGHT:
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
55 case MENU_CMD_OK: {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
56 int d = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
57 char str[15];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
58 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
59 mp_cmd_t* c;
22284
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
60 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
61
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
62 if(playtree_iter->tree == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
63 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
64
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
65 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
66 snprintf(str,15,"pt_up_step 1");
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
67 else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
68 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
69 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
70 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
71 d++;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
72 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
73 if(i == NULL) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
74 d = -1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
75 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
76 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
77 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
78 d--;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
79 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
80 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
81 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
82 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
83 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
84 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
85 snprintf(str,15,"pt_step %d",d);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
86 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
87 c = mp_input_parse_cmd(str);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
88 if(c)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
89 mp_input_queue_cmd(c);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
90 else
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
91 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
92 } break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
93 default:
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
94 menu_list_read_cmd(menu,cmd);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
95 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
96 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
97
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
98 static void read_key(menu_t* menu,int c){
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
99 menu_list_read_key(menu,c,1);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
100 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
101
18817
a2b064a48775 declaring static functions with the same name than libc ones was not the best idea ever
ben
parents: 17994
diff changeset
102 static void close_menu(menu_t* menu) {
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
103 menu_list_uninit(menu,NULL);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
104 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
105
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
106 static int op(menu_t* menu, char* args) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
107 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
108 list_entry_t* e;
22284
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
109 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx);
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
110
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
111 args = NULL; // Warning kill
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
112
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
113 menu->draw = menu_list_draw;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
114 menu->read_cmd = read_cmd;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
115 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
116 menu->close = close_menu;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
117
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
118 menu_list_init(menu);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
119
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
120 mpriv->p.title = mpriv->title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
121
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
122 if(playtree_iter->tree->parent != playtree_iter->root) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
123 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
124 e->p.txt = "..";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
125 e->pt = playtree_iter->tree->parent;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
126 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
127 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
128
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
129 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
130 /* NOP */;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
131 for( ; i != NULL ; i = i->next ) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
132 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
133 if(i->files)
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
134 e->p.txt = mp_basename(i->files[0]);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
135 else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
136 e->p.txt = "Group ...";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
137 e->pt = i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
138 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
139 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
140
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
141 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
142 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
143
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
144 const menu_info_t menu_info_pt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
145 "Playtree menu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
146 "pt",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
147 "Albeu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
148 "",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
149 {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
150 "pt_cfg",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
151 sizeof(struct menu_priv_s),
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
152 &cfg_dflt,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
153 cfg_fields
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
154 },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
155 op
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
156 };