2002-11-14 23:47:11 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2002-12-28 18:51:10 +00:00
|
|
|
#include <string.h>
|
2003-01-26 15:55:35 +00:00
|
|
|
//#include <libgen.h>
|
2002-11-14 23:47:11 +00:00
|
|
|
|
2005-10-26 00:07:43 +00:00
|
|
|
#include "config.h"
|
2006-03-30 06:40:58 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "help_mp.h"
|
2002-11-14 23:47:11 +00:00
|
|
|
|
2006-08-18 13:58:03 +00:00
|
|
|
#include "libmpcodecs/img_format.h"
|
|
|
|
#include "libmpcodecs/mp_image.h"
|
2002-11-14 23:47:11 +00:00
|
|
|
|
2005-10-26 00:07:43 +00:00
|
|
|
#include "m_struct.h"
|
|
|
|
#include "m_option.h"
|
2002-11-14 23:47:11 +00:00
|
|
|
#include "menu.h"
|
|
|
|
#include "menu_list.h"
|
|
|
|
|
|
|
|
|
2005-10-26 00:07:43 +00:00
|
|
|
#include "playtree.h"
|
|
|
|
#include "input/input.h"
|
2002-11-14 23:47:11 +00:00
|
|
|
|
2003-01-26 15:55:35 +00:00
|
|
|
#define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1))
|
2002-11-14 23:47:11 +00:00
|
|
|
|
|
|
|
extern play_tree_iter_t* playtree_iter;
|
|
|
|
|
|
|
|
struct list_entry_s {
|
|
|
|
struct list_entry p;
|
|
|
|
play_tree_t* pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct menu_priv_s {
|
|
|
|
menu_list_priv_t p;
|
|
|
|
char* title;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct menu_priv_s cfg_dflt = {
|
|
|
|
MENU_LIST_PRIV_DFLT,
|
|
|
|
"Jump to"
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m)
|
|
|
|
|
|
|
|
static m_option_t cfg_fields[] = {
|
|
|
|
MENU_LIST_PRIV_FIELDS,
|
|
|
|
{ "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL },
|
|
|
|
{ NULL, NULL, NULL, 0,0,0,NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
#define mpriv (menu->priv)
|
|
|
|
|
|
|
|
static void read_cmd(menu_t* menu,int cmd) {
|
|
|
|
switch(cmd) {
|
2006-03-25 17:32:10 +00:00
|
|
|
case MENU_CMD_RIGHT:
|
2002-11-14 23:47:11 +00:00
|
|
|
case MENU_CMD_OK: {
|
|
|
|
int d = 1;
|
|
|
|
char str[15];
|
|
|
|
play_tree_t* i;
|
|
|
|
mp_cmd_t* c;
|
|
|
|
|
|
|
|
|
|
|
|
if(playtree_iter->tree == mpriv->p.current->pt)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent)
|
|
|
|
snprintf(str,15,"pt_up_step 1");
|
|
|
|
else {
|
|
|
|
for(i = playtree_iter->tree->next; i != NULL ; i = i->next) {
|
|
|
|
if(i == mpriv->p.current->pt)
|
|
|
|
break;
|
|
|
|
d++;
|
|
|
|
}
|
|
|
|
if(i == NULL) {
|
|
|
|
d = -1;
|
|
|
|
for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) {
|
|
|
|
if(i == mpriv->p.current->pt)
|
|
|
|
break;
|
|
|
|
d--;
|
|
|
|
}
|
|
|
|
if(i == NULL) {
|
2006-03-30 06:40:58 +00:00
|
|
|
mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem);
|
2002-11-14 23:47:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
snprintf(str,15,"pt_step %d",d);
|
|
|
|
}
|
|
|
|
c = mp_input_parse_cmd(str);
|
|
|
|
if(c)
|
|
|
|
mp_input_queue_cmd(c);
|
|
|
|
else
|
2006-03-30 06:40:58 +00:00
|
|
|
mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str);
|
2002-11-14 23:47:11 +00:00
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
menu_list_read_cmd(menu,cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void read_key(menu_t* menu,int c){
|
|
|
|
menu_list_read_key(menu,c,1);
|
|
|
|
}
|
|
|
|
|
2006-06-25 20:59:12 +00:00
|
|
|
static void close_menu(menu_t* menu) {
|
2002-11-14 23:47:11 +00:00
|
|
|
menu_list_uninit(menu,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int op(menu_t* menu, char* args) {
|
|
|
|
play_tree_t* i;
|
|
|
|
list_entry_t* e;
|
|
|
|
args = NULL; // Warning kill
|
|
|
|
|
|
|
|
menu->draw = menu_list_draw;
|
|
|
|
menu->read_cmd = read_cmd;
|
|
|
|
menu->read_key = read_key;
|
2006-06-25 20:59:12 +00:00
|
|
|
menu->close = close_menu;
|
2002-11-14 23:47:11 +00:00
|
|
|
|
|
|
|
menu_list_init(menu);
|
|
|
|
|
|
|
|
mpriv->p.title = mpriv->title;
|
|
|
|
|
|
|
|
if(playtree_iter->tree->parent != playtree_iter->root) {
|
|
|
|
e = calloc(1,sizeof(list_entry_t));
|
|
|
|
e->p.txt = "..";
|
|
|
|
e->pt = playtree_iter->tree->parent;
|
|
|
|
menu_list_add_entry(menu,e);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev)
|
|
|
|
/* NOP */;
|
|
|
|
for( ; i != NULL ; i = i->next ) {
|
|
|
|
e = calloc(1,sizeof(list_entry_t));
|
|
|
|
if(i->files)
|
2003-01-26 15:55:35 +00:00
|
|
|
e->p.txt = mp_basename(i->files[0]);
|
2002-11-14 23:47:11 +00:00
|
|
|
else
|
|
|
|
e->p.txt = "Group ...";
|
|
|
|
e->pt = i;
|
|
|
|
menu_list_add_entry(menu,e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const menu_info_t menu_info_pt = {
|
|
|
|
"Playtree menu",
|
|
|
|
"pt",
|
|
|
|
"Albeu",
|
|
|
|
"",
|
|
|
|
{
|
|
|
|
"pt_cfg",
|
|
|
|
sizeof(struct menu_priv_s),
|
|
|
|
&cfg_dflt,
|
|
|
|
cfg_fields
|
|
|
|
},
|
|
|
|
op
|
|
|
|
};
|