comparison libmenu/menu.c @ 22284:83366c8e1928

Fix menu to work with mpctx
author uau
date Wed, 21 Feb 2007 18:28:48 +0000
parents 14061bc22cb3
children a142b048c65e
comparison
equal deleted inserted replaced
22283:bc9e95184521 22284:83366c8e1928
50 menu_info_t* type; 50 menu_info_t* type;
51 void* cfg; 51 void* cfg;
52 char* args; 52 char* args;
53 } menu_def_t; 53 } menu_def_t;
54 54
55 static struct MPContext *menu_ctx = NULL;
55 static menu_def_t* menu_list = NULL; 56 static menu_def_t* menu_list = NULL;
56 static int menu_count = 0; 57 static int menu_count = 0;
57 58
58 59
59 static int menu_parse_config(char* buffer) { 60 static int menu_parse_config(char* buffer) {
120 121
121 /// This will build the menu_defs list from the cfg file 122 /// This will build the menu_defs list from the cfg file
122 #define BUF_STEP 1024 123 #define BUF_STEP 1024
123 #define BUF_MIN 128 124 #define BUF_MIN 128
124 #define BUF_MAX BUF_STEP*1024 125 #define BUF_MAX BUF_STEP*1024
125 int menu_init(char* cfg_file) { 126 int menu_init(struct MPContext *mpctx, char* cfg_file) {
126 char* buffer = NULL; 127 char* buffer = NULL;
127 int bl = BUF_STEP, br = 0; 128 int bl = BUF_STEP, br = 0;
128 int f, fd; 129 int f, fd;
129 #ifndef HAVE_FREETYPE 130 #ifndef HAVE_FREETYPE
130 if(vo_font == NULL) 131 if(vo_font == NULL)
158 } 159 }
159 buffer[br-1] = '\0'; 160 buffer[br-1] = '\0';
160 161
161 close(fd); 162 close(fd);
162 163
164 menu_ctx = mpctx;
163 f = menu_parse_config(buffer); 165 f = menu_parse_config(buffer);
164 free(buffer); 166 free(buffer);
165 return f; 167 return f;
166 } 168 }
167 169
214 return NULL; 216 return NULL;
215 } 217 }
216 m = calloc(1,sizeof(menu_t)); 218 m = calloc(1,sizeof(menu_t));
217 m->priv_st = &(menu_list[i].type->priv_st); 219 m->priv_st = &(menu_list[i].type->priv_st);
218 m->priv = m_struct_copy(m->priv_st,menu_list[i].cfg); 220 m->priv = m_struct_copy(m->priv_st,menu_list[i].cfg);
221 m->ctx = menu_ctx;
219 if(menu_list[i].type->open(m,menu_list[i].args)) 222 if(menu_list[i].type->open(m,menu_list[i].args))
220 return m; 223 return m;
221 if(m->priv) 224 if(m->priv)
222 m_struct_free(m->priv_st,m->priv); 225 m_struct_free(m->priv_st,m->priv);
223 free(m); 226 free(m);