mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[v3] Move dialogs out of application
This commit is contained in:
parent
4de5e1b9f1
commit
3827ca2d78
13 changed files with 183 additions and 183 deletions
|
|
@ -137,7 +137,7 @@ func main() {
|
|||
sizeMenu.Add("Get Current WebviewWindow Size").OnClick(func(ctx *application.Context) {
|
||||
currentWindow(func(w *application.WebviewWindow) {
|
||||
width, height := w.Size()
|
||||
app.InfoDialog().SetTitle("Current WebviewWindow Size").SetMessage("Width: " + strconv.Itoa(width) + " Height: " + strconv.Itoa(height)).Show()
|
||||
application.InfoDialog().SetTitle("Current WebviewWindow Size").SetMessage("Width: " + strconv.Itoa(width) + " Height: " + strconv.Itoa(height)).Show()
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ func main() {
|
|||
positionMenu.Add("Get Relative Position").OnClick(func(ctx *application.Context) {
|
||||
currentWindow(func(w *application.WebviewWindow) {
|
||||
x, y := w.RelativePosition()
|
||||
app.InfoDialog().SetTitle("Current WebviewWindow Relative Position").SetMessage("X: " + strconv.Itoa(x) + " Y: " + strconv.Itoa(y)).Show()
|
||||
application.InfoDialog().SetTitle("Current WebviewWindow Relative Position").SetMessage("X: " + strconv.Itoa(x) + " Y: " + strconv.Itoa(y)).Show()
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -235,32 +235,32 @@ func main() {
|
|||
stateMenu.Add("Get Primary Screen").OnClick(func(ctx *application.Context) {
|
||||
screen, err := app.GetPrimaryScreen()
|
||||
if err != nil {
|
||||
app.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
application.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("Screen: %+v", screen)
|
||||
app.InfoDialog().SetTitle("Primary Screen").SetMessage(msg).Show()
|
||||
application.InfoDialog().SetTitle("Primary Screen").SetMessage(msg).Show()
|
||||
})
|
||||
stateMenu.Add("Get Screens").OnClick(func(ctx *application.Context) {
|
||||
screens, err := app.GetScreens()
|
||||
if err != nil {
|
||||
app.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
application.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
return
|
||||
}
|
||||
for _, screen := range screens {
|
||||
msg := fmt.Sprintf("Screen: %+v", screen)
|
||||
app.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
application.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
}
|
||||
})
|
||||
stateMenu.Add("Get Screen for WebviewWindow").OnClick(func(ctx *application.Context) {
|
||||
currentWindow(func(w *application.WebviewWindow) {
|
||||
screen, err := w.GetScreen()
|
||||
if err != nil {
|
||||
app.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
application.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("Screen: %+v", screen)
|
||||
app.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
application.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
})
|
||||
})
|
||||
app.NewWebviewWindow()
|
||||
|
|
|
|||
|
|
@ -29,28 +29,28 @@ func main() {
|
|||
setClipboardMenu.Add("Set Text 'Hello'").OnClick(func(ctx *application.Context) {
|
||||
success := app.Clipboard().SetText("Hello")
|
||||
if !success {
|
||||
app.InfoDialog().SetMessage("Failed to set clipboard text").Show()
|
||||
application.InfoDialog().SetMessage("Failed to set clipboard text").Show()
|
||||
}
|
||||
})
|
||||
setClipboardMenu.Add("Set Text 'World'").OnClick(func(ctx *application.Context) {
|
||||
success := app.Clipboard().SetText("World")
|
||||
if !success {
|
||||
app.InfoDialog().SetMessage("Failed to set clipboard text").Show()
|
||||
application.InfoDialog().SetMessage("Failed to set clipboard text").Show()
|
||||
}
|
||||
})
|
||||
setClipboardMenu.Add("Set Text (current time)").OnClick(func(ctx *application.Context) {
|
||||
success := app.Clipboard().SetText(time.Now().String())
|
||||
if !success {
|
||||
app.InfoDialog().SetMessage("Failed to set clipboard text").Show()
|
||||
application.InfoDialog().SetMessage("Failed to set clipboard text").Show()
|
||||
}
|
||||
})
|
||||
getClipboardMenu := menu.AddSubmenu("Get Clipboard")
|
||||
getClipboardMenu.Add("Get Text").OnClick(func(ctx *application.Context) {
|
||||
result, ok := app.Clipboard().Text()
|
||||
if !ok {
|
||||
app.InfoDialog().SetMessage("Failed to get clipboard text").Show()
|
||||
application.InfoDialog().SetMessage("Failed to get clipboard text").Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("Got:\n\n" + result).Show()
|
||||
application.InfoDialog().SetMessage("Got:\n\n" + result).Show()
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -58,9 +58,9 @@ func main() {
|
|||
clearClipboardMenu.Add("Clear Text").OnClick(func(ctx *application.Context) {
|
||||
success := app.Clipboard().SetText("")
|
||||
if success {
|
||||
app.InfoDialog().SetMessage("Clipboard text cleared").Show()
|
||||
application.InfoDialog().SetMessage("Clipboard text cleared").Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("Clipboard text not cleared").Show()
|
||||
application.InfoDialog().SetMessage("Clipboard text not cleared").Show()
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -28,23 +28,23 @@ func main() {
|
|||
// Let's make a "Demo" menu
|
||||
infoMenu := menu.AddSubmenu("Info")
|
||||
infoMenu.Add("Info").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.InfoDialog()
|
||||
dialog := application.InfoDialog()
|
||||
dialog.SetTitle("Custom Title")
|
||||
dialog.SetMessage("This is a custom message")
|
||||
dialog.Show()
|
||||
})
|
||||
infoMenu.Add("Info (Title only)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.InfoDialog()
|
||||
dialog := application.InfoDialog()
|
||||
dialog.SetTitle("Custom Title")
|
||||
dialog.Show()
|
||||
})
|
||||
infoMenu.Add("Info (Message only)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.InfoDialog()
|
||||
dialog := application.InfoDialog()
|
||||
dialog.SetMessage("This is a custom message")
|
||||
dialog.Show()
|
||||
})
|
||||
infoMenu.Add("Info (Custom Icon)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.InfoDialog()
|
||||
dialog := application.InfoDialog()
|
||||
dialog.SetTitle("Custom Icon Example")
|
||||
dialog.SetMessage("Using a custom icon")
|
||||
dialog.SetIcon(icons.ApplicationDarkMode256)
|
||||
|
|
@ -56,14 +56,14 @@ func main() {
|
|||
|
||||
questionMenu := menu.AddSubmenu("Question")
|
||||
questionMenu.Add("Question (No default)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.QuestionDialog()
|
||||
dialog := application.QuestionDialog()
|
||||
dialog.SetMessage("No default button")
|
||||
dialog.AddButton("Yes")
|
||||
dialog.AddButton("No")
|
||||
dialog.Show()
|
||||
})
|
||||
questionMenu.Add("Question (Attached to Window)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.QuestionDialog()
|
||||
dialog := application.QuestionDialog()
|
||||
dialog.AttachToWindow(app.CurrentWindow())
|
||||
dialog.SetMessage("No default button")
|
||||
dialog.AddButton("Yes")
|
||||
|
|
@ -71,7 +71,7 @@ func main() {
|
|||
dialog.Show()
|
||||
})
|
||||
questionMenu.Add("Question (With Default)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.QuestionDialog()
|
||||
dialog := application.QuestionDialog()
|
||||
dialog.SetTitle("Quit")
|
||||
dialog.SetMessage("You have unsaved work. Are you sure you want to quit?")
|
||||
dialog.AddButton("Yes").OnClick(func() {
|
||||
|
|
@ -82,12 +82,12 @@ func main() {
|
|||
dialog.Show()
|
||||
})
|
||||
questionMenu.Add("Question (With Cancel)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.QuestionDialog().
|
||||
dialog := application.QuestionDialog().
|
||||
SetTitle("Update").
|
||||
SetMessage("The cancel button is selected when pressing escape")
|
||||
download := dialog.AddButton("📥 Download")
|
||||
download.OnClick(func() {
|
||||
app.InfoDialog().SetMessage("Downloading...").Show()
|
||||
application.InfoDialog().SetMessage("Downloading...").Show()
|
||||
})
|
||||
no := dialog.AddButton("Cancel")
|
||||
dialog.SetDefaultButton(download)
|
||||
|
|
@ -95,7 +95,7 @@ func main() {
|
|||
dialog.Show()
|
||||
})
|
||||
questionMenu.Add("Question (Custom Icon)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.QuestionDialog()
|
||||
dialog := application.QuestionDialog()
|
||||
dialog.SetTitle("Custom Icon Example")
|
||||
dialog.SetMessage("Using a custom icon")
|
||||
dialog.SetIcon(icons.WailsLogoWhiteTransparent)
|
||||
|
|
@ -106,23 +106,23 @@ func main() {
|
|||
|
||||
warningMenu := menu.AddSubmenu("Warning")
|
||||
warningMenu.Add("Warning").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.WarningDialog()
|
||||
dialog := application.WarningDialog()
|
||||
dialog.SetTitle("Custom Title")
|
||||
dialog.SetMessage("This is a custom message")
|
||||
dialog.Show()
|
||||
})
|
||||
warningMenu.Add("Warning (Title only)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.WarningDialog()
|
||||
dialog := application.WarningDialog()
|
||||
dialog.SetTitle("Custom Title")
|
||||
dialog.Show()
|
||||
})
|
||||
warningMenu.Add("Warning (Message only)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.WarningDialog()
|
||||
dialog := application.WarningDialog()
|
||||
dialog.SetMessage("This is a custom message")
|
||||
dialog.Show()
|
||||
})
|
||||
warningMenu.Add("Warning (Custom Icon)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.WarningDialog()
|
||||
dialog := application.WarningDialog()
|
||||
dialog.SetTitle("Custom Icon Example")
|
||||
dialog.SetMessage("Using a custom icon")
|
||||
dialog.SetIcon(icons.ApplicationLightMode256)
|
||||
|
|
@ -131,23 +131,23 @@ func main() {
|
|||
|
||||
errorMenu := menu.AddSubmenu("Error")
|
||||
errorMenu.Add("Error").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.ErrorDialog()
|
||||
dialog := application.ErrorDialog()
|
||||
dialog.SetTitle("Ooops")
|
||||
dialog.SetMessage("I accidentally the whole of Twitter")
|
||||
dialog.Show()
|
||||
})
|
||||
errorMenu.Add("Error (Title Only)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.ErrorDialog()
|
||||
dialog := application.ErrorDialog()
|
||||
dialog.SetTitle("Custom Title")
|
||||
dialog.Show()
|
||||
})
|
||||
errorMenu.Add("Error (Custom Message)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.ErrorDialog()
|
||||
dialog := application.ErrorDialog()
|
||||
dialog.SetMessage("This is a custom message")
|
||||
dialog.Show()
|
||||
})
|
||||
errorMenu.Add("Error (Custom Icon)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.ErrorDialog()
|
||||
dialog := application.ErrorDialog()
|
||||
dialog.SetTitle("Custom Icon Example")
|
||||
dialog.SetMessage("Using a custom icon")
|
||||
dialog.SetIcon(icons.WailsLogoWhite)
|
||||
|
|
@ -156,87 +156,87 @@ func main() {
|
|||
|
||||
openMenu := menu.AddSubmenu("Open")
|
||||
openMenu.Add("Open File").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.OpenFileDialog().
|
||||
result, _ := application.OpenFileDialog().
|
||||
CanChooseFiles(true).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("No file selected").Show()
|
||||
application.InfoDialog().SetMessage("No file selected").Show()
|
||||
}
|
||||
})
|
||||
openMenu.Add("Open File (Show Hidden Files)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.OpenFileDialog().
|
||||
result, _ := application.OpenFileDialog().
|
||||
CanChooseFiles(true).
|
||||
CanCreateDirectories(true).
|
||||
ShowHiddenFiles(true).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("No file selected").Show()
|
||||
application.InfoDialog().SetMessage("No file selected").Show()
|
||||
}
|
||||
})
|
||||
openMenu.Add("Open File (Attach to window)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.OpenFileDialog().
|
||||
result, _ := application.OpenFileDialog().
|
||||
CanChooseFiles(true).
|
||||
CanCreateDirectories(true).
|
||||
ShowHiddenFiles(true).
|
||||
AttachToWindow(app.CurrentWindow()).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("No file selected").Show()
|
||||
application.InfoDialog().SetMessage("No file selected").Show()
|
||||
}
|
||||
})
|
||||
openMenu.Add("Open Multiple Files (Show Hidden Files)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.OpenFileDialog().
|
||||
result, _ := application.OpenFileDialog().
|
||||
CanChooseFiles(true).
|
||||
CanCreateDirectories(true).
|
||||
ShowHiddenFiles(true).
|
||||
PromptForMultipleSelection()
|
||||
if len(result) > 0 {
|
||||
app.InfoDialog().SetMessage(strings.Join(result, ",")).Show()
|
||||
application.InfoDialog().SetMessage(strings.Join(result, ",")).Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("No file selected").Show()
|
||||
application.InfoDialog().SetMessage("No file selected").Show()
|
||||
}
|
||||
})
|
||||
openMenu.Add("Open Directory").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.OpenFileDialog().
|
||||
result, _ := application.OpenFileDialog().
|
||||
CanChooseDirectories(true).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("No directory selected").Show()
|
||||
application.InfoDialog().SetMessage("No directory selected").Show()
|
||||
}
|
||||
})
|
||||
openMenu.Add("Open Directory (Create Directories)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.OpenFileDialog().
|
||||
result, _ := application.OpenFileDialog().
|
||||
CanChooseDirectories(true).
|
||||
CanCreateDirectories(true).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("No directory selected").Show()
|
||||
application.InfoDialog().SetMessage("No directory selected").Show()
|
||||
}
|
||||
})
|
||||
openMenu.Add("Open Directory (Resolves Aliases)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.OpenFileDialog().
|
||||
result, _ := application.OpenFileDialog().
|
||||
CanChooseDirectories(true).
|
||||
CanCreateDirectories(true).
|
||||
ResolvesAliases(true).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("No directory selected").Show()
|
||||
application.InfoDialog().SetMessage("No directory selected").Show()
|
||||
}
|
||||
})
|
||||
openMenu.Add("Open File/Directory (Set Title)").OnClick(func(ctx *application.Context) {
|
||||
dialog := app.OpenFileDialog().
|
||||
dialog := application.OpenFileDialog().
|
||||
CanChooseDirectories(true).
|
||||
CanCreateDirectories(true).
|
||||
ResolvesAliases(true)
|
||||
|
|
@ -248,14 +248,14 @@ func main() {
|
|||
|
||||
result, _ := dialog.PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("No file/directory selected").Show()
|
||||
application.InfoDialog().SetMessage("No file/directory selected").Show()
|
||||
}
|
||||
})
|
||||
openMenu.Add("Open (Full Example)").OnClick(func(ctx *application.Context) {
|
||||
cwd, _ := os.Getwd()
|
||||
dialog := app.OpenFileDialog().
|
||||
dialog := application.OpenFileDialog().
|
||||
SetTitle("Select a file").
|
||||
SetMessage("Select a file to open").
|
||||
SetButtonText("Let's do this!").
|
||||
|
|
@ -277,46 +277,46 @@ func main() {
|
|||
|
||||
result, _ := dialog.PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
} else {
|
||||
app.InfoDialog().SetMessage("No file selected").Show()
|
||||
application.InfoDialog().SetMessage("No file selected").Show()
|
||||
}
|
||||
})
|
||||
|
||||
saveMenu := menu.AddSubmenu("Save")
|
||||
saveMenu.Add("Select File (Defaults)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.SaveFileDialog().
|
||||
result, _ := application.SaveFileDialog().
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
}
|
||||
})
|
||||
saveMenu.Add("Select File (Attach To WebviewWindow)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.SaveFileDialog().
|
||||
result, _ := application.SaveFileDialog().
|
||||
AttachToWindow(app.CurrentWindow()).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
}
|
||||
})
|
||||
saveMenu.Add("Select File (Show Hidden Files)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.SaveFileDialog().
|
||||
result, _ := application.SaveFileDialog().
|
||||
ShowHiddenFiles(true).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
}
|
||||
})
|
||||
saveMenu.Add("Select File (Cannot Create Directories)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.SaveFileDialog().
|
||||
result, _ := application.SaveFileDialog().
|
||||
CanCreateDirectories(false).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
}
|
||||
})
|
||||
saveMenu.Add("Select File (Full Example)").OnClick(func(ctx *application.Context) {
|
||||
result, _ := app.SaveFileDialog().
|
||||
result, _ := application.SaveFileDialog().
|
||||
CanCreateDirectories(false).
|
||||
ShowHiddenFiles(true).
|
||||
SetMessage("Select a file").
|
||||
|
|
@ -329,7 +329,7 @@ func main() {
|
|||
ShowHiddenFiles(true).
|
||||
PromptForSingleSelection()
|
||||
if result != "" {
|
||||
app.InfoDialog().SetMessage(result).Show()
|
||||
application.InfoDialog().SetMessage(result).Show()
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func main() {
|
|||
myMenu := app.NewMenu()
|
||||
myMenu.Add("Hello World!").OnClick(func(ctx *application.Context) {
|
||||
println("Hello World!")
|
||||
q := app.QuestionDialog().SetTitle("Ready?").SetMessage("Are you feeling ready?")
|
||||
q := application.QuestionDialog().SetTitle("Ready?").SetMessage("Are you feeling ready?")
|
||||
q.AddButton("Yes").OnClick(func() {
|
||||
println("Awesome!")
|
||||
})
|
||||
|
|
@ -52,7 +52,7 @@ func main() {
|
|||
myMenu.AddSeparator()
|
||||
myMenu.AddCheckbox("Checked", true).OnClick(func(ctx *application.Context) {
|
||||
println("Checked: ", ctx.ClickedMenuItem().Checked())
|
||||
app.InfoDialog().SetTitle("Hello World!").SetMessage("Hello World!").Show()
|
||||
application.InfoDialog().SetTitle("Hello World!").SetMessage("Hello World!").Show()
|
||||
})
|
||||
myMenu.Add("Enabled").OnClick(func(ctx *application.Context) {
|
||||
println("Click me!")
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ func main() {
|
|||
sizeMenu.Add("Get Current WebviewWindow Size").OnClick(func(ctx *application.Context) {
|
||||
currentWindow(func(w *application.WebviewWindow) {
|
||||
width, height := w.Size()
|
||||
app.InfoDialog().SetTitle("Current WebviewWindow Size").SetMessage("Width: " + strconv.Itoa(width) + " Height: " + strconv.Itoa(height)).Show()
|
||||
application.InfoDialog().SetTitle("Current WebviewWindow Size").SetMessage("Width: " + strconv.Itoa(width) + " Height: " + strconv.Itoa(height)).Show()
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ func main() {
|
|||
positionMenu.Add("Get Relative Position").OnClick(func(ctx *application.Context) {
|
||||
currentWindow(func(w *application.WebviewWindow) {
|
||||
x, y := w.RelativePosition()
|
||||
app.InfoDialog().SetTitle("Current WebviewWindow Position").SetMessage("X: " + strconv.Itoa(x) + " Y: " + strconv.Itoa(y)).Show()
|
||||
application.InfoDialog().SetTitle("Current WebviewWindow Position").SetMessage("X: " + strconv.Itoa(x) + " Y: " + strconv.Itoa(y)).Show()
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ func main() {
|
|||
positionMenu.Add("Get Absolute Position").OnClick(func(ctx *application.Context) {
|
||||
currentWindow(func(w *application.WebviewWindow) {
|
||||
x, y := w.AbsolutePosition()
|
||||
app.InfoDialog().SetTitle("Current WebviewWindow Position").SetMessage("X: " + strconv.Itoa(x) + " Y: " + strconv.Itoa(y)).Show()
|
||||
application.InfoDialog().SetTitle("Current WebviewWindow Position").SetMessage("X: " + strconv.Itoa(x) + " Y: " + strconv.Itoa(y)).Show()
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -285,32 +285,32 @@ func main() {
|
|||
stateMenu.Add("Get Primary Screen").OnClick(func(ctx *application.Context) {
|
||||
screen, err := app.GetPrimaryScreen()
|
||||
if err != nil {
|
||||
app.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
application.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("Screen: %+v", screen)
|
||||
app.InfoDialog().SetTitle("Primary Screen").SetMessage(msg).Show()
|
||||
application.InfoDialog().SetTitle("Primary Screen").SetMessage(msg).Show()
|
||||
})
|
||||
stateMenu.Add("Get Screens").OnClick(func(ctx *application.Context) {
|
||||
screens, err := app.GetScreens()
|
||||
if err != nil {
|
||||
app.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
application.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
return
|
||||
}
|
||||
for _, screen := range screens {
|
||||
msg := fmt.Sprintf("Screen: %+v", screen)
|
||||
app.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
application.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
}
|
||||
})
|
||||
stateMenu.Add("Get Screen for WebviewWindow").OnClick(func(ctx *application.Context) {
|
||||
currentWindow(func(w *application.WebviewWindow) {
|
||||
screen, err := w.GetScreen()
|
||||
if err != nil {
|
||||
app.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
application.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("Screen: %+v", screen)
|
||||
app.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
application.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
})
|
||||
})
|
||||
stateMenu.Add("Disable for 5s").OnClick(func(ctx *application.Context) {
|
||||
|
|
|
|||
|
|
@ -543,31 +543,31 @@ func (a *App) ShowAboutDialog() {
|
|||
}
|
||||
}
|
||||
|
||||
func (a *App) InfoDialog() *MessageDialog {
|
||||
return newMessageDialog(InfoDialog)
|
||||
func InfoDialog() *MessageDialog {
|
||||
return newMessageDialog(InfoDialogType)
|
||||
}
|
||||
|
||||
func (a *App) QuestionDialog() *MessageDialog {
|
||||
return newMessageDialog(QuestionDialog)
|
||||
func QuestionDialog() *MessageDialog {
|
||||
return newMessageDialog(QuestionDialogType)
|
||||
}
|
||||
|
||||
func (a *App) WarningDialog() *MessageDialog {
|
||||
return newMessageDialog(WarningDialog)
|
||||
func WarningDialog() *MessageDialog {
|
||||
return newMessageDialog(WarningDialogType)
|
||||
}
|
||||
|
||||
func (a *App) ErrorDialog() *MessageDialog {
|
||||
return newMessageDialog(ErrorDialog)
|
||||
func ErrorDialog() *MessageDialog {
|
||||
return newMessageDialog(ErrorDialogType)
|
||||
}
|
||||
|
||||
func (a *App) OpenDirectoryDialog() *MessageDialog {
|
||||
return newMessageDialog(OpenDirectoryDialog)
|
||||
func OpenDirectoryDialog() *MessageDialog {
|
||||
return newMessageDialog(OpenDirectoryDialogType)
|
||||
}
|
||||
|
||||
func (a *App) OpenFileDialog() *OpenFileDialog {
|
||||
func OpenFileDialog() *OpenFileDialogStruct {
|
||||
return newOpenFileDialog()
|
||||
}
|
||||
|
||||
func (a *App) SaveFileDialog() *SaveFileDialog {
|
||||
func SaveFileDialog() *SaveFileDialogStruct {
|
||||
return newSaveFileDialog()
|
||||
}
|
||||
|
||||
|
|
@ -601,14 +601,14 @@ func (a *App) dispatchOnMainThread(fn func()) {
|
|||
a.impl.dispatchOnMainThread(id)
|
||||
}
|
||||
|
||||
func (a *App) OpenFileDialogWithOptions(options *OpenFileDialogOptions) *OpenFileDialog {
|
||||
result := a.OpenFileDialog()
|
||||
func OpenFileDialogWithOptions(options *OpenFileDialogOptions) *OpenFileDialogStruct {
|
||||
result := OpenFileDialog()
|
||||
result.SetOptions(options)
|
||||
return result
|
||||
}
|
||||
|
||||
func (a *App) SaveFileDialogWithOptions(s *SaveFileDialogOptions) *SaveFileDialog {
|
||||
result := a.SaveFileDialog()
|
||||
func SaveFileDialogWithOptions(s *SaveFileDialogOptions) *SaveFileDialogStruct {
|
||||
result := SaveFileDialog()
|
||||
result.SetOptions(s)
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ var openFileResponses = make(map[uint]chan string)
|
|||
var saveFileResponses = make(map[uint]chan string)
|
||||
|
||||
const (
|
||||
InfoDialog DialogType = iota
|
||||
QuestionDialog
|
||||
WarningDialog
|
||||
ErrorDialog
|
||||
OpenDirectoryDialog
|
||||
InfoDialogType DialogType = iota
|
||||
QuestionDialogType
|
||||
WarningDialogType
|
||||
ErrorDialogType
|
||||
OpenDirectoryDialogType
|
||||
)
|
||||
|
||||
type Button struct {
|
||||
|
|
@ -87,10 +87,10 @@ type MessageDialog struct {
|
|||
}
|
||||
|
||||
var defaultTitles = map[DialogType]string{
|
||||
InfoDialog: "Information",
|
||||
QuestionDialog: "Question",
|
||||
WarningDialog: "Warning",
|
||||
ErrorDialog: "Error",
|
||||
InfoDialogType: "Information",
|
||||
QuestionDialogType: "Question",
|
||||
WarningDialogType: "Warning",
|
||||
ErrorDialogType: "Error",
|
||||
}
|
||||
|
||||
func newMessageDialog(dialogType DialogType) *MessageDialog {
|
||||
|
|
@ -187,7 +187,7 @@ type OpenFileDialogOptions struct {
|
|||
Directory string
|
||||
}
|
||||
|
||||
type OpenFileDialog struct {
|
||||
type OpenFileDialogStruct struct {
|
||||
id uint
|
||||
canChooseDirectories bool
|
||||
canChooseFiles bool
|
||||
|
|
@ -210,57 +210,57 @@ type OpenFileDialog struct {
|
|||
impl openFileDialogImpl
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) CanChooseFiles(canChooseFiles bool) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) CanChooseFiles(canChooseFiles bool) *OpenFileDialogStruct {
|
||||
d.canChooseFiles = canChooseFiles
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) CanChooseDirectories(canChooseDirectories bool) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) CanChooseDirectories(canChooseDirectories bool) *OpenFileDialogStruct {
|
||||
d.canChooseDirectories = canChooseDirectories
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) CanCreateDirectories(canCreateDirectories bool) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) CanCreateDirectories(canCreateDirectories bool) *OpenFileDialogStruct {
|
||||
d.canCreateDirectories = canCreateDirectories
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) AllowsOtherFileTypes(allowsOtherFileTypes bool) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) AllowsOtherFileTypes(allowsOtherFileTypes bool) *OpenFileDialogStruct {
|
||||
d.allowsOtherFileTypes = allowsOtherFileTypes
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) ShowHiddenFiles(showHiddenFiles bool) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) ShowHiddenFiles(showHiddenFiles bool) *OpenFileDialogStruct {
|
||||
d.showHiddenFiles = showHiddenFiles
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) HideExtension(hideExtension bool) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) HideExtension(hideExtension bool) *OpenFileDialogStruct {
|
||||
d.hideExtension = hideExtension
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) TreatsFilePackagesAsDirectories(treatsFilePackagesAsDirectories bool) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) TreatsFilePackagesAsDirectories(treatsFilePackagesAsDirectories bool) *OpenFileDialogStruct {
|
||||
d.treatsFilePackagesAsDirectories = treatsFilePackagesAsDirectories
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) AttachToWindow(window *WebviewWindow) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) AttachToWindow(window *WebviewWindow) *OpenFileDialogStruct {
|
||||
d.window = window
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) ResolvesAliases(resolvesAliases bool) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) ResolvesAliases(resolvesAliases bool) *OpenFileDialogStruct {
|
||||
d.resolvesAliases = resolvesAliases
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) SetTitle(title string) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) SetTitle(title string) *OpenFileDialogStruct {
|
||||
d.title = title
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) PromptForSingleSelection() (string, error) {
|
||||
func (d *OpenFileDialogStruct) PromptForSingleSelection() (string, error) {
|
||||
d.allowsMultipleSelection = false
|
||||
if d.impl == nil {
|
||||
d.impl = newOpenFileDialogImpl(d)
|
||||
|
|
@ -276,7 +276,7 @@ func (d *OpenFileDialog) PromptForSingleSelection() (string, error) {
|
|||
|
||||
// AddFilter adds a filter to the dialog. The filter is a display name and a semicolon separated list of extensions.
|
||||
// EG: AddFilter("Image Files", "*.jpg;*.png")
|
||||
func (d *OpenFileDialog) AddFilter(displayName, pattern string) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) AddFilter(displayName, pattern string) *OpenFileDialogStruct {
|
||||
d.filters = append(d.filters, FileFilter{
|
||||
DisplayName: strings.TrimSpace(displayName),
|
||||
Pattern: strings.TrimSpace(pattern),
|
||||
|
|
@ -284,7 +284,7 @@ func (d *OpenFileDialog) AddFilter(displayName, pattern string) *OpenFileDialog
|
|||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) PromptForMultipleSelection() ([]string, error) {
|
||||
func (d *OpenFileDialogStruct) PromptForMultipleSelection() ([]string, error) {
|
||||
d.allowsMultipleSelection = true
|
||||
if d.impl == nil {
|
||||
d.impl = newOpenFileDialogImpl(d)
|
||||
|
|
@ -292,27 +292,27 @@ func (d *OpenFileDialog) PromptForMultipleSelection() ([]string, error) {
|
|||
return invokeSyncWithResultAndError(d.impl.show)
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) SetMessage(message string) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) SetMessage(message string) *OpenFileDialogStruct {
|
||||
d.message = message
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) SetButtonText(text string) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) SetButtonText(text string) *OpenFileDialogStruct {
|
||||
d.buttonText = text
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) SetDirectory(directory string) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) SetDirectory(directory string) *OpenFileDialogStruct {
|
||||
d.directory = directory
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) CanSelectHiddenExtension(canSelectHiddenExtension bool) *OpenFileDialog {
|
||||
func (d *OpenFileDialogStruct) CanSelectHiddenExtension(canSelectHiddenExtension bool) *OpenFileDialogStruct {
|
||||
d.canSelectHiddenExtension = canSelectHiddenExtension
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *OpenFileDialog) SetOptions(options *OpenFileDialogOptions) {
|
||||
func (d *OpenFileDialogStruct) SetOptions(options *OpenFileDialogOptions) {
|
||||
d.title = options.Title
|
||||
d.message = options.Message
|
||||
d.buttonText = options.ButtonText
|
||||
|
|
@ -331,8 +331,8 @@ func (d *OpenFileDialog) SetOptions(options *OpenFileDialogOptions) {
|
|||
d.window = options.Window
|
||||
}
|
||||
|
||||
func newOpenFileDialog() *OpenFileDialog {
|
||||
return &OpenFileDialog{
|
||||
func newOpenFileDialog() *OpenFileDialogStruct {
|
||||
return &OpenFileDialogStruct{
|
||||
id: getDialogID(),
|
||||
canChooseDirectories: false,
|
||||
canChooseFiles: true,
|
||||
|
|
@ -341,8 +341,8 @@ func newOpenFileDialog() *OpenFileDialog {
|
|||
}
|
||||
}
|
||||
|
||||
func newSaveFileDialog() *SaveFileDialog {
|
||||
return &SaveFileDialog{
|
||||
func newSaveFileDialog() *SaveFileDialogStruct {
|
||||
return &SaveFileDialogStruct{
|
||||
id: getDialogID(),
|
||||
canCreateDirectories: true,
|
||||
}
|
||||
|
|
@ -364,7 +364,7 @@ type SaveFileDialogOptions struct {
|
|||
Window *WebviewWindow
|
||||
}
|
||||
|
||||
type SaveFileDialog struct {
|
||||
type SaveFileDialogStruct struct {
|
||||
id uint
|
||||
canCreateDirectories bool
|
||||
showHiddenFiles bool
|
||||
|
|
@ -388,7 +388,7 @@ type saveFileDialogImpl interface {
|
|||
show() (string, error)
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) SetOptions(options *SaveFileDialogOptions) {
|
||||
func (d *SaveFileDialogStruct) SetOptions(options *SaveFileDialogOptions) {
|
||||
d.title = options.Title
|
||||
d.canCreateDirectories = options.CanCreateDirectories
|
||||
d.showHiddenFiles = options.ShowHiddenFiles
|
||||
|
|
@ -406,7 +406,7 @@ func (d *SaveFileDialog) SetOptions(options *SaveFileDialogOptions) {
|
|||
|
||||
// AddFilter adds a filter to the dialog. The filter is a display name and a semicolon separated list of extensions.
|
||||
// EG: AddFilter("Image Files", "*.jpg;*.png")
|
||||
func (d *SaveFileDialog) AddFilter(displayName, pattern string) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) AddFilter(displayName, pattern string) *SaveFileDialogStruct {
|
||||
d.filters = append(d.filters, FileFilter{
|
||||
DisplayName: strings.TrimSpace(displayName),
|
||||
Pattern: strings.TrimSpace(pattern),
|
||||
|
|
@ -414,64 +414,64 @@ func (d *SaveFileDialog) AddFilter(displayName, pattern string) *SaveFileDialog
|
|||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) CanCreateDirectories(canCreateDirectories bool) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) CanCreateDirectories(canCreateDirectories bool) *SaveFileDialogStruct {
|
||||
d.canCreateDirectories = canCreateDirectories
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) CanSelectHiddenExtension(canSelectHiddenExtension bool) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) CanSelectHiddenExtension(canSelectHiddenExtension bool) *SaveFileDialogStruct {
|
||||
d.canSelectHiddenExtension = canSelectHiddenExtension
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) ShowHiddenFiles(showHiddenFiles bool) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) ShowHiddenFiles(showHiddenFiles bool) *SaveFileDialogStruct {
|
||||
d.showHiddenFiles = showHiddenFiles
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) SetMessage(message string) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) SetMessage(message string) *SaveFileDialogStruct {
|
||||
d.message = message
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) SetDirectory(directory string) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) SetDirectory(directory string) *SaveFileDialogStruct {
|
||||
d.directory = directory
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) AttachToWindow(window *WebviewWindow) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) AttachToWindow(window *WebviewWindow) *SaveFileDialogStruct {
|
||||
d.window = window
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) PromptForSingleSelection() (string, error) {
|
||||
func (d *SaveFileDialogStruct) PromptForSingleSelection() (string, error) {
|
||||
if d.impl == nil {
|
||||
d.impl = newSaveFileDialogImpl(d)
|
||||
}
|
||||
return invokeSyncWithResultAndError(d.impl.show)
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) SetButtonText(text string) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) SetButtonText(text string) *SaveFileDialogStruct {
|
||||
d.buttonText = text
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) SetFilename(filename string) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) SetFilename(filename string) *SaveFileDialogStruct {
|
||||
d.filename = filename
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) AllowsOtherFileTypes(allowOtherFileTypes bool) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) AllowsOtherFileTypes(allowOtherFileTypes bool) *SaveFileDialogStruct {
|
||||
d.allowOtherFileTypes = allowOtherFileTypes
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) HideExtension(hideExtension bool) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) HideExtension(hideExtension bool) *SaveFileDialogStruct {
|
||||
d.hideExtension = hideExtension
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *SaveFileDialog) TreatsFilePackagesAsDirectories(treatsFilePackagesAsDirectories bool) *SaveFileDialog {
|
||||
func (d *SaveFileDialogStruct) TreatsFilePackagesAsDirectories(treatsFilePackagesAsDirectories bool) *SaveFileDialogStruct {
|
||||
d.treatsFilePackagesAsDirectories = treatsFilePackagesAsDirectories
|
||||
return d
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,10 +299,10 @@ const NSAlertStyleInformational = C.int(1)
|
|||
const NSAlertStyleCritical = C.int(2)
|
||||
|
||||
var alertTypeMap = map[DialogType]C.int{
|
||||
WarningDialog: NSAlertStyleWarning,
|
||||
InfoDialog: NSAlertStyleInformational,
|
||||
ErrorDialog: NSAlertStyleCritical,
|
||||
QuestionDialog: NSAlertStyleInformational,
|
||||
WarningDialogType: NSAlertStyleWarning,
|
||||
InfoDialogType: NSAlertStyleInformational,
|
||||
ErrorDialogType: NSAlertStyleCritical,
|
||||
QuestionDialogType: NSAlertStyleInformational,
|
||||
}
|
||||
|
||||
func (m *macosApp) showAboutDialog(title string, message string, icon []byte) {
|
||||
|
|
@ -345,7 +345,7 @@ func (m *macosDialog) show() {
|
|||
iconLength = C.int(len(m.dialog.Icon))
|
||||
} else {
|
||||
// if it's an error, use the application Icon
|
||||
if m.dialog.DialogType == ErrorDialog {
|
||||
if m.dialog.DialogType == ErrorDialogType {
|
||||
iconData = unsafe.Pointer(&globalApplication.options.Icon[0])
|
||||
iconLength = C.int(len(globalApplication.options.Icon))
|
||||
}
|
||||
|
|
@ -390,10 +390,10 @@ func newDialogImpl(d *MessageDialog) *macosDialog {
|
|||
}
|
||||
|
||||
type macosOpenFileDialog struct {
|
||||
dialog *OpenFileDialog
|
||||
dialog *OpenFileDialogStruct
|
||||
}
|
||||
|
||||
func newOpenFileDialogImpl(d *OpenFileDialog) *macosOpenFileDialog {
|
||||
func newOpenFileDialogImpl(d *OpenFileDialogStruct) *macosOpenFileDialog {
|
||||
return &macosOpenFileDialog{
|
||||
dialog: d,
|
||||
}
|
||||
|
|
@ -481,10 +481,10 @@ func openFileDialogCallbackEnd(cid C.uint) {
|
|||
}
|
||||
|
||||
type macosSaveFileDialog struct {
|
||||
dialog *SaveFileDialog
|
||||
dialog *SaveFileDialogStruct
|
||||
}
|
||||
|
||||
func newSaveFileDialogImpl(d *SaveFileDialog) *macosSaveFileDialog {
|
||||
func newSaveFileDialogImpl(d *SaveFileDialogStruct) *macosSaveFileDialog {
|
||||
return &macosSaveFileDialog{
|
||||
dialog: d,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ func (m *linuxApp) showAboutDialog(title string, message string, icon []byte) {
|
|||
if window != nil {
|
||||
parent = window.impl.(*linuxWebviewWindow).window
|
||||
}
|
||||
about := newMessageDialog(InfoDialog)
|
||||
about := newMessageDialog(InfoDialogType)
|
||||
about.SetTitle(title).
|
||||
SetMessage(message).
|
||||
SetIcon(icon)
|
||||
|
|
@ -44,10 +44,10 @@ func newDialogImpl(d *MessageDialog) *linuxDialog {
|
|||
}
|
||||
|
||||
type linuxOpenFileDialog struct {
|
||||
dialog *OpenFileDialog
|
||||
dialog *OpenFileDialogStruct
|
||||
}
|
||||
|
||||
func newOpenFileDialogImpl(d *OpenFileDialog) *linuxOpenFileDialog {
|
||||
func newOpenFileDialogImpl(d *OpenFileDialogStruct) *linuxOpenFileDialog {
|
||||
return &linuxOpenFileDialog{
|
||||
dialog: d,
|
||||
}
|
||||
|
|
@ -58,10 +58,10 @@ func (m *linuxOpenFileDialog) show() ([]string, error) {
|
|||
}
|
||||
|
||||
type linuxSaveFileDialog struct {
|
||||
dialog *SaveFileDialog
|
||||
dialog *SaveFileDialogStruct
|
||||
}
|
||||
|
||||
func newSaveFileDialogImpl(d *SaveFileDialog) *linuxSaveFileDialog {
|
||||
func newSaveFileDialogImpl(d *SaveFileDialogStruct) *linuxSaveFileDialog {
|
||||
return &linuxSaveFileDialog{
|
||||
dialog: d,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
func (m *windowsApp) showAboutDialog(title string, message string, icon []byte) {
|
||||
about := newDialogImpl(&MessageDialog{
|
||||
MessageDialogOptions: MessageDialogOptions{
|
||||
DialogType: InfoDialog,
|
||||
DialogType: InfoDialogType,
|
||||
Title: title,
|
||||
Message: message,
|
||||
},
|
||||
|
|
@ -74,10 +74,10 @@ func newDialogImpl(d *MessageDialog) *windowsDialog {
|
|||
}
|
||||
|
||||
type windowOpenFileDialog struct {
|
||||
dialog *OpenFileDialog
|
||||
dialog *OpenFileDialogStruct
|
||||
}
|
||||
|
||||
func newOpenFileDialogImpl(d *OpenFileDialog) *windowOpenFileDialog {
|
||||
func newOpenFileDialogImpl(d *OpenFileDialogStruct) *windowOpenFileDialog {
|
||||
return &windowOpenFileDialog{
|
||||
dialog: d,
|
||||
}
|
||||
|
|
@ -136,10 +136,10 @@ func (m *windowOpenFileDialog) show() ([]string, error) {
|
|||
}
|
||||
|
||||
type windowSaveFileDialog struct {
|
||||
dialog *SaveFileDialog
|
||||
dialog *SaveFileDialogStruct
|
||||
}
|
||||
|
||||
func newSaveFileDialogImpl(d *SaveFileDialog) *windowSaveFileDialog {
|
||||
func newSaveFileDialogImpl(d *SaveFileDialogStruct) *windowSaveFileDialog {
|
||||
return &windowSaveFileDialog{
|
||||
dialog: d,
|
||||
}
|
||||
|
|
@ -170,18 +170,18 @@ func calculateMessageDialogFlags(options MessageDialogOptions) uint32 {
|
|||
var flags uint32
|
||||
|
||||
switch options.DialogType {
|
||||
case InfoDialog:
|
||||
case InfoDialogType:
|
||||
flags = windows.MB_OK | windows.MB_ICONINFORMATION
|
||||
case ErrorDialog:
|
||||
case ErrorDialogType:
|
||||
flags = windows.MB_ICONERROR | windows.MB_OK
|
||||
case QuestionDialog:
|
||||
case QuestionDialogType:
|
||||
flags = windows.MB_YESNO
|
||||
for _, button := range options.Buttons {
|
||||
if strings.TrimSpace(strings.ToLower(button.Label)) == "no" && button.IsDefault {
|
||||
flags |= windows.MB_DEFBUTTON2
|
||||
}
|
||||
}
|
||||
case WarningDialog:
|
||||
case WarningDialogType:
|
||||
flags = windows.MB_OK | windows.MB_ICONWARNING
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -882,7 +882,7 @@ func messageDialogCB(button C.int) {
|
|||
|
||||
}
|
||||
|
||||
func runOpenFileDialog(dialog *OpenFileDialog) ([]string, error) {
|
||||
func runOpenFileDialog(dialog *OpenFileDialogStruct) ([]string, error) {
|
||||
return []string{}, fmt.Errorf("not implemented")
|
||||
}
|
||||
|
||||
|
|
@ -897,9 +897,9 @@ func runQuestionDialog(parent pointer, options *MessageDialog) int {
|
|||
}
|
||||
|
||||
dType, ok := map[DialogType]C.int{
|
||||
InfoDialog: C.GTK_MESSAGE_INFO,
|
||||
QuestionDialog: C.GTK_MESSAGE_QUESTION,
|
||||
WarningDialog: C.GTK_MESSAGE_WARNING,
|
||||
InfoDialogType: C.GTK_MESSAGE_INFO,
|
||||
QuestionDialogType: C.GTK_MESSAGE_QUESTION,
|
||||
WarningDialogType: C.GTK_MESSAGE_WARNING,
|
||||
}[options.DialogType]
|
||||
if !ok {
|
||||
// FIXME: Add logging here!
|
||||
|
|
@ -949,7 +949,7 @@ func runQuestionDialog(parent pointer, options *MessageDialog) int {
|
|||
return int(C.gtk_dialog_run((*C.GtkDialog)(unsafe.Pointer(dialog))))
|
||||
}
|
||||
|
||||
func runSaveFileDialog(dialog *SaveFileDialog) (string, error) {
|
||||
func runSaveFileDialog(dialog *SaveFileDialogStruct) (string, error) {
|
||||
return "", fmt.Errorf("not implemented")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1037,7 +1037,7 @@ func runChooserDialog(window pointer, allowMultiple, createFolders, showHidden b
|
|||
}
|
||||
|
||||
// dialog related
|
||||
func runOpenFileDialog(dialog *OpenFileDialog) ([]string, error) {
|
||||
func runOpenFileDialog(dialog *OpenFileDialogStruct) ([]string, error) {
|
||||
GtkFileChooserActionOpen := 0
|
||||
// GtkFileChooserActionSave := 1
|
||||
// GtkFileChooserActionSelectFolder := 2
|
||||
|
|
@ -1064,9 +1064,9 @@ func runOpenFileDialog(dialog *OpenFileDialog) ([]string, error) {
|
|||
|
||||
func runQuestionDialog(parent pointer, options *MessageDialog) int {
|
||||
dType, ok := map[DialogType]int{
|
||||
InfoDialog: GtkMessageInfo,
|
||||
WarningDialog: GtkMessageWarning,
|
||||
QuestionDialog: GtkMessageQuestion,
|
||||
InfoDialogType: GtkMessageInfo,
|
||||
WarningDialogType: GtkMessageWarning,
|
||||
QuestionDialogType: GtkMessageQuestion,
|
||||
}[options.DialogType]
|
||||
if !ok {
|
||||
// FIXME: Add logging here!
|
||||
|
|
@ -1123,7 +1123,7 @@ func runQuestionDialog(parent pointer, options *MessageDialog) int {
|
|||
return gtkDialogRun(dialog)
|
||||
}
|
||||
|
||||
func runSaveFileDialog(dialog *SaveFileDialog) (string, error) {
|
||||
func runSaveFileDialog(dialog *SaveFileDialogStruct) (string, error) {
|
||||
GtkFileChooserActionSave := 1
|
||||
// GtkFileChooserActionSelectFolder := 2
|
||||
// GtkFileChooserActionCreateFolder := 3
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr
|
|||
var dialog *MessageDialog
|
||||
switch method {
|
||||
case "Info":
|
||||
dialog = globalApplication.InfoDialog()
|
||||
dialog = InfoDialog()
|
||||
case "Warning":
|
||||
dialog = globalApplication.WarningDialog()
|
||||
dialog = WarningDialog()
|
||||
case "Error":
|
||||
dialog = globalApplication.ErrorDialog()
|
||||
dialog = ErrorDialog()
|
||||
case "Question":
|
||||
dialog = globalApplication.QuestionDialog()
|
||||
dialog = QuestionDialog()
|
||||
}
|
||||
var detached = args.Bool("Detached")
|
||||
if detached == nil || !*detached {
|
||||
|
|
@ -84,7 +84,7 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr
|
|||
if detached == nil || !*detached {
|
||||
options.Window = window
|
||||
}
|
||||
dialog := globalApplication.OpenFileDialogWithOptions(&options)
|
||||
dialog := OpenFileDialogWithOptions(&options)
|
||||
|
||||
go func() {
|
||||
if options.AllowsMultipleSelection {
|
||||
|
|
@ -121,7 +121,7 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr
|
|||
if detached == nil || !*detached {
|
||||
options.Window = window
|
||||
}
|
||||
dialog := globalApplication.SaveFileDialogWithOptions(&options)
|
||||
dialog := SaveFileDialogWithOptions(&options)
|
||||
|
||||
go func() {
|
||||
file, err := dialog.PromptForSingleSelection()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue