mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-25 13:48:49 +08:00
wrap timedPopup for convenience
This commit is contained in:
parent
1fb393a8cf
commit
4ebcfc6951
@ -201,7 +201,7 @@ func (c Command) defineCommands() {
|
||||
msg = "off"
|
||||
}
|
||||
|
||||
timedPopup("Loop", msg, getPopupTimeout(), 30, 5)
|
||||
defaultTimedPopup("Loop", msg)
|
||||
})
|
||||
|
||||
c.define("shuffle_queue", func() {
|
||||
|
@ -87,7 +87,7 @@ func (p *Player) run(currSong *AudioFile) error {
|
||||
popupMessage := fmt.Sprintf("%s\n\n[ %s ]",
|
||||
currSong.name, fmtDuration(p.length))
|
||||
|
||||
timedPopup(" Current Song ", popupMessage, getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup(" Current Song ", popupMessage)
|
||||
|
||||
done := make(chan bool, 1)
|
||||
p.done = done
|
||||
|
29
playlist.go
29
playlist.go
@ -183,15 +183,14 @@ func (p *Playlist) deleteSong(audioFile *AudioFile) (err error) {
|
||||
|
||||
if err != nil {
|
||||
|
||||
timedPopup(" Error ", "Unable to delete "+audioFile.name,
|
||||
getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup(" Error ", "Unable to delete "+audioFile.name)
|
||||
|
||||
err = tracerr.Wrap(err)
|
||||
|
||||
} else {
|
||||
|
||||
timedPopup(" Success ", audioFile.name+"\nhas been deleted successfully",
|
||||
getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup(" Success ",
|
||||
audioFile.name+"\nhas been deleted successfully")
|
||||
|
||||
p.refresh()
|
||||
}
|
||||
@ -224,19 +223,17 @@ func (p *Playlist) deletePlaylist(audioFile *AudioFile) (err error) {
|
||||
|
||||
if err != nil {
|
||||
|
||||
timedPopup(
|
||||
defaultTimedPopup(
|
||||
" Error ",
|
||||
"Unable to delete dir "+selectedDir.name,
|
||||
getPopupTimeout(), 0, 0)
|
||||
"Unable to delete dir "+selectedDir.name)
|
||||
|
||||
err = tracerr.Wrap(err)
|
||||
|
||||
} else {
|
||||
|
||||
timedPopup(
|
||||
defaultTimedPopup(
|
||||
" Success ",
|
||||
selectedDir.name+"\nhas been deleted successfully",
|
||||
getPopupTimeout(), 0, 0)
|
||||
selectedDir.name+"\nhas been deleted successfully")
|
||||
|
||||
p.refresh()
|
||||
}
|
||||
@ -577,8 +574,7 @@ func ytdl(url string, selPlaylist *tview.TreeNode) error {
|
||||
_, err := exec.LookPath("youtube-dl")
|
||||
|
||||
if err != nil {
|
||||
timedPopup(" Error ", "youtube-dl is not in your $PATH",
|
||||
getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup(" Error ", "youtube-dl is not in your $PATH")
|
||||
|
||||
return tracerr.Wrap(err)
|
||||
}
|
||||
@ -588,7 +584,7 @@ func ytdl(url string, selPlaylist *tview.TreeNode) error {
|
||||
selAudioFile := selPlaylist.GetReference().(*AudioFile)
|
||||
selPlaylistName := selAudioFile.name
|
||||
|
||||
timedPopup(" Ytdl ", "Downloading", getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup(" Ytdl ", "Downloading")
|
||||
|
||||
// specify the output path for ytdl
|
||||
outputDir := fmt.Sprintf(
|
||||
@ -619,7 +615,7 @@ func ytdl(url string, selPlaylist *tview.TreeNode) error {
|
||||
gomu.playlist.done <- struct{}{}
|
||||
|
||||
if err != nil {
|
||||
timedPopup(" Error ", "Error running youtube-dl", getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup(" Error ", "Error running youtube-dl")
|
||||
return tracerr.Wrap(err)
|
||||
}
|
||||
|
||||
@ -639,10 +635,7 @@ func ytdl(url string, selPlaylist *tview.TreeNode) error {
|
||||
downloadFinishedMessage := fmt.Sprintf("Finished downloading\n%s",
|
||||
getName(audioPath))
|
||||
|
||||
timedPopup(
|
||||
" Ytdl ",
|
||||
downloadFinishedMessage,
|
||||
getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup(" Ytdl ", downloadFinishedMessage)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
12
popup.go
12
popup.go
@ -171,6 +171,11 @@ func timedPopup(
|
||||
}()
|
||||
}
|
||||
|
||||
// Wrapper for timed popup
|
||||
func defaultTimedPopup(title, description string) {
|
||||
timedPopup(title, description, getPopupTimeout(), 0, 0)
|
||||
}
|
||||
|
||||
// Shows popup for the current volume
|
||||
func volumePopup(volume float64) {
|
||||
|
||||
@ -187,7 +192,7 @@ func volumePopup(volume float64) {
|
||||
maxVol,
|
||||
)
|
||||
|
||||
timedPopup(" Volume ", progress, getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup(" Volume ", progress)
|
||||
}
|
||||
|
||||
// Shows a list of keybind. The upper list is the local keybindings to specific
|
||||
@ -276,8 +281,7 @@ func downloadMusicPopup(selPlaylist *tview.TreeNode) {
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
timedPopup("Invalid url", "Invalid youtube url was given",
|
||||
getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup("Invalid url", "Invalid youtube url was given")
|
||||
}
|
||||
|
||||
gomu.pages.RemovePage("download-input-popup")
|
||||
@ -477,7 +481,7 @@ func renamePopup(node *AudioFile) {
|
||||
}
|
||||
err := gomu.playlist.rename(newName)
|
||||
if err != nil {
|
||||
timedPopup(" Error ", err.Error(), getPopupTimeout(), 0, 0)
|
||||
defaultTimedPopup(" Error ", err.Error())
|
||||
logError(err)
|
||||
}
|
||||
gomu.pages.RemovePage(popupId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user