Esempio n. 1
0
static void export_list(GTKMusicBrowser *p, guint action, GtkWidget *w)
{
    FileSelector *filesel = new FileSelector(p->GetContext(),"Export This Playlist to Disk");
    if (filesel->Run())
        p->SaveCurrentPlaylist(filesel->GetReturnPath());
    delete filesel;
}
Esempio n. 2
0
static void add_tool(GtkWidget *widget, GTKMusicBrowser *p)
{
    p->SetClickState(kContextPlaylist);
    FileSelector *filesel = new FileSelector(p->GetContext(),"Add a Track");
    filesel->SetExtended();
    if (filesel->Run()) {
        char *returnpath = filesel->GetReturnPath();
        char *ext = p->GetContext()->player->GetExtension(returnpath);
        uint32 length = strlen(returnpath) + 10;
        char *tempurl = new char[length];
        if (IsntError(FilePathToURL(returnpath, tempurl, &length))) {
            if (ext && p->GetContext()->plm->IsSupportedPlaylistFormat(ext)) {
                string tobeloaded = tempurl;
                p->LoadPlaylist(tobeloaded);
            }
            else {
                char *filereturn = strdup_new(filesel->GetReturnPath());
                if (filereturn) {
                    char *temp;
                    char *first= strtok(filereturn, "\n");

                    while ((temp = strtok(NULL, "\n"))) {
                        if (ext)
                            delete [] ext;
                        ext = p->GetContext()->player->GetExtension(temp);
                        if (ext &&
                            p->GetContext()->player->IsSupportedExtension(ext)) 
                        {
                            p->AddTrackPlaylistEvent(temp);
                            p->m_lastindex++;
                        }
                    }
                    if (ext)
                        delete [] ext;
                    ext = p->GetContext()->player->GetExtension(first);
                    if (ext &&
                        p->GetContext()->player->IsSupportedExtension(ext))
                        p->AddTrackPlaylistEvent(first);
                }
                delete [] filereturn;
            }
        }
        delete [] tempurl;
        delete [] ext;
    }
    delete filesel;
}
Esempio n. 3
0
static void open_list(GTKMusicBrowser *p, guint action, GtkWidget *w)
{
    p->SaveCurrentPlaylist();

    FileSelector *filesel = new FileSelector(p->GetContext(),"Open a Playlist from Disk");
    if (filesel->Run())
        p->CreateNewEditor(filesel->GetReturnPath());
    delete filesel;
}
Esempio n. 4
0
static void import_tool(GtkWidget *w, GTKMusicBrowser *p)
{
    FileSelector *filesel = new FileSelector(p->GetContext(),"Import a Track or Playlist into My Music");
    if (filesel->Run()) {
        FAContext *m_context = p->GetContext();
        char *returnpath = filesel->GetReturnPath();
        char *filereturn = strdup_new(returnpath);
        if (filereturn)
        {
            char *first = strtok(filereturn, "\n");
            while (first) {
                char *ext = m_context->player->GetExtension(first);
                uint32 length = strlen(first) + 10;
                char *tempurl = new char[length];

                if (IsntError(FilePathToURL(first, tempurl, &length))) 
                {
                    if (ext && m_context->plm->IsSupportedPlaylistFormat(ext))
                        p->ImportPlaylist(tempurl);
                    else if (ext && 
                             m_context->player->IsSupportedExtension(ext)) 
                    {
                        PlaylistItem *plist = new PlaylistItem(tempurl);
                        m_context->plm->RetrieveMetaDataNow(plist);

                        m_context->catalog->WriteMetaDataToDatabase(tempurl,
                                                          plist->GetMetaData());
                        m_context->catalog->AddSong(tempurl);

                        delete plist;
                    }
                }
                delete [] tempurl;
                delete ext;

                first = strtok(NULL, "\n");
            }
            delete [] filereturn;
        }
    }
    delete filesel;
}
Esempio n. 5
0
static void add_track(GTKMusicBrowser *p, guint action, GtkWidget *w)
{   
    FileSelector *filesel = new FileSelector(p->GetContext(),"Add a Track");
    filesel->SetExtended();
    if (filesel->Run()) {
        char *filereturn = strdup_new(filesel->GetReturnPath());
        if (filereturn) {
            char *temp;
            char *first;
            first = strtok(filereturn, "\n");
            while ((temp = strtok(NULL, "\n"))) {
                p->AddTrackPlaylistEvent(temp);
                p->m_lastindex++;
            }
            p->AddTrackPlaylistEvent(first);
       }
       delete filereturn;
    }
    delete filesel;
}