Exemple #1
0
static void rtgui_filelist_view_onenturn(struct rtgui_filelist_view* view)
{
	if (view->items[view->current_item].type == RTGUI_FITEM_DIR)
	{
		char new_path[64];

		if (strcmp(view->items[view->current_item].name, ".") == 0) return ;
		if (strcmp(view->items[view->current_item].name, "..") == 0)
		{
			char *ptr;
			ptr = strrchr(view->current_directory, PATH_SEPARATOR);

			if (ptr == RT_NULL) return ;
			if (ptr == &(view->current_directory[0]))
			{
				/* it's root directory */
				new_path[0] = PATH_SEPARATOR;
				new_path[1] = '\0';
			}
			else
			{
				strncpy(new_path, view->current_directory, ptr - view->current_directory + 1);
				new_path[ptr - view->current_directory] = '\0';
			}
		}
		else if (view->current_item == 0 &&
#ifdef _WIN32
			(view->current_directory[1] == ':') && (view->current_directory[2] == '\\')
#else
			(view->current_directory[0] == '/') && (view->current_directory[1] == '\0')
#endif
			)
		{
			rtgui_filelist_view_destroy(view);

			return ;
		}
		else
		{
			rtgui_filelist_view_menu_pop(RTGUI_WIDGET(view));
			return ;
		}
		rtgui_filelist_view_set_directory(view, new_path);
	}
}
Exemple #2
0
static void function_filelist(struct rtgui_widget* widget, void* parameter)
{
    rtgui_rect_t rect;
    rtgui_filelist_view_t *view;

    rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
    view = rtgui_filelist_view_create(workbench, "/SD", "*.*", &rect);
    if (view != RT_NULL)
    {
        if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK)
        {
        	int type;
            char fn[64];

            /* get file */
			rtgui_filelist_view_get_fullpath(view, fn, sizeof(fn));
			type = media_type(fn);

			/* stop playing */
			player_stop();

			/* check whether it's a folder */
			if (is_directory(fn) == RT_TRUE)
			{
				play_list_append_directory(fn);
                if (play_list_items() > 0)
                {
                    player_play_item(play_list_start());
                }
			}
            else if (type == MEDIA_WAV || type == MEDIA_MP3)
            {
                /* clear old play list */
                play_list_clear();
				/* append file */
                play_list_append(fn);

				player_play_item(play_list_start());
            }
            else if (type == MEDIA_M3U)
            {
            	/* append m3u filelist */
            	play_list_append_m3u(fn);
                if (play_list_items() > 0)
                {
                    player_play_item(play_list_start());
                }
            }

			player_update_list();
        }

        /* destroy view */
        rtgui_filelist_view_destroy(view);
    }

	/* show home view */
	rtgui_view_show(home_view, RT_FALSE);

    return;
}