Skip to content

Commit

Permalink
FileListPage: move another function into the class
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 11, 2024
1 parent 2494c38 commit aad767a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/FileListPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -116,34 +116,34 @@ FileListPage::LoadPlaylist(struct mpdclient &c,
return true;
}

static bool
enqueue_and_play(struct mpdclient *c, FileListEntry *entry)
inline bool
FileListPage::EnqueueAndPlay(struct mpdclient &c, FileListEntry &entry) noexcept
{
auto *connection = c->GetConnection();
auto *connection = c.GetConnection();
if (connection == nullptr)
return false;

const auto *song = mpd_entity_get_song(entry->entity);
const auto *song = mpd_entity_get_song(entry.entity);
assert(song != nullptr);

int id;

#ifndef NCMPC_MINI
if (!(entry->flags & HIGHLIGHT))
if (!(entry.flags & HIGHLIGHT))
id = -1;
else
#endif
id = c->playlist.FindIdByUri(mpd_song_get_uri(song));
id = c.playlist.FindIdByUri(mpd_song_get_uri(song));

if (id < 0) {
id = mpd_run_add_id(connection, mpd_song_get_uri(song));
if (id < 0) {
c->HandleError();
c.HandleError();
return false;
}

#ifndef NCMPC_MINI
entry->flags |= HIGHLIGHT;
entry.flags |= HIGHLIGHT;
#endif

char buf[BUFSIZE];
Expand All @@ -152,7 +152,7 @@ enqueue_and_play(struct mpdclient *c, FileListEntry *entry)
}

if (!mpd_run_play_id(connection, id)) {
c->HandleError();
c.HandleError();
return false;
}

Expand Down Expand Up @@ -217,7 +217,7 @@ FileListPage::HandleEnter(struct mpdclient &c)
if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_PLAYLIST)
return LoadPlaylist(c, *mpd_entity_get_playlist(entity));
else if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG)
return enqueue_and_play(&c, entry);
return EnqueueAndPlay(c, *entry);
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/FileListPage.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected:
virtual bool HandleEnter(struct mpdclient &c);

private:
bool EnqueueAndPlay(struct mpdclient &c, FileListEntry &entry) noexcept;
bool LoadPlaylist(struct mpdclient &c,
const struct mpd_playlist &playlist) noexcept;
bool HandleSelectEntry(struct mpdclient &c, FileListEntry &entry,
Expand Down

0 comments on commit aad767a

Please sign in to comment.