From 34794f4c7782def5125c54bdf4354675b820b0cb Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 18 May 2024 14:16:57 -0400 Subject: [PATCH] Make the dialog API more normal It was very nice but inconsistent with literally everything else, and never in my life have I seen someone else make a constructor that way. --- dialog.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dialog.go b/dialog.go index 1cd3928..e40c011 100644 --- a/dialog.go +++ b/dialog.go @@ -24,8 +24,8 @@ type clickable interface { OnClick (func ()) event.Cookie } -// New creates a new dialog window given a dialog kind. -func (kind DialogKind) New (parent tomo.Window, title, message string, options ...tomo.Object) (*Dialog, error) { +// NewDialog creates a new dialog window given a dialog kind. +func NewDialog (kind DialogKind, parent tomo.Window, title, message string, options ...tomo.Object) (*Dialog, error) { if title == "" { switch kind { case DialogInformation: title = "Information" @@ -73,8 +73,8 @@ func (kind DialogKind) New (parent tomo.Window, title, message string, options . return dialog, nil } -// NewOk creates a new dialog window with an OK option. -func (kind DialogKind) NewOk (parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) { +// NewDialogOk creates a new dialog window with an OK option. +func NewDialogOk (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) { okButton := NewButton("OK") okButton.SetIcon(theme.IconStatusOkay) okButton.OnClick(func () { @@ -82,11 +82,11 @@ func (kind DialogKind) NewOk (parent tomo.Window, title, message string, onOk fu }) okButton.SetFocused(true) - return kind.New(parent, title, message, okButton) + return NewDialog(kind, parent, title, message, okButton) } -// NewOkCancel creates a new dialog window with OK and Cancel options. -func (kind DialogKind) NewOkCancel (parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) { +// NewDialogOkCancel creates a new dialog window with OK and Cancel options. +func NewDialogOkCancel (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) { cancelButton := NewButton("Cancel") cancelButton.SetIcon(theme.IconStatusCancel) @@ -97,5 +97,5 @@ func (kind DialogKind) NewOkCancel (parent tomo.Window, title, message string, o }) okButton.SetFocused(true) - return kind.New(parent, title, message, cancelButton, okButton) + return NewDialog(kind, parent, title, message, cancelButton, okButton) }