diff --git a/src/display.cpp b/src/display.cpp index 0838dfba..df2ef7fb 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -459,8 +459,7 @@ void Display::Items(const MPD::Item &item, void *, Menu *menu) *menu << "[..]"; return; } - size_t slash = item.name.rfind("/"); - *menu << "[" << (slash != string::npos ? item.name.substr(slash+1) : item.name) << "]"; + *menu << "[" << ExtractTopDirectory(item.name) << "]"; return; } case MPD::itSong: diff --git a/src/helpers.cpp b/src/helpers.cpp index 995cd194..e62d4542 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -41,12 +41,6 @@ namespace if (the_pos == 0 && the_pos != string::npos) s = s.substr(4); } - - inline string extract_top_directory(const string &s) - { - size_t slash = s.rfind("/"); - return slash != string::npos ? s.substr(++slash) : s; - } } bool ConnectToMPD() @@ -207,7 +201,7 @@ bool CaseInsensitiveSorting::operator()(const Item &a, const Item &b) switch (a.type) { case itDirectory: - return operator()(extract_top_directory(a.name), extract_top_directory(b.name)); + return operator()(ExtractTopDirectory(a.name), ExtractTopDirectory(b.name)); case itPlaylist: return operator()(a.name, b.name); case itSong: @@ -287,6 +281,12 @@ string GetLineValue(string &line, char a, char b, bool once) return ""; } +std::string ExtractTopDirectory(const std::string &s) +{ + size_t slash = s.rfind("/"); + return slash != string::npos ? s.substr(++slash) : s; +} + const Buffer &ShowTag(const string &tag) { static Buffer result; diff --git a/src/helpers.h b/src/helpers.h index 4014ec27..f829e5c5 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -46,6 +46,8 @@ std::string FindSharedDir(const std::string &, const std::string &); std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0); +std::string ExtractTopDirectory(const std::string &); + const Buffer &ShowTag(const std::string &); const std::basic_string &Scroller(const std::string &, size_t, size_t &); diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 1457e43d..48c240ac 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1212,8 +1212,9 @@ int main(int argc, char *argv[]) continue; } - size_t dialog_width = COLS*0.8; - size_t dialog_height = LINES*0.6; + const size_t dialog_width = COLS*0.8; + const size_t dialog_height = LINES*0.6; + Menu *mDialog = new Menu((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); @@ -1397,7 +1398,7 @@ int main(int argc, char *argv[]) switch (myBrowser->Main()->at(i).type) { case itDirectory: - name = myBrowser->Main()->at(i).name; + name = ExtractTopDirectory(myBrowser->Main()->at(i).name); break; case itSong: name = myBrowser->Main()->at(i).song->toString(Config.song_list_format); diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index b812fdbc..167999b8 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -409,7 +409,7 @@ void TagEditor::Update() if (Config.albums_in_tag_editor) { std::map maplist; - *Albums << XY(0, 0) << "Fetching albums' list..."; + *Albums << XY(0, 0) << "Fetching albums' list..." << wrefresh; Mpd->GetAlbums("", list); for (TagList::const_iterator it = list.begin(); it != list.end(); it++) {