예제 #1
0
int import_playtree_playlist_into_gui(play_tree_t* my_playtree, m_config_t* config)
{
  play_tree_iter_t* my_pt_iter=NULL;
  int result=0;
  plItem * save=(plItem*)gtkSet( gtkGetCurrPlItem, 0, 0); // Save current item

  if((my_pt_iter=pt_iter_create(&my_playtree,config)))
  {
    while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL)
    {
      if (import_file_into_gui(filename, 1)) // insert it into the list and set plCurrent=new item
        result=1;
    }
    pt_iter_destroy(&my_pt_iter);
  }

  if (save)
    gtkSet(gtkSetCurrPlItem, 0, (void*)save);
  else
    gtkSet(gtkSetCurrPlItem, 0, (void*)plList); // go to head, if plList was empty before

  if (save && result)
    gtkSet(gtkDelCurrPlItem, 0, 0);

  mplCurr();  // Update filename
  filename=NULL;

  return result;
}
예제 #2
0
/**
 * @brief Initialize the GUI playlist (i.e. import files that had been given
 *        on the command line) or add files "on the fly" (i.e. replace the
 *        current one (a playlist file) by other ones (its content)).
 *
 * @param what command (#GUI_PLAYLIST_INIT or #GUI_PLAYLIST_ADD) to be performed
 * @param playtree MPlayer playtree to read from
 * @param config MPlayer config context
 * @param enqueue whether to overwrite GUI playlist (#False) or to append to it (#True)
 *
 * @return #True (ok) or #False (error)
 */
int guiPlaylist(int what, play_tree_t *playtree, m_config_t *config, int enqueue)
{
    play_tree_iter_t *pt_iter;
    const char *file;
    int added = False;
    plItem *curr;

    pt_iter = pt_iter_create(&playtree, config);

    if (!pt_iter)
        return False;

    switch (what) {
    case GUI_PLAYLIST_INIT:

        if (!enqueue)
            listMgr(PLAYLIST_DELETE, 0);

        while ((file = pt_iter_get_next_file(pt_iter)))
            if (add_to_gui_playlist(file, PLAYLIST_ITEM_APPEND))
                added = True;

        uiCurr();   // update filename
        guiInfo.PlaylistNext = True;

        if (added)
            guiInfo.Track = 1;

        if (enqueue)
            filename = NULL;            // don't start playing

        break;

    case GUI_PLAYLIST_ADD:

        curr = listMgr(PLAYLIST_ITEM_GET_CURR, 0);

        while ((file = pt_iter_get_next_file(pt_iter)))
            if (add_to_gui_playlist(file, PLAYLIST_ITEM_INSERT))
                added = True;

        if (curr)
            listMgr(PLAYLIST_ITEM_SET_CURR, curr);
        else
            listMgr(PLAYLIST_ITEM_SET_CURR, listMgr(PLAYLIST_GET, 0));

        if (curr && added)
            listMgr(PLAYLIST_ITEM_DEL_CURR, 0);

        uiCurr();   // update filename

        break;
    }

    pt_iter_destroy(&pt_iter);

    return added;
}
예제 #3
0
int guiPlaylist (int what, play_tree_t *playtree, m_config_t *config, int enqueue)
{
    play_tree_iter_t *pt_iter = NULL;
    char *file;
    int added = FALSE;

    switch (what)
    {
        /*  This function imports the initial playtree (based on cmd-line files) into the gui playlist
            by either:
            - overwriting gui pl (enqueue=0) */
        case GUI_PLAYLIST_INIT:

            if(!mygui) guiInit();

            if((pt_iter = pt_iter_create(&playtree, config)))
            {
                while ((file = pt_iter_get_next_file(pt_iter)) != NULL)
                {
                    if (parse_filename(file, playtree, config, 0))
                        added = TRUE;
                    else if (import_file_into_gui(file, 0)) /* Add it to end of list */
                        added = TRUE;
                }
            }
            guiInfo.PlaylistNext = TRUE;

            if (added)
            {
                mygui->playlist->current = 0;
                uiSetFile(NULL, mygui->playlist->tracks[0]->filename, STREAMTYPE_FILE);
            }

            if (enqueue) filename = NULL;

            break;

        /* This function imports and inserts an playtree, that is created "on the fly", for example by
           parsing some MOV-Reference-File; or by loading an playlist with "File Open"
           The file which contained the playlist is thereby replaced with it's contents. */
        case GUI_PLAYLIST_ADD:

            if((pt_iter = pt_iter_create(&playtree, config)))
            {
                while ((file = pt_iter_get_next_file(pt_iter)) != NULL)
                    if (import_file_into_gui(file, 1)) /* insert it into the list and set plCurrent = new item */
                        added = TRUE;
                pt_iter_destroy(&pt_iter);
            }

            break;
    }

    return added;
}
예제 #4
0
static int playtree_add_file(play_tree_t* tree, char *lfilename)
{
	int result = 0;
	if(!tree) return -1;
	play_tree_iter_t *pi = NULL;
	if((pi = pt_iter_create(&tree, mconfig)))
	{
		pt_iter_add_file(pi , lfilename);
		pt_iter_destroy(&pi);
		result = 1;
	}
	return result;
}
예제 #5
0
int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config)
{
    play_tree_iter_t *my_pt_iter = NULL;
    int result = 0;

    if((my_pt_iter = pt_iter_create(&my_playtree, config)))
    {
        while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)
            if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */
                result = 1;
        pt_iter_destroy(&my_pt_iter);
    }
    return result;
}
예제 #6
0
int import_playtree_into_playlist(play_tree_t *tree, m_config_t *config)
{
	char *lfilename;
	int result = 0;
	play_tree_iter_t *pi = NULL;
	if(!tree) return 0;

	if((pi = pt_iter_create(&tree, config)))
	{
		while ((lfilename = pt_iter_get_next_file(pi)) != NULL)
		{
			playlist->add_track(playlist, lfilename, NULL, NULL, 0);
			result = 1;
		}
		pt_iter_destroy(&pi);
	}
	lfilename = NULL;
	return result;
}