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