1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-19 05:27:57 +00:00
rolens/internal/ui/dialogs.go

31 lines
740 B
Go
Raw Normal View History

2023-02-21 16:47:21 +00:00
package ui
import "github.com/ncruces/zenity"
func (u *UI) OpenDirectory(id, title string) string {
if title == "" {
title = "Choose a directory"
}
2023-02-21 19:11:40 +00:00
dir, err := zenity.SelectFile(zenity.Title(title), zenity.Directory(), zenity.Modal())
2023-02-21 16:47:21 +00:00
if err != nil && err != zenity.ErrCanceled {
zenity.Error("Error while opening directory", zenity.ErrorIcon)
}
return dir
}
func (u *UI) EnterText(title, info, defaultEntry string) string {
2023-02-21 19:11:40 +00:00
input, err := zenity.Entry(info, zenity.Title(title), zenity.EntryText(defaultEntry), zenity.Modal())
2023-02-21 16:47:21 +00:00
if err == zenity.ErrCanceled {
return ""
} else if err != nil {
zenity.Error(err.Error(), zenity.Title("Encountered an error!"), zenity.ErrorIcon)
return ""
} else {
return input
}
}