mirror of
https://github.com/mpv-player/mpv
synced 2024-12-28 06:03:45 +01:00
Fix menu to work with mpctx
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22302 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
e1547563a9
commit
00b3c78196
2
access_mpcontext.h
Normal file
2
access_mpcontext.h
Normal file
@ -0,0 +1,2 @@
|
||||
void *mpctx_get_video_out(struct MPContext *mpctx);
|
||||
void *mpctx_get_playtree_iter(struct MPContext *mpctx);
|
@ -52,6 +52,7 @@ typedef struct menu_def_st {
|
||||
char* args;
|
||||
} menu_def_t;
|
||||
|
||||
static struct MPContext *menu_ctx = NULL;
|
||||
static menu_def_t* menu_list = NULL;
|
||||
static int menu_count = 0;
|
||||
|
||||
@ -122,7 +123,7 @@ static int menu_parse_config(char* buffer) {
|
||||
#define BUF_STEP 1024
|
||||
#define BUF_MIN 128
|
||||
#define BUF_MAX BUF_STEP*1024
|
||||
int menu_init(char* cfg_file) {
|
||||
int menu_init(struct MPContext *mpctx, char* cfg_file) {
|
||||
char* buffer = NULL;
|
||||
int bl = BUF_STEP, br = 0;
|
||||
int f, fd;
|
||||
@ -160,6 +161,7 @@ int menu_init(char* cfg_file) {
|
||||
|
||||
close(fd);
|
||||
|
||||
menu_ctx = mpctx;
|
||||
f = menu_parse_config(buffer);
|
||||
free(buffer);
|
||||
return f;
|
||||
@ -216,6 +218,7 @@ menu_t* menu_open(char *name) {
|
||||
m = calloc(1,sizeof(menu_t));
|
||||
m->priv_st = &(menu_list[i].type->priv_st);
|
||||
m->priv = m_struct_copy(m->priv_st,menu_list[i].cfg);
|
||||
m->ctx = menu_ctx;
|
||||
if(menu_list[i].type->open(m,menu_list[i].args))
|
||||
return m;
|
||||
if(m->priv)
|
||||
|
@ -3,6 +3,7 @@ struct menu_priv_s;
|
||||
typedef struct menu_s menu_t;
|
||||
|
||||
struct menu_s {
|
||||
struct MPContext *ctx;
|
||||
void (*draw)(menu_t* menu,mp_image_t* mpi);
|
||||
void (*read_cmd)(menu_t* menu,int cmd);
|
||||
void (*read_key)(menu_t* menu,int cmd);
|
||||
@ -36,7 +37,7 @@ typedef struct menu_info_s {
|
||||
#define MENU_CMD_ACTION 6
|
||||
|
||||
/// Global init/uninit
|
||||
int menu_init(char* cfg_file);
|
||||
int menu_init(struct MPContext *mpctx, char* cfg_file);
|
||||
void menu_unint(void);
|
||||
|
||||
/// Open a menu defined in the config file
|
||||
|
@ -79,7 +79,7 @@ static m_option_t cfg_fields[] = {
|
||||
m_option_t* mp_property_find(const char* name);
|
||||
|
||||
static void entry_set_text(menu_t* menu, list_entry_t* e) {
|
||||
char* val = m_property_print(e->opt);
|
||||
char* val = m_property_print(e->opt, menu->ctx);
|
||||
int l,edit = (mpriv->edit && e == mpriv->p.current);
|
||||
if(!val) {
|
||||
if(mpriv->hide_na) {
|
||||
@ -227,22 +227,22 @@ static void read_cmd(menu_t* menu,int cmd) {
|
||||
case MENU_CMD_UP:
|
||||
if(!mpriv->edit) break;
|
||||
case MENU_CMD_RIGHT:
|
||||
if(m_property_do(e->opt,M_PROPERTY_STEP_UP,NULL) > 0)
|
||||
if(m_property_do(e->opt,M_PROPERTY_STEP_UP,NULL,menu->ctx) > 0)
|
||||
update_entries(menu);
|
||||
return;
|
||||
case MENU_CMD_DOWN:
|
||||
if(!mpriv->edit) break;
|
||||
case MENU_CMD_LEFT:
|
||||
if(m_property_do(e->opt,M_PROPERTY_STEP_DOWN,NULL) > 0)
|
||||
if(m_property_do(e->opt,M_PROPERTY_STEP_DOWN,NULL,menu->ctx) > 0)
|
||||
update_entries(menu);
|
||||
return;
|
||||
|
||||
case MENU_CMD_OK:
|
||||
// check that the property is writable
|
||||
if(m_property_do(e->opt,M_PROPERTY_SET,NULL) < 0) return;
|
||||
if(m_property_do(e->opt,M_PROPERTY_SET,NULL,menu->ctx) < 0) return;
|
||||
// shortcut for flags
|
||||
if(e->opt->type == CONF_TYPE_FLAG) {
|
||||
if(m_property_do(e->opt,M_PROPERTY_STEP_UP,NULL) > 0)
|
||||
if(m_property_do(e->opt,M_PROPERTY_STEP_UP,NULL,menu->ctx) > 0)
|
||||
update_entries(menu);
|
||||
return;
|
||||
}
|
||||
|
@ -19,11 +19,10 @@
|
||||
|
||||
#include "playtree.h"
|
||||
#include "input/input.h"
|
||||
#include "access_mpcontext.h"
|
||||
|
||||
#define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1))
|
||||
|
||||
extern play_tree_iter_t* playtree_iter;
|
||||
|
||||
struct list_entry_s {
|
||||
struct list_entry p;
|
||||
play_tree_t* pt;
|
||||
@ -58,7 +57,7 @@ static void read_cmd(menu_t* menu,int cmd) {
|
||||
char str[15];
|
||||
play_tree_t* i;
|
||||
mp_cmd_t* c;
|
||||
|
||||
play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx);
|
||||
|
||||
if(playtree_iter->tree == mpriv->p.current->pt)
|
||||
break;
|
||||
@ -107,6 +106,8 @@ static void close_menu(menu_t* menu) {
|
||||
static int op(menu_t* menu, char* args) {
|
||||
play_tree_t* i;
|
||||
list_entry_t* e;
|
||||
play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx);
|
||||
|
||||
args = NULL; // Warning kill
|
||||
|
||||
menu->draw = menu_list_draw;
|
||||
|
@ -23,8 +23,7 @@
|
||||
#include "input/input.h"
|
||||
#include "m_struct.h"
|
||||
#include "menu.h"
|
||||
|
||||
extern vo_functions_t* video_out;
|
||||
#include "access_mpcontext.h"
|
||||
|
||||
|
||||
static struct vf_priv_s* st_priv = NULL;
|
||||
@ -78,6 +77,7 @@ static mp_image_t* alloc_mpi(int w, int h, uint32_t fmt) {
|
||||
}
|
||||
|
||||
void vf_menu_pause_update(struct vf_instance_s* vf) {
|
||||
vo_functions_t *video_out = mpctx_get_video_out(vf->priv->current->ctx);
|
||||
if(pause_mpi) {
|
||||
put_image(vf,pause_mpi, MP_NOPTS_VALUE);
|
||||
// Don't draw the osd atm
|
||||
|
16
mplayer.c
16
mplayer.c
@ -381,6 +381,16 @@ static unsigned int inited_flags=0;
|
||||
|
||||
#define mp_basename2(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1))
|
||||
|
||||
void *mpctx_get_video_out(MPContext *mpctx)
|
||||
{
|
||||
return mpctx->video_out;
|
||||
}
|
||||
|
||||
void *mpctx_get_playtree_iter(MPContext *mpctx)
|
||||
{
|
||||
return mpctx->playtree_iter;
|
||||
}
|
||||
|
||||
static int is_valid_metadata_type (metadata_t type) {
|
||||
switch (type)
|
||||
{
|
||||
@ -2485,14 +2495,14 @@ current_module = NULL;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if(use_menu) {
|
||||
if(menu_cfg && menu_init(menu_cfg))
|
||||
if(menu_cfg && menu_init(mpctx, menu_cfg))
|
||||
mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MenuInitialized, menu_cfg);
|
||||
else {
|
||||
menu_cfg = get_path("menu.conf");
|
||||
if(menu_init(menu_cfg))
|
||||
if(menu_init(mpctx, menu_cfg))
|
||||
mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MenuInitialized, menu_cfg);
|
||||
else {
|
||||
if(menu_init(MPLAYER_CONFDIR "/menu.conf"))
|
||||
if(menu_init(mpctx, MPLAYER_CONFDIR "/menu.conf"))
|
||||
mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MenuInitialized, MPLAYER_CONFDIR"/menu.conf");
|
||||
else {
|
||||
mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MenuInitFailed);
|
||||
|
Loading…
Reference in New Issue
Block a user