Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .SetIcon() to custom dialogs #5386

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dialog/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func (d *dialog) setButtons(buttons fyne.CanvasObject) {
d.win.Refresh()
}

func (d *dialog) setIcon(icon fyne.Resource) {
d.win.Content.(*fyne.Container).Objects[0] = &canvas.Image{Resource: icon}
lostdusty marked this conversation as resolved.
Show resolved Hide resolved
d.win.Refresh()
}

// The method .create() needs to be called before the dialog can be shown.
func newDialog(title, message string, icon fyne.Resource, callback func(bool), parent fyne.Window) *dialog {
d := &dialog{content: newCenterWrappedLabel(message), title: title, icon: icon, parent: parent}
Expand Down
8 changes: 8 additions & 0 deletions dialog/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func (d *CustomDialog) SetButtons(buttons []fyne.CanvasObject) {
d.setButtons(container.NewGridWithRows(1, buttons...))
}

// SetIcon sets an icon to be shown on the right of the dialog, like the NewInformation dialog.
lostdusty marked this conversation as resolved.
Show resolved Hide resolved
// Passing a nil resource will remove the icon from the dialog.
//
// Since: 2.6
func (d *CustomDialog) SetIcon(icon fyne.Resource) {
d.setIcon(icon)
}

// ShowCustomWithoutButtons shows a dialog, without buttons, over the specified application
// using custom content.
// The MinSize() of the CanvasObject passed will be used to set the size of the window.
Expand Down
Loading