Icon options.
This commit is contained in:
parent
a1e9ae327f
commit
6e3393bd4f
5 changed files with 11 additions and 11 deletions
|
@ -376,7 +376,7 @@ func loadFlags() []zenity.Option {
|
||||||
case "":
|
case "":
|
||||||
ico = zenity.NoIcon
|
ico = zenity.NoIcon
|
||||||
}
|
}
|
||||||
opts = append(opts, zenity.Icon(ico))
|
opts = append(opts, ico)
|
||||||
|
|
||||||
// Message options
|
// Message options
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ func notify(opts ...zenity.Option) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
zenutil.Command = false
|
zenutil.Command = false
|
||||||
var icon zenity.DialogIcon
|
icon := zenity.InfoIcon
|
||||||
for scanner := bufio.NewScanner(os.Stdin); scanner.Scan(); {
|
for scanner := bufio.NewScanner(os.Stdin); scanner.Scan(); {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
var cmd, msg string
|
var cmd, msg string
|
||||||
|
@ -43,7 +43,7 @@ func notify(opts ...zenity.Option) error {
|
||||||
icon = zenity.NoIcon
|
icon = zenity.NoIcon
|
||||||
}
|
}
|
||||||
case "message", "tooltip":
|
case "message", "tooltip":
|
||||||
opts := []zenity.Option{zenity.Icon(icon)}
|
opts := []zenity.Option{icon}
|
||||||
if n := strings.IndexByte(msg, '\n'); n >= 0 {
|
if n := strings.IndexByte(msg, '\n'); n >= 0 {
|
||||||
opts = append(opts, zenity.Title(msg[:n]))
|
opts = append(opts, zenity.Title(msg[:n]))
|
||||||
msg = msg[n+1:]
|
msg = msg[n+1:]
|
||||||
|
|
|
@ -14,28 +14,28 @@ import (
|
||||||
func ExampleError() {
|
func ExampleError() {
|
||||||
zenity.Error("An error has occurred.",
|
zenity.Error("An error has occurred.",
|
||||||
zenity.Title("Error"),
|
zenity.Title("Error"),
|
||||||
zenity.Icon(zenity.ErrorIcon))
|
zenity.ErrorIcon)
|
||||||
// Output:
|
// Output:
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleInfo() {
|
func ExampleInfo() {
|
||||||
zenity.Info("All updates are complete.",
|
zenity.Info("All updates are complete.",
|
||||||
zenity.Title("Information"),
|
zenity.Title("Information"),
|
||||||
zenity.Icon(zenity.InfoIcon))
|
zenity.InfoIcon)
|
||||||
// Output:
|
// Output:
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleWarning() {
|
func ExampleWarning() {
|
||||||
zenity.Warning("Are you sure you want to proceed?",
|
zenity.Warning("Are you sure you want to proceed?",
|
||||||
zenity.Title("Warning"),
|
zenity.Title("Warning"),
|
||||||
zenity.Icon(zenity.WarningIcon))
|
zenity.WarningIcon)
|
||||||
// Output:
|
// Output:
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleQuestion() {
|
func ExampleQuestion() {
|
||||||
zenity.Question("Are you sure you want to proceed?",
|
zenity.Question("Are you sure you want to proceed?",
|
||||||
zenity.Title("Question"),
|
zenity.Title("Question"),
|
||||||
zenity.Icon(zenity.QuestionIcon))
|
zenity.QuestionIcon)
|
||||||
// Output:
|
// Output:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
func ExampleNotify() {
|
func ExampleNotify() {
|
||||||
zenity.Notify("There are system updates necessary!",
|
zenity.Notify("There are system updates necessary!",
|
||||||
zenity.Title("Warning"),
|
zenity.Title("Warning"),
|
||||||
zenity.Icon(zenity.InfoIcon))
|
zenity.InfoIcon)
|
||||||
// Output:
|
// Output:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,8 @@ func ExtraButton(extra string) Option {
|
||||||
// DialogIcon is the enumeration for dialog icons.
|
// DialogIcon is the enumeration for dialog icons.
|
||||||
type DialogIcon int
|
type DialogIcon int
|
||||||
|
|
||||||
|
func (i DialogIcon) apply(o *options) { o.icon = i }
|
||||||
|
|
||||||
// The stock dialog icons.
|
// The stock dialog icons.
|
||||||
const (
|
const (
|
||||||
ErrorIcon DialogIcon = iota + 1
|
ErrorIcon DialogIcon = iota + 1
|
||||||
|
@ -139,9 +141,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Icon returns an Option to set the dialog icon.
|
// Icon returns an Option to set the dialog icon.
|
||||||
func Icon(icon DialogIcon) Option {
|
func Icon(icon DialogIcon) Option { return icon }
|
||||||
return funcOption(func(o *options) { o.icon = icon })
|
|
||||||
}
|
|
||||||
|
|
||||||
// Context returns an Option to set a Context that can dismiss the dialog.
|
// Context returns an Option to set a Context that can dismiss the dialog.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue