changeset 22284:83366c8e1928

Fix menu to work with mpctx
author uau
date Wed, 21 Feb 2007 18:28:48 +0000
parents bc9e95184521
children 5d12a6e96930
files access_mpcontext.h libmenu/menu.c libmenu/menu.h libmenu/menu_param.c libmenu/menu_pt.c libmenu/vf_menu.c mplayer.c
diffstat 7 files changed, 32 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/access_mpcontext.h	Wed Feb 21 18:28:48 2007 +0000
@@ -0,0 +1,2 @@
+void *mpctx_get_video_out(struct MPContext *mpctx);
+void *mpctx_get_playtree_iter(struct MPContext *mpctx);
--- a/libmenu/menu.c	Wed Feb 21 10:05:46 2007 +0000
+++ b/libmenu/menu.c	Wed Feb 21 18:28:48 2007 +0000
@@ -52,6 +52,7 @@
   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 @@
 #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 @@
 
   close(fd);
 
+  menu_ctx = mpctx;
   f = menu_parse_config(buffer);
   free(buffer);
   return f;
@@ -216,6 +218,7 @@
   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)
--- a/libmenu/menu.h	Wed Feb 21 10:05:46 2007 +0000
+++ b/libmenu/menu.h	Wed Feb 21 18:28:48 2007 +0000
@@ -3,6 +3,7 @@
 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 @@
 #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
--- a/libmenu/menu_param.c	Wed Feb 21 10:05:46 2007 +0000
+++ b/libmenu/menu_param.c	Wed Feb 21 18:28:48 2007 +0000
@@ -79,7 +79,7 @@
 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 @@
     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;
       }
--- a/libmenu/menu_pt.c	Wed Feb 21 10:05:46 2007 +0000
+++ b/libmenu/menu_pt.c	Wed Feb 21 18:28:48 2007 +0000
@@ -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 @@
     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 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;
--- a/libmenu/vf_menu.c	Wed Feb 21 10:05:46 2007 +0000
+++ b/libmenu/vf_menu.c	Wed Feb 21 18:28:48 2007 +0000
@@ -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 @@
 }
 
 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
--- a/mplayer.c	Wed Feb 21 10:05:46 2007 +0000
+++ b/mplayer.c	Wed Feb 21 18:28:48 2007 +0000
@@ -381,6 +381,16 @@
 
 #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 @@
 
 #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);