general code cleaning
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
bin_PROGRAMS = ncmpcpp
|
||||
ncmpcpp_SOURCES = browser.cpp charset.cpp clock.cpp display.cpp help.cpp \
|
||||
helpers.cpp info.cpp libmpdclient.c lyrics.cpp media_library.cpp misc.cpp mpdpp.cpp \
|
||||
ncmpcpp.cpp playlist.cpp playlist_editor.cpp scrollpad.cpp search_engine.cpp \
|
||||
settings.cpp song.cpp status_checker.cpp str_pool.c tag_editor.cpp window.cpp
|
||||
ncmpcpp.cpp playlist.cpp playlist_editor.cpp screen.cpp scrollpad.cpp \
|
||||
search_engine.cpp settings.cpp song.cpp status_checker.cpp str_pool.c tag_editor.cpp \
|
||||
window.cpp
|
||||
|
||||
# set the include path found by configure
|
||||
INCLUDES= $(all_includes)
|
||||
|
||||
@@ -57,20 +57,14 @@ void Browser::Resize()
|
||||
|
||||
void Browser::SwitchTo()
|
||||
{
|
||||
if (current_screen != csBrowser
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& current_screen != csTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
w->Empty() ? myBrowser->GetDirectory(itsBrowsedDir) : myBrowser->UpdateItemList();
|
||||
myScreen = this;
|
||||
w->Hide();
|
||||
current_screen = csBrowser;
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
}
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
CLEAR_FIND_HISTORY;
|
||||
w->Empty() ? myBrowser->GetDirectory(itsBrowsedDir) : myBrowser->UpdateItemList();
|
||||
myScreen = this;
|
||||
w->Hide();
|
||||
redraw_header = 1;
|
||||
}
|
||||
|
||||
std::string Browser::Title()
|
||||
@@ -147,6 +141,13 @@ void Browser::EnterPressed()
|
||||
|
||||
void Browser::SpacePressed()
|
||||
{
|
||||
if (Config.space_selects && w->Choice() >= (itsBrowsedDir != "/" ? 1 : 0))
|
||||
{
|
||||
Select(w);
|
||||
w->Scroll(wDown);
|
||||
return;
|
||||
}
|
||||
|
||||
if (w->Empty())
|
||||
return;
|
||||
|
||||
@@ -229,6 +230,11 @@ void Browser::SpacePressed()
|
||||
w->Scroll(wDown);
|
||||
}
|
||||
|
||||
MPD::Song *Browser::CurrentSong()
|
||||
{
|
||||
return !w->Empty() && w->Current().type == itSong ? w->Current().song : 0;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
const char *supported_extensions[] = { "wma", "asf", "rm", "mp1", "mp2", "mp3", "mp4", "m4a", "flac", "ogg", "wav", "au", "aiff", "aif", "ac3", "aac", "mpc", "it", "mod", "s3m", "xm", "wv", 0 };
|
||||
@@ -358,7 +364,7 @@ void Browser::GetDirectory(string dir, string subdir)
|
||||
}
|
||||
if (highlightme >= 0)
|
||||
w->Highlight(highlightme);
|
||||
if (current_screen == csBrowser)
|
||||
if (myScreen == myBrowser)
|
||||
w->Hide();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#ifndef _BROWSER_H
|
||||
#define _BROWSER_H
|
||||
|
||||
#include "mpdpp.h"
|
||||
#include "ncmpcpp.h"
|
||||
#include "screen.h"
|
||||
|
||||
@@ -39,6 +38,8 @@ class Browser : public Screen< Menu<MPD::Item> >
|
||||
virtual void EnterPressed();
|
||||
virtual void SpacePressed();
|
||||
|
||||
virtual MPD::Song *CurrentSong();
|
||||
|
||||
const std::string &CurrentDir() { return itsBrowsedDir; }
|
||||
|
||||
void GetDirectory(std::string, std::string = "/");
|
||||
|
||||
@@ -57,7 +57,7 @@ void Clock::Resize()
|
||||
if (Width <= size_t(COLS) && Height <= main_height)
|
||||
{
|
||||
w->MoveTo((COLS-Width)/2, (LINES-Height)/2);
|
||||
if (current_screen == csClock)
|
||||
if (myScreen == myClock)
|
||||
{
|
||||
myPlaylist->Main()->Hide();
|
||||
Prepare();
|
||||
@@ -71,22 +71,17 @@ void Clock::SwitchTo()
|
||||
if (Width > size_t(COLS) || Height > main_height)
|
||||
{
|
||||
ShowMessage("Screen is too small to display clock!");
|
||||
return;
|
||||
}
|
||||
else if (
|
||||
current_screen != csClock
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& current_screen != csTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
myScreen = this;
|
||||
myPlaylist->Main()->Hide();
|
||||
current_screen = csClock;
|
||||
redraw_header = 1;
|
||||
Clock::Prepare();
|
||||
w->Display();
|
||||
}
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
CLEAR_FIND_HISTORY;
|
||||
myScreen = this;
|
||||
myPlaylist->Main()->Hide();
|
||||
redraw_header = 1;
|
||||
Prepare();
|
||||
w->Display();
|
||||
}
|
||||
|
||||
std::string Clock::Title()
|
||||
|
||||
@@ -86,8 +86,8 @@ namespace Global
|
||||
extern std::string editor_highlighted_dir;
|
||||
// extern std::string info_title;
|
||||
|
||||
extern NcmpcppScreen current_screen;
|
||||
extern NcmpcppScreen prev_screen;
|
||||
// extern BasicScreen myScreen;
|
||||
// extern NcmpcppScreen myOldScreen;
|
||||
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
extern pthread_mutex_t curl;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "global.h"
|
||||
#include "help.h"
|
||||
#include "settings.h"
|
||||
#include "tag_editor.h"
|
||||
|
||||
using namespace Global;
|
||||
|
||||
@@ -43,15 +44,14 @@ void Help::Resize()
|
||||
|
||||
void Help::SwitchTo()
|
||||
{
|
||||
if (current_screen != csHelp
|
||||
if (myScreen != myHelp
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& current_screen != csTinyTagEditor
|
||||
&& myScreen != myTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
{
|
||||
myScreen = this;
|
||||
w->Hide();
|
||||
current_screen = csHelp;
|
||||
redraw_header = 1;
|
||||
}
|
||||
}
|
||||
|
||||
127
src/info.cpp
127
src/info.cpp
@@ -84,67 +84,19 @@ void Info::GetSong()
|
||||
if (myScreen == this)
|
||||
{
|
||||
w->Hide();
|
||||
current_screen = prev_screen;
|
||||
myScreen = myOldScreen;
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
if (current_screen == csLibrary)
|
||||
{
|
||||
myLibrary->Refresh();
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
{
|
||||
myPlaylistEditor->Refresh();
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (current_screen == csTagEditor)
|
||||
{
|
||||
myTagEditor->Refresh();
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
myScreen->Refresh();
|
||||
}
|
||||
else if (
|
||||
(myScreen == myPlaylist && !myPlaylist->Main()->Empty())
|
||||
|| (myScreen == myBrowser && myBrowser->Main()->Current().type == MPD::itSong)
|
||||
|| (myScreen == mySearcher && !mySearcher->Main()->Current().first)
|
||||
|| (myScreen->Cmp() == myLibrary->Songs && !myLibrary->Songs->Empty())
|
||||
|| (myScreen->Cmp() == myPlaylistEditor->Content && !myPlaylistEditor->Content->Empty())
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| (myScreen->Cmp() == myTagEditor->Tags && !myTagEditor->Tags->Empty())
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
else
|
||||
{
|
||||
MPD::Song *s = 0;
|
||||
size_t id = reinterpret_cast<Menu<MPD::Song> *>(((Screen<Window> *)myScreen)->Main())->Choice();
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
s = &myPlaylist->Main()->at(id);
|
||||
break;
|
||||
case csBrowser:
|
||||
s = myBrowser->Main()->at(id).song;
|
||||
break;
|
||||
case csSearcher:
|
||||
s = mySearcher->Main()->at(id).second;
|
||||
break;
|
||||
case csLibrary:
|
||||
s = &myLibrary->Songs->at(id);
|
||||
break;
|
||||
case csPlaylistEditor:
|
||||
s = &myPlaylistEditor->Content->at(id);
|
||||
break;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
case csTagEditor:
|
||||
s = &myTagEditor->Tags->at(id);
|
||||
break;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
default:
|
||||
break;
|
||||
}
|
||||
MPD::Song *s = myScreen->CurrentSong();
|
||||
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
myOldScreen = myScreen;
|
||||
myScreen = this;
|
||||
prev_screen = current_screen;
|
||||
current_screen = csInfo;
|
||||
redraw_header = 1;
|
||||
itsTitle = "Song info";
|
||||
w->Clear();
|
||||
@@ -161,36 +113,11 @@ void Info::GetArtist()
|
||||
if (myScreen == this)
|
||||
{
|
||||
w->Hide();
|
||||
current_screen = prev_screen;
|
||||
myScreen = myOldScreen;
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
if (current_screen == csLibrary)
|
||||
{
|
||||
myLibrary->Refresh();
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
{
|
||||
myPlaylistEditor->Refresh();
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (current_screen == csTagEditor)
|
||||
{
|
||||
myTagEditor->Refresh();
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
myScreen->Refresh();
|
||||
}
|
||||
else if (
|
||||
(myScreen == myPlaylist && !myPlaylist->Main()->Empty())
|
||||
|| (myScreen == myBrowser && myBrowser->Main()->Current().type == MPD::itSong)
|
||||
|| (myScreen == mySearcher && !mySearcher->Main()->Current().first)
|
||||
|| (myScreen->Cmp() == myLibrary->Artists && !myLibrary->Artists->Empty())
|
||||
|| (myScreen->Cmp() == myLibrary->Songs && !myLibrary->Songs->Empty())
|
||||
|| (myScreen->Cmp() == myPlaylistEditor->Content && !myPlaylistEditor->Content->Empty())
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| (myScreen->Cmp() == myTagEditor->Tags && !myTagEditor->Tags->Empty())
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
else
|
||||
{
|
||||
if (Downloader && !ArtistReady)
|
||||
{
|
||||
@@ -201,38 +128,18 @@ void Info::GetArtist()
|
||||
Update();
|
||||
|
||||
string *artist = new string();
|
||||
size_t id = reinterpret_cast<Menu<MPD::Song> *>(((Screen<Window> *)myScreen)->Main())->Choice();
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
*artist = myPlaylist->Main()->at(id).GetArtist();
|
||||
break;
|
||||
case csBrowser:
|
||||
*artist = myBrowser->Main()->at(id).song->GetArtist();
|
||||
break;
|
||||
case csSearcher:
|
||||
*artist = mySearcher->Main()->at(id).second->GetArtist();
|
||||
break;
|
||||
case csLibrary:
|
||||
*artist = myLibrary->Artists->at(id);
|
||||
break;
|
||||
case csPlaylistEditor:
|
||||
*artist = myPlaylistEditor->Content->at(id).GetArtist();
|
||||
break;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
case csTagEditor:
|
||||
*artist = myTagEditor->Tags->at(id).GetArtist();
|
||||
break;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
MPD::Song *s = myScreen->CurrentSong();
|
||||
|
||||
if (!s && myScreen->Cmp() != myLibrary->Artists)
|
||||
return;
|
||||
|
||||
*artist = !s ? myLibrary->Artists->Current() : s->GetArtist();
|
||||
|
||||
if (!artist->empty())
|
||||
{
|
||||
myOldScreen = myScreen;
|
||||
myScreen = this;
|
||||
prev_screen = current_screen;
|
||||
current_screen = csInfo;
|
||||
redraw_header = 1;
|
||||
itsTitle = "Artist's info - " + *artist;
|
||||
w->Clear();
|
||||
|
||||
@@ -87,36 +87,11 @@ void Lyrics::SwitchTo()
|
||||
if (myScreen == this && !Reload)
|
||||
{
|
||||
w->Hide();
|
||||
current_screen = prev_screen;
|
||||
myScreen = myOldScreen;
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
if (current_screen == csLibrary)
|
||||
{
|
||||
myLibrary->Refresh();
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
{
|
||||
myPlaylistEditor->Refresh();
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (current_screen == csTagEditor)
|
||||
{
|
||||
myTagEditor->Refresh();
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
myScreen->Refresh();
|
||||
}
|
||||
else if (
|
||||
Reload
|
||||
|| (myScreen == myPlaylist && !myPlaylist->Main()->Empty())
|
||||
|| (myScreen == myBrowser && myBrowser->Main()->Current().type == MPD::itSong)
|
||||
|| (myScreen == mySearcher && !mySearcher->Main()->Current().first)
|
||||
|| (myScreen->Cmp() == myLibrary->Songs && !myLibrary->Songs->Empty())
|
||||
|| (myScreen->Cmp() == myPlaylistEditor->Content && !myPlaylistEditor->Content->Empty())
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| (myScreen->Cmp() == myTagEditor->Tags && !myTagEditor->Tags->Empty())
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
else
|
||||
{
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
if (Downloader && !Ready)
|
||||
@@ -131,52 +106,18 @@ void Lyrics::SwitchTo()
|
||||
}
|
||||
# endif
|
||||
|
||||
MPD::Song *s = 0;
|
||||
int id;
|
||||
MPD::Song *s = Reload ? myPlaylist->CurrentSong() : myScreen->CurrentSong();
|
||||
Reload = 0;
|
||||
|
||||
if (Reload)
|
||||
{
|
||||
current_screen = csPlaylist;
|
||||
myScreen = myPlaylist;
|
||||
Reload = 0;
|
||||
id = myPlaylist->NowPlaying;
|
||||
}
|
||||
else
|
||||
id = reinterpret_cast<Menu<MPD::Song> *>(((Screen<Window> *)myScreen)->Main())->Choice();
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
s = &myPlaylist->Main()->at(id);
|
||||
break;
|
||||
case csBrowser:
|
||||
s = myBrowser->Main()->at(id).song;
|
||||
break;
|
||||
case csSearcher:
|
||||
s = mySearcher->Main()->at(id).second;
|
||||
break;
|
||||
case csLibrary:
|
||||
s = &myLibrary->Songs->at(id);
|
||||
break;
|
||||
case csPlaylistEditor:
|
||||
s = &myPlaylistEditor->Content->at(id);
|
||||
break;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
case csTagEditor:
|
||||
s = &myTagEditor->Tags->at(id);
|
||||
break;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!s->GetArtist().empty() && !s->GetTitle().empty())
|
||||
{
|
||||
itsScrollBegin = 0;
|
||||
itsSong = *s;
|
||||
myOldScreen = myScreen;
|
||||
prev_screen = current_screen;
|
||||
myScreen = this;
|
||||
current_screen = csLyrics;
|
||||
redraw_header = 1;
|
||||
w->Clear();
|
||||
w->WriteXY(0, 0, 0, "Fetching lyrics...");
|
||||
@@ -201,6 +142,12 @@ std::string Lyrics::Title()
|
||||
return result;
|
||||
}
|
||||
|
||||
void Lyrics::SpacePressed()
|
||||
{
|
||||
Config.now_playing_lyrics = !Config.now_playing_lyrics;
|
||||
ShowMessage("Reload lyrics if song changes: %s", Config.now_playing_lyrics ? "On" : "Off");
|
||||
}
|
||||
|
||||
void *Lyrics::Get(void *song)
|
||||
{
|
||||
string artist = static_cast<MPD::Song *>(song)->GetArtist();
|
||||
|
||||
@@ -52,6 +52,8 @@ class Lyrics : public Screen<Scrollpad>
|
||||
|
||||
virtual void Update();
|
||||
|
||||
virtual void SpacePressed();
|
||||
|
||||
static bool Reload;
|
||||
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
|
||||
@@ -103,25 +103,15 @@ void MediaLibrary::Refresh()
|
||||
|
||||
void MediaLibrary::SwitchTo()
|
||||
{
|
||||
if (current_screen != csLibrary
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& current_screen != csTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
myPlaylist->Main()->Hide(); // hack, should be myScreen, but it doesn't always have 100% width
|
||||
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
MediaLibrary::Refresh();
|
||||
|
||||
myScreen = this;
|
||||
current_screen = csLibrary;
|
||||
|
||||
UpdateSongList(Songs);
|
||||
}
|
||||
CLEAR_FIND_HISTORY;
|
||||
myScreen = this;
|
||||
myPlaylist->Main()->Hide(); // hack, should be myScreen, but it doesn't always have 100% width
|
||||
redraw_header = 1;
|
||||
Refresh();
|
||||
UpdateSongList(Songs);
|
||||
}
|
||||
|
||||
std::string MediaLibrary::Title()
|
||||
@@ -248,6 +238,22 @@ void MediaLibrary::Update()
|
||||
}
|
||||
}
|
||||
|
||||
void MediaLibrary::SpacePressed()
|
||||
{
|
||||
if (Config.space_selects && w == Songs)
|
||||
{
|
||||
Select(Songs);
|
||||
w->Scroll(wDown);
|
||||
return;
|
||||
}
|
||||
AddToPlaylist(0);
|
||||
}
|
||||
|
||||
MPD::Song *MediaLibrary::CurrentSong()
|
||||
{
|
||||
return w == Songs && !Songs->Empty() ? &Songs->Current() : 0;
|
||||
}
|
||||
|
||||
void MediaLibrary::NextColumn()
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
|
||||
@@ -37,7 +37,9 @@ class MediaLibrary : public Screen<Window>
|
||||
virtual void Update();
|
||||
|
||||
virtual void EnterPressed() { AddToPlaylist(1); }
|
||||
virtual void SpacePressed() { AddToPlaylist(0); }
|
||||
virtual void SpacePressed();
|
||||
|
||||
virtual MPD::Song *CurrentSong();
|
||||
|
||||
void NextColumn();
|
||||
void PrevColumn();
|
||||
|
||||
668
src/ncmpcpp.cpp
668
src/ncmpcpp.cpp
@@ -75,16 +75,12 @@ int Global::lock_statusbar_delay = -1;
|
||||
|
||||
size_t Global::main_start_y;
|
||||
size_t Global::main_height;
|
||||
//size_t Global::lyrics_scroll_begin = 0;
|
||||
|
||||
time_t Global::timer;
|
||||
|
||||
string Global::editor_browsed_dir = "/";
|
||||
string Global::editor_highlighted_dir;
|
||||
|
||||
NcmpcppScreen Global::current_screen;
|
||||
NcmpcppScreen Global::prev_screen;
|
||||
|
||||
bool Global::dont_change_now_playing = 0;
|
||||
bool Global::block_progressbar_update = 0;
|
||||
bool Global::block_playlist_update = 0;
|
||||
@@ -179,7 +175,6 @@ int main(int argc, char *argv[])
|
||||
wFooter->Display();
|
||||
|
||||
myScreen = myPlaylist;
|
||||
current_screen = csPlaylist;
|
||||
|
||||
timer = time(NULL);
|
||||
|
||||
@@ -225,59 +220,18 @@ int main(int argc, char *argv[])
|
||||
const size_t max_allowed_title_length = wHeader ? wHeader->GetWidth()-volume_state.length() : 0;
|
||||
if (((past.tv_sec == now.tv_sec && past.tv_usec >= now.tv_usec+500000)
|
||||
|| past.tv_sec > now.tv_sec)
|
||||
&& ((current_screen == csBrowser && myBrowser->CurrentDir().length() > max_allowed_title_length)
|
||||
|| current_screen == csLyrics))
|
||||
&& ((myScreen == myBrowser && myBrowser->CurrentDir().length() > max_allowed_title_length)
|
||||
|| myScreen == myLyrics))
|
||||
{
|
||||
redraw_header = 1;
|
||||
gettimeofday(&now, 0);
|
||||
}
|
||||
if (Config.header_visibility && redraw_header)
|
||||
{
|
||||
switch (current_screen)
|
||||
{
|
||||
case csHelp:
|
||||
screen_title = myHelp->Title();
|
||||
break;
|
||||
case csPlaylist:
|
||||
screen_title = myPlaylist->Title();
|
||||
break;
|
||||
case csBrowser:
|
||||
screen_title = myBrowser->Title();
|
||||
break;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
case csTinyTagEditor:
|
||||
case csTagEditor:
|
||||
screen_title = myTagEditor->Title();
|
||||
break;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
case csInfo:
|
||||
screen_title = myInfo->Title();
|
||||
break;
|
||||
case csSearcher:
|
||||
screen_title = mySearcher->Title();
|
||||
break;
|
||||
case csLibrary:
|
||||
screen_title = myLibrary->Title();
|
||||
break;
|
||||
case csLyrics:
|
||||
screen_title = myLyrics->Title();
|
||||
break;
|
||||
case csPlaylistEditor:
|
||||
screen_title = myPlaylistEditor->Title();
|
||||
break;
|
||||
# ifdef ENABLE_CLOCK
|
||||
case csClock:
|
||||
screen_title = myClock->Title();
|
||||
break;
|
||||
# endif // ENABLE_CLOCK
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (title_allowed)
|
||||
{
|
||||
wHeader->Bold(1);
|
||||
wHeader->WriteXY(0, 0, 1, "%s", screen_title.c_str());
|
||||
wHeader->WriteXY(0, 0, 1, "%s", myScreen->Title().c_str());
|
||||
wHeader->Bold(0);
|
||||
}
|
||||
else
|
||||
@@ -305,43 +259,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
// header stuff end
|
||||
|
||||
if (current_screen == csHelp
|
||||
|| current_screen == csPlaylist
|
||||
|| current_screen == csBrowser);
|
||||
else if (current_screen == csLibrary)
|
||||
{
|
||||
myLibrary->Update();
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
{
|
||||
myPlaylistEditor->Update();
|
||||
}
|
||||
else
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (current_screen == csTagEditor)
|
||||
{
|
||||
myTagEditor->Update();
|
||||
}
|
||||
else
|
||||
# endif // HAVE_TAGLIB_H
|
||||
# ifdef ENABLE_CLOCK
|
||||
if (current_screen == csClock)
|
||||
{
|
||||
myClock->Update();
|
||||
}
|
||||
else
|
||||
# endif
|
||||
if (current_screen == csLyrics)
|
||||
{
|
||||
myLyrics->Update();
|
||||
}
|
||||
else if (current_screen == csInfo)
|
||||
{
|
||||
myInfo->Update();
|
||||
}
|
||||
myScreen->Update();
|
||||
|
||||
myWindow->Main()->Display();
|
||||
// redraw_screen = 0;
|
||||
|
||||
myWindow->Main()->ReadKey(input);
|
||||
if (input == ERR)
|
||||
@@ -352,45 +272,41 @@ int main(int argc, char *argv[])
|
||||
title_allowed = 1;
|
||||
timer = time(NULL);
|
||||
|
||||
switch (current_screen)
|
||||
if (myScreen == myPlaylist)
|
||||
{
|
||||
case csPlaylist:
|
||||
myPlaylist->Main()->Highlighting(1);
|
||||
break;
|
||||
case csLibrary:
|
||||
case csPlaylistEditor:
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
case csTagEditor:
|
||||
# endif // HAVE_TAGLIB_H
|
||||
myPlaylist->Main()->Highlighting(1);
|
||||
}
|
||||
else if (
|
||||
myScreen == myLibrary
|
||||
|| myScreen == myPlaylistEditor
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| myScreen == myTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
{
|
||||
if (Keypressed(input, Key.Up) || Keypressed(input, Key.Down) || Keypressed(input, Key.PageUp) || Keypressed(input, Key.PageDown) || Keypressed(input, Key.Home) || Keypressed(input, Key.End) || Keypressed(input, Key.FindForward) || Keypressed(input, Key.FindBackward) || Keypressed(input, Key.NextFoundPosition) || Keypressed(input, Key.PrevFoundPosition))
|
||||
{
|
||||
if (Keypressed(input, Key.Up) || Keypressed(input, Key.Down) || Keypressed(input, Key.PageUp) || Keypressed(input, Key.PageDown) || Keypressed(input, Key.Home) || Keypressed(input, Key.End) || Keypressed(input, Key.FindForward) || Keypressed(input, Key.FindBackward) || Keypressed(input, Key.NextFoundPosition) || Keypressed(input, Key.PrevFoundPosition))
|
||||
if (myScreen->Cmp() == myLibrary->Artists)
|
||||
{
|
||||
if (myScreen->Cmp() == myLibrary->Artists)
|
||||
{
|
||||
myLibrary->Albums->Clear(0);
|
||||
myLibrary->Songs->Clear(0);
|
||||
}
|
||||
else if (myScreen->Cmp() == myLibrary->Albums)
|
||||
{
|
||||
myLibrary->Songs->Clear(0);
|
||||
}
|
||||
else if (myScreen->Cmp() == myPlaylistEditor->List)
|
||||
{
|
||||
myPlaylistEditor->Content->Clear(0);
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (myScreen->Cmp() == myTagEditor->LeftColumn)
|
||||
{
|
||||
myTagEditor->Tags->Clear(0);
|
||||
myTagEditor->TagTypes->Refresh();
|
||||
}
|
||||
// else if (myScreen == myTagEditor->TagTypes)
|
||||
// redraw_screen = 1;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
myLibrary->Albums->Clear(0);
|
||||
myLibrary->Songs->Clear(0);
|
||||
}
|
||||
else if (myScreen->Cmp() == myLibrary->Albums)
|
||||
{
|
||||
myLibrary->Songs->Clear(0);
|
||||
}
|
||||
else if (myScreen->Cmp() == myPlaylistEditor->List)
|
||||
{
|
||||
myPlaylistEditor->Content->Clear(0);
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (myScreen->Cmp() == myTagEditor->LeftColumn)
|
||||
{
|
||||
myTagEditor->Tags->Clear(0);
|
||||
myTagEditor->TagTypes->Refresh();
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// key mapping beginning
|
||||
@@ -398,7 +314,7 @@ int main(int argc, char *argv[])
|
||||
if (
|
||||
Keypressed(input, Key.Up)
|
||||
#ifdef ENABLE_CLOCK
|
||||
&& current_screen != csClock
|
||||
&& myScreen != myClock
|
||||
# endif // ENABLE_CLOCK
|
||||
)
|
||||
{
|
||||
@@ -426,7 +342,7 @@ int main(int argc, char *argv[])
|
||||
else if (
|
||||
Keypressed(input, Key.Down)
|
||||
#ifdef ENABLE_CLOCK
|
||||
&& current_screen != csClock
|
||||
&& myScreen != myClock
|
||||
# endif // ENABLE_CLOCK
|
||||
)
|
||||
{
|
||||
@@ -454,7 +370,7 @@ int main(int argc, char *argv[])
|
||||
else if (
|
||||
Keypressed(input, Key.PageUp)
|
||||
#ifdef ENABLE_CLOCK
|
||||
&& current_screen != csClock
|
||||
&& myScreen != myClock
|
||||
# endif // ENABLE_CLOCK
|
||||
)
|
||||
{
|
||||
@@ -463,7 +379,7 @@ int main(int argc, char *argv[])
|
||||
else if (
|
||||
Keypressed(input, Key.PageDown)
|
||||
#ifdef ENABLE_CLOCK
|
||||
&& current_screen != csClock
|
||||
&& myScreen != myClock
|
||||
# endif // ENABLE_CLOCK
|
||||
)
|
||||
{
|
||||
@@ -522,17 +438,17 @@ int main(int argc, char *argv[])
|
||||
wFooter->Resize(COLS, wFooter->GetHeight());
|
||||
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (current_screen == csLibrary)
|
||||
if (myScreen == myLibrary)
|
||||
{
|
||||
myLibrary->Refresh();
|
||||
}
|
||||
else if (current_screen == csTagEditor)
|
||||
else if (myScreen == myTagEditor)
|
||||
{
|
||||
myTagEditor->Refresh();
|
||||
}
|
||||
else
|
||||
# endif // HAVE_TAGLIB_H
|
||||
if (current_screen == csPlaylistEditor)
|
||||
if (myScreen == myPlaylistEditor)
|
||||
{
|
||||
myPlaylistEditor->Refresh();
|
||||
}
|
||||
@@ -556,119 +472,24 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.Enter))
|
||||
{
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
{
|
||||
myPlaylist->EnterPressed();
|
||||
break;
|
||||
}
|
||||
case csBrowser:
|
||||
{
|
||||
myBrowser->EnterPressed();
|
||||
break;
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
case csTinyTagEditor:
|
||||
{
|
||||
myTinyTagEditor->EnterPressed();
|
||||
break;
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
case csSearcher:
|
||||
{
|
||||
mySearcher->EnterPressed();
|
||||
break;
|
||||
}
|
||||
case csLibrary:
|
||||
{
|
||||
myLibrary->EnterPressed();
|
||||
break;
|
||||
}
|
||||
case csPlaylistEditor:
|
||||
{
|
||||
myPlaylistEditor->EnterPressed();
|
||||
break;
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
case csTagEditor:
|
||||
{
|
||||
myTagEditor->EnterPressed();
|
||||
break;
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
default:
|
||||
break;
|
||||
}
|
||||
myScreen->EnterPressed();
|
||||
}
|
||||
else if (Keypressed(input, Key.Space))
|
||||
{
|
||||
if (Config.space_selects
|
||||
|| myScreen == myPlaylist
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| myScreen->Cmp() == myTagEditor->Tags
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
{
|
||||
if (myScreen == myPlaylist
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| myScreen->Cmp() == myTagEditor->Tags
|
||||
# endif // HAVE_TAGLIB_H
|
||||
|| (myScreen == myBrowser && ((Menu<Song> *)myWindow->Main())->Choice() >= (myBrowser->CurrentDir() != "/" ? 1 : 0)) || (myScreen == mySearcher && !mySearcher->Main()->Current().first)
|
||||
|| myScreen->Cmp() == myLibrary->Songs
|
||||
|| myScreen->Cmp() == myPlaylistEditor->Content)
|
||||
{
|
||||
List *mList = (Menu<Song> *)myWindow->Main();
|
||||
if (mList->Empty())
|
||||
continue;
|
||||
size_t i = mList->Choice();
|
||||
mList->Select(i, !mList->isSelected(i));
|
||||
myWindow->Main()->Scroll(wDown);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (current_screen == csBrowser)
|
||||
{
|
||||
myBrowser->SpacePressed();
|
||||
}
|
||||
else if (current_screen == csSearcher)
|
||||
{
|
||||
mySearcher->SpacePressed();
|
||||
}
|
||||
else if (current_screen == csLibrary)
|
||||
{
|
||||
myLibrary->SpacePressed();
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
{
|
||||
myPlaylistEditor->SpacePressed();
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (current_screen == csTagEditor)
|
||||
{
|
||||
myTagEditor->SpacePressed();
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
else if (current_screen == csLyrics)
|
||||
{
|
||||
Config.now_playing_lyrics = !Config.now_playing_lyrics;
|
||||
ShowMessage("Reload lyrics if song changes: %s", Config.now_playing_lyrics ? "On" : "Off");
|
||||
}
|
||||
}
|
||||
myScreen->SpacePressed();
|
||||
}
|
||||
else if (Keypressed(input, Key.VolumeUp))
|
||||
{
|
||||
if (current_screen == csLibrary && input == Key.VolumeUp[0])
|
||||
if (myScreen == myLibrary && input == Key.VolumeUp[0])
|
||||
{
|
||||
myLibrary->NextColumn();
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor && input == Key.VolumeUp[0])
|
||||
else if (myScreen == myPlaylistEditor && input == Key.VolumeUp[0])
|
||||
{
|
||||
myPlaylistEditor->NextColumn();
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (current_screen == csTagEditor && input == Key.VolumeUp[0])
|
||||
else if (myScreen == myTagEditor && input == Key.VolumeUp[0])
|
||||
{
|
||||
myTagEditor->NextColumn();
|
||||
}
|
||||
@@ -678,16 +499,16 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.VolumeDown))
|
||||
{
|
||||
if (current_screen == csLibrary && input == Key.VolumeDown[0])
|
||||
if (myScreen == myLibrary && input == Key.VolumeDown[0])
|
||||
{
|
||||
myLibrary->PrevColumn();
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor && input == Key.VolumeDown[0])
|
||||
else if (myScreen == myPlaylistEditor && input == Key.VolumeDown[0])
|
||||
{
|
||||
myPlaylistEditor->PrevColumn();
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (current_screen == csTagEditor && input == Key.VolumeDown[0])
|
||||
else if (myScreen == myTagEditor && input == Key.VolumeDown[0])
|
||||
{
|
||||
myTagEditor->PrevColumn();
|
||||
}
|
||||
@@ -697,7 +518,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.Delete))
|
||||
{
|
||||
if (!myPlaylist->Main()->Empty() && current_screen == csPlaylist)
|
||||
if (!myPlaylist->Main()->Empty() && myScreen == myPlaylist)
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
if (myPlaylist->Main()->hasSelected())
|
||||
@@ -733,11 +554,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
Mpd->CommitQueue();
|
||||
}
|
||||
else if (current_screen == csBrowser || myScreen->Cmp() == myPlaylistEditor->List)
|
||||
else if (myScreen == myBrowser || myScreen->Cmp() == myPlaylistEditor->List)
|
||||
{
|
||||
LockStatusbar();
|
||||
string name = myScreen == myBrowser ? myBrowser->Main()->Current().name : myPlaylistEditor->List->Current();
|
||||
if (current_screen != csBrowser || myBrowser->Main()->Current().type == itPlaylist)
|
||||
if (myScreen != myBrowser || myBrowser->Main()->Current().type == itPlaylist)
|
||||
{
|
||||
Statusbar() << "Delete playlist " << name << " ? [y/n] ";
|
||||
curs_set(1);
|
||||
@@ -865,7 +686,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.MvSongUp))
|
||||
{
|
||||
if (current_screen == csPlaylist && !myPlaylist->Main()->Empty())
|
||||
if (myScreen == myPlaylist && !myPlaylist->Main()->Empty())
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
myPlaylist->Main()->SetTimeout(50);
|
||||
@@ -968,7 +789,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.MvSongDown))
|
||||
{
|
||||
if (current_screen == csPlaylist && !myPlaylist->Main()->Empty())
|
||||
if (myScreen == myPlaylist && !myPlaylist->Main()->Empty())
|
||||
{
|
||||
block_playlist_update = 1;
|
||||
myPlaylist->Main()->SetTimeout(50);
|
||||
@@ -1197,10 +1018,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.UpdateDB))
|
||||
{
|
||||
if (current_screen == csBrowser)
|
||||
if (myScreen == myBrowser)
|
||||
Mpd->UpdateDirectory(myBrowser->CurrentDir());
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (current_screen == csTagEditor && !Config.albums_in_tag_editor)
|
||||
else if (myScreen == myTagEditor && !Config.albums_in_tag_editor)
|
||||
Mpd->UpdateDirectory(editor_browsed_dir);
|
||||
# endif // HAVE_TAGLIB_H
|
||||
else
|
||||
@@ -1208,7 +1029,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.GoToNowPlaying))
|
||||
{
|
||||
if (current_screen == csPlaylist && myPlaylist->isPlaying())
|
||||
if (myScreen == myPlaylist && myPlaylist->isPlaying())
|
||||
myPlaylist->Main()->Highlight(myPlaylist->NowPlaying);
|
||||
}
|
||||
else if (Keypressed(input, Key.ToggleRepeat))
|
||||
@@ -1324,13 +1145,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (
|
||||
(myScreen == myPlaylist && !myPlaylist->Main()->Empty())
|
||||
|| (myScreen == myBrowser && myBrowser->Main()->Current().type == itSong)
|
||||
|| (myScreen == mySearcher && !mySearcher->Main()->Current().first)
|
||||
|| (myScreen->Cmp() == myLibrary->Songs && !myLibrary->Songs->Empty())
|
||||
|| (myScreen->Cmp() == myPlaylistEditor->Content && !myPlaylistEditor->Content->Empty())
|
||||
|| (myScreen->Cmp() == myTagEditor->Tags && !myTagEditor->Tags->Empty()))
|
||||
else if (myTinyTagEditor->SetEdited(myScreen->CurrentSong()))
|
||||
{
|
||||
myTinyTagEditor->SwitchTo();
|
||||
}
|
||||
@@ -1405,58 +1220,25 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.GoToContainingDir))
|
||||
{
|
||||
if ((myScreen == myPlaylist && !myPlaylist->Main()->Empty())
|
||||
|| (myScreen == mySearcher && !mySearcher->Main()->Current().first)
|
||||
|| (myScreen->Cmp() == myLibrary->Songs && !myLibrary->Songs->Empty())
|
||||
|| (myScreen->Cmp() == myPlaylistEditor->Content && !myPlaylistEditor->Content->Empty())
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| (myScreen->Cmp() == myTagEditor->Tags && !myTagEditor->Tags->Empty())
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
Song *s = myScreen->CurrentSong();
|
||||
|
||||
if (!s || s->GetDirectory().empty())
|
||||
continue;
|
||||
|
||||
Config.local_browser = !s->IsFromDB();
|
||||
|
||||
string option = s->toString(Config.song_status_format);
|
||||
locale_to_utf(option);
|
||||
myBrowser->GetDirectory(s->GetDirectory());
|
||||
for (size_t i = 0; i < myBrowser->Main()->Size(); i++)
|
||||
{
|
||||
size_t id = ((Menu<Song> *)myScreen)->Choice();
|
||||
Song *s = 0;
|
||||
switch (current_screen)
|
||||
if (myBrowser->Main()->at(i).type == itSong && option == myBrowser->Main()->at(i).song->toString(Config.song_status_format))
|
||||
{
|
||||
case csPlaylist:
|
||||
s = &myPlaylist->Main()->at(id);
|
||||
break;
|
||||
case csSearcher:
|
||||
s = mySearcher->Main()->at(id).second;
|
||||
break;
|
||||
case csLibrary:
|
||||
s = &myLibrary->Songs->at(id);
|
||||
break;
|
||||
case csPlaylistEditor:
|
||||
s = &myPlaylistEditor->Content->at(id);
|
||||
break;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
case csTagEditor:
|
||||
s = &myTagEditor->Tags->at(id);
|
||||
break;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
default:
|
||||
break;
|
||||
myBrowser->Main()->Highlight(i);
|
||||
break;
|
||||
}
|
||||
|
||||
if (s->GetDirectory().empty()) // for streams
|
||||
continue;
|
||||
|
||||
Config.local_browser = !s->IsFromDB();
|
||||
|
||||
string option = s->toString(Config.song_status_format);
|
||||
locale_to_utf(option);
|
||||
myBrowser->GetDirectory(s->GetDirectory());
|
||||
for (size_t i = 0; i < myBrowser->Main()->Size(); i++)
|
||||
{
|
||||
if (myBrowser->Main()->at(i).type == itSong && option == myBrowser->Main()->at(i).song->toString(Config.song_status_format))
|
||||
{
|
||||
myBrowser->Main()->Highlight(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
myBrowser->SwitchTo();
|
||||
}
|
||||
myBrowser->SwitchTo();
|
||||
}
|
||||
else if (Keypressed(input, Key.StartSearching))
|
||||
{
|
||||
@@ -1553,68 +1335,57 @@ int main(int argc, char *argv[])
|
||||
SongList result;
|
||||
for (vector<size_t>::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
switch (current_screen)
|
||||
if (myScreen == myPlaylist)
|
||||
{
|
||||
case csPlaylist:
|
||||
Song *s = new Song(myPlaylist->Main()->at(*it));
|
||||
result.push_back(s);
|
||||
}
|
||||
else if (myScreen == myBrowser)
|
||||
{
|
||||
const Item &item = myBrowser->Main()->at(*it);
|
||||
switch (item.type)
|
||||
{
|
||||
Song *s = new Song(myPlaylist->Main()->at(*it));
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
case csBrowser:
|
||||
{
|
||||
const Item &item = myBrowser->Main()->at(*it);
|
||||
switch (item.type)
|
||||
case itDirectory:
|
||||
{
|
||||
case itDirectory:
|
||||
{
|
||||
Mpd->GetDirectoryRecursive(locale_to_utf_cpy(item.name), result);
|
||||
break;
|
||||
}
|
||||
case itSong:
|
||||
{
|
||||
Song *s = new Song(*item.song);
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
case itPlaylist:
|
||||
{
|
||||
Mpd->GetPlaylistContent(locale_to_utf_cpy(item.name), result);
|
||||
break;
|
||||
}
|
||||
Mpd->GetDirectoryRecursive(locale_to_utf_cpy(item.name), result);
|
||||
break;
|
||||
}
|
||||
case itSong:
|
||||
{
|
||||
Song *s = new Song(*item.song);
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
case itPlaylist:
|
||||
{
|
||||
Mpd->GetPlaylistContent(locale_to_utf_cpy(item.name), result);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case csSearcher:
|
||||
{
|
||||
Song *s = new Song(*mySearcher->Main()->at(*it).second);
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
case csLibrary:
|
||||
{
|
||||
Song *s = new Song(myLibrary->Songs->at(*it));
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
case csPlaylistEditor:
|
||||
{
|
||||
Song *s = new Song(myPlaylistEditor->Content->at(*it));
|
||||
result.push_back(s);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else if (myScreen == mySearcher)
|
||||
{
|
||||
Song *s = new Song(*mySearcher->Main()->at(*it).second);
|
||||
result.push_back(s);
|
||||
}
|
||||
else if (myScreen == myLibrary)
|
||||
{
|
||||
Song *s = new Song(myLibrary->Songs->at(*it));
|
||||
result.push_back(s);
|
||||
}
|
||||
else if (myScreen == myPlaylistEditor)
|
||||
{
|
||||
Song *s = new Song(myPlaylistEditor->Content->at(*it));
|
||||
result.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
size_t dialog_width = COLS*0.8;
|
||||
size_t dialog_height = LINES*0.6;
|
||||
Menu<string> *mDialog = new Menu<string>((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", Config.main_color, Config.window_border);
|
||||
mDialog->SetTimeout(ncmpcpp_window_timeout);
|
||||
mDialog->SetItemDisplayer(Display::Generic);
|
||||
|
||||
bool playlists_not_active = current_screen == csBrowser && Config.local_browser;
|
||||
bool playlists_not_active = myScreen == myBrowser && Config.local_browser;
|
||||
|
||||
if (playlists_not_active)
|
||||
{
|
||||
@@ -1635,8 +1406,6 @@ int main(int argc, char *argv[])
|
||||
mDialog->AddOption("Cancel");
|
||||
|
||||
mDialog->Display();
|
||||
prev_screen = current_screen;
|
||||
current_screen = csOther;
|
||||
|
||||
while (!Keypressed(input, Key.Enter))
|
||||
{
|
||||
@@ -1658,15 +1427,14 @@ int main(int argc, char *argv[])
|
||||
mDialog->Scroll(wEnd);
|
||||
}
|
||||
|
||||
current_screen = prev_screen;
|
||||
size_t id = mDialog->Choice();
|
||||
|
||||
// redraw_screen = 1;
|
||||
if (current_screen == csLibrary)
|
||||
if (myScreen == myLibrary)
|
||||
{
|
||||
myLibrary->Refresh();
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
else if (myScreen == myPlaylistEditor)
|
||||
{
|
||||
myPlaylistEditor->Refresh();
|
||||
}
|
||||
@@ -1764,14 +1532,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (Keypressed(input, Key.FindForward) || Keypressed(input, Key.FindBackward))
|
||||
{
|
||||
if ((current_screen == csHelp
|
||||
|| current_screen == csSearcher
|
||||
if ((myScreen == myHelp
|
||||
|| myScreen == mySearcher
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| current_screen == csTinyTagEditor
|
||||
|| myScreen == myTinyTagEditor
|
||||
|| myScreen->Cmp() == myTagEditor->TagTypes
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
&& (current_screen != csSearcher
|
||||
&& (myScreen != mySearcher
|
||||
|| mySearcher->Main()->Current().first)
|
||||
)
|
||||
continue;
|
||||
@@ -1793,101 +1561,102 @@ int main(int argc, char *argv[])
|
||||
for (size_t i = (myScreen == mySearcher ? SearchEngine::StaticOptions : 0); i < mList->Size(); i++)
|
||||
{
|
||||
string name;
|
||||
switch (current_screen)
|
||||
if (myScreen == myPlaylist)
|
||||
{
|
||||
case csPlaylist:
|
||||
name = myPlaylist->Main()->at(i).toString(Config.song_list_format);
|
||||
break;
|
||||
case csBrowser:
|
||||
switch (myBrowser->Main()->at(i).type)
|
||||
{
|
||||
case itDirectory:
|
||||
name = myBrowser->Main()->at(i).name;
|
||||
break;
|
||||
case itSong:
|
||||
name = myBrowser->Main()->at(i).song->toString(Config.song_list_format);
|
||||
break;
|
||||
case itPlaylist:
|
||||
name = Config.browser_playlist_prefix.Str();
|
||||
name += myBrowser->Main()->at(i).name;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case csSearcher:
|
||||
name = mySearcher->Main()->at(i).second->toString(Config.song_list_format);
|
||||
break;
|
||||
case csLibrary:
|
||||
if (myScreen->Cmp() == myLibrary->Artists)
|
||||
name = myLibrary->Artists->at(i);
|
||||
else if (myScreen->Cmp() == myLibrary->Albums)
|
||||
name = myLibrary->Albums->at(i).first;
|
||||
else
|
||||
name = myLibrary->Songs->at(i).toString(Config.song_library_format);
|
||||
break;
|
||||
case csPlaylistEditor:
|
||||
if (myScreen->Cmp() == myPlaylistEditor->List)
|
||||
name = myPlaylistEditor->List->at(i);
|
||||
else
|
||||
name = myPlaylistEditor->Content->at(i).toString(Config.song_list_format);
|
||||
break;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
case csTagEditor:
|
||||
if (myScreen->Cmp() == myTagEditor->LeftColumn)
|
||||
name = myTagEditor->LeftColumn->at(i).first;
|
||||
else
|
||||
{
|
||||
const Song &s = myTagEditor->Tags->at(i);
|
||||
switch (myTagEditor->TagTypes->Choice())
|
||||
{
|
||||
case 0:
|
||||
name = s.GetTitle();
|
||||
break;
|
||||
case 1:
|
||||
name = s.GetArtist();
|
||||
break;
|
||||
case 2:
|
||||
name = s.GetAlbum();
|
||||
break;
|
||||
case 3:
|
||||
name = s.GetYear();
|
||||
break;
|
||||
case 4:
|
||||
name = s.GetTrack();
|
||||
break;
|
||||
case 5:
|
||||
name = s.GetGenre();
|
||||
break;
|
||||
case 6:
|
||||
name = s.GetComposer();
|
||||
break;
|
||||
case 7:
|
||||
name = s.GetPerformer();
|
||||
break;
|
||||
case 8:
|
||||
name = s.GetDisc();
|
||||
break;
|
||||
case 9:
|
||||
name = s.GetComment();
|
||||
break;
|
||||
case 11:
|
||||
if (s.GetNewName().empty())
|
||||
name = s.GetName();
|
||||
else
|
||||
{
|
||||
name = s.GetName();
|
||||
name += " -> ";
|
||||
name += s.GetNewName();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
default:
|
||||
break;
|
||||
name = myPlaylist->Main()->at(i).toString(Config.song_list_format);
|
||||
}
|
||||
else if (myScreen == myBrowser)
|
||||
{
|
||||
switch (myBrowser->Main()->at(i).type)
|
||||
{
|
||||
case itDirectory:
|
||||
name = myBrowser->Main()->at(i).name;
|
||||
break;
|
||||
case itSong:
|
||||
name = myBrowser->Main()->at(i).song->toString(Config.song_list_format);
|
||||
break;
|
||||
case itPlaylist:
|
||||
name = Config.browser_playlist_prefix.Str();
|
||||
name += myBrowser->Main()->at(i).name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (myScreen == mySearcher)
|
||||
{
|
||||
name = mySearcher->Main()->at(i).second->toString(Config.song_list_format);
|
||||
}
|
||||
else if (myScreen == myLibrary)
|
||||
{
|
||||
if (myScreen->Cmp() == myLibrary->Artists)
|
||||
name = myLibrary->Artists->at(i);
|
||||
else if (myScreen->Cmp() == myLibrary->Albums)
|
||||
name = myLibrary->Albums->at(i).first;
|
||||
else
|
||||
name = myLibrary->Songs->at(i).toString(Config.song_library_format);
|
||||
}
|
||||
else if (myScreen == myPlaylistEditor)
|
||||
{
|
||||
if (myScreen->Cmp() == myPlaylistEditor->List)
|
||||
name = myPlaylistEditor->List->at(i);
|
||||
else
|
||||
name = myPlaylistEditor->Content->at(i).toString(Config.song_list_format);
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (myScreen == myTagEditor)
|
||||
{
|
||||
if (myScreen->Cmp() == myTagEditor->LeftColumn)
|
||||
name = myTagEditor->LeftColumn->at(i).first;
|
||||
else
|
||||
{
|
||||
const Song &s = myTagEditor->Tags->at(i);
|
||||
switch (myTagEditor->TagTypes->Choice())
|
||||
{
|
||||
case 0:
|
||||
name = s.GetTitle();
|
||||
break;
|
||||
case 1:
|
||||
name = s.GetArtist();
|
||||
break;
|
||||
case 2:
|
||||
name = s.GetAlbum();
|
||||
break;
|
||||
case 3:
|
||||
name = s.GetYear();
|
||||
break;
|
||||
case 4:
|
||||
name = s.GetTrack();
|
||||
break;
|
||||
case 5:
|
||||
name = s.GetGenre();
|
||||
break;
|
||||
case 6:
|
||||
name = s.GetComposer();
|
||||
break;
|
||||
case 7:
|
||||
name = s.GetPerformer();
|
||||
break;
|
||||
case 8:
|
||||
name = s.GetDisc();
|
||||
break;
|
||||
case 9:
|
||||
name = s.GetComment();
|
||||
break;
|
||||
case 11:
|
||||
if (s.GetNewName().empty())
|
||||
name = s.GetName();
|
||||
else
|
||||
{
|
||||
name = s.GetName();
|
||||
name += " -> ";
|
||||
name += s.GetNewName();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
ToLower(name);
|
||||
if (name.find(findme) != string::npos && !mList->isStatic(i))
|
||||
{
|
||||
@@ -2011,13 +1780,23 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
myLyrics->SwitchTo();
|
||||
}
|
||||
else if (Keypressed(input, Key.Quit))
|
||||
{
|
||||
main_exit = 1;
|
||||
}
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
else if (myScreen == myTinyTagEditor)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
else if (Keypressed(input, Key.Help))
|
||||
{
|
||||
myHelp->SwitchTo();
|
||||
}
|
||||
else if (Keypressed(input, Key.ScreenSwitcher))
|
||||
{
|
||||
if (current_screen == csPlaylist)
|
||||
if (myScreen == myPlaylist)
|
||||
myBrowser->SwitchTo();
|
||||
else
|
||||
myPlaylist->SwitchTo();
|
||||
@@ -2055,9 +1834,6 @@ int main(int argc, char *argv[])
|
||||
myClock->SwitchTo();
|
||||
}
|
||||
# endif // ENABLE_CLOCK
|
||||
else if (Keypressed(input, Key.Quit))
|
||||
main_exit = 1;
|
||||
|
||||
// key mapping end
|
||||
}
|
||||
// restore old cerr buffer
|
||||
|
||||
@@ -34,27 +34,27 @@
|
||||
|
||||
typedef std::pair<std::string, std::string> string_pair;
|
||||
|
||||
enum NcmpcppScreen
|
||||
/*enum NcmpcppScreen
|
||||
{
|
||||
csHelp,
|
||||
csPlaylist,
|
||||
csBrowser,
|
||||
myHelp,
|
||||
myPlaylist,
|
||||
myBrowser,
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
csTinyTagEditor,
|
||||
myTinyTagEditor,
|
||||
# endif // HAVE_TAGLIB_H
|
||||
csInfo,
|
||||
csSearcher,
|
||||
csLibrary,
|
||||
csLyrics,
|
||||
csPlaylistEditor,
|
||||
myInfo,
|
||||
mySearcher,
|
||||
myLibrary,
|
||||
myLyrics,
|
||||
myPlaylistEditor,
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
csTagEditor,
|
||||
myTagEditor,
|
||||
# endif // HAVE_TAGLIB_H
|
||||
# ifdef ENABLE_CLOCK
|
||||
csClock,
|
||||
myClock,
|
||||
# endif // ENABLE_CLOCK
|
||||
csOther
|
||||
};
|
||||
};*/
|
||||
|
||||
const int ncmpcpp_window_timeout = 500;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "playlist.h"
|
||||
#include "song.h"
|
||||
#include "status_checker.h"
|
||||
#include "tag_editor.h"
|
||||
|
||||
using namespace Global;
|
||||
using std::vector;
|
||||
@@ -44,19 +45,13 @@ void Playlist::Init()
|
||||
|
||||
void Playlist::SwitchTo()
|
||||
{
|
||||
if (current_screen != csPlaylist
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& current_screen != csTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
myScreen = this;
|
||||
w->Hide();
|
||||
current_screen = csPlaylist;
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
}
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
CLEAR_FIND_HISTORY;
|
||||
myScreen = this;
|
||||
w->Hide();
|
||||
redraw_header = 1;
|
||||
}
|
||||
|
||||
void Playlist::Resize()
|
||||
@@ -72,21 +67,23 @@ std::string Playlist::Title()
|
||||
return result;
|
||||
}
|
||||
|
||||
void Playlist::SpacePressed()
|
||||
{
|
||||
if (w->Empty())
|
||||
return;
|
||||
size_t i = w->Choice();
|
||||
w->Select(i, !w->isSelected(i));
|
||||
w->Scroll(wDown);
|
||||
}
|
||||
|
||||
void Playlist::EnterPressed()
|
||||
{
|
||||
if (!w->Empty())
|
||||
Mpd->PlayID(w->Current().GetID());
|
||||
}
|
||||
|
||||
void Playlist::SpacePressed()
|
||||
{
|
||||
Select(w);
|
||||
w->Scroll(wDown);
|
||||
}
|
||||
|
||||
MPD::Song *Playlist::CurrentSong()
|
||||
{
|
||||
return !w->Empty() ? &w->Current() : 0;
|
||||
}
|
||||
|
||||
std::string Playlist::TotalLength()
|
||||
{
|
||||
std::ostringstream result;
|
||||
|
||||
@@ -40,6 +40,8 @@ class Playlist : public Screen< Menu<MPD::Song> >
|
||||
virtual void EnterPressed();
|
||||
virtual void SpacePressed();
|
||||
|
||||
virtual MPD::Song *CurrentSong();
|
||||
|
||||
bool isPlaying() { return NowPlaying >= 0 && !w->Empty(); }
|
||||
const MPD::Song &NowPlayingSong();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "playlist_editor.h"
|
||||
#include "mpdpp.h"
|
||||
#include "status_checker.h"
|
||||
#include "tag_editor.h"
|
||||
|
||||
using namespace Global;
|
||||
using namespace MPD;
|
||||
@@ -91,25 +92,15 @@ void PlaylistEditor::Refresh()
|
||||
|
||||
void PlaylistEditor::SwitchTo()
|
||||
{
|
||||
if (current_screen != csPlaylistEditor
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& current_screen != csTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
myPlaylist->Main()->Hide(); // hack, should be myScreen, but it doesn't always have 100% width
|
||||
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
Refresh();
|
||||
|
||||
myScreen = this;
|
||||
current_screen = csPlaylistEditor;
|
||||
|
||||
UpdateSongList(Content);
|
||||
}
|
||||
CLEAR_FIND_HISTORY;
|
||||
myScreen = this;
|
||||
myPlaylist->Main()->Hide(); // hack, should be myScreen, but it doesn't always have 100% width
|
||||
redraw_header = 1;
|
||||
Refresh();
|
||||
UpdateSongList(Content);
|
||||
}
|
||||
|
||||
void PlaylistEditor::Update()
|
||||
@@ -271,3 +262,19 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
|
||||
w->Scroll(wDown);
|
||||
}
|
||||
|
||||
void PlaylistEditor::SpacePressed()
|
||||
{
|
||||
if (Config.space_selects && w == Content)
|
||||
{
|
||||
Select(Content);
|
||||
w->Scroll(wDown);
|
||||
return;
|
||||
}
|
||||
AddToPlaylist(0);
|
||||
}
|
||||
|
||||
MPD::Song *PlaylistEditor::CurrentSong()
|
||||
{
|
||||
return w == Content && !Content->Empty() ? &Content->Current() : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@ class PlaylistEditor : public Screen<Window>
|
||||
virtual void Update();
|
||||
|
||||
virtual void EnterPressed() { AddToPlaylist(1); }
|
||||
virtual void SpacePressed() { AddToPlaylist(0); }
|
||||
virtual void SpacePressed();
|
||||
|
||||
virtual MPD::Song *CurrentSong();
|
||||
|
||||
void NextColumn();
|
||||
void PrevColumn();
|
||||
|
||||
30
src/screen.cpp
Normal file
30
src/screen.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008-2009 by Andrzej Rybczak *
|
||||
* electricityispower@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "screen.h"
|
||||
|
||||
void BasicScreen::Select(List *l)
|
||||
{
|
||||
if (l->Empty())
|
||||
return;
|
||||
size_t i = l->Choice();
|
||||
l->Select(i, !l->isSelected(i));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#define _SCREEN_H
|
||||
|
||||
#include "window.h"
|
||||
#include "menu.h"
|
||||
#include "mpdpp.h"
|
||||
|
||||
class BasicScreen
|
||||
{
|
||||
@@ -42,6 +44,11 @@ class BasicScreen
|
||||
|
||||
virtual void EnterPressed() { }
|
||||
virtual void SpacePressed() { }
|
||||
|
||||
virtual MPD::Song *CurrentSong() { return 0; }
|
||||
|
||||
protected:
|
||||
void Select(List *);
|
||||
};
|
||||
|
||||
template <class WindowType> class Screen : public BasicScreen
|
||||
|
||||
@@ -59,25 +59,20 @@ void SearchEngine::Resize()
|
||||
|
||||
void SearchEngine::SwitchTo()
|
||||
{
|
||||
if (current_screen != csSearcher
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& current_screen != csTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
CLEAR_FIND_HISTORY;
|
||||
if (w->Empty())
|
||||
Prepare();
|
||||
myScreen = this;
|
||||
w->Hide();
|
||||
redraw_header = 1;
|
||||
|
||||
if (!w->Back().first)
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
if (w->Empty())
|
||||
Prepare();
|
||||
myScreen = this;
|
||||
w->Hide();
|
||||
current_screen = csSearcher;
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
if (!w->Back().first)
|
||||
{
|
||||
w->WriteXY(0, 0, 0, "Updating list...");
|
||||
UpdateFoundList();
|
||||
}
|
||||
w->WriteXY(0, 0, 0, "Updating list...");
|
||||
UpdateFoundList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,6 +249,13 @@ void SearchEngine::SpacePressed()
|
||||
if (w->Current().first)
|
||||
return;
|
||||
|
||||
if (Config.space_selects)
|
||||
{
|
||||
Select(w);
|
||||
w->Scroll(wDown);
|
||||
return;
|
||||
}
|
||||
|
||||
block_item_list_update = 1;
|
||||
if (Config.ncmpc_like_songs_adding && w->isBold())
|
||||
{
|
||||
@@ -283,6 +285,11 @@ void SearchEngine::SpacePressed()
|
||||
w->Scroll(wDown);
|
||||
}
|
||||
|
||||
MPD::Song *SearchEngine::CurrentSong()
|
||||
{
|
||||
return !w->Empty() ? w->Current().second : 0;
|
||||
}
|
||||
|
||||
void SearchEngine::UpdateFoundList()
|
||||
{
|
||||
bool bold = 0;
|
||||
|
||||
@@ -49,6 +49,8 @@ class SearchEngine : public Screen < Menu< std::pair<Buffer *, MPD::Song *> > >
|
||||
virtual void EnterPressed();
|
||||
virtual void SpacePressed();
|
||||
|
||||
virtual MPD::Song *CurrentSong();
|
||||
|
||||
void UpdateFoundList();
|
||||
|
||||
static size_t StaticOptions;
|
||||
|
||||
@@ -88,7 +88,7 @@ void TraceMpdStatus()
|
||||
Mpd->UpdateStatus();
|
||||
time_t now = time(NULL);
|
||||
|
||||
if (current_screen == csPlaylist && now == timer+Config.playlist_disable_highlight_delay)
|
||||
if (myScreen == myPlaylist && now == timer+Config.playlist_disable_highlight_delay)
|
||||
myPlaylist->Main()->Highlighting(!Config.playlist_disable_highlight_delay);
|
||||
|
||||
if (lock_statusbar_delay > 0)
|
||||
@@ -167,7 +167,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
{
|
||||
if (playlist_length < myPlaylist->Main()->Size())
|
||||
{
|
||||
myPlaylist->Main()->Clear(playlist_length < myPlaylist->Main()->GetHeight() && current_screen == csPlaylist);
|
||||
myPlaylist->Main()->Clear(playlist_length < myPlaylist->Main()->GetHeight() && myScreen == myPlaylist);
|
||||
Mpd->GetPlaylistChanges(-1, list);
|
||||
}
|
||||
else
|
||||
@@ -191,7 +191,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
(*it)->NullMe();
|
||||
}
|
||||
|
||||
if (current_screen == csPlaylist)
|
||||
if (myScreen == myPlaylist)
|
||||
{
|
||||
if (!playlist_length || myPlaylist->Main()->Size() < myPlaylist->Main()->GetHeight())
|
||||
myPlaylist->Main()->Window::Clear();
|
||||
@@ -215,7 +215,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
FreeSongList(list);
|
||||
}
|
||||
|
||||
if (current_screen == csPlaylist)
|
||||
if (myScreen == myPlaylist)
|
||||
redraw_header = 1;
|
||||
|
||||
if (myPlaylist->Main()->Empty())
|
||||
@@ -226,19 +226,19 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
|
||||
if (!block_item_list_update)
|
||||
{
|
||||
if (current_screen == csBrowser)
|
||||
if (myScreen == myBrowser)
|
||||
{
|
||||
myBrowser->UpdateItemList();
|
||||
}
|
||||
else if (current_screen == csSearcher)
|
||||
else if (myScreen == mySearcher)
|
||||
{
|
||||
mySearcher->UpdateFoundList();
|
||||
}
|
||||
else if (current_screen == csLibrary)
|
||||
else if (myScreen == myLibrary)
|
||||
{
|
||||
UpdateSongList(myLibrary->Songs);
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
else if (myScreen == myPlaylistEditor)
|
||||
{
|
||||
UpdateSongList(myPlaylistEditor->Content);
|
||||
}
|
||||
@@ -317,7 +317,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
if (!Mpd->GetElapsedTime())
|
||||
mvwhline(wFooter->Raw(), 0, 0, 0, wFooter->GetWidth());
|
||||
|
||||
if (Config.now_playing_lyrics && !Config.repeat_one_mode && current_screen == csLyrics && prev_screen == csPlaylist)
|
||||
if (Config.now_playing_lyrics && !Config.repeat_one_mode && myScreen == myLyrics && myOldScreen == myPlaylist)
|
||||
Lyrics::Reload = 1;
|
||||
}
|
||||
playing_song_scroll_begin = 0;
|
||||
@@ -455,7 +455,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
wHeader->SetColor(Config.header_color);
|
||||
wHeader->Refresh();
|
||||
}
|
||||
if (current_screen == csPlaylist)
|
||||
if (myScreen == myPlaylist)
|
||||
myPlaylist->Main()->Refresh();
|
||||
wFooter->Bold(0);
|
||||
wFooter->GotoXY(sx, sy);
|
||||
|
||||
@@ -60,31 +60,6 @@ void TinyTagEditor::Resize()
|
||||
|
||||
void TinyTagEditor::SwitchTo()
|
||||
{
|
||||
List *mList = reinterpret_cast<Menu<Song> *>(((Screen<Window> *)myScreen)->Main());
|
||||
size_t id = mList->Choice();
|
||||
switch (current_screen)
|
||||
{
|
||||
case csPlaylist:
|
||||
itsEdited = myPlaylist->Main()->at(id);
|
||||
break;
|
||||
case csBrowser:
|
||||
itsEdited = *myBrowser->Main()->at(id).song;
|
||||
break;
|
||||
case csSearcher:
|
||||
itsEdited = *mySearcher->Main()->at(id).second;
|
||||
break;
|
||||
case csLibrary:
|
||||
itsEdited = myLibrary->Songs->at(id);
|
||||
break;
|
||||
case csPlaylistEditor:
|
||||
itsEdited = myPlaylistEditor->Content->at(id);
|
||||
break;
|
||||
case csTagEditor:
|
||||
itsEdited = myTagEditor->Tags->at(id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (itsEdited.IsStream())
|
||||
{
|
||||
ShowMessage("Cannot edit streams!");
|
||||
@@ -93,8 +68,6 @@ void TinyTagEditor::SwitchTo()
|
||||
{
|
||||
myOldScreen = myScreen;
|
||||
myScreen = this;
|
||||
prev_screen = current_screen;
|
||||
current_screen = csTinyTagEditor;
|
||||
redraw_header = 1;
|
||||
}
|
||||
else
|
||||
@@ -216,7 +189,7 @@ void TinyTagEditor::EnterPressed()
|
||||
if (s.IsFromDB())
|
||||
{
|
||||
Mpd->UpdateDirectory(locale_to_utf_cpy(s.GetDirectory()));
|
||||
if (prev_screen == csSearcher)
|
||||
if (myOldScreen == mySearcher)
|
||||
*mySearcher->Main()->Current().second = s;
|
||||
}
|
||||
else
|
||||
@@ -234,17 +207,16 @@ void TinyTagEditor::EnterPressed()
|
||||
{
|
||||
w->Clear();
|
||||
myScreen = myOldScreen;
|
||||
current_screen = prev_screen;
|
||||
redraw_header = 1;
|
||||
if (current_screen == csLibrary)
|
||||
if (myScreen == myLibrary)
|
||||
{
|
||||
myLibrary->Refresh();
|
||||
}
|
||||
else if (current_screen == csPlaylistEditor)
|
||||
else if (myScreen == myPlaylistEditor)
|
||||
{
|
||||
myPlaylistEditor->Refresh();
|
||||
}
|
||||
else if (current_screen == csTagEditor)
|
||||
else if (myScreen == myTagEditor)
|
||||
{
|
||||
myTagEditor->Refresh();
|
||||
}
|
||||
@@ -254,6 +226,14 @@ void TinyTagEditor::EnterPressed()
|
||||
UnlockStatusbar();
|
||||
}
|
||||
|
||||
bool TinyTagEditor::SetEdited(MPD::Song *s)
|
||||
{
|
||||
if (!s)
|
||||
return false;
|
||||
itsEdited = *s;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TinyTagEditor::GetTags()
|
||||
{
|
||||
Song &s = itsEdited;
|
||||
@@ -316,13 +296,6 @@ bool TinyTagEditor::GetTags()
|
||||
return true;
|
||||
}
|
||||
|
||||
//Window *Global::wTagEditorActiveCol;
|
||||
/*Menu<string_pair> *Global::Albums;
|
||||
Menu<string_pair> *Global::Dirs;
|
||||
Menu<string_pair> *Global::LeftColumn;
|
||||
Menu<string> *Global::TagTypes;
|
||||
Menu<Song> *Global::Tags;*/
|
||||
|
||||
TagEditor *myTagEditor = new TagEditor;
|
||||
|
||||
const size_t TagEditor::MiddleColumnWidth = 26;
|
||||
@@ -388,42 +361,38 @@ std::string TagEditor::Title()
|
||||
|
||||
void TagEditor::SwitchTo()
|
||||
{
|
||||
if (current_screen != csTagEditor && current_screen != csTinyTagEditor)
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
CLEAR_FIND_HISTORY;
|
||||
|
||||
myScreen = this;
|
||||
myPlaylist->Main()->Hide(); // hack, should be myScreen, but it doesn't always have 100% width
|
||||
redraw_header = 1;
|
||||
Refresh();
|
||||
|
||||
if (TagTypes->Empty())
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
|
||||
myPlaylist->Main()->Hide(); // hack, should be myScreen, but it doesn't always have 100% width
|
||||
|
||||
// redraw_screen = 1;
|
||||
redraw_header = 1;
|
||||
TagEditor::Refresh();
|
||||
|
||||
if (TagTypes->Empty())
|
||||
{
|
||||
TagTypes->AddOption("Title");
|
||||
TagTypes->AddOption("Artist");
|
||||
TagTypes->AddOption("Album");
|
||||
TagTypes->AddOption("Year");
|
||||
TagTypes->AddOption("Track");
|
||||
TagTypes->AddOption("Genre");
|
||||
TagTypes->AddOption("Composer");
|
||||
TagTypes->AddOption("Performer");
|
||||
TagTypes->AddOption("Disc");
|
||||
TagTypes->AddOption("Comment");
|
||||
TagTypes->AddSeparator();
|
||||
TagTypes->AddOption("Filename");
|
||||
TagTypes->AddSeparator();
|
||||
TagTypes->AddOption("Options", 1, 1, 0);
|
||||
TagTypes->AddSeparator();
|
||||
TagTypes->AddOption("Reset");
|
||||
TagTypes->AddOption("Save");
|
||||
TagTypes->AddSeparator();
|
||||
TagTypes->AddOption("Capitalize First Letters");
|
||||
TagTypes->AddOption("lower all letters");
|
||||
}
|
||||
|
||||
myScreen = this;
|
||||
current_screen = csTagEditor;
|
||||
TagTypes->AddOption("Title");
|
||||
TagTypes->AddOption("Artist");
|
||||
TagTypes->AddOption("Album");
|
||||
TagTypes->AddOption("Year");
|
||||
TagTypes->AddOption("Track");
|
||||
TagTypes->AddOption("Genre");
|
||||
TagTypes->AddOption("Composer");
|
||||
TagTypes->AddOption("Performer");
|
||||
TagTypes->AddOption("Disc");
|
||||
TagTypes->AddOption("Comment");
|
||||
TagTypes->AddSeparator();
|
||||
TagTypes->AddOption("Filename");
|
||||
TagTypes->AddSeparator();
|
||||
TagTypes->AddOption("Options", 1, 1, 0);
|
||||
TagTypes->AddSeparator();
|
||||
TagTypes->AddOption("Reset");
|
||||
TagTypes->AddOption("Save");
|
||||
TagTypes->AddSeparator();
|
||||
TagTypes->AddOption("Capitalize First Letters");
|
||||
TagTypes->AddOption("lower all letters");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,10 +613,8 @@ void TagEditor::EnterPressed()
|
||||
{
|
||||
if (w == TagTypes)
|
||||
{
|
||||
current_screen = csOther;
|
||||
DealWithFilenames(list);
|
||||
current_screen = csTagEditor;
|
||||
TagEditor::Refresh();
|
||||
Refresh();
|
||||
}
|
||||
else if (w == Tags)
|
||||
{
|
||||
@@ -743,6 +710,12 @@ void TagEditor::EnterPressed()
|
||||
|
||||
void TagEditor::SpacePressed()
|
||||
{
|
||||
if (w == Tags)
|
||||
{
|
||||
Select(Tags);
|
||||
w->Scroll(wDown);
|
||||
return;
|
||||
}
|
||||
if (w != LeftColumn)
|
||||
return;
|
||||
|
||||
@@ -753,6 +726,11 @@ void TagEditor::SpacePressed()
|
||||
Tags->Clear(0);
|
||||
}
|
||||
|
||||
MPD::Song *TagEditor::CurrentSong()
|
||||
{
|
||||
return w == Tags && !Tags->Empty() ? &Tags->Current() : 0;
|
||||
}
|
||||
|
||||
void TagEditor::NextColumn()
|
||||
{
|
||||
CLEAR_FIND_HISTORY;
|
||||
|
||||
@@ -44,6 +44,8 @@ class TinyTagEditor : public Screen< Menu<Buffer> >
|
||||
|
||||
virtual void EnterPressed();
|
||||
|
||||
bool SetEdited(MPD::Song *);
|
||||
|
||||
protected:
|
||||
bool GetTags();
|
||||
MPD::Song itsEdited;
|
||||
@@ -66,6 +68,8 @@ class TagEditor : public Screen<Window>
|
||||
virtual void EnterPressed();
|
||||
virtual void SpacePressed();
|
||||
|
||||
virtual MPD::Song *CurrentSong();
|
||||
|
||||
void NextColumn();
|
||||
void PrevColumn();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user